revert between 56095 -> 55830 in arch
[AROS.git] / workbench / prefs / Zune / scrollbarsp.c
blob5f6c8d18c239d4be0f747c88e3cf915bd90e43d5
1 /*
2 Copyright 2002-2006, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include <graphics/gfx.h>
7 #include <graphics/view.h>
8 #include <clib/alib_protos.h>
9 #include <libraries/asl.h>
10 #include <libraries/mui.h>
11 #include <mui/Rawimage_mcc.h>
12 #include <proto/exec.h>
13 #include <proto/graphics.h>
14 #include <proto/utility.h>
15 #include <proto/intuition.h>
16 #include <proto/muimaster.h>
18 #ifdef __AROS__
19 #include <proto/alib.h>
20 #endif
22 #include "zunestuff.h"
23 #include <string.h>
25 /* #define DEBUG 1 */
26 /* #include <aros/debug.h> */
28 extern struct Library *MUIMasterBase;
30 struct MUI_ScrollbarsPData
32 Object *popframe;
33 Object *arrow_up_popimage;
34 Object *arrow_down_popimage;
35 Object *arrow_left_popimage;
36 Object *arrow_right_popimage;
37 Object *gadget_type_cycle;
38 Object *background_popimage;
39 Object *knob_popimage;
40 Object *pos_radios[3];
43 static CONST_STRPTR gadget_type_labels[4];
45 #define FindFont(id) (void*)DoMethod(msg->configdata,MUIM_Dataspace_Find,id)
47 Object *MakeArrowPopimage (CONST_STRPTR wintitle)
49 return MUI_NewObject(MUIC_Popimage,
50 MUIA_Imageadjust_Type, MUIV_Imageadjust_Type_Image,
51 MUIA_CycleChain, 1,
52 MUIA_MaxWidth, 30,
53 MUIA_MaxHeight, 30,
54 MUIA_Imagedisplay_FreeHoriz, FALSE,
55 MUIA_Imagedisplay_FreeVert, FALSE,
56 MUIA_Window_Title, (IPTR)wintitle,
57 TAG_DONE, 0);
60 Object *MakeSingleRadio (void)
62 return ImageObject,
63 MUIA_Image_FontMatch, TRUE,
64 MUIA_InputMode, MUIV_InputMode_Immediate,
65 MUIA_Selected, FALSE,
66 MUIA_ShowSelState, FALSE,
67 MUIA_Image_Spec, MUII_RadioButton,
68 MUIA_Frame, MUIV_Frame_None,
69 End;
72 Object *MakeScrollbar(IPTR type)
74 return ScrollbarObject,
75 MUIA_Scrollbar_Type, type,
76 MUIA_Prop_Entries, 10,
77 MUIA_Prop_Visible, 4,
78 MUIA_Prop_First, 3,
79 End;
82 Object *MakeSpacer(void)
84 return RectangleObject, MUIA_FixWidth, 0, MUIA_FixHeight, 0, MUIA_Weight, 1, End;
87 static IPTR ScrollbarsP_New(struct IClass *cl, Object *obj, struct opSet *msg)
89 struct MUI_ScrollbarsPData *data;
90 struct MUI_ScrollbarsPData d;
91 gadget_type_labels[0] = _(MSG_STANDARD);
92 gadget_type_labels[1] = _(MSG_NEWLOOK);
93 gadget_type_labels[2] = _(MSG_CUSTOM);
96 obj = (Object *) DoSuperNewTags
98 cl, obj, NULL,
100 MUIA_Group_Horiz, TRUE,
101 Child, (IPTR) VGroup, /* left */
103 Child, (IPTR) VGroup,
104 GroupFrameT(_(MSG_ARROWS)),
105 MUIA_Group_Spacing, 0,
106 Child, (IPTR) MakeSpacer(),
107 Child, (IPTR) HGroup,
108 MUIA_Group_Spacing, 0,
109 Child, (IPTR) MakeSpacer(),
110 Child, (IPTR) ColGroup(4),
111 MUIA_Group_SameHeight, TRUE,
112 Child, (IPTR) FreeLabel(_(MSG_UP)),
113 Child, (IPTR) (d.arrow_up_popimage = MakeArrowPopimage(_(MSG_ARROW_UP))),
114 Child, (IPTR) (d.arrow_down_popimage = MakeArrowPopimage(_(MSG_ARROW_DOWN))),
115 Child, (IPTR) FreeLLabel(_(MSG_DOWN)),
116 Child, (IPTR) FreeLabel(_(MSG_LEFT)),
117 Child, (IPTR) (d.arrow_left_popimage = MakeArrowPopimage(_(MSG_ARROW_LEFT))),
118 Child, (IPTR) (d.arrow_right_popimage = MakeArrowPopimage(_(MSG_ARROW_RIGHT))),
119 Child, (IPTR) FreeLLabel(_(MSG_RIGHT)),
120 End, /* ColGroup(6) */
121 Child, (IPTR) MakeSpacer(),
122 End, /* HGroup */
123 Child, (IPTR) MakeSpacer(),
124 End, /* Arrows */
126 Child, (IPTR) VGroup,
127 GroupFrameT(_(MSG_BAR)),
128 Child, (IPTR) HGroup,
129 Child, (IPTR) Label(_(MSG_GADGET_TYPE)),
130 Child, (IPTR) (d.gadget_type_cycle = MakeCycle(_(MSG_GADGET_TYPE), gadget_type_labels)),
131 End, /* HGroup Gadget Type */
132 Child, (IPTR) HGroup,
133 MUIA_Group_SameWidth, TRUE,
134 Child, (IPTR) VGroup,
135 MUIA_Group_VertSpacing, 1,
136 Child, (IPTR) (d.knob_popimage = MUI_NewObject
138 MUIC_Popimage,
139 MUIA_Imageadjust_Type, MUIV_Imageadjust_Type_Image,
140 MUIA_CycleChain, 1,
141 MUIA_Imagedisplay_FreeHoriz, FALSE,
142 MUIA_Imagedisplay_FreeVert, FALSE,
143 MUIA_Window_Title, (IPTR) _(MSG_SCROLLER),
144 TAG_DONE
146 Child, (IPTR) CLabel(_(MSG_KNOB)),
147 End, /* VGroup Knob */
148 Child, (IPTR) VGroup,
149 MUIA_Group_VertSpacing, 1,
150 Child, (IPTR) (d.background_popimage = MakeBackgroundPopimage()),
151 Child, (IPTR) CLabel(_(MSG_BACKGROUND)),
152 End, /* VGroup Background */
153 End, /* HGroup Images */
154 End, /* Bar VGroup*/
155 End, /* VGroup left */
156 Child, (IPTR) VGroup,
157 Child, (IPTR) VGroup,
158 GroupFrameT(_(MSG_FRAME)),
159 Child, (IPTR) (d.popframe = MakePopframe()),
160 End, /* Frame VGroup*/
161 Child, (IPTR) ColGroup(3),
162 GroupFrameT(_(MSG_ARRANGEMENT)),
163 MUIA_CycleChain, 1,
164 Child, (IPTR) (d.pos_radios[0] = MakeSingleRadio()),
165 Child, (IPTR) (d.pos_radios[1] = MakeSingleRadio()),
166 Child, (IPTR) (d.pos_radios[2] = MakeSingleRadio()),
167 Child, (IPTR) MakeScrollbar(MUIV_Scrollbar_Type_Top),
168 Child, (IPTR) MakeScrollbar(MUIV_Scrollbar_Type_Sym),
169 Child, (IPTR) MakeScrollbar(MUIV_Scrollbar_Type_Bottom),
170 End,
171 End, /* VGroup right */
172 TAG_MORE, (IPTR) msg->ops_AttrList);
174 if (!obj) return FALSE;
176 data = INST_DATA(cl, obj);
177 *data = d;
179 DoMethod(d.gadget_type_cycle, MUIM_Notify, MUIA_Cycle_Active, 2, (IPTR) obj,
180 6, MUIM_MultiSet, MUIA_Disabled, FALSE,
181 (IPTR) d.background_popimage, (IPTR) d.knob_popimage, (IPTR) NULL);
182 DoMethod(d.gadget_type_cycle, MUIM_Notify, MUIA_Cycle_Active, 0, (IPTR) obj,
183 6, MUIM_MultiSet, MUIA_Disabled, TRUE,
184 (IPTR) d.background_popimage, (IPTR) d.knob_popimage, (IPTR) NULL);
185 DoMethod(d.gadget_type_cycle, MUIM_Notify, MUIA_Cycle_Active, 1, (IPTR) obj,
186 6, MUIM_MultiSet, MUIA_Disabled, TRUE,
187 (IPTR) d.background_popimage, (IPTR) d.knob_popimage, (IPTR) NULL);
189 DoMethod(d.pos_radios[0], MUIM_Notify, MUIA_Selected, MUIV_EveryTime,
190 (IPTR) d.pos_radios[1], 3, MUIM_NoNotifySet, MUIA_Selected, FALSE);
191 DoMethod(d.pos_radios[0], MUIM_Notify, MUIA_Selected, MUIV_EveryTime,
192 (IPTR) d.pos_radios[2], 3, MUIM_NoNotifySet, MUIA_Selected, FALSE);
193 DoMethod(d.pos_radios[1], MUIM_Notify, MUIA_Selected, MUIV_EveryTime,
194 (IPTR) d.pos_radios[0], 3, MUIM_NoNotifySet, MUIA_Selected, FALSE);
195 DoMethod(d.pos_radios[1], MUIM_Notify, MUIA_Selected, MUIV_EveryTime,
196 (IPTR) d.pos_radios[2], 3, MUIM_NoNotifySet, MUIA_Selected, FALSE);
197 DoMethod(d.pos_radios[2], MUIM_Notify, MUIA_Selected, MUIV_EveryTime,
198 (IPTR) d.pos_radios[0], 3, MUIM_NoNotifySet, MUIA_Selected, FALSE);
199 DoMethod(d.pos_radios[2], MUIM_Notify, MUIA_Selected, MUIV_EveryTime,
200 (IPTR) d.pos_radios[1], 3, MUIM_NoNotifySet, MUIA_Selected, FALSE);
202 return (IPTR) obj;
207 * MUIM_Settingsgroup_ConfigToGadgets
209 static IPTR ScrollbarsP_ConfigToGadgets(struct IClass *cl, Object *obj,
210 struct MUIP_Settingsgroup_ConfigToGadgets *msg)
212 struct MUI_ScrollbarsPData *data = INST_DATA(cl, obj);
213 STRPTR spec;
214 int pos;
216 /* Images */
217 spec = (STRPTR)DoMethod(msg->configdata, MUIM_Configdata_GetString,
218 MUICFG_Image_ArrowUp);
219 set(data->arrow_up_popimage,MUIA_Imagedisplay_Spec, (IPTR)spec);
220 spec = (STRPTR)DoMethod(msg->configdata, MUIM_Configdata_GetString,
221 MUICFG_Image_ArrowDown);
222 set(data->arrow_down_popimage,MUIA_Imagedisplay_Spec, (IPTR)spec);
223 spec = (STRPTR)DoMethod(msg->configdata, MUIM_Configdata_GetString,
224 MUICFG_Image_ArrowLeft);
225 set(data->arrow_left_popimage,MUIA_Imagedisplay_Spec, (IPTR)spec);
226 spec = (STRPTR)DoMethod(msg->configdata, MUIM_Configdata_GetString,
227 MUICFG_Image_ArrowRight);
228 set(data->arrow_right_popimage,MUIA_Imagedisplay_Spec, (IPTR)spec);
230 spec = (STRPTR)DoMethod(msg->configdata, MUIM_Configdata_GetString,
231 MUICFG_Image_PropKnob);
232 set(data->knob_popimage,MUIA_Imagedisplay_Spec, (IPTR)spec);
234 spec = (STRPTR)DoMethod(msg->configdata, MUIM_Configdata_GetString,
235 MUICFG_Background_Prop);
236 set(data->background_popimage,MUIA_Imagedisplay_Spec, (IPTR)spec);
238 /* Cycle */
239 setcycle(data->gadget_type_cycle,
240 DoMethod(msg->configdata, MUIM_Configdata_GetULong,
241 MUICFG_Scrollbar_Type));
243 /* Frame */
244 spec = (STRPTR)DoMethod(msg->configdata, MUIM_Configdata_GetString,
245 MUICFG_Frame_Prop);
246 set(data->popframe, MUIA_Framedisplay_Spec, (IPTR)spec);
248 /* Radio (Arrangement) */
249 pos = DoMethod(msg->configdata, MUIM_Configdata_GetULong,
250 MUICFG_Scrollbar_Arrangement);
251 if (pos < 0 || pos > 2)
252 pos = 0;
253 set(data->pos_radios[pos], MUIA_Selected, TRUE);
255 return 1;
260 * MUIM_Settingsgroup_ConfigToGadgets
262 static IPTR ScrollbarsP_GadgetsToConfig(struct IClass *cl, Object *obj,
263 struct MUIP_Settingsgroup_GadgetsToConfig *msg)
265 struct MUI_ScrollbarsPData *data = INST_DATA(cl, obj);
266 STRPTR str;
267 int pos = 0;
268 int i;
270 /* Frame */
271 str = (STRPTR)XGET(data->popframe, MUIA_Framedisplay_Spec);
272 DoMethod(msg->configdata, MUIM_Configdata_SetFramespec, MUICFG_Frame_Prop,
273 (IPTR)str);
275 /* Cycles */
276 DoMethod(msg->configdata, MUIM_Configdata_SetULong, MUICFG_Scrollbar_Type,
277 XGET(data->gadget_type_cycle, MUIA_Cycle_Active));
279 /* Radio */
280 for (i = 0; i < 3; i++)
282 if (XGET(data->pos_radios[i], MUIA_Selected))
283 pos = i;
286 DoMethod(msg->configdata, MUIM_Configdata_SetULong,
287 MUICFG_Scrollbar_Arrangement, pos);
289 /* Images */
290 str = (STRPTR)XGET(data->background_popimage, MUIA_Imagedisplay_Spec);
291 DoMethod(msg->configdata, MUIM_Configdata_SetImspec, MUICFG_Background_Prop,
292 (IPTR)str);
293 str = (STRPTR)XGET(data->knob_popimage, MUIA_Imagedisplay_Spec);
294 DoMethod(msg->configdata, MUIM_Configdata_SetImspec, MUICFG_Image_PropKnob,
295 (IPTR)str);
296 str = (STRPTR)XGET(data->arrow_up_popimage, MUIA_Imagedisplay_Spec);
297 DoMethod(msg->configdata, MUIM_Configdata_SetImspec, MUICFG_Image_ArrowUp,
298 (IPTR)str);
299 str = (STRPTR)XGET(data->arrow_down_popimage, MUIA_Imagedisplay_Spec);
300 DoMethod(msg->configdata, MUIM_Configdata_SetImspec, MUICFG_Image_ArrowDown,
301 (IPTR)str);
302 str = (STRPTR)XGET(data->arrow_left_popimage, MUIA_Imagedisplay_Spec);
303 DoMethod(msg->configdata, MUIM_Configdata_SetImspec, MUICFG_Image_ArrowLeft,
304 (IPTR)str);
305 str = (STRPTR)XGET(data->arrow_right_popimage, MUIA_Imagedisplay_Spec);
306 DoMethod(msg->configdata, MUIM_Configdata_SetImspec, MUICFG_Image_ArrowRight,
307 (IPTR)str);
308 return TRUE;
312 BOOPSI_DISPATCHER(IPTR, ScrollbarsP_Dispatcher, cl, obj, msg)
314 switch (msg->MethodID)
316 case OM_NEW: return ScrollbarsP_New(cl, obj, (struct opSet *)msg);
317 case MUIM_Settingsgroup_ConfigToGadgets: return ScrollbarsP_ConfigToGadgets(cl,obj,(APTR)msg);break;
318 case MUIM_Settingsgroup_GadgetsToConfig: return ScrollbarsP_GadgetsToConfig(cl,obj,(APTR)msg);break;
321 return DoSuperMethodA(cl, obj, msg);
323 BOOPSI_DISPATCHER_END
326 * Class descriptor.
328 const struct __MUIBuiltinClass _MUIP_Scrollbars_desc = {
329 "Scrollbars",
330 MUIC_Group,
331 sizeof(struct MUI_ScrollbarsPData),
332 (void*)ScrollbarsP_Dispatcher
336 static const UBYTE icon32[] =
338 0x00, 0x00, 0x00, 0x18, // width
339 0x00, 0x00, 0x00, 0x13, // height
340 'B', 'Z', '2', '\0',
341 0x00, 0x00, 0x00, 0x73, // number of bytes
343 0x42, 0x5a, 0x68, 0x39, 0x31, 0x41, 0x59, 0x26, 0x53, 0x59, 0x59, 0x8b,
344 0x3a, 0xec, 0x00, 0x02, 0xf4, 0x61, 0x12, 0xa2, 0x20, 0x00, 0x02, 0x00,
345 0x04, 0x00, 0x01, 0x42, 0x40, 0x00, 0x00, 0xb0, 0x00, 0xb9, 0x21, 0x09,
346 0x50, 0x01, 0x00, 0x30, 0x0a, 0x8a, 0x6a, 0x68, 0xc9, 0xd1, 0x2a, 0x9a,
347 0x29, 0x30, 0xa2, 0x6c, 0x84, 0xb2, 0x26, 0x3c, 0x6d, 0x99, 0xad, 0xae,
348 0xb4, 0xc0, 0xf4, 0x89, 0x38, 0x10, 0x74, 0x20, 0xc1, 0x10, 0xe0, 0x75,
349 0x24, 0x24, 0xf4, 0xa3, 0x20, 0xb1, 0x26, 0x24, 0x0a, 0xda, 0xce, 0x24,
350 0x74, 0xd2, 0x18, 0x83, 0x59, 0x80, 0x62, 0x51, 0x34, 0xe9, 0x07, 0x01,
351 0x2a, 0x97, 0x00, 0x0c, 0x62, 0x94, 0xa5, 0x29, 0xf8, 0xbb, 0x92, 0x29,
352 0xc2, 0x84, 0x82, 0xcc, 0x59, 0xd7, 0x60,
356 Object *scrollbarsclass_get_icon(void)
358 return RawimageObject,
359 MUIA_Rawimage_Data, icon32,
360 End;