summaryrefslogtreecommitdiff
path: root/app/wlib/test/alarmtst.c
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff-webhosting.net>2016-12-28 16:52:56 +0100
committerJörg Frings-Fürst <debian@jff-webhosting.net>2016-12-28 16:52:56 +0100
commit7b358424ebad9349421acd533c2fa1cbf6cf3e3e (patch)
tree686678532eefed525c242fd214d0cfb2914726c5 /app/wlib/test/alarmtst.c
Initial import of xtrkcad version 1:4.0.2-2
Diffstat (limited to 'app/wlib/test/alarmtst.c')
-rw-r--r--app/wlib/test/alarmtst.c59
1 files changed, 59 insertions, 0 deletions
diff --git a/app/wlib/test/alarmtst.c b/app/wlib/test/alarmtst.c
new file mode 100644
index 0000000..da11c91
--- /dev/null
+++ b/app/wlib/test/alarmtst.c
@@ -0,0 +1,59 @@
+#include <stdio.h>
+#include "wlib.h"
+
+
+#define TRUE (1)
+#define FALSE (0)
+
+wMessage_p msgP;
+int ticks;
+char tickM[40] = "INIT";
+int alarmCont = 0;
+
+void tick( void )
+{
+ sprintf( tickM, "%d", ticks++ );
+ wMessageSetValue( msgP, tickM );
+ if (alarmCont)
+ wAlarm( 1000, tick );
+}
+
+
+void doCmd( void * cmd )
+{
+ int i;
+ switch ((int)cmd) {
+ case 1:
+ alarmCont = 1;
+ wAlarm( 1000, tick );
+ break;
+ case 2:
+ for (i=0; i<10; i++ ) {
+ sprintf( tickM, "%d", ticks++ );
+ wMessageSetValue( msgP, tickM );
+ wPause( 1000 );
+ }
+ break;
+ case 3:
+ alarmCont = 0;
+ break;
+ case 4:
+ wExit( 0 );
+ }
+}
+
+wWin_p wMain( int argc, char * argv[] )
+{
+
+ wWin_p mainW;
+ wMenu_p m;
+
+ mainW = wWinMainCreate( "Fred", 60, 40, "Help", "Main", "", F_MENUBAR, NULL, NULL );
+ m = wMenuBarAdd( mainW, NULL, "Cmd" );
+ wMenuPushCreate( m, NULL, "Alarm", 0, doCmd, (void*)1 );
+ wMenuPushCreate( m, NULL, "Pause", 0, doCmd, (void*)2 );
+ wMenuPushCreate( m, NULL, "Stop", 0, doCmd, (void*)3 );
+ wMenuPushCreate( m, NULL, "Exit", 0, doCmd, (void*)4 );
+ msgP = wMessageCreate( mainW, 2, 2, NULL, 40, tickM );
+ return mainW;
+}