Removed the obsolete complex number test from acltest.
authorarjen <arjen>
Sat, 27 Jul 2002 06:34:06 +0000 (06:34 +0000)
committerarjen <arjen>
Sat, 27 Jul 2002 06:34:06 +0000 (06:34 +0000)
BUG FIX: testaxe crashed when no configuration file is available.

demos/acltest.cpp
demos/metronome.cpp [new file with mode: 0644]
demos/testaxe.cpp

index 7121166..689ddb1 100644 (file)
@@ -5,7 +5,7 @@
 ***********************
 **      FILE NAME      : acltest.cpp
 **      SYSTEM NAME    : AXE - Andromeda X-windows Encapsulation
-**      VERSION NUMBER : $Revision: 1.1 $
+**      VERSION NUMBER : $Revision: 1.2 $
 **
 **  DESCRIPTION      :  Test routine for non-X classes
 **
 ********************************
 **      ORIGINAL AUTHOR : Arjen Baart - arjen@andromeda.nl
 **      CREATION DATE   : Feb 06, 1998
-**      LAST UPDATE     : Oct 16, 1999
+**      LAST UPDATE     : Jul 27, 2002
 **************************************************************************/
 
 /*****************************
    $Log: acltest.cpp,v $
-   Revision 1.1  2002-07-25 08:01:18  arjen
+   Revision 1.2  2002-07-27 06:34:06  arjen
+   Removed the obsolete complex number test from acltest.
+   BUG FIX: testaxe crashed when no configuration file is available.
+
+   Revision 1.1  2002/07/25 08:01:18  arjen
    First checkin, AXE release 0.2
 
 *****************************/
 
-static const char *RCSID = "$Id: acltest.cpp,v 1.1 2002-07-25 08:01:18 arjen Exp $";
+static const char *RCSID = "$Id: acltest.cpp,v 1.2 2002-07-27 06:34:06 arjen Exp $";
 
 #include "String.h"
 #include "integer.h" 
-#include "complex/complex.h" 
 #include "date.h"
 
 int main()
@@ -105,22 +108,6 @@ int main()
    c = b;
    cout << "c = b : c = " << c << "\n";
 
-   cout << "***********************\nComplex Number Test\n*********************\n";
-
-#if 0
-   complex z1, z2, z3;
-   z1 = complex(1,0);
-   z2 = complex(0,1);
-   z3 = z1 + z2;
-   cout << z1 << " + " << z2 << " = " << z3 << "\n";
-   z3 = z1 - z2;
-   cout << z1 << " - " << z2 << " = " << z3 << "\n";
-   z3 = z1 * z2;
-   cout << z1 << " * " << z2 << " = " << z3 << "\n";
-   z3 = z1 / z2;
-   cout << z1 << " / " << z2 << " = " << z3 << "\n";
-#endif
-   
    cout << "***********************\nDate Test\n*********************\n";
    date d1, d2(22,7,1964);
    
diff --git a/demos/metronome.cpp b/demos/metronome.cpp
new file mode 100644 (file)
index 0000000..690a50f
--- /dev/null
@@ -0,0 +1,106 @@
+#include <pthread.h>
+#include <unistd.h>
+#include <AXE/button.h>
+
+#define CMD_QUIT    1
+#define CMD_FASTER  2
+#define CMD_SLOWER  3
+
+class xapp: public xapplication
+{
+   window *main_frame;
+   window *flash;
+
+   pthread_t  beat;
+
+   virtual void SetupResources(void);
+
+   virtual int DoCommand(int code);
+
+public:
+
+
+};
+
+xapp Application;
+unsigned       BPM  = 80;
+
+void * heartbeat(void *v)
+{
+   unsigned long  period;
+   unsigned long  flash_time = 200000;
+   int    count = 0;
+   color  forebeat("red");
+   color  afterbeat("blue");
+   color  idle("white");
+   window *w = (window *)v;
+
+
+   for (;;)
+   {
+      period = 1000000 * 60 / BPM;
+      if (count == 0)
+         w->Background(forebeat);
+      else
+         w->Background(afterbeat);
+
+      w->Clear();
+      XFlush(stddpy.Dpy());
+      usleep(flash_time);
+
+      w->Background(idle);
+      w->Clear();
+      XFlush(stddpy.Dpy());
+      usleep(period - flash_time);
+
+      count++;
+      if (count == 4)
+         count = 0;
+   }
+
+}
+
+void xapp::SetupResources()
+{
+   command_button *btn;
+
+   main_frame = new managed_window;
+
+   main_frame->Resize(700, 500);
+   flash = new window(*main_frame, 92, 2, 606, 496, 1);
+
+   btn = new command_button(*main_frame, 2, 2, "QUIT", CMD_QUIT);
+   btn = new command_button(*main_frame, 2, 42, "++", CMD_FASTER);
+   btn = new command_button(*main_frame, 2, 82, "--", CMD_SLOWER);
+   main_frame->Realize();
+
+   pthread_create(&beat, NULL, heartbeat, flash);
+}
+
+int xapp::DoCommand(int code)
+{
+   switch (code)
+   {
+   case CMD_FASTER:
+      if (BPM < 200)
+      {
+         BPM += 10;
+      }
+      cout << BPM << "beats per minute\n";
+      return 1;
+
+   case CMD_SLOWER:
+      if (BPM > 20)
+      {
+         BPM -= 10;
+      }
+      cout << BPM << "beats per minute\n";
+      return 1;
+
+   case CMD_QUIT:
+      return 0;
+
+   default:
+      return 1;
+   }
+}
index 4c8fc11..1bcefe4 100644 (file)
@@ -44,7 +44,7 @@ public:
    virtual int EV_Expose(XExposeEvent ev)
    {
       DrawString(white_gc, 100, 30, "Andromeda X Windows Encapsulation");
-      DrawString(white_gc, 120, 90, "Version 0.2 - July 30, 2001");
+      DrawString(white_gc, 120, 90, "Version 0.2 - July 25, 2002");
       return 1;
    }
 
@@ -113,7 +113,12 @@ void xapp::SetupResources(void)
 
    main_frame = new managed_window;
    main_frame->Command_WhenClosed(CMD_QUIT);
-   main_frame->Background(color(config.find_parameter("colors", "background")));
+
+   String bgcolor = config.find_parameter("colors", "background");
+   if (bgcolor != "")
+   {
+      main_frame->Background(color(bgcolor));
+   }
 
    fr = new button(*main_frame, 20, 30, "Up");