6 * (C) Copyright 1998 Manuel Lemos.
7 * (C) Copyright 1995 Jaba Development.
8 * (C) Copyright 1995 Jan van den Baard.
12 * Revision 42.1 2000/08/10 11:50:54 chodorowski
13 * Cleaned up and prettyfied the GUIs a bit.
15 * Revision 42.0 2000/05/09 22:19:29 mlemos
16 * Bumped to revision 42.0 before handing BGUI to AROS team
18 * Revision 41.11 2000/05/09 20:33:19 mlemos
19 * Bumped to revision 41.11
21 * Revision 1.2 2000/05/09 19:58:40 mlemos
22 * Merged with the branch Manuel_Lemos_fixes.
24 * Revision 1.1.2.1 1998/02/28 17:45:09 mlemos
30 /* Execute me to compile with DICE V3.0.
31 dcc CXDemo.c -proto -mi -ms -mRR -lbgui
40 #define CX_F1_PRESSED 1L
51 UBYTE
*InfoTxt
= ISEQ_C ISEQ_B ISEQ_HIGHLIGHT
52 "\33sCxDemo\n\n" ISEQ_TEXT ISEQ_N
53 "This is a small \"do-nothing\" example of how\n"
54 "to use the BGUI commodity class.\n"
55 "In this example F1 is the Hotkey used to\n"
56 "signal the broker to open the window.";
58 VOID
StartDemo( void )
60 Object
*CM_Broker
, *WN_Window
, *GA_Hide
, *GA_Quit
;
61 ULONG sigrec
, type
, id
, rc
;
62 IPTR signal
= 0L, winsig
= 0L;
66 ** Setup a commodity object.
68 CM_Broker
= CommodityObject
,
70 COMM_Title
, "Simple BGUI broker.",
71 COMM_Description
, "Does not do anything useful.",
81 ** Create a small window.
83 WN_Window
= WindowObject
,
84 WINDOW_Title
, "CxDemo",
86 WINDOW_SizeGadget
, FALSE
, /* No use in this window. */
87 WINDOW_AutoAspect
, TRUE
,
88 WINDOW_AutoKeyLabel
, TRUE
,
90 VGroupObject
, HOffset(6), VOffset(6), Spacing(6), GROUP_BackFill
, SHINE_RASTER
,
92 InfoObject
, ButtonFrame
,
93 FRM_Flags
, FRF_RECESSED
,
94 INFO_TextFormat
, InfoTxt
,
95 INFO_FixTextWidth
, TRUE
,
101 StartMember
, GA_Hide
= PrefButton( "_Hide", ID_HIDE
), EndMember
,
102 VarSpace(DEFAULT_WEIGHT
),
103 StartMember
, GA_Quit
= PrefButton( "_Quit", ID_QUIT
), EndMember
,
104 EndObject
, FixMinHeight
,
117 if ( AddHotkey( CM_Broker
, "f1", CX_F1_PRESSED
, 0L ))
120 ** Obtain broker signal mask.
122 GetAttr( COMM_SigMask
, CM_Broker
, &signal
);
124 ** Activate the broker.
126 EnableBroker( CM_Broker
);
128 ** Open up the window.
130 if ( WindowOpen( WN_Window
))
133 ** Obtain window sigmask.
135 GetAttr( WINDOW_SigMask
, WN_Window
, &winsig
);
137 ** Wait for messages.
140 sigrec
= Wait( signal
| winsig
| SIGBREAKF_CTRL_C
);
144 if ( sigrec
& signal
)
147 ** Obtain the messages from the broker.
149 while ( MsgInfo( CM_Broker
, &type
, &id
, NULL
) != CMMI_NOMORE
)
173 Tell( "broker disabled\n" );
174 DisableBroker( CM_Broker
);
178 Tell( "broker enabled\n" );
179 EnableBroker( CM_Broker
);
185 if ( WindowOpen( WN_Window
))
186 GetAttr( WINDOW_SigMask
, WN_Window
, &winsig
);
189 case CXCMD_DISAPPEAR
:
190 WindowClose( WN_Window
);
202 if ( sigrec
& winsig
) {
203 while ( WN_Window
&& (( rc
= HandleEvent( WN_Window
)) != WMHI_NOMORE
)) {
207 case WMHI_CLOSEWINDOW
:
211 WindowClose( WN_Window
);
229 if ( sigrec
& SIGBREAKF_CTRL_C
) {
235 Tell( "unable to open the window\n" );
237 Tell( "unable to add the hotkey\n" );
238 DisposeObject( WN_Window
);
240 Tell( "unable to create a window object\n" );
241 DisposeObject( CM_Broker
);
243 Tell( "unable to create a commodity object\n" );