define __KERNEL_STRICT_NAMES to avoid inclusion of kernel types on systems that carry...
[cake.git] / workbench / prefs / Zune / scrollbarsp.c
blob4f29881a9753bd61d64179f94e9f79cbcf2463bc
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 <proto/exec.h>
12 #include <proto/graphics.h>
13 #include <proto/utility.h>
14 #include <proto/intuition.h>
15 #include <proto/muimaster.h>
17 #ifdef __AROS__
18 #include <proto/alib.h>
19 #endif
21 #include "zunestuff.h"
22 #include <string.h>
24 /* #define DEBUG 1 */
25 /* #include <aros/debug.h> */
27 extern struct Library *MUIMasterBase;
29 struct MUI_ScrollbarsPData
31 Object *popframe;
32 Object *arrow_up_popimage;
33 Object *arrow_down_popimage;
34 Object *arrow_left_popimage;
35 Object *arrow_right_popimage;
36 Object *gadget_type_cycle;
37 Object *background_popimage;
38 Object *knob_popimage;
39 Object *pos_radios[3];
42 static CONST_STRPTR gadget_type_labels[4];
44 #define FindFont(id) (void*)DoMethod(msg->configdata,MUIM_Dataspace_Find,id)
46 Object *MakeArrowPopimage (CONST_STRPTR wintitle)
48 return MUI_NewObject(MUIC_Popimage,
49 MUIA_Imageadjust_Type, MUIV_Imageadjust_Type_Image,
50 MUIA_CycleChain, 1,
51 MUIA_MaxWidth, 30,
52 MUIA_MaxHeight, 30,
53 MUIA_Imagedisplay_FreeHoriz, FALSE,
54 MUIA_Imagedisplay_FreeVert, FALSE,
55 MUIA_Window_Title, (IPTR)wintitle,
56 TAG_DONE, 0);
59 Object *MakeSingleRadio (void)
61 return ImageObject,
62 MUIA_Image_FontMatch, TRUE,
63 MUIA_InputMode, MUIV_InputMode_Immediate,
64 MUIA_Selected, FALSE,
65 MUIA_ShowSelState, FALSE,
66 MUIA_Image_Spec, MUII_RadioButton,
67 MUIA_Frame, MUIV_Frame_None,
68 End;
71 Object *MakeScrollbar(IPTR type)
73 return ScrollbarObject,
74 MUIA_Scrollbar_Type, type,
75 MUIA_Prop_Entries, 10,
76 MUIA_Prop_Visible, 4,
77 MUIA_Prop_First, 3,
78 End;
81 Object *MakeSpacer(void)
83 return RectangleObject, MUIA_FixWidth, 0, MUIA_FixHeight, 0, MUIA_Weight, 1, End;
86 static IPTR ScrollbarsP_New(struct IClass *cl, Object *obj, struct opSet *msg)
88 struct MUI_ScrollbarsPData *data;
89 struct MUI_ScrollbarsPData d;
90 gadget_type_labels[0] = _(MSG_STANDARD);
91 gadget_type_labels[1] = _(MSG_NEWLOOK);
92 gadget_type_labels[2] = _(MSG_CUSTOM);
95 obj = (Object *) DoSuperNewTags
97 cl, obj, NULL,
99 MUIA_Group_Horiz, TRUE,
100 Child, (IPTR) VGroup, /* left */
102 Child, (IPTR) VGroup,
103 GroupFrameT(_(MSG_ARROWS)),
104 MUIA_Group_Spacing, 0,
105 Child, (IPTR) MakeSpacer(),
106 Child, (IPTR) HGroup,
107 MUIA_Group_Spacing, 0,
108 Child, (IPTR) MakeSpacer(),
109 Child, (IPTR) ColGroup(4),
110 MUIA_Group_SameHeight, TRUE,
111 Child, (IPTR) FreeLabel(_(MSG_UP)),
112 Child, (IPTR) (d.arrow_up_popimage = MakeArrowPopimage(_(MSG_ARROW_UP))),
113 Child, (IPTR) (d.arrow_down_popimage = MakeArrowPopimage(_(MSG_ARROW_DOWN))),
114 Child, (IPTR) FreeLLabel(_(MSG_DOWN)),
115 Child, (IPTR) FreeLabel(_(MSG_LEFT)),
116 Child, (IPTR) (d.arrow_left_popimage = MakeArrowPopimage(_(MSG_ARROW_LEFT))),
117 Child, (IPTR) (d.arrow_right_popimage = MakeArrowPopimage(_(MSG_ARROW_RIGHT))),
118 Child, (IPTR) FreeLLabel(_(MSG_RIGHT)),
119 End, /* ColGroup(6) */
120 Child, (IPTR) MakeSpacer(),
121 End, /* HGroup */
122 Child, (IPTR) MakeSpacer(),
123 End, /* Arrows */
125 Child, (IPTR) VGroup,
126 GroupFrameT(_(MSG_BAR)),
127 Child, (IPTR) HGroup,
128 Child, (IPTR) Label(_(MSG_GADGET_TYPE)),
129 Child, (IPTR) (d.gadget_type_cycle = MakeCycle(_(MSG_GADGET_TYPE), gadget_type_labels)),
130 End, /* HGroup Gadget Type */
131 Child, (IPTR) HGroup,
132 MUIA_Group_SameWidth, TRUE,
133 Child, (IPTR) VGroup,
134 MUIA_Group_VertSpacing, 1,
135 Child, (IPTR) (d.knob_popimage = MUI_NewObject
137 MUIC_Popimage,
138 MUIA_Imageadjust_Type, MUIV_Imageadjust_Type_Image,
139 MUIA_CycleChain, 1,
140 MUIA_Imagedisplay_FreeHoriz, FALSE,
141 MUIA_Imagedisplay_FreeVert, FALSE,
142 MUIA_Window_Title, (IPTR) _(MSG_SCROLLER),
143 TAG_DONE
145 Child, (IPTR) CLabel(_(MSG_KNOB)),
146 End, /* VGroup Knob */
147 Child, (IPTR) VGroup,
148 MUIA_Group_VertSpacing, 1,
149 Child, (IPTR) (d.background_popimage = MakeBackgroundPopimage()),
150 Child, (IPTR) CLabel(_(MSG_BACKGROUND)),
151 End, /* VGroup Background */
152 End, /* HGroup Images */
153 End, /* Bar VGroup*/
154 End, /* VGroup left */
155 Child, (IPTR) VGroup,
156 Child, (IPTR) VGroup,
157 GroupFrameT(_(MSG_FRAME)),
158 Child, (IPTR) (d.popframe = MakePopframe()),
159 End, /* Frame VGroup*/
160 Child, (IPTR) ColGroup(3),
161 GroupFrameT(_(MSG_ARRANGEMENT)),
162 MUIA_CycleChain, 1,
163 Child, (IPTR) (d.pos_radios[0] = MakeSingleRadio()),
164 Child, (IPTR) (d.pos_radios[1] = MakeSingleRadio()),
165 Child, (IPTR) (d.pos_radios[2] = MakeSingleRadio()),
166 Child, (IPTR) MakeScrollbar(MUIV_Scrollbar_Type_Top),
167 Child, (IPTR) MakeScrollbar(MUIV_Scrollbar_Type_Sym),
168 Child, (IPTR) MakeScrollbar(MUIV_Scrollbar_Type_Bottom),
169 End,
170 End, /* VGroup right */
171 TAG_MORE, (IPTR) msg->ops_AttrList);
173 if (!obj) return FALSE;
175 data = INST_DATA(cl, obj);
176 *data = d;
178 DoMethod(d.gadget_type_cycle, MUIM_Notify, MUIA_Cycle_Active, 2, (IPTR) obj,
179 6, MUIM_MultiSet, MUIA_Disabled, FALSE,
180 (IPTR) d.background_popimage, (IPTR) d.knob_popimage, (IPTR) NULL);
181 DoMethod(d.gadget_type_cycle, MUIM_Notify, MUIA_Cycle_Active, 0, (IPTR) obj,
182 6, MUIM_MultiSet, MUIA_Disabled, TRUE,
183 (IPTR) d.background_popimage, (IPTR) d.knob_popimage, (IPTR) NULL);
184 DoMethod(d.gadget_type_cycle, MUIM_Notify, MUIA_Cycle_Active, 1, (IPTR) obj,
185 6, MUIM_MultiSet, MUIA_Disabled, TRUE,
186 (IPTR) d.background_popimage, (IPTR) d.knob_popimage, (IPTR) NULL);
188 DoMethod(d.pos_radios[0], MUIM_Notify, MUIA_Selected, MUIV_EveryTime,
189 (IPTR) d.pos_radios[1], 3, MUIM_NoNotifySet, MUIA_Selected, FALSE);
190 DoMethod(d.pos_radios[0], MUIM_Notify, MUIA_Selected, MUIV_EveryTime,
191 (IPTR) d.pos_radios[2], 3, MUIM_NoNotifySet, MUIA_Selected, FALSE);
192 DoMethod(d.pos_radios[1], MUIM_Notify, MUIA_Selected, MUIV_EveryTime,
193 (IPTR) d.pos_radios[0], 3, MUIM_NoNotifySet, MUIA_Selected, FALSE);
194 DoMethod(d.pos_radios[1], MUIM_Notify, MUIA_Selected, MUIV_EveryTime,
195 (IPTR) d.pos_radios[2], 3, MUIM_NoNotifySet, MUIA_Selected, FALSE);
196 DoMethod(d.pos_radios[2], MUIM_Notify, MUIA_Selected, MUIV_EveryTime,
197 (IPTR) d.pos_radios[0], 3, MUIM_NoNotifySet, MUIA_Selected, FALSE);
198 DoMethod(d.pos_radios[2], MUIM_Notify, MUIA_Selected, MUIV_EveryTime,
199 (IPTR) d.pos_radios[1], 3, MUIM_NoNotifySet, MUIA_Selected, FALSE);
201 return (IPTR) obj;
206 * MUIM_Settingsgroup_ConfigToGadgets
208 static IPTR ScrollbarsP_ConfigToGadgets(struct IClass *cl, Object *obj,
209 struct MUIP_Settingsgroup_ConfigToGadgets *msg)
211 struct MUI_ScrollbarsPData *data = INST_DATA(cl, obj);
212 STRPTR spec;
213 int pos;
215 /* Images */
216 spec = (STRPTR)DoMethod(msg->configdata, MUIM_Configdata_GetString,
217 MUICFG_Image_ArrowUp);
218 set(data->arrow_up_popimage,MUIA_Imagedisplay_Spec, (IPTR)spec);
219 spec = (STRPTR)DoMethod(msg->configdata, MUIM_Configdata_GetString,
220 MUICFG_Image_ArrowDown);
221 set(data->arrow_down_popimage,MUIA_Imagedisplay_Spec, (IPTR)spec);
222 spec = (STRPTR)DoMethod(msg->configdata, MUIM_Configdata_GetString,
223 MUICFG_Image_ArrowLeft);
224 set(data->arrow_left_popimage,MUIA_Imagedisplay_Spec, (IPTR)spec);
225 spec = (STRPTR)DoMethod(msg->configdata, MUIM_Configdata_GetString,
226 MUICFG_Image_ArrowRight);
227 set(data->arrow_right_popimage,MUIA_Imagedisplay_Spec, (IPTR)spec);
229 spec = (STRPTR)DoMethod(msg->configdata, MUIM_Configdata_GetString,
230 MUICFG_Image_PropKnob);
231 set(data->knob_popimage,MUIA_Imagedisplay_Spec, (IPTR)spec);
233 spec = (STRPTR)DoMethod(msg->configdata, MUIM_Configdata_GetString,
234 MUICFG_Background_Prop);
235 set(data->background_popimage,MUIA_Imagedisplay_Spec, (IPTR)spec);
237 /* Cycle */
238 setcycle(data->gadget_type_cycle,
239 DoMethod(msg->configdata, MUIM_Configdata_GetULong,
240 MUICFG_Scrollbar_Type));
242 /* Frame */
243 spec = (STRPTR)DoMethod(msg->configdata, MUIM_Configdata_GetString,
244 MUICFG_Frame_Prop);
245 set(data->popframe, MUIA_Framedisplay_Spec, (IPTR)spec);
247 /* Radio (Arrangement) */
248 pos = DoMethod(msg->configdata, MUIM_Configdata_GetULong,
249 MUICFG_Scrollbar_Arrangement);
250 if (pos < 0 || pos > 2)
251 pos = 0;
252 set(data->pos_radios[pos], MUIA_Selected, TRUE);
254 return 1;
259 * MUIM_Settingsgroup_ConfigToGadgets
261 static IPTR ScrollbarsP_GadgetsToConfig(struct IClass *cl, Object *obj,
262 struct MUIP_Settingsgroup_GadgetsToConfig *msg)
264 struct MUI_ScrollbarsPData *data = INST_DATA(cl, obj);
265 STRPTR str;
266 int pos = 0;
267 int i;
269 /* Frame */
270 str = (STRPTR)XGET(data->popframe, MUIA_Framedisplay_Spec);
271 DoMethod(msg->configdata, MUIM_Configdata_SetFramespec, MUICFG_Frame_Prop,
272 (IPTR)str);
274 /* Cycles */
275 DoMethod(msg->configdata, MUIM_Configdata_SetULong, MUICFG_Scrollbar_Type,
276 XGET(data->gadget_type_cycle, MUIA_Cycle_Active));
278 /* Radio */
279 for (i = 0; i < 3; i++)
281 if (XGET(data->pos_radios[i], MUIA_Selected))
282 pos = i;
285 DoMethod(msg->configdata, MUIM_Configdata_SetULong,
286 MUICFG_Scrollbar_Arrangement, pos);
288 /* Images */
289 str = (STRPTR)XGET(data->background_popimage, MUIA_Imagedisplay_Spec);
290 DoMethod(msg->configdata, MUIM_Configdata_SetImspec, MUICFG_Background_Prop,
291 (IPTR)str);
292 str = (STRPTR)XGET(data->knob_popimage, MUIA_Imagedisplay_Spec);
293 DoMethod(msg->configdata, MUIM_Configdata_SetImspec, MUICFG_Image_PropKnob,
294 (IPTR)str);
295 str = (STRPTR)XGET(data->arrow_up_popimage, MUIA_Imagedisplay_Spec);
296 DoMethod(msg->configdata, MUIM_Configdata_SetImspec, MUICFG_Image_ArrowUp,
297 (IPTR)str);
298 str = (STRPTR)XGET(data->arrow_down_popimage, MUIA_Imagedisplay_Spec);
299 DoMethod(msg->configdata, MUIM_Configdata_SetImspec, MUICFG_Image_ArrowDown,
300 (IPTR)str);
301 str = (STRPTR)XGET(data->arrow_left_popimage, MUIA_Imagedisplay_Spec);
302 DoMethod(msg->configdata, MUIM_Configdata_SetImspec, MUICFG_Image_ArrowLeft,
303 (IPTR)str);
304 str = (STRPTR)XGET(data->arrow_right_popimage, MUIA_Imagedisplay_Spec);
305 DoMethod(msg->configdata, MUIM_Configdata_SetImspec, MUICFG_Image_ArrowRight,
306 (IPTR)str);
307 return TRUE;
311 BOOPSI_DISPATCHER(IPTR, ScrollbarsP_Dispatcher, cl, obj, msg)
313 switch (msg->MethodID)
315 case OM_NEW: return ScrollbarsP_New(cl, obj, (struct opSet *)msg);
316 case MUIM_Settingsgroup_ConfigToGadgets: return ScrollbarsP_ConfigToGadgets(cl,obj,(APTR)msg);break;
317 case MUIM_Settingsgroup_GadgetsToConfig: return ScrollbarsP_GadgetsToConfig(cl,obj,(APTR)msg);break;
320 return DoSuperMethodA(cl, obj, msg);
322 BOOPSI_DISPATCHER_END
325 * Class descriptor.
327 const struct __MUIBuiltinClass _MUIP_Scrollbars_desc = {
328 "Scrollbars",
329 MUIC_Group,
330 sizeof(struct MUI_ScrollbarsPData),
331 (void*)ScrollbarsP_Dispatcher