delint: unused on AROS
[AROS-Contrib.git] / bgui / examples / IDCMPHook.c
blobdeaf879c1942dc6a7d71c02522e2775f113295ae
1 /*
2 * @(#) $Header$
4 * IDCMPHook.c
6 * (C) Copyright 1998 Manuel Lemos.
7 * (C) Copyright 1995 Jaba Development.
8 * (C) Copyright 1995 Jan van den Baard.
9 * All Rights Reserved.
11 * $Log$
12 * Revision 42.2 2004/06/17 07:38:47 chodorowski
13 * Added missing REGFUNC_END.
15 * Revision 42.1 2000/05/15 19:29:50 stegerg
16 * replacements for REG macro.
18 * Revision 42.0 2000/05/09 22:19:48 mlemos
19 * Bumped to revision 42.0 before handing BGUI to AROS team
21 * Revision 41.11 2000/05/09 20:33:38 mlemos
22 * Bumped to revision 41.11
24 * Revision 1.2 2000/05/09 19:58:56 mlemos
25 * Merged with the branch Manuel_Lemos_fixes.
27 * Revision 1.1.2.2 1999/02/19 05:03:54 mlemos
28 * Added support to build with Storm C.
30 * Revision 1.1.2.1 1998/02/28 17:45:20 mlemos
31 * Ian sources
36 /* Execute me to compile with DICE V3.0
37 dcc IDCMPHook.c -proto -mi -ms -mRR -lbgui
38 quit
41 #include "DemoCode.h"
44 ** Object ID.
45 **/
46 #define ID_QUIT 1
49 ** "tick" counter for the hook.
50 **/
51 UBYTE Ticks = 0;
54 ** Simple example of the hook code.
55 **/
56 #ifdef __STORM__
57 VOID SAVEDS ASM
58 #else
59 SAVEDS ASM VOID
60 #endif
61 //hookFunc( REG(a0) struct Hook *hook, REG(a2) Object *obj, REG(a1) struct IntuiMessage *imsg )
62 REGFUNC3(,hookFunc,
63 REGPARAM(A0, struct Hook *, hook),
64 REGPARAM(A2, Object *, obj),
65 REGPARAM(A1, struct IntuiMessage *, imsg))
67 struct Window *wptr = NULL;
70 ** This hook is a simple IDCMP_INTUITICKS hook.
71 ** More complex hooks can receive several message
72 ** types depending on the setting of the
73 ** WINDOW_IDCMPHookBits attribute.
75 ** Simply beep the screen
76 ** every two seconds or so
77 ** while the window is active.
78 **/
79 if ( Ticks == 20 ) {
80 Ticks = 0;
82 ** Only flash the screen on which
83 ** the window is located.
84 **/
85 GetAttr( WINDOW_Window, obj, ( IPTR * )&wptr );
86 if ( wptr )
87 DisplayBeep( wptr->WScreen );
89 Ticks++;
91 REGFUNC_END
95 ** The hook structure.
97 ** typedef unsigned long (*HOOKFUNC)();
98 **/
99 struct Hook idcmpHook = { { NULL, NULL}, (HOOKFUNC)hookFunc, NULL, NULL };
101 VOID StartDemo( void )
103 struct Window *window;
104 Object *WO_Window, *GO_Quit;
105 IPTR signal = 0;
106 ULONG rc;
107 BOOL running = TRUE;
110 ** Create the window object.
112 WO_Window = WindowObject,
113 WINDOW_Title, "IDCMPHook Demo",
114 WINDOW_SizeGadget, FALSE,
115 WINDOW_RMBTrap, TRUE,
116 WINDOW_IDCMP, IDCMP_INTUITICKS,
117 WINDOW_IDCMPHookBits, IDCMP_INTUITICKS,
118 WINDOW_IDCMPHook, &idcmpHook,
119 WINDOW_AutoAspect, TRUE,
120 WINDOW_MasterGroup,
122 ** A simple vertical group
123 ** containing a descriptive text
124 ** and a "Quit" button.
126 VGroupObject, HOffset( 4 ), VOffset( 4 ), Spacing( 4 ), GROUP_BackFill, SHINE_RASTER,
127 StartMember, InfoFixed( NULL, "\33cThis small demo has a IDCMP-hook\n"
128 "installed which will flash the\n"
129 "display every two seconds while the\n"
130 "window is active.", NULL, 4 ), EndMember,
131 StartMember,
132 HGroupObject,
133 VarSpace( DEFAULT_WEIGHT ),
134 StartMember, GO_Quit = KeyButton( "_Quit", ID_QUIT ), EndMember,
135 VarSpace( DEFAULT_WEIGHT ),
136 EndObject,
137 EndMember,
138 EndObject,
139 EndObject;
142 ** Object created OK?
144 if ( WO_Window ) {
146 ** Assign a key to the button.
148 if ( GadgetKey( WO_Window, GO_Quit, "q" )) {
150 ** try to open the window.
152 if (( window = WindowOpen( WO_Window ))) {
154 ** Obtain it's wait mask.
156 GetAttr( WINDOW_SigMask, WO_Window, &signal );
158 ** Event loop...
160 do {
161 Wait( signal );
163 ** Handle events.
165 while (( rc = HandleEvent( WO_Window )) != WMHI_NOMORE ) {
167 ** Evaluate return code.
169 switch ( rc ) {
171 case WMHI_CLOSEWINDOW:
172 case ID_QUIT:
173 running = FALSE;
174 break;
177 } while ( running );
178 } else
179 Tell( "Could not open the window\n" );
180 } else
181 Tell( "Could not assign gadget key\n" );
183 ** Disposing of the window object will
184 ** also close the window if it is
185 ** already opened and it will dispose of
186 ** all objects attached to it.
188 DisposeObject( WO_Window );
189 } else
190 Tell( "Unable to create the window object\n" );