BUG FIX: testaxe crashed when no configuration file is available.
***********************
** 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()
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);
--- /dev/null
+#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;
+ }
+}
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;
}
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");