Use hardcoded settings for VIA VT1708S (they are reported to work
[AROS.git] / workbench / prefs / Zune / slidersp.c
blob96dd76bc0f7e2a56a7ddb999622233f1b7cba9cc
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_SlidersPData
31 Object *container_background_popimage;
32 Object *container_popframe;
33 Object *knob_background_popimage;
34 Object *knob_popframe;
35 Object *knob_font_string;
39 static Object *MakeSmallHorizSlider(void)
41 Object *obj = MUI_MakeObject(MUIO_Slider, (IPTR)"", 0, 9);
42 set(obj, MUIA_CycleChain, 1);
43 set(obj, MUIA_Numeric_Value, 5);
44 return obj;
47 static Object *MakeBigHorizSlider(void)
49 Object *obj = MUI_MakeObject(MUIO_Slider, (IPTR)"", 0, 99);
50 set(obj, MUIA_CycleChain, 1);
51 set(obj, MUIA_Numeric_Value, 42);
52 return obj;
55 static Object *MakeSmallVertSlider(void)
57 return SliderObject,
58 MUIA_Slider_Horiz, FALSE,
59 MUIA_CycleChain, 1,
60 MUIA_Numeric_Min, 0,
61 MUIA_Numeric_Max, 9,
62 MUIA_Numeric_Value, 5,
63 End;
66 static Object *MakeBigVertSlider(void)
68 return SliderObject,
69 MUIA_Slider_Horiz, FALSE,
70 MUIA_CycleChain, 1,
71 MUIA_Numeric_Min, 0,
72 MUIA_Numeric_Max, 99,
73 MUIA_Numeric_Value, 42,
74 End;
77 static IPTR SlidersP_New(struct IClass *cl, Object *obj, struct opSet *msg)
79 struct MUI_SlidersPData *data;
80 struct MUI_SlidersPData d;
82 obj = (Object *) DoSuperNewTags
84 cl, obj, NULL,
86 MUIA_Group_Horiz, FALSE,
88 Child, (IPTR) HGroup,
89 MUIA_VertWeight, 800,
90 Child, (IPTR) HGroup,
91 GroupFrameT(_(MSG_CONTAINER_DESIGN)),
92 Child, (IPTR) HGroup,
93 MUIA_Group_SameWidth, TRUE,
94 Child, (IPTR) VGroup,
95 MUIA_Group_VertSpacing, 1,
96 Child, (IPTR) (d.container_background_popimage = MakeBackgroundPopimage()),
97 Child, (IPTR) CLabel(_(MSG_BACKGROUND)),
98 End, /* VGroup BG */
99 Child, (IPTR) VGroup,
100 MUIA_Group_VertSpacing, 1,
101 Child, (IPTR) (d.container_popframe = MakePopframe()),
102 Child, (IPTR) CLabel(_(MSG_FRAME)),
103 End, /* VGroup Frame */
104 End, /* HGroup Frame/BG */
105 End, /* HGroup Container Design */
106 Child, (IPTR) VGroup,
107 GroupFrameT(_(MSG_KNOB_DESIGN)),
108 Child, (IPTR) HGroup,
109 MUIA_Group_SameWidth, TRUE,
110 Child, (IPTR) VGroup,
111 MUIA_Group_VertSpacing, 1,
112 Child, (IPTR) (d.knob_background_popimage = MakeBackgroundPopimage()),
113 Child, (IPTR) CLabel(_(MSG_BACKGROUND)),
114 End, /* VGroup BG */
115 Child, (IPTR) VGroup,
116 MUIA_Group_VertSpacing, 1,
117 Child, (IPTR) (d.knob_popframe = MakePopframe()),
118 Child, (IPTR) CLabel(_(MSG_FRAME)),
119 End, /* VGroup Frame */
120 End, /* HGroup Frame/BG */
121 Child, (IPTR) HGroup,
122 Child, (IPTR) Label2(_(MSG_FONT)),
123 Child, (IPTR) (d.knob_font_string = MakePopfont(FALSE)),
124 End, /* HGroup font */
125 End, /* VGroup Knob Design */
126 End, /* HGroup Container/Knob design */
128 Child, (IPTR) VGroup,
129 GroupFrameT(_(MSG_EXAMPLE_SLIDERS)),
130 Child, (IPTR) VSpace(0),
131 Child, (IPTR) HGroup,
132 Child, (IPTR) VGroup,
133 Child, (IPTR) MakeSmallHorizSlider(),
134 Child, (IPTR) MakeBigHorizSlider(),
135 End, /* VGroup horiz sliders */
136 Child, (IPTR) MakeSmallVertSlider(),
137 Child, (IPTR) MakeBigVertSlider(),
138 End, /* HGroup */
139 Child, (IPTR) HVSpace,
140 End, /* VGroup Slider examples */
142 TAG_MORE, (IPTR) msg->ops_AttrList
145 if (!obj) return FALSE;
147 data = INST_DATA(cl, obj);
148 *data = d;
150 return (IPTR)obj;
155 * MUIM_Settingsgroup_ConfigToGadgets
157 static IPTR SlidersP_ConfigToGadgets(struct IClass *cl, Object *obj,
158 struct MUIP_Settingsgroup_ConfigToGadgets *msg)
160 struct MUI_SlidersPData *data = INST_DATA(cl, obj);
161 STRPTR spec;
163 /* Frame */
164 spec = (STRPTR)DoMethod(msg->configdata, MUIM_Configdata_GetString,
165 MUICFG_Frame_Slider);
166 set(data->container_popframe, MUIA_Framedisplay_Spec, (IPTR)spec);
168 spec = (STRPTR)DoMethod(msg->configdata, MUIM_Configdata_GetString,
169 MUICFG_Frame_Knob);
170 set(data->knob_popframe, MUIA_Framedisplay_Spec, (IPTR)spec);
172 /* Images */
173 spec = (STRPTR)DoMethod(msg->configdata, MUIM_Configdata_GetString,
174 MUICFG_Background_Slider);
175 set(data->container_background_popimage,MUIA_Imagedisplay_Spec, (IPTR)spec);
176 spec = (STRPTR)DoMethod(msg->configdata, MUIM_Configdata_GetString,
177 MUICFG_Background_SliderKnob);
178 set(data->knob_background_popimage,MUIA_Imagedisplay_Spec, (IPTR)spec);
180 /* Fonts */
181 setstring(data->knob_font_string, (IPTR)FindFont(MUICFG_Font_Knob));
183 return 1;
188 * MUIM_Settingsgroup_ConfigToGadgets
190 static IPTR SlidersP_GadgetsToConfig(struct IClass *cl, Object *obj,
191 struct MUIP_Settingsgroup_GadgetsToConfig *msg)
193 struct MUI_SlidersPData *data = INST_DATA(cl, obj);
194 STRPTR str;
196 /* Fonts */
197 str = getstring(data->knob_font_string);
198 DoMethod(msg->configdata, MUIM_Configdata_SetFont, MUICFG_Font_Knob, (IPTR)str);
200 /* Backgrounds */
201 str = (STRPTR)XGET(data->container_background_popimage,MUIA_Imagedisplay_Spec);
202 DoMethod(msg->configdata, MUIM_Configdata_SetImspec, MUICFG_Background_Slider,
203 (IPTR)str);
205 str = (STRPTR)XGET(data->knob_background_popimage,MUIA_Imagedisplay_Spec);
206 DoMethod(msg->configdata, MUIM_Configdata_SetImspec, MUICFG_Background_SliderKnob,
207 (IPTR)str);
209 /* Frame */
210 str = (STRPTR)XGET(data->container_popframe, MUIA_Framedisplay_Spec);
211 DoMethod(msg->configdata, MUIM_Configdata_SetFramespec, MUICFG_Frame_Slider,
212 (IPTR)str);
213 str = (STRPTR)XGET(data->knob_popframe, MUIA_Framedisplay_Spec);
214 DoMethod(msg->configdata, MUIM_Configdata_SetFramespec, MUICFG_Frame_Knob,
215 (IPTR)str);
216 return TRUE;
220 BOOPSI_DISPATCHER(IPTR, SlidersP_Dispatcher, cl, obj, msg)
222 switch (msg->MethodID)
224 case OM_NEW: return SlidersP_New(cl, obj, (struct opSet *)msg);
225 case MUIM_Settingsgroup_ConfigToGadgets: return SlidersP_ConfigToGadgets(cl,obj,(APTR)msg);break;
226 case MUIM_Settingsgroup_GadgetsToConfig: return SlidersP_GadgetsToConfig(cl,obj,(APTR)msg);break;
229 return DoSuperMethodA(cl, obj, msg);
231 BOOPSI_DISPATCHER_END
234 * Class descriptor.
236 const struct __MUIBuiltinClass _MUIP_Sliders_desc = {
237 "Sliders",
238 MUIC_Group,
239 sizeof(struct MUI_SlidersPData),
240 (void*)SlidersP_Dispatcher