Replaced System by SYS because on "native" the volume name of the system partition...
[AROS-Contrib.git] / bgui / examples / Colors.c
blob82055cee614409cee84a481ca03c77078d6eb6d3
1 /*
2 * @(#) $Header$
4 * Colors.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.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
22 * Ian sources
27 /* Execute me to compile with DICE V3.0
28 dcc Colors.c -mi -ms -mRR -proto -lbgui
29 quit
32 #include "DemoCode.h"
35 ** Object ID's.
36 **/
37 #define ID_ALT 1
38 #define ID_QUIT 2
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;
45 BOOL running = TRUE;
48 * Create the window object.
50 WO_Window = WindowObject,
51 WINDOW_Title, "Colors Demo",
52 WINDOW_AutoAspect, TRUE,
53 WINDOW_SmartRefresh, TRUE,
54 WINDOW_RMBTrap, TRUE,
55 WINDOW_MasterGroup,
56 VGroupObject, HOffset( 4 ), VOffset( 4 ), Spacing( 4 ), GROUP_BackFill, SHINE_RASTER,
57 StartMember,
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.",
64 NULL, 7 ),
65 EndMember,
66 StartMember,
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,
71 EndMember,
72 StartMember,
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,
78 EndMember,
79 StartMember,
80 HGroupObject,
81 VarSpace( DEFAULT_WEIGHT ),
82 StartMember, GO_Quit = KeyButton( "_Quit", ID_QUIT ), EndMember,
83 VarSpace( DEFAULT_WEIGHT ),
84 EndObject, FixMinHeight,
85 EndMember,
86 EndObject,
87 EndObject;
90 ** Object created OK?
91 **/
92 if ( WO_Window ) {
94 ** Assign the keys to the buttons.
95 **/
96 tmp += GadgetKey( WO_Window, GO_Quit, "q" );
97 tmp += GadgetKey( WO_Window, GO_Alt, "a" );
99 ** OK?
101 if ( tmp == 2 ) {
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 );
111 ** Event loop...
113 do {
114 Wait( signal );
116 ** Handle events.
118 while (( rc = HandleEvent( WO_Window )) != WMHI_NOMORE ) {
120 ** Evaluate return code.
122 switch ( rc ) {
124 case WMHI_CLOSEWINDOW:
125 case ID_QUIT:
126 running = FALSE;
127 break;
129 case ID_ALT:
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,
145 TAG_END );
146 break;
149 } while ( running );
150 } else
151 Tell( "Could not open the window\n" );
152 } else
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 );
161 } else
162 Tell( "Could not create the window object\n" );