6 * (C) Copyright 1998 Manuel Lemos.
7 * (C) Copyright 1995 Jaba Development.
8 * (C) Copyright 1995 Jan van den Baard.
12 * Revision 42.0 2000/05/09 22:19:35 mlemos
13 * Bumped to revision 42.0 before handing BGUI to AROS team
15 * Revision 41.11 2000/05/09 20:33:25 mlemos
16 * Bumped to revision 41.11
18 * Revision 1.2 2000/05/09 19:58:45 mlemos
19 * Merged with the branch Manuel_Lemos_fixes.
21 * Revision 1.1.2.1 1998/02/28 17:45:01 mlemos
27 /* Execute me to compile with DICE V3.0
28 dcc Colors.c -mi -ms -mRR -proto -lbgui
40 VOID
StartDemo( void )
42 struct Window
*window
;
43 Object
*WO_Window
, *GO_Quit
, *GO_B
[ 2 ], *GO_Alt
;
44 ULONG signal
, rc
, tmp
= 0, a
;
48 * Create the window object.
50 WO_Window
= WindowObject
,
51 WINDOW_Title
, "Colors Demo",
52 WINDOW_AutoAspect
, TRUE
,
53 WINDOW_SmartRefresh
, TRUE
,
56 VGroupObject
, HOffset( 4 ), VOffset( 4 ), Spacing( 4 ), GROUP_BackFill
, SHINE_RASTER
,
58 InfoFixed( NULL
, ISEQ_C
"This small demo shows you how you can\n"
59 "change the background and label colors\n"
60 "of an object on the fly.\n\n"
61 "As you can see the colors of the below buttons\n"
62 "are normal but when the " ISEQ_B
"Alternate" ISEQ_N
" checkbox\n"
63 "is selected the colors are changed.",
67 HGroupObject
, HOffset( 4 ), VOffset( 4 ), Spacing( 4 ), FRM_Type
, FRTYPE_BUTTON
, FRM_Recessed
, TRUE
,
68 StartMember
, GO_B
[ 0 ] = Button( "Colors", 0 ), EndMember
,
69 StartMember
, GO_B
[ 1 ] = Button( "Demo", 0 ), EndMember
,
70 EndObject
, FixMinHeight
,
73 HGroupObject
, HOffset( 4 ), VOffset( 4 ), Spacing( 4 ), FRM_Type
, FRTYPE_BUTTON
, FRM_Recessed
, TRUE
,
74 VarSpace( DEFAULT_WEIGHT
),
75 StartMember
, GO_Alt
= KeyCheckBox( "_Alternate", FALSE
, ID_ALT
), EndMember
,
76 VarSpace( DEFAULT_WEIGHT
),
77 EndObject
, FixMinHeight
,
81 VarSpace( DEFAULT_WEIGHT
),
82 StartMember
, GO_Quit
= KeyButton( "_Quit", ID_QUIT
), EndMember
,
83 VarSpace( DEFAULT_WEIGHT
),
84 EndObject
, FixMinHeight
,
94 ** Assign the keys to the buttons.
96 tmp
+= GadgetKey( WO_Window
, GO_Quit
, "q" );
97 tmp
+= GadgetKey( WO_Window
, GO_Alt
, "a" );
103 ** try to open the window.
105 if ( window
= WindowOpen( WO_Window
)) {
107 ** Obtain it's wait mask.
109 GetAttr( WINDOW_SigMask
, WO_Window
, &signal
);
118 while (( rc
= HandleEvent( WO_Window
)) != WMHI_NOMORE
) {
120 ** Evaluate return code.
124 case WMHI_CLOSEWINDOW
:
131 * When the object is selected we use
132 * alternate coloring on the objects.
133 * If not we revert to default coloring.
135 GetAttr( GA_Selected
, GO_Alt
, &tmp
);
137 * Setup the colors on the buttons.
139 for ( a
= 0; a
< 2; a
++ )
140 SetGadgetAttrs(( struct Gadget
* )GO_B
[ a
], window
, NULL
,
141 FRM_BackDriPen
, tmp
? TEXTPEN
: (ULONG
)~0,
142 FRM_SelectedBackDriPen
, tmp
? SHINEPEN
: (ULONG
)~0,
143 LAB_DriPen
, tmp
? SHINEPEN
: (ULONG
)~0,
144 LAB_SelectedDriPen
, tmp
? TEXTPEN
: (ULONG
)~0,
151 Tell( "Could not open the window\n" );
153 Tell( "Could not assign gadget keys\n" );
155 ** Disposing of the window object will
156 ** also close the window if it is
157 ** already opened and it will dispose of
158 ** all objects attached to it.
160 DisposeObject( WO_Window
);
162 Tell( "Could not create the window object\n" );