2 Copyright 2002-2003, The AROS Development Team. All rights reserved.
6 #define MUIMASTER_YES_INLINE_STDARG
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>
24 /* #define MYDEBUG 1 */
27 #include "muimaster_intern.h"
29 #include "support_classes.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);
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
;
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
;
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
);
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
;
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
;
109 if (i
< 0 || i
> (10 + 16))
112 fsi
.innerTop
= fsi
.innerLeft
= fsi
.innerBottom
= fsi
.innerRight
= 9;
115 zune_frame_intern_to_spec(&fsi
, fs
);
117 obj
= MUI_NewObject(MUIC_Framedisplay
,
118 // MUIA_FixWidth, 12,
119 // MUIA_FixHeight, 12,
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);
129 IPTR
Frameadjust__OM_NEW(struct IClass
*cl
, Object
*obj
,
132 struct Frameadjust_DATA
*data
;
133 struct TagItem
*tags
;
136 Object
*SL_top
, *SL_left
, *SL_right
, *SL_bottom
;
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 };
145 obj
= (Object
*) DoSuperNewTags
149 MUIA_Group_Horiz
, TRUE
,
150 MUIA_Group_HorizSpacing
, 20,
152 Child
, (IPTR
) (FD_display
= MUI_NewObject
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()),
180 TAG_MORE
, (IPTR
) msg
->ops_AttrList
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
++)
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,
205 DoMethod(GR_fd
, OM_ADDMEMBER
, (IPTR
) obj
);
208 DoMethod(GR_fd
, OM_ADDMEMBER
, (IPTR
) HVSpace
);
210 for (i
= 1; i
< 11; i
++)
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,
218 DoMethod(GR_fd
, OM_ADDMEMBER
, (IPTR
) obj
);
226 for (i
= 11; i
< (11 + 8); i
++)
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,
234 DoMethod(GR_fd1
, OM_ADDMEMBER
, (IPTR
) obj
);
237 for (i
= 11; i
< (11 + 8); i
++)
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,
245 DoMethod(GR_fd1
, OM_ADDMEMBER
, (IPTR
) obj
);
249 for (i
= 19; i
< (19 + 8); i
++)
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,
257 DoMethod(GR_fd2
, OM_ADDMEMBER
, (IPTR
) obj
);
260 for (i
= 19; i
< (19 + 8); i
++)
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,
268 DoMethod(GR_fd2
, OM_ADDMEMBER
, (IPTR
) obj
);
274 /* parse initial taglist */
275 for (tags
= msg
->ops_AttrList
; (tag
= NextTagItem(&tags
));)
279 case MUIA_Frameadjust_Spec
:
280 zune_frame_spec_to_intern((CONST_STRPTR
) tag
->ti_Data
,
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
);
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
);
310 IPTR
Frameadjust__OM_GET(struct IClass
*cl
, Object
*obj
,
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
;
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
)
332 return Frameadjust__OM_NEW(cl
, obj
, (struct opSet
*)msg
);
334 return Frameadjust__OM_GET(cl
, obj
, (APTR
) msg
);
336 return DoSuperMethodA(cl
, obj
, msg
);
339 BOOPSI_DISPATCHER_END
341 const struct __MUIBuiltinClass _MUI_Frameadjust_desc
=
345 sizeof(struct Frameadjust_DATA
),
346 (void *) Frameadjust_Dispatcher
348 #endif /* ZUNE_BUILTIN_FRAMEADJUST */