define __KERNEL_STRICT_NAMES to avoid inclusion of kernel types on systems that carry...
[cake.git] / workbench / prefs / Zune / cyclesp.c
blob152ec7e7e14f76a290a1b065f9e7b52fb9952309
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_CyclesPData
31 Object *cycle_popimage;
32 Object *menu_position_cycle;
33 Object *menu_level_slider;
34 Object *menu_speed_slider;
35 Object *menu_popframe;
36 Object *background_menu_popimage;
37 Object *recessed_entries_checkmark;
40 static CONST_STRPTR positions_labels[3];
42 static Object*MakeLevelSlider (void)
44 Object *obj = MUI_MakeObject(MUIO_Slider, (IPTR)"", 2, 20);
45 set(obj, MUIA_CycleChain, 1);
46 return obj;
50 static Object*MakeSpeedSlider (void)
52 Object *obj = MUI_MakeObject(MUIO_Slider, (IPTR)"", 0, 50);
53 set(obj, MUIA_CycleChain, 1);
54 return obj;
58 static IPTR CyclesP_New(struct IClass *cl, Object *obj, struct opSet *msg)
60 struct MUI_CyclesPData *data;
61 struct MUI_CyclesPData d;
63 positions_labels[0] = _(MSG_BELOW);
64 positions_labels[1] = _(MSG_ON_ACTIVE);
66 obj = (Object *) DoSuperNewTags
68 cl, obj, NULL,
70 MUIA_Group_Horiz, FALSE,
71 Child, (IPTR) HGroup,
72 GroupFrameT(_(MSG_CYCLE_GADGET_DESIGN)),
73 Child, (IPTR) HVSpace,
74 Child, (IPTR) (d.cycle_popimage =
75 MUI_NewObject
77 MUIC_Popimage,
78 MUIA_Imageadjust_Type, MUIV_Imageadjust_Type_Image,
79 MUIA_CycleChain, 1,
80 MUIA_MaxWidth, 28,
81 MUIA_MaxHeight, 28,
82 MUIA_Imagedisplay_FreeHoriz, FALSE,
83 MUIA_Imagedisplay_FreeVert, FALSE,
84 MUIA_Window_Title, (IPTR) _(MSG_CYCLE),
85 TAG_DONE
86 )),
87 Child, (IPTR) HVSpace,
88 End, /* Cycle Gadget Design */
89 Child, (IPTR) HGroup,
90 Child, (IPTR) VGroup,
91 GroupFrameT(_(MSG_POPUP_MENU_CONTROL)),
92 Child, (IPTR) VSpace(0),
93 Child, (IPTR) ColGroup(2),
94 MUIA_Group_VertSpacing, 2,
95 Child, (IPTR) Label(_(MSG_POSITION)),
96 Child, (IPTR) (d.menu_position_cycle = MakeCycle(_(MSG_POSITION), positions_labels)),
97 Child, (IPTR) Label(_(MSG_LEVEL)),
98 Child, (IPTR) (d.menu_level_slider = MakeLevelSlider()),
99 Child, (IPTR) Label(_(MSG_SPEED)),
100 Child, (IPTR) (d.menu_speed_slider = MakeSpeedSlider()),
101 End,
102 Child, (IPTR) VSpace(0),
103 End, /* Popup Menu Control */
104 Child, (IPTR) VGroup,
105 MUIA_Group_VertSpacing, 2,
106 GroupFrameT(_(MSG_POPUP_MENU_DESIGN)),
107 Child, (IPTR) HGroup,
108 MUIA_Group_SameWidth, TRUE,
109 Child, (IPTR) VGroup,
110 MUIA_Group_VertSpacing, 1,
111 Child, (IPTR) (d.menu_popframe = MakePopframe()),
112 Child, (IPTR) CLabel(_(MSG_FRAME)),
113 End, /* VGroup */
114 Child, (IPTR) VGroup,
115 MUIA_Group_VertSpacing, 1,
116 Child, (IPTR) (d.background_menu_popimage = MUI_NewObject
118 MUIC_Popimage,
119 MUIA_CycleChain, 1,
120 MUIA_Window_Title, (IPTR) _(MSG_ADJUST_BACKGROUND),
121 TAG_DONE
123 Child, (IPTR) CLabel(_(MSG_BACKGROUND)),
124 End, /* VGroup */
125 End, /* HGroup */
126 Child, (IPTR) HGroup,
127 Child, (IPTR) HSpace(0),
128 Child, (IPTR) Label1(_(MSG_RECESSED_ENTRIES)),
129 Child, (IPTR) (d.recessed_entries_checkmark = MakeCheck(NULL)),
130 End, /* HGroup recessed CM */
131 End, /* Popup Menu Design */
132 End, /* HGroup Popup Menu */
134 TAG_MORE, (IPTR) msg->ops_AttrList
137 if (!obj) return FALSE;
139 data = INST_DATA(cl, obj);
140 *data = d;
141 set(data->menu_position_cycle, MUIA_CycleChain, 1);
143 return (IPTR)obj;
148 * MUIM_Settingsgroup_ConfigToGadgets
150 static IPTR CyclesP_ConfigToGadgets(struct IClass *cl, Object *obj,
151 struct MUIP_Settingsgroup_ConfigToGadgets *msg)
153 struct MUI_CyclesPData *data = INST_DATA(cl, obj);
154 STRPTR spec;
156 /* Frame */
157 spec = (STRPTR)DoMethod(msg->configdata, MUIM_Configdata_GetString,
158 MUICFG_Frame_PopUp);
159 set(data->menu_popframe, MUIA_Framedisplay_Spec, (IPTR)spec);
162 /* Images */
163 spec = (STRPTR)DoMethod(msg->configdata, MUIM_Configdata_GetString,
164 MUICFG_Background_PopUp);
165 set(data->background_menu_popimage,MUIA_Imagedisplay_Spec, (IPTR)spec);
166 spec = (STRPTR)DoMethod(msg->configdata, MUIM_Configdata_GetString,
167 MUICFG_Image_Cycle);
168 set(data->cycle_popimage,MUIA_Imagedisplay_Spec, (IPTR)spec);
170 /* Sliders */
171 setslider(data->menu_level_slider,
172 DoMethod(msg->configdata, MUIM_Configdata_GetULong,
173 MUICFG_Cycle_MenuCtrl_Level));
174 setslider(data->menu_speed_slider,
175 DoMethod(msg->configdata, MUIM_Configdata_GetULong,
176 MUICFG_Cycle_MenuCtrl_Speed));
177 /* Checkmark */
178 setcheckmark(data->recessed_entries_checkmark,
179 DoMethod(msg->configdata, MUIM_Configdata_GetULong,
180 MUICFG_Cycle_Menu_Recessed));
182 /* Cycles */
183 setcycle(data->menu_position_cycle,
184 DoMethod(msg->configdata, MUIM_Configdata_GetULong,
185 MUICFG_Cycle_MenuCtrl_Position));
187 return 1;
192 * MUIM_Settingsgroup_ConfigToGadgets
194 static IPTR CyclesP_GadgetsToConfig(struct IClass *cl, Object *obj,
195 struct MUIP_Settingsgroup_GadgetsToConfig *msg)
197 struct MUI_CyclesPData *data = INST_DATA(cl, obj);
198 STRPTR str;
200 /* Frame */
201 str = (STRPTR)XGET(data->menu_popframe, MUIA_Framedisplay_Spec);
202 DoMethod(msg->configdata, MUIM_Configdata_SetFramespec, MUICFG_Frame_PopUp,
203 (IPTR)str);
204 /* Images */
205 str = (STRPTR)XGET(data->background_menu_popimage, MUIA_Imagedisplay_Spec);
206 DoMethod(msg->configdata, MUIM_Configdata_SetImspec, MUICFG_Background_PopUp,
207 (IPTR)str);
208 str = (STRPTR)XGET(data->cycle_popimage, MUIA_Imagedisplay_Spec);
209 DoMethod(msg->configdata, MUIM_Configdata_SetImspec, MUICFG_Image_Cycle,
210 (IPTR)str);
211 /* Sliders */
212 DoMethod(msg->configdata, MUIM_Configdata_SetULong, MUICFG_Cycle_MenuCtrl_Level,
213 XGET(data->menu_level_slider, MUIA_Numeric_Value));
214 DoMethod(msg->configdata, MUIM_Configdata_SetULong, MUICFG_Cycle_MenuCtrl_Speed,
215 XGET(data->menu_speed_slider, MUIA_Numeric_Value));
216 /* Checkmark */
217 DoMethod(msg->configdata, MUIM_Configdata_SetULong, MUICFG_Cycle_Menu_Recessed,
218 XGET(data->recessed_entries_checkmark, MUIA_Selected));
219 /* Cycles */
220 DoMethod(msg->configdata, MUIM_Configdata_SetULong, MUICFG_Cycle_MenuCtrl_Position,
221 XGET(data->menu_position_cycle, MUIA_Cycle_Active));
223 return TRUE;
227 BOOPSI_DISPATCHER(IPTR, CyclesP_Dispatcher, cl, obj, msg)
229 switch (msg->MethodID)
231 case OM_NEW: return CyclesP_New(cl, obj, (struct opSet *)msg);
232 case MUIM_Settingsgroup_ConfigToGadgets: return CyclesP_ConfigToGadgets(cl,obj,(APTR)msg);break;
233 case MUIM_Settingsgroup_GadgetsToConfig: return CyclesP_GadgetsToConfig(cl,obj,(APTR)msg);break;
236 return DoSuperMethodA(cl, obj, msg);
238 BOOPSI_DISPATCHER_END
241 * Class descriptor.
243 const struct __MUIBuiltinClass _MUIP_Cycles_desc = {
244 "Cycles",
245 MUIC_Group,
246 sizeof(struct MUI_CyclesPData),
247 (void*)CyclesP_Dispatcher