forgotten commit. disabled until egl is adapted.
[AROS-Contrib.git] / fish / gooddouble / ClickTest.c
blob2ea7586f8821294549597ae5133a82d6ec5d8821
1 #include <aros/oldprograms.h>
2 /*
3 * ClickTest.c
5 * compile & link with GoodDouble.o
7 * ( or with GoodDouble2.o if you are NOT INTERESTED in MIDDLE
8 * button, but you MUST also #undefine ALL_BUTTONS. FORGET IT! )
9 */
11 #include <exec/types.h>
12 #include <intuition/intuition.h>
14 #include "good_double.h" /* macros & functions' prototypes */
16 #include <stdio.h>
19 * they usually put something like that it ROM Kernel manuals...
21 #ifdef LATTICE
22 int CXBRK(void) { return(0); }
23 void chkabort(void) { return; }
24 #endif
26 /* something to brighten-up the output... */
27 #define ANSI_WHITE "›2m" /* sometimes it's white, sometimes not... */
28 #define ANSI_NORMAL "›0m"
31 struct IntuitionBase *IntuitionBase;
33 int main(int argc, char **argv)
35 LONG ret_val = 5L;
37 struct NewWindow TestWindow = {
38 50, 50, /* left, top */
39 450, 80, /* width, height */
40 0, 1, /* detailpen, blockpen */
41 ( CLOSEWINDOW | MOUSEBUTTONS | VANILLAKEY ),
42 ( WINDOWCLOSE | WINDOWDRAG | NOCAREREFRESH | RMBTRAP ),
43 NULL, /* no custom gadgets */
44 NULL, /* no custom menu images */
45 (UBYTE *)"Let's play -- HIT ME ME WITH EVERYTHING YOU GOT!",
46 NULL, /* no custom screen structure */
47 NULL, /* no superbitmap */
48 0, 0, 0, 0,
49 WBENCHSCREEN
52 struct Window *testWnd;
53 struct IntuiMessage *msg;
55 ULONG class;
56 USHORT code;
57 ULONG secs, micros;
59 BOOL fDone = FALSE; /* the Hungarian naming convention! */
62 * this, as well as CloseLibrary(), wouldn't be needed for DICE
64 IntuitionBase =
65 (struct IntuitionBase *)OpenLibrary( "intuition.library", 0L );
67 if ( ! IntuitionBase )
68 return( ret_val );
71 * open our window
73 testWnd = (struct Window *)OpenWindow( &TestWindow );
74 if ( ! testWnd )
75 goto BAD_RETURN;
77 while ( ! fDone ) {
78 WaitPort( testWnd->UserPort );
79 while (( msg = (struct IntuiMessage *)GetMsg( testWnd->UserPort ) )) {
81 class = msg->Class;
82 code = msg->Code;
83 secs = msg->Seconds;
84 micros = msg->Micros;
86 ReplyMsg( (struct Message *)msg );
88 switch ( class ) {
89 case MOUSEBUTTONS:
90 switch ( code ) {
91 case MENUDOWN:
92 /* ---> */ if ( RightDouble( secs, micros ) )
93 puts( "Second, quick one... It was "
94 ANSI_WHITE "DOUBLE "
95 ANSI_NORMAL "RIGHT!" );
96 else
97 puts( "Just a simple RIGHT..." );
98 break;
99 case MIDDLEDOWN:
100 /* ---> */ if ( MiddleDouble( secs, micros ) )
101 puts( "Next! It was quick... So it was "
102 ANSI_WHITE "DOUBLE "
103 ANSI_NORMAL "MIDDLE!" );
104 else
105 puts( "Just a MIDDLE..." );
106 break;
107 case SELECTDOWN:
108 /* ---> */ if ( LeftDouble( secs, micros ) )
109 puts( "And now a second... "
110 ANSI_WHITE "DOUBLE "
111 ANSI_NORMAL "LEFT then!" );
112 else
113 puts( "Just a straight LEFT..." );
114 break;
116 break;
117 case VANILLAKEY:
118 puts( ANSI_WHITE "Ouch! " ANSI_NORMAL
119 "You wacked me with " ANSI_WHITE "VANILLA"
120 ANSI_NORMAL "...!" );
121 break;
122 case CLOSEWINDOW:
123 fDone = TRUE;
124 break;
125 default:
126 break;
131 while (( msg = (struct IntuiMessage *)GetMsg( testWnd->UserPort )) )
132 ReplyMsg( (struct Message *)msg );
134 CloseWindow( testWnd );
135 puts( "Well, it " ANSI_WHITE "WAS fun" ANSI_NORMAL ". Wasn't it?" );
136 ret_val = 0L;
138 BAD_RETURN:
139 CloseLibrary( (struct Library *)IntuitionBase );
140 return( ret_val );