6 * (C) Copyright 1998 Manuel Lemos.
7 * (C) Copyright 1995 Jaba Development.
8 * (C) Copyright 1995 Jan van den Baard.
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
36 /* Execute me to compile with DICE V3.0
37 dcc IDCMPHook.c -proto -mi -ms -mRR -lbgui
49 ** "tick" counter for the hook.
54 ** Simple example of the hook code.
61 //hookFunc( REG(a0) struct Hook *hook, REG(a2) Object *obj, REG(a1) struct IntuiMessage *imsg )
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.
82 ** Only flash the screen on which
83 ** the window is located.
85 GetAttr( WINDOW_Window
, obj
, ( IPTR
* )&wptr
);
87 DisplayBeep( wptr
->WScreen
);
95 ** The hook structure.
97 ** typedef unsigned long (*HOOKFUNC)();
99 struct Hook idcmpHook
= { { NULL
, NULL
}, (HOOKFUNC
)hookFunc
, NULL
, NULL
};
101 VOID
StartDemo( void )
103 struct Window
*window
;
104 Object
*WO_Window
, *GO_Quit
;
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
,
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
,
133 VarSpace( DEFAULT_WEIGHT
),
134 StartMember
, GO_Quit
= KeyButton( "_Quit", ID_QUIT
), EndMember
,
135 VarSpace( DEFAULT_WEIGHT
),
142 ** Object created OK?
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
);
165 while (( rc
= HandleEvent( WO_Window
)) != WMHI_NOMORE
) {
167 ** Evaluate return code.
171 case WMHI_CLOSEWINDOW
:
179 Tell( "Could not open the window\n" );
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
);
190 Tell( "Unable to create the window object\n" );