Paolones's icons for Zune Prefs Editor.
[AROS.git] / workbench / prefs / Zune / windowp.c
blobd2b24c3a4eb0216ef68984d0a29e01f5b281392f
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 //#define DEBUG 1
21 //#include <aros/debug.h>
22 #endif
24 #include "zunestuff.h"
25 #include <string.h>
27 extern struct Library *MUIMasterBase;
29 struct MUI_WindowPData
31 Object *positions_cycle;
32 Object *refresh_cycle;
33 Object *redraw_cycle;
34 Object *font_normal_string;
35 Object *font_tiny_string;
36 Object *font_big_string;
37 Object *background_window_popimage;
38 Object *background_requester_popimage;
39 Object *spacing_left_slider;
40 Object *spacing_right_slider;
41 Object *spacing_top_slider;
42 Object *spacing_bottom_slider;
43 Object *mui;
44 Object *popup;
45 Object *iconify;
46 Object *snapshot;
49 static CONST_STRPTR positions_labels[4];
50 static CONST_STRPTR refresh_labels[3];
51 static CONST_STRPTR redraw_labels[3];
53 #define _Button(name)\
54 TextObject,\
55 ButtonFrame,\
56 MUIA_Font, MUIV_Font_Button,\
57 MUIA_Text_Contents, name,\
58 MUIA_Text_PreParse, "\33c",\
59 MUIA_InputMode , MUIV_InputMode_Toggle,\
60 MUIA_Background , MUII_ButtonBack,\
61 End
63 static IPTR WindowP_New(struct IClass *cl, Object *obj, struct opSet *msg)
65 struct MUI_WindowPData *data;
66 struct MUI_WindowPData d;
68 positions_labels[0] = _(MSG_FORGET_ON_EXIT);
69 positions_labels[1] = _(MSG_REMEMBER_ON_EXIT);
70 positions_labels[2] = _(MSG_SAVE_ON_EXIT);
72 refresh_labels[0] = _(MSG_SMART);
73 refresh_labels[1] = _(MSG_SIMPLE);
75 redraw_labels[0] = _(MSG_WITHOUT_CLEAR);
76 redraw_labels[1] = _(MSG_WITH_CLEAR);
78 obj = (Object *) DoSuperNewTags
80 cl, obj, NULL,
82 Child, (IPTR) HGroup,
83 Child, (IPTR) VGroup,
84 Child, (IPTR) VGroup,
85 GroupFrameT(_(MSG_CONTROL)),
86 Child, (IPTR) VSpace(0),
87 Child, (IPTR) ColGroup(2),
88 MUIA_Group_VertSpacing, 2,
89 Child, (IPTR) Label(_(MSG_POSITIONS)),
90 Child, (IPTR) (d.positions_cycle = MakeCycle(_(MSG_POSITIONS), positions_labels)),
91 Child, (IPTR) Label(_(MSG_REFRESH)),
92 Child, (IPTR) (d.refresh_cycle = MakeCycle(_(MSG_REFRESH), refresh_labels)),
93 Child, (IPTR) Label(_(MSG_REDRAW)),
94 Child, (IPTR) (d.redraw_cycle = MakeCycle(_(MSG_REDRAW), redraw_labels)),
95 Child, (IPTR) Label(_(MSG_BUTTONS)),
96 Child, HGroup,
97 NoFrame,
98 Child, ColGroup(8),
99 NoFrame,
100 Child, HVSpace,
101 Child, d.mui = _Button("M"),
102 Child, HVSpace,
103 Child, d.snapshot = _Button("S"),
104 Child, HVSpace,
105 Child, d.popup = _Button("P"),
106 Child, HVSpace,
107 Child, d.iconify = _Button("I"),
108 End,
109 End,
110 End,
111 Child, (IPTR) VSpace(0),
112 End,
113 Child, (IPTR) VGroup,
114 GroupFrameT(_(MSG_FONTS)),
115 Child, (IPTR) VSpace(0),
116 Child, (IPTR) ColGroup(2),
117 MUIA_Group_VertSpacing, 2,
118 Child, (IPTR) Label(_(MSG_NORMAL_COLON)),
119 Child, (IPTR) (d.font_normal_string = MakePopfont(FALSE)),
120 Child, (IPTR) Label(_(MSG_TINY)),
121 Child, (IPTR) (d.font_tiny_string = MakePopfont(FALSE)),
122 Child, (IPTR) Label(_(MSG_BIG)),
123 Child, (IPTR) (d.font_big_string = MakePopfont(FALSE)),
124 End,
125 Child, (IPTR) VSpace(0),
126 End,
127 End,
128 Child, (IPTR) VGroup,
129 Child, (IPTR) HGroup,
130 GroupFrameT(_(MSG_BACKGROUND)),
131 MUIA_Group_SameWidth, TRUE,
132 Child, (IPTR) VGroup,
133 MUIA_Group_VertSpacing, 1,
134 Child, (IPTR) (d.background_window_popimage = MakeBackgroundPopimage()),
135 Child, (IPTR) CLabel(_(MSG_WINDOW)),
136 End,
137 Child, (IPTR) VGroup,
138 MUIA_Group_VertSpacing, 1,
139 Child, (IPTR) (d.background_requester_popimage = MakeBackgroundPopimage()),
140 Child, (IPTR) CLabel(_(MSG_REQUESTER)),
141 End,
142 End,
143 Child, (IPTR) ColGroup(4),
144 GroupFrameT(_(MSG_SPACING)),
145 MUIA_Group_Spacing, 2,
146 Child, (IPTR) Label(_(MSG_L)),
147 Child, (IPTR) (d.spacing_left_slider = MakeSpacingSlider()),
148 Child, (IPTR) (d.spacing_top_slider = MakeSpacingSlider()),
149 Child, (IPTR) Label(_(MSG_T)),
150 Child, (IPTR) Label(_(MSG_R)),
151 Child, (IPTR) (d.spacing_right_slider = MakeSpacingSlider()),
152 Child, (IPTR) (d.spacing_bottom_slider = MakeSpacingSlider()),
153 Child, (IPTR) Label(_(MSG_B)),
154 End,
155 End,
156 End,
157 TAG_MORE, (IPTR) msg->ops_AttrList);
159 if (!obj) return FALSE;
161 data = INST_DATA(cl, obj);
162 *data = d;
164 set(data->refresh_cycle, MUIA_Disabled, TRUE);
165 //set(data->positions_cycle, MUIA_Disabled, TRUE);
167 return (IPTR)obj;
171 static IPTR WindowP_ConfigToGadgets(struct IClass *cl, Object *obj,
172 struct MUIP_Settingsgroup_ConfigToGadgets *msg)
174 struct MUI_WindowPData *data = INST_DATA(cl, obj);
175 STRPTR spec;
177 /* Fonts */
178 setstring(data->font_normal_string, (IPTR)FindFont(MUICFG_Font_Normal));
179 setstring(data->font_tiny_string, (IPTR)FindFont(MUICFG_Font_Tiny));
180 setstring(data->font_big_string, (IPTR)FindFont(MUICFG_Font_Big));
182 /* Backgrounds */
183 spec = (STRPTR)DoMethod(msg->configdata, MUIM_Configdata_GetString,
184 MUICFG_Background_Window);
185 set(data->background_window_popimage,MUIA_Imagedisplay_Spec, (IPTR)spec);
187 spec = (STRPTR)DoMethod(msg->configdata, MUIM_Configdata_GetString,
188 MUICFG_Background_Requester);
189 set(data->background_requester_popimage,MUIA_Imagedisplay_Spec, (IPTR)spec);
191 /* Spacing */
192 setslider(data->spacing_left_slider,
193 DoMethod(msg->configdata, MUIM_Configdata_GetULong,
194 MUICFG_Window_Spacing_Left));
195 setslider(data->spacing_right_slider,
196 DoMethod(msg->configdata, MUIM_Configdata_GetULong,
197 MUICFG_Window_Spacing_Right));
198 setslider(data->spacing_top_slider,
199 DoMethod(msg->configdata, MUIM_Configdata_GetULong,
200 MUICFG_Window_Spacing_Top));
201 setslider(data->spacing_bottom_slider,
202 DoMethod(msg->configdata, MUIM_Configdata_GetULong,
203 MUICFG_Window_Spacing_Bottom));
205 /* Cycles */
206 setcycle(data->redraw_cycle,
207 DoMethod(msg->configdata, MUIM_Configdata_GetULong,
208 MUICFG_Window_Redraw));
209 setcycle(data->positions_cycle,
210 DoMethod(msg->configdata, MUIM_Configdata_GetULong,
211 MUICFG_Window_Positions));
213 ULONG buttons = DoMethod(msg->configdata, MUIM_Configdata_GetULong, MUICFG_Window_Buttons);
215 if ((buttons & MUIV_Window_Button_MUI) != 0) set(data->mui, MUIA_Selected, TRUE); else set(data->mui, MUIA_Selected, FALSE);
216 if ((buttons & MUIV_Window_Button_Popup) != 0) set(data->popup, MUIA_Selected, TRUE); else set(data->popup, MUIA_Selected, FALSE);
217 if ((buttons & MUIV_Window_Button_Iconify) != 0) set(data->iconify, MUIA_Selected, TRUE); else set(data->iconify, MUIA_Selected, FALSE);
218 if ((buttons & MUIV_Window_Button_Snapshot) != 0) set(data->snapshot, MUIA_Selected, TRUE); else set(data->snapshot, MUIA_Selected, FALSE);
220 return 1;
224 static IPTR WindowP_GadgetsToConfig(struct IClass *cl, Object *obj,
225 struct MUIP_Settingsgroup_GadgetsToConfig *msg)
227 struct MUI_WindowPData *data = INST_DATA(cl, obj);
228 STRPTR str;
230 /* Fonts */
231 str = getstring(data->font_normal_string);
232 DoMethod(msg->configdata, MUIM_Configdata_SetFont, MUICFG_Font_Normal, (IPTR)str);
234 str = getstring(data->font_tiny_string);
235 DoMethod(msg->configdata, MUIM_Configdata_SetFont, MUICFG_Font_Tiny, (IPTR)str);
237 str = getstring(data->font_big_string);
238 DoMethod(msg->configdata, MUIM_Configdata_SetFont, MUICFG_Font_Big, (IPTR)str);
240 /* Backgrounds */
241 str = (STRPTR)XGET(data->background_window_popimage,MUIA_Imagedisplay_Spec);
242 DoMethod(msg->configdata, MUIM_Configdata_SetImspec, MUICFG_Background_Window,
243 (IPTR)str);
245 str = (STRPTR)XGET(data->background_requester_popimage,MUIA_Imagedisplay_Spec);
246 DoMethod(msg->configdata, MUIM_Configdata_SetImspec, MUICFG_Background_Requester,
247 (IPTR)str);
249 /* Spacing */
250 DoMethod(msg->configdata, MUIM_Configdata_SetULong, MUICFG_Window_Spacing_Left,
251 XGET(data->spacing_left_slider, MUIA_Numeric_Value));
252 DoMethod(msg->configdata, MUIM_Configdata_SetULong, MUICFG_Window_Spacing_Right,
253 XGET(data->spacing_right_slider, MUIA_Numeric_Value));
254 DoMethod(msg->configdata, MUIM_Configdata_SetULong, MUICFG_Window_Spacing_Top,
255 XGET(data->spacing_top_slider, MUIA_Numeric_Value));
256 DoMethod(msg->configdata, MUIM_Configdata_SetULong, MUICFG_Window_Spacing_Bottom,
257 XGET(data->spacing_bottom_slider, MUIA_Numeric_Value));
259 /* Cycles */
260 DoMethod(msg->configdata, MUIM_Configdata_SetULong, MUICFG_Window_Redraw,
261 XGET(data->redraw_cycle, MUIA_Cycle_Active));
262 DoMethod(msg->configdata, MUIM_Configdata_SetULong, MUICFG_Window_Positions,
263 XGET(data->positions_cycle, MUIA_Cycle_Active));
265 ULONG buttons = 0;
267 if (XGET(data->mui, MUIA_Selected) != FALSE) buttons |= MUIV_Window_Button_MUI;
268 if (XGET(data->popup, MUIA_Selected) != FALSE) buttons |= MUIV_Window_Button_Popup;
269 if (XGET(data->snapshot, MUIA_Selected) != FALSE) buttons |= MUIV_Window_Button_Snapshot;
270 if (XGET(data->iconify, MUIA_Selected) != FALSE) buttons |= MUIV_Window_Button_Iconify;
272 DoMethod(msg->configdata, MUIM_Configdata_SetULong, MUICFG_Window_Buttons, buttons);
274 return TRUE;
277 BOOPSI_DISPATCHER(IPTR, WindowP_Dispatcher, cl, obj, msg)
279 switch (msg->MethodID)
281 case OM_NEW: return WindowP_New(cl, obj, (struct opSet *)msg);
282 case MUIM_Settingsgroup_ConfigToGadgets: return WindowP_ConfigToGadgets(cl,obj,(APTR)msg);break;
283 case MUIM_Settingsgroup_GadgetsToConfig: return WindowP_GadgetsToConfig(cl,obj,(APTR)msg);break;
286 return DoSuperMethodA(cl, obj, msg);
288 BOOPSI_DISPATCHER_END
291 * Class descriptor.
293 const struct __MUIBuiltinClass _MUIP_Windows_desc = {
294 "Windows",
295 MUIC_Group,
296 sizeof(struct MUI_WindowPData),
297 (void*)WindowP_Dispatcher
301 static const UBYTE icon32[] =
303 0x00, 0x00, 0x00, 0x18, // width
304 0x00, 0x00, 0x00, 0x13, // height
305 'B', 'Z', '2', '\0',
306 0x00, 0x00, 0x00, 0x5e, // number of bytes
308 0x42, 0x5a, 0x68, 0x39, 0x31, 0x41, 0x59, 0x26, 0x53, 0x59, 0x43, 0xaf,
309 0xfa, 0xa4, 0x00, 0x02, 0x1f, 0xc2, 0x02, 0xa2, 0x20, 0x22, 0x01, 0x42,
310 0x40, 0x00, 0x00, 0xa0, 0x00, 0x90, 0x20, 0x06, 0x01, 0x49, 0x45, 0x23,
311 0xd3, 0x4f, 0x69, 0x38, 0xc6, 0xcd, 0xb6, 0xb9, 0xf3, 0x9d, 0xec, 0xe6,
312 0x63, 0x9f, 0xe0, 0x7d, 0x04, 0x7a, 0x08, 0xf8, 0xab, 0xf9, 0x32, 0x51,
313 0xe6, 0x91, 0xf7, 0xbb, 0x47, 0x29, 0xe7, 0x79, 0xd6, 0xa8, 0x79, 0x0f,
314 0x48, 0x1c, 0x52, 0x72, 0xe3, 0x59, 0x36, 0x8d, 0xb4, 0xcc, 0xc7, 0xe1,
315 0x77, 0x24, 0x53, 0x85, 0x09, 0x04, 0x3a, 0xff, 0xaa, 0x40,
319 Object *windowsclass_get_icon(void)
321 return RawimageObject,
322 MUIA_Rawimage_Data, icon32,
323 End;