Removed the unnecessary inner group: the list and scrollbar are now
[AROS.git] / workbench / libs / muimaster / classes / frameadjust.c
blobe9737f4d132b51df521acaf9155ae73180c2bdae
1 /*
2 Copyright 2002-2003, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #define MUIMASTER_YES_INLINE_STDARG
8 #include <stdio.h>
9 #include <stdlib.h>
11 #include <graphics/gfx.h>
12 #include <graphics/view.h>
13 #include <clib/alib_protos.h>
15 #include <proto/dos.h>
16 #include <proto/exec.h>
17 #include <proto/graphics.h>
18 #include <proto/utility.h>
19 #include <proto/intuition.h>
20 #include <proto/muimaster.h>
22 #include <string.h>
24 /* #define MYDEBUG 1 */
25 #include "debug.h"
26 #include "mui.h"
27 #include "muimaster_intern.h"
28 #include "support.h"
29 #include "support_classes.h"
30 #include "frame.h"
31 #include "frameadjust_private.h"
33 extern struct Library *MUIMasterBase;
35 static Object *MakeSpacingSlider(void)
37 Object *obj = MUI_MakeObject(MUIO_Slider, (IPTR) "", 0, 9);
38 set(obj, MUIA_CycleChain, 1);
39 return obj;
42 struct SliderFuncMsg
44 STACKED Object *slider;
45 STACKED struct Frameadjust_DATA *data;
48 static void SliderFunc(struct Hook *hook, Object *obj,
49 struct SliderFuncMsg *msg)
51 struct Frameadjust_DATA *data = msg->data;
52 Object *slider = msg->slider;
53 ULONG val = 0;
54 char fs[10];
56 get(slider, MUIA_Numeric_Value, &val);
58 if (slider == data->SL_top)
60 nnset(data->SL_bottom, MUIA_Numeric_Value, val);
61 data->fs_intern.innerTop = val;
62 data->fs_intern.innerBottom = val;
64 else if (slider == data->SL_left)
66 nnset(data->SL_right, MUIA_Numeric_Value, val);
67 data->fs_intern.innerLeft = val;
68 data->fs_intern.innerRight = val;
70 else if (slider == data->SL_bottom)
72 data->fs_intern.innerBottom = val;
74 else
76 data->fs_intern.innerRight = val;
79 zune_frame_intern_to_spec(&data->fs_intern, fs);
80 set(data->FD_display, MUIA_Framedisplay_Spec, (IPTR) fs);
84 struct FramesFuncMsg
86 STACKED ULONG type;
87 STACKED ULONG state;
88 STACKED struct Frameadjust_DATA *data;
91 static void FramesFunc(struct Hook *hook, Object *obj,
92 struct FramesFuncMsg *msg)
94 struct Frameadjust_DATA *data = msg->data;
95 char fs[10];
97 data->fs_intern.type = msg->type;
98 data->fs_intern.state = msg->state;
99 zune_frame_intern_to_spec(&data->fs_intern, fs);
100 set(data->FD_display, MUIA_Framedisplay_Spec, (IPTR) fs);
103 static Object *MakeFrameDisplay(int i, int state)
105 struct MUI_FrameSpec_intern fsi;
106 char fs[10];
107 Object *obj;
109 if (i < 0 || i > (10 + 16))
110 return HVSpace;
112 fsi.innerTop = fsi.innerLeft = fsi.innerBottom = fsi.innerRight = 9;
113 fsi.type = i;
114 fsi.state = state;
115 zune_frame_intern_to_spec(&fsi, fs);
117 obj = MUI_NewObject(MUIC_Framedisplay,
118 // MUIA_FixWidth, 12,
119 // MUIA_FixHeight, 12,
120 ButtonFrame,
121 InnerSpacing(6, 6),
122 MUIA_Background, MUII_ButtonBack,
123 MUIA_InputMode, MUIV_InputMode_RelVerify,
124 MUIA_Framedisplay_Spec, (IPTR) fs, TAG_DONE);
125 set(obj, MUIA_CycleChain, 1);
126 return obj;
129 IPTR Frameadjust__OM_NEW(struct IClass *cl, Object *obj,
130 struct opSet *msg)
132 struct Frameadjust_DATA *data;
133 struct TagItem *tags;
134 struct TagItem *tag;
135 Object *FD_display;
136 Object *SL_top, *SL_left, *SL_right, *SL_bottom;
137 Object *GR_fd;
138 Object *GR_fd1;
139 Object *GR_fd2;
140 int lut[] =
141 { 0, 1, 2, 3, 4, 6, 9, 10, 8, 7, 5, 11, 12, 13, 14, 15, 16, 17, 18,
142 19, 20, 21, 22, 23, 24, 25, 26 };
143 int i;
145 obj = (Object *) DoSuperNewTags
147 cl, obj, NULL,
149 MUIA_Group_Horiz, TRUE,
150 MUIA_Group_HorizSpacing, 20,
152 Child, (IPTR) (FD_display = MUI_NewObject
154 MUIC_Framedisplay,
155 MUIA_FixWidth, 32,
156 TAG_DONE
158 Child, (IPTR) VGroup,
159 MUIA_Group_VertSpacing, 10,
160 Child, (IPTR) (GR_fd = (Object *)RowGroup(2), End), /* RowGroup */
161 Child, (IPTR) (GR_fd1 = (Object *)RowGroup(2), End), /* RowGroup */
162 Child, (IPTR) (GR_fd2 = (Object *)RowGroup(2), End), /* RowGroup */
163 Child, (IPTR) HGroup,
164 Child, (IPTR) Label("Inner Spacing:"),
165 Child, (IPTR) RowGroup(2),
166 Child, (IPTR) Label2("Left"),
167 Child, (IPTR) (SL_left = MakeSpacingSlider()),
168 Child, (IPTR) HSpace(8),
169 Child, (IPTR) Label2("Top"),
170 Child, (IPTR) (SL_top = MakeSpacingSlider()),
171 Child, (IPTR) Label2("Right"),
172 Child, (IPTR) (SL_right = MakeSpacingSlider()),
173 Child, (IPTR) HSpace(8),
174 Child, (IPTR) Label2("Bottom"),
175 Child, (IPTR) (SL_bottom = MakeSpacingSlider()),
176 End, /* RowGroup */
177 End, /* HGroup */
178 End, /* VGroup */
180 TAG_MORE, (IPTR) msg->ops_AttrList
183 if (!obj)
184 return FALSE;
186 data = INST_DATA(cl, obj);
187 data->FD_display = FD_display;
188 data->SL_left = SL_left;
189 data->SL_top = SL_top;
190 data->SL_bottom = SL_bottom;
191 data->SL_right = SL_right;
192 data->slider_hook.h_Entry = HookEntry;
193 data->slider_hook.h_SubEntry = (HOOKFUNC) SliderFunc;
194 data->frames_hook.h_Entry = HookEntry;
195 data->frames_hook.h_SubEntry = (HOOKFUNC) FramesFunc;
197 for (i = 0; i < 11; i++)
199 Object *obj;
201 obj = MakeFrameDisplay(lut[i], 0);
202 DoMethod(obj, MUIM_Notify, MUIA_Pressed, FALSE, (IPTR) obj, 5,
203 MUIM_CallHook, (IPTR) & data->frames_hook, lut[i], 0,
204 (IPTR) data);
205 DoMethod(GR_fd, OM_ADDMEMBER, (IPTR) obj);
208 DoMethod(GR_fd, OM_ADDMEMBER, (IPTR) HVSpace);
210 for (i = 1; i < 11; i++)
212 Object *obj;
214 obj = MakeFrameDisplay(lut[i], 1);
215 DoMethod(obj, MUIM_Notify, MUIA_Pressed, FALSE, (IPTR) obj, 5,
216 MUIM_CallHook, (IPTR) & data->frames_hook, lut[i], 1,
217 (IPTR) data);
218 DoMethod(GR_fd, OM_ADDMEMBER, (IPTR) obj);
226 for (i = 11; i < (11 + 8); i++)
228 Object *obj;
230 obj = MakeFrameDisplay(lut[i], 0);
231 DoMethod(obj, MUIM_Notify, MUIA_Pressed, FALSE, (IPTR) obj, 5,
232 MUIM_CallHook, (IPTR) & data->frames_hook, lut[i], 0,
233 (IPTR) data);
234 DoMethod(GR_fd1, OM_ADDMEMBER, (IPTR) obj);
237 for (i = 11; i < (11 + 8); i++)
239 Object *obj;
241 obj = MakeFrameDisplay(lut[i], 1);
242 DoMethod(obj, MUIM_Notify, MUIA_Pressed, FALSE, (IPTR) obj, 5,
243 MUIM_CallHook, (IPTR) & data->frames_hook, lut[i], 1,
244 (IPTR) data);
245 DoMethod(GR_fd1, OM_ADDMEMBER, (IPTR) obj);
249 for (i = 19; i < (19 + 8); i++)
251 Object *obj;
253 obj = MakeFrameDisplay(lut[i], 0);
254 DoMethod(obj, MUIM_Notify, MUIA_Pressed, FALSE, (IPTR) obj, 5,
255 MUIM_CallHook, (IPTR) & data->frames_hook, lut[i], 0,
256 (IPTR) data);
257 DoMethod(GR_fd2, OM_ADDMEMBER, (IPTR) obj);
260 for (i = 19; i < (19 + 8); i++)
262 Object *obj;
264 obj = MakeFrameDisplay(lut[i], 1);
265 DoMethod(obj, MUIM_Notify, MUIA_Pressed, FALSE, (IPTR) obj, 5,
266 MUIM_CallHook, (IPTR) & data->frames_hook, lut[i], 1,
267 (IPTR) data);
268 DoMethod(GR_fd2, OM_ADDMEMBER, (IPTR) obj);
274 /* parse initial taglist */
275 for (tags = msg->ops_AttrList; (tag = NextTagItem(&tags));)
277 switch (tag->ti_Tag)
279 case MUIA_Frameadjust_Spec:
280 zune_frame_spec_to_intern((CONST_STRPTR) tag->ti_Data,
281 &data->fs_intern);
282 set(data->FD_display, MUIA_Framedisplay_Spec, tag->ti_Data);
283 set(data->SL_left, MUIA_Numeric_Value,
284 data->fs_intern.innerLeft);
285 set(data->SL_top, MUIA_Numeric_Value, data->fs_intern.innerTop);
286 set(data->SL_right, MUIA_Numeric_Value,
287 data->fs_intern.innerRight);
288 set(data->SL_bottom, MUIA_Numeric_Value,
289 data->fs_intern.innerBottom);
290 break;
294 DoMethod(data->SL_left, MUIM_Notify, MUIA_Numeric_Value, MUIV_EveryTime,
295 (IPTR) obj, 4, MUIM_CallHook,
296 (IPTR) & data->slider_hook, (IPTR) data->SL_left, (IPTR) data);
297 DoMethod(data->SL_top, MUIM_Notify, MUIA_Numeric_Value, MUIV_EveryTime,
298 (IPTR) obj, 4, MUIM_CallHook,
299 (IPTR) & data->slider_hook, (IPTR) data->SL_top, (IPTR) data);
300 DoMethod(data->SL_right, MUIM_Notify, MUIA_Numeric_Value,
301 MUIV_EveryTime, (IPTR) obj, 4, MUIM_CallHook,
302 (IPTR) & data->slider_hook, (IPTR) data->SL_right, (IPTR) data);
303 DoMethod(data->SL_bottom, MUIM_Notify, MUIA_Numeric_Value,
304 MUIV_EveryTime, (IPTR) obj, 4, MUIM_CallHook,
305 (IPTR) & data->slider_hook, (IPTR) data->SL_bottom, (IPTR) data);
307 return (IPTR) obj;
310 IPTR Frameadjust__OM_GET(struct IClass *cl, Object *obj,
311 struct opGet *msg)
313 struct Frameadjust_DATA *data = INST_DATA(cl, obj);
315 switch (msg->opg_AttrID)
317 case MUIA_Frameadjust_Spec:
318 zune_frame_intern_to_spec(&data->fs_intern, (STRPTR) data->spec);
319 *msg->opg_Storage = (IPTR) data->spec;
320 return (TRUE);
323 return (DoSuperMethodA(cl, obj, (Msg) msg));
326 #if ZUNE_BUILTIN_FRAMEADJUST
327 BOOPSI_DISPATCHER(IPTR, Frameadjust_Dispatcher, cl, obj, msg)
329 switch (msg->MethodID)
331 case OM_NEW:
332 return Frameadjust__OM_NEW(cl, obj, (struct opSet *)msg);
333 case OM_GET:
334 return Frameadjust__OM_GET(cl, obj, (APTR) msg);
335 default:
336 return DoSuperMethodA(cl, obj, msg);
339 BOOPSI_DISPATCHER_END
341 const struct __MUIBuiltinClass _MUI_Frameadjust_desc =
343 MUIC_Frameadjust,
344 MUIC_Group,
345 sizeof(struct Frameadjust_DATA),
346 (void *) Frameadjust_Dispatcher
348 #endif /* ZUNE_BUILTIN_FRAMEADJUST */