define __KERNEL_STRICT_NAMES to avoid inclusion of kernel types on systems that carry...
[cake.git] / workbench / prefs / Zune / listviewsp.c
blob878d5bf52d1e45f5f39a637360dac222e0281386
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_ListviewsPData
31 Object *multi_cycle;
32 Object *refresh_cycle;
33 Object *smooth_checkmark;
34 Object *smooth_slider;
36 Object *fonts_normal_string;
37 Object *fonts_fixed_string;
38 Object *fonts_leading_slider;
40 Object *input_popframe;
41 Object *input_popimage;
42 Object *readonly_popframe;
43 Object *readonly_popimage;
45 Object *active_popimage;
46 Object *selected_popimage;
47 Object *activeselected_popimage;
50 static CONST_STRPTR multi_labels[3];
51 static CONST_STRPTR refresh_labels[3];
53 static Object*MakeListviewspSlider (void)
55 Object *obj = MUI_MakeObject(MUIO_Slider, (IPTR)"", 0, 9);
56 set(obj, MUIA_CycleChain, 1);
57 return obj;
60 static IPTR ListviewsP_New(struct IClass *cl, Object *obj, struct opSet *msg)
62 struct MUI_ListviewsPData *data;
63 struct MUI_ListviewsPData d;
65 multi_labels[0] = _(MSG_SHIFTED);
66 multi_labels[1] = _(MSG_ALWAYS);
68 refresh_labels[0] = _(MSG_LINEAR);
69 refresh_labels[1] = _(MSG_MIXED);
71 obj = (Object *) DoSuperNewTags
73 cl, obj, NULL,
75 MUIA_Group_Columns, 2,
76 MUIA_Group_SameSize, TRUE,
77 Child, (IPTR) VGroup,
78 GroupFrameT(_(MSG_CONTROL)),
79 MUIA_Group_VertSpacing, 0,
80 Child, (IPTR) VSpace(0),
81 Child, (IPTR) ColGroup(2),
82 MUIA_Group_VertSpacing, 2,
83 Child, (IPTR) Label(_(MSG_MULTI)),
84 Child, (IPTR) (d.multi_cycle = MakeCycle(_(MSG_MULTI), multi_labels)),
85 Child, (IPTR) Label(_(MSG_REFRESH)),
86 Child, (IPTR) (d.refresh_cycle = MakeCycle(_(MSG_REFRESH), refresh_labels)),
87 Child, (IPTR) Label(_(MSG_SMOOTH)),
88 Child, (IPTR) HGroup,
89 MUIA_Group_HorizSpacing, 4,
90 Child, (IPTR) (d.smooth_checkmark = MakeCheck(NULL)),
91 Child, (IPTR) (d.smooth_slider = MakeListviewspSlider()),
92 End, /* HGroup */
93 End, /* ColGroup */
94 Child, (IPTR) VSpace(0),
95 End, /* Control VGroup */
97 Child, (IPTR) VGroup,
98 GroupFrameT(_(MSG_FONTS)),
99 MUIA_Group_VertSpacing, 0,
100 Child, (IPTR) VSpace(0),
101 Child, (IPTR) ColGroup(2),
102 MUIA_Group_VertSpacing, 2,
103 Child, (IPTR) Label(_(MSG_NORMAL_COLON)),
104 Child, (IPTR) (d.fonts_normal_string = MakePopfont(FALSE)),
105 Child, (IPTR) Label(_(MSG_FIXED)),
106 Child, (IPTR) (d.fonts_fixed_string = MakePopfont(TRUE)),
107 Child, (IPTR) Label(_(MSG_LEADING)),
108 Child, (IPTR) (d.fonts_leading_slider = MakeListviewspSlider()),
110 End, /* ColGroup */
111 Child, (IPTR) VSpace(0),
112 End, /* Fonts */
114 Child, (IPTR) ColGroup(3),
115 GroupFrameT(_(MSG_DESIGN)),
116 MUIA_Group_VertSpacing, 2,
117 Child, (IPTR) FreeLabel(_(MSG_INPUT_LISTS)),
118 Child, (IPTR) (d.input_popframe = MakePopframe()),
119 Child, (IPTR) (d.input_popimage = MakeBackgroundPopimage()),
120 Child, (IPTR) FreeLabel(_(MSG_READONLY_LISTS)),
121 Child, (IPTR) (d.readonly_popframe = MakePopframe()),
122 Child, (IPTR) (d.readonly_popimage = MakeBackgroundPopimage()),
123 Child, (IPTR) VSpace(0),
124 Child, (IPTR) CLabel(_(MSG_FRAME)),
125 Child, (IPTR) CLabel(_(MSG_BACKGROUND)),
126 End, /* Design ColGroup(3) */
128 Child, (IPTR) ColGroup(3),
129 GroupFrameT(_(MSG_CURSOR)),
130 MUIA_Group_VertSpacing, 2,
131 MUIA_Group_SameSize, TRUE,
132 Child, (IPTR) FreeLabel(_(MSG_ACTIVE)),
133 Child, (IPTR) (d.active_popimage = MakeBackgroundPopimage()),
134 Child, (IPTR) VGroup,
135 Child, (IPTR) HVSpace,
136 Child, (IPTR) CLabel(_(MSG_ACTIVE_SELECTED)),
137 End, /* VGroup */
138 Child, (IPTR) FreeLabel(_(MSG_SELECTED)),
139 Child, (IPTR) (d.selected_popimage = MakeBackgroundPopimage()),
140 Child, (IPTR) (d.activeselected_popimage = MakeBackgroundPopimage()),
141 End, /* Cursor ColGroup */
143 TAG_MORE, (IPTR) msg->ops_AttrList
146 if (!obj) return FALSE;
148 data = INST_DATA(cl, obj);
149 *data = d;
150 set(data->refresh_cycle, MUIA_CycleChain, 1);
151 set(data->multi_cycle, MUIA_CycleChain, 1);
153 DoMethod
155 d.smooth_checkmark, MUIM_Notify, MUIA_Selected, MUIV_EveryTime,
156 (IPTR) d.smooth_slider, 3, MUIM_Set, MUIA_Disabled, MUIV_NotTriggerValue
159 return (IPTR)obj;
163 static IPTR ListviewsP_ConfigToGadgets(struct IClass *cl, Object *obj,
164 struct MUIP_Settingsgroup_ConfigToGadgets *msg)
166 struct MUI_ListviewsPData *data = INST_DATA(cl, obj);
167 STRPTR spec;
169 /* Backgrounds */
170 spec = (STRPTR)DoMethod(msg->configdata, MUIM_Configdata_GetString,
171 MUICFG_Background_List);
172 set(data->input_popimage, MUIA_Imagedisplay_Spec, (IPTR)spec);
174 spec = (STRPTR)DoMethod(msg->configdata, MUIM_Configdata_GetString,
175 MUICFG_Background_ReadList);
176 set(data->readonly_popimage, MUIA_Imagedisplay_Spec, (IPTR)spec);
178 spec = (STRPTR)DoMethod(msg->configdata, MUIM_Configdata_GetString,
179 MUICFG_Background_ListCursor);
180 set(data->active_popimage, MUIA_Imagedisplay_Spec, (IPTR)spec);
182 spec = (STRPTR)DoMethod(msg->configdata, MUIM_Configdata_GetString,
183 MUICFG_Background_ListSelect);
184 set(data->selected_popimage, MUIA_Imagedisplay_Spec, (IPTR)spec);
186 spec = (STRPTR)DoMethod(msg->configdata, MUIM_Configdata_GetString,
187 MUICFG_Background_ListSelCur);
188 set(data->activeselected_popimage, MUIA_Imagedisplay_Spec, (IPTR)spec);
190 /* Frames */
191 spec = (STRPTR)DoMethod(msg->configdata, MUIM_Configdata_GetString,
192 MUICFG_Frame_InputList);
193 set(data->input_popframe, MUIA_Framedisplay_Spec, (IPTR)spec);
195 spec = (STRPTR)DoMethod(msg->configdata, MUIM_Configdata_GetString,
196 MUICFG_Frame_ReadList);
197 set(data->readonly_popframe, MUIA_Framedisplay_Spec, (IPTR)spec);
199 /* Font */
200 setstring(data->fonts_normal_string, (IPTR)FindFont(MUICFG_Font_List));
201 setstring(data->fonts_fixed_string, (IPTR)FindFont(MUICFG_Font_Fixed));
203 /* Sliders */
204 setslider(data->smooth_slider,
205 DoMethod(msg->configdata, MUIM_Configdata_GetULong,
206 MUICFG_Listview_SmoothVal));
207 setslider(data->fonts_leading_slider,
208 DoMethod(msg->configdata, MUIM_Configdata_GetULong,
209 MUICFG_Listview_Font_Leading));
211 /* Checkmarks */
212 setcheckmark(data->smooth_checkmark,
213 DoMethod(msg->configdata, MUIM_Configdata_GetULong,
214 MUICFG_Listview_Smoothed));
215 /* Cycles */
216 setcycle(data->multi_cycle,
217 DoMethod(msg->configdata, MUIM_Configdata_GetULong,
218 MUICFG_Listview_Multi));
220 setcycle(data->refresh_cycle,
221 DoMethod(msg->configdata, MUIM_Configdata_GetULong,
222 MUICFG_Listview_Refresh));
224 return 1;
228 static IPTR ListviewsP_GadgetsToConfig(struct IClass *cl, Object *obj,
229 struct MUIP_Settingsgroup_GadgetsToConfig *msg)
231 struct MUI_ListviewsPData *data = INST_DATA(cl, obj);
232 STRPTR str;
234 /* Font */
235 str = getstring(data->fonts_normal_string);
236 DoMethod(msg->configdata, MUIM_Configdata_SetFont, MUICFG_Font_List, (IPTR)str);
238 str = getstring(data->fonts_fixed_string);
239 DoMethod(msg->configdata, MUIM_Configdata_SetFont, MUICFG_Font_Fixed, (IPTR)str);
241 /* Frames */
242 str = (STRPTR)XGET(data->input_popframe, MUIA_Framedisplay_Spec);
243 DoMethod(msg->configdata, MUIM_Configdata_SetFramespec, MUICFG_Frame_InputList,
244 (IPTR)str);
246 str = (STRPTR)XGET(data->readonly_popframe, MUIA_Framedisplay_Spec);
247 DoMethod(msg->configdata, MUIM_Configdata_SetFramespec, MUICFG_Frame_ReadList,
248 (IPTR)str);
250 /* Backgrounds */
251 str = (STRPTR)XGET(data->input_popimage, MUIA_Imagedisplay_Spec);
252 DoMethod(msg->configdata, MUIM_Configdata_SetImspec, MUICFG_Background_List,
253 (IPTR)str);
255 str = (STRPTR)XGET(data->readonly_popimage, MUIA_Imagedisplay_Spec);
256 DoMethod(msg->configdata, MUIM_Configdata_SetImspec, MUICFG_Background_ReadList,
257 (IPTR)str);
259 str = (STRPTR)XGET(data->active_popimage, MUIA_Imagedisplay_Spec);
260 DoMethod(msg->configdata, MUIM_Configdata_SetImspec, MUICFG_Background_ListCursor,
261 (IPTR)str);
263 str = (STRPTR)XGET(data->selected_popimage, MUIA_Imagedisplay_Spec);
264 DoMethod(msg->configdata, MUIM_Configdata_SetImspec, MUICFG_Background_ListSelect,
265 (IPTR)str);
267 str = (STRPTR)XGET(data->activeselected_popimage, MUIA_Imagedisplay_Spec);
268 DoMethod(msg->configdata, MUIM_Configdata_SetImspec, MUICFG_Background_ListSelCur,
269 (IPTR)str);
271 /* Sliders */
272 DoMethod(msg->configdata, MUIM_Configdata_SetULong, MUICFG_Listview_SmoothVal,
273 XGET(data->smooth_slider, MUIA_Numeric_Value));
275 DoMethod(msg->configdata, MUIM_Configdata_SetULong, MUICFG_Listview_Font_Leading,
276 XGET(data->fonts_leading_slider, MUIA_Numeric_Value));
278 /* Checkmarks */
279 DoMethod(msg->configdata, MUIM_Configdata_SetULong, MUICFG_Listview_Smoothed,
280 XGET(data->smooth_checkmark, MUIA_Selected));
282 /* Cycles */
283 DoMethod(msg->configdata, MUIM_Configdata_SetULong, MUICFG_Listview_Multi,
284 XGET(data->multi_cycle, MUIA_Cycle_Active));
286 DoMethod(msg->configdata, MUIM_Configdata_SetULong, MUICFG_Listview_Refresh,
287 XGET(data->refresh_cycle, MUIA_Cycle_Active));
289 return TRUE;
293 BOOPSI_DISPATCHER(IPTR, ListviewsP_Dispatcher, cl, obj, msg)
295 switch (msg->MethodID)
297 case OM_NEW: return ListviewsP_New(cl, obj, (struct opSet *)msg);
298 case MUIM_Settingsgroup_ConfigToGadgets: return ListviewsP_ConfigToGadgets(cl,obj,(APTR)msg);break;
299 case MUIM_Settingsgroup_GadgetsToConfig: return ListviewsP_GadgetsToConfig(cl,obj,(APTR)msg);break;
302 return DoSuperMethodA(cl, obj, msg);
304 BOOPSI_DISPATCHER_END
307 * Class descriptor.
309 const struct __MUIBuiltinClass _MUIP_Listviews_desc = {
310 "Listviews",
311 MUIC_Group,
312 sizeof(struct MUI_ListviewsPData),
313 (void*)ListviewsP_Dispatcher