2 Copyright © 1995-2011, The AROS Development Team. All rights reserved.
5 Desc: Demo/test for AROS boopsi objects
9 #include <aros/config.h>
11 #if !(AROS_FLAVOUR & AROS_FLAVOUR_NATIVE)
15 #include <proto/exec.h>
16 #include <proto/intuition.h>
17 #include <proto/graphics.h>
18 #include <intuition/intuition.h>
19 #include <intuition/screens.h>
20 #include <gadgets/arospalette.h>
21 #include <gadgets/aroscheckbox.h>
22 #include <intuition/classes.h>
23 #include <utility/tagitem.h>
29 #include <aros/debug.h>
34 STATIC VOID
HandleEvents(struct Window
*);
36 struct IntuitionBase
*IntuitionBase
;
37 struct Library
*AROSPaletteBase
;
39 Object
*palette
, *prop
;
45 int main(int argc
, char **argv
)
47 struct Task
*inputDevice
;
49 EnterFunc(bug("main()\n"));
53 /* Initialize the input.device's tc_UserData to 0 */
54 inputDevice
= FindTask("input.device");
57 D(bug("Initializing input device's indent count\n"));
58 inputDevice
->tc_UserData
= NULL
;
62 IntuitionBase
= (struct IntuitionBase
*)OpenLibrary("intuition.library", 37);
65 D(bug("Intuiton opened\n"));
67 AROSPaletteBase
= OpenLibrary(AROSPALETTENAME
, 0);
72 D(bug("AROSPalette opened\n"));
74 scr
= LockPubScreen(NULL
);
77 struct Window
*window
;
79 D(bug("Got screen %p\n", scr
));
81 window
= OpenWindowTags(NULL
,
82 WA_PubScreen
, (IPTR
) scr
,
91 WA_Title
, (IPTR
) "Try resize to another aspect ratio",
100 WA_SimpleRefresh
, TRUE
,
102 WA_CloseGadget
, TRUE
,
104 WA_DepthGadget
, TRUE
,
110 D(bug("Window opened\n"));
112 palette
= NewObject(NULL
, AROSPALETTECLASS
,
113 GA_Left
, window
->BorderLeft
+ 5,
114 GA_Top
, window
->BorderTop
* 2 + 5,
115 GA_RelWidth
, -(window
->BorderLeft
+ window
->BorderRight
+ 10),
116 GA_RelHeight
, -(window
->BorderTop
* 2 + window
->BorderBottom
+ 30),
119 AROSA_Palette_Depth
, 3,
120 AROSA_Palette_IndicatorWidth
, 40,
121 GA_Text
, (IPTR
) "Palette gadget",
122 GA_LabelPlace
, GV_LabelPlace_Above
,
125 prop
= NewObject(NULL
, PROPGCLASS
,
128 GA_RelBottom
, -(window
->BorderBottom
+ 22),
129 GA_RelWidth
, -(window
->BorderLeft
+ window
->BorderRight
+ 10),
131 GA_Previous
, (IPTR
) palette
,
136 PGA_Freedom
, FREEHORIZ
,
141 D(bug("Palette created\n"));
143 D(bug("Adding Palette\n"));
144 AddGList(window
, (struct Gadget
*)palette
, 0, 2, NULL
);
146 D(bug("Refreshing Palette\n"));
147 RefreshGList((struct Gadget
*)palette
, window
, NULL
, 2);
149 HandleEvents(window
);
158 DisposeObject(palette
);
160 } /* if (window opened) */
162 UnlockPubScreen(NULL
, scr
);
163 } /*if (screen locked) */
165 CloseLibrary(AROSPaletteBase
);
166 } /* if (paletteclass opened) */
168 CloseLibrary((struct Library
*)IntuitionBase
);
169 } /* if (intuition opened) */
173 ReturnInt ("main", int, 0);
180 VOID
HandleEvents(struct Window
*win
)
182 struct IntuiMessage
*imsg
;
183 struct MsgPort
*port
= win
->UserPort
;
184 BOOL terminated
= FALSE
;
186 EnterFunc(bug("HandleEvents(win=%p)\n", win
));
190 if ((imsg
= (struct IntuiMessage
*)GetMsg(port
)) != NULL
)
196 case IDCMP_GADGETUP
: {
200 D(bug("Received gadgetup"));
202 gad
= (Object
*)imsg
->IAddress
;
204 switch (((struct Gadget
*)gad
)->GadgetID
)
207 D(bug("Color selected: %d\n", imsg
->Code
));
211 D(bug("Changed to depth %d\n", imsg
->Code
));
212 /* Update the palette gadget accordingly */
213 SetGadgetAttrs((struct Gadget
*)palette
, win
, NULL
,
214 AROSA_Palette_Depth
, imsg
->Code
+ 1,
216 RefreshGList((struct Gadget
*)palette
, win
, NULL
, 1);
221 case IDCMP_REFRESHWINDOW
:
223 EndRefresh(win
, TRUE
);
227 case IDCMP_CLOSEWINDOW
:
231 } /* switch (imsg->Class) */
232 ReplyMsg((struct Message
*)imsg
);
235 } /* if ((imsg = GetMsg(port)) != NULL) */
238 Wait(1L << port
->mp_SigBit
);
240 } /* while (!terminated) */
242 ReturnVoid("HandleEvents");
243 } /* HandleEvents() */