2 Copyright 2002-2006, The AROS Development Team. All rights reserved.
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>
18 #include <proto/alib.h>
21 #include "zunestuff.h"
25 /* #include <aros/debug.h> */
27 extern struct Library
*MUIMasterBase
;
29 struct MUI_ScrollbarsPData
32 Object
*arrow_up_popimage
;
33 Object
*arrow_down_popimage
;
34 Object
*arrow_left_popimage
;
35 Object
*arrow_right_popimage
;
36 Object
*gadget_type_cycle
;
37 Object
*background_popimage
;
38 Object
*knob_popimage
;
39 Object
*pos_radios
[3];
42 static CONST_STRPTR gadget_type_labels
[4];
44 #define FindFont(id) (void*)DoMethod(msg->configdata,MUIM_Dataspace_Find,id)
46 Object
*MakeArrowPopimage (CONST_STRPTR wintitle
)
48 return MUI_NewObject(MUIC_Popimage
,
49 MUIA_Imageadjust_Type
, MUIV_Imageadjust_Type_Image
,
53 MUIA_Imagedisplay_FreeHoriz
, FALSE
,
54 MUIA_Imagedisplay_FreeVert
, FALSE
,
55 MUIA_Window_Title
, (IPTR
)wintitle
,
59 Object
*MakeSingleRadio (void)
62 MUIA_Image_FontMatch
, TRUE
,
63 MUIA_InputMode
, MUIV_InputMode_Immediate
,
65 MUIA_ShowSelState
, FALSE
,
66 MUIA_Image_Spec
, MUII_RadioButton
,
67 MUIA_Frame
, MUIV_Frame_None
,
71 Object
*MakeScrollbar(IPTR type
)
73 return ScrollbarObject
,
74 MUIA_Scrollbar_Type
, type
,
75 MUIA_Prop_Entries
, 10,
81 Object
*MakeSpacer(void)
83 return RectangleObject
, MUIA_FixWidth
, 0, MUIA_FixHeight
, 0, MUIA_Weight
, 1, End
;
86 static IPTR
ScrollbarsP_New(struct IClass
*cl
, Object
*obj
, struct opSet
*msg
)
88 struct MUI_ScrollbarsPData
*data
;
89 struct MUI_ScrollbarsPData d
;
90 gadget_type_labels
[0] = _(MSG_STANDARD
);
91 gadget_type_labels
[1] = _(MSG_NEWLOOK
);
92 gadget_type_labels
[2] = _(MSG_CUSTOM
);
95 obj
= (Object
*) DoSuperNewTags
99 MUIA_Group_Horiz
, TRUE
,
100 Child
, (IPTR
) VGroup
, /* left */
102 Child
, (IPTR
) VGroup
,
103 GroupFrameT(_(MSG_ARROWS
)),
104 MUIA_Group_Spacing
, 0,
105 Child
, (IPTR
) MakeSpacer(),
106 Child
, (IPTR
) HGroup
,
107 MUIA_Group_Spacing
, 0,
108 Child
, (IPTR
) MakeSpacer(),
109 Child
, (IPTR
) ColGroup(4),
110 MUIA_Group_SameHeight
, TRUE
,
111 Child
, (IPTR
) FreeLabel(_(MSG_UP
)),
112 Child
, (IPTR
) (d
.arrow_up_popimage
= MakeArrowPopimage(_(MSG_ARROW_UP
))),
113 Child
, (IPTR
) (d
.arrow_down_popimage
= MakeArrowPopimage(_(MSG_ARROW_DOWN
))),
114 Child
, (IPTR
) FreeLLabel(_(MSG_DOWN
)),
115 Child
, (IPTR
) FreeLabel(_(MSG_LEFT
)),
116 Child
, (IPTR
) (d
.arrow_left_popimage
= MakeArrowPopimage(_(MSG_ARROW_LEFT
))),
117 Child
, (IPTR
) (d
.arrow_right_popimage
= MakeArrowPopimage(_(MSG_ARROW_RIGHT
))),
118 Child
, (IPTR
) FreeLLabel(_(MSG_RIGHT
)),
119 End
, /* ColGroup(6) */
120 Child
, (IPTR
) MakeSpacer(),
122 Child
, (IPTR
) MakeSpacer(),
125 Child
, (IPTR
) VGroup
,
126 GroupFrameT(_(MSG_BAR
)),
127 Child
, (IPTR
) HGroup
,
128 Child
, (IPTR
) Label(_(MSG_GADGET_TYPE
)),
129 Child
, (IPTR
) (d
.gadget_type_cycle
= MakeCycle(_(MSG_GADGET_TYPE
), gadget_type_labels
)),
130 End
, /* HGroup Gadget Type */
131 Child
, (IPTR
) HGroup
,
132 MUIA_Group_SameWidth
, TRUE
,
133 Child
, (IPTR
) VGroup
,
134 MUIA_Group_VertSpacing
, 1,
135 Child
, (IPTR
) (d
.knob_popimage
= MUI_NewObject
138 MUIA_Imageadjust_Type
, MUIV_Imageadjust_Type_Image
,
140 MUIA_Imagedisplay_FreeHoriz
, FALSE
,
141 MUIA_Imagedisplay_FreeVert
, FALSE
,
142 MUIA_Window_Title
, (IPTR
) _(MSG_SCROLLER
),
145 Child
, (IPTR
) CLabel(_(MSG_KNOB
)),
146 End
, /* VGroup Knob */
147 Child
, (IPTR
) VGroup
,
148 MUIA_Group_VertSpacing
, 1,
149 Child
, (IPTR
) (d
.background_popimage
= MakeBackgroundPopimage()),
150 Child
, (IPTR
) CLabel(_(MSG_BACKGROUND
)),
151 End
, /* VGroup Background */
152 End
, /* HGroup Images */
154 End
, /* VGroup left */
155 Child
, (IPTR
) VGroup
,
156 Child
, (IPTR
) VGroup
,
157 GroupFrameT(_(MSG_FRAME
)),
158 Child
, (IPTR
) (d
.popframe
= MakePopframe()),
159 End
, /* Frame VGroup*/
160 Child
, (IPTR
) ColGroup(3),
161 GroupFrameT(_(MSG_ARRANGEMENT
)),
163 Child
, (IPTR
) (d
.pos_radios
[0] = MakeSingleRadio()),
164 Child
, (IPTR
) (d
.pos_radios
[1] = MakeSingleRadio()),
165 Child
, (IPTR
) (d
.pos_radios
[2] = MakeSingleRadio()),
166 Child
, (IPTR
) MakeScrollbar(MUIV_Scrollbar_Type_Top
),
167 Child
, (IPTR
) MakeScrollbar(MUIV_Scrollbar_Type_Sym
),
168 Child
, (IPTR
) MakeScrollbar(MUIV_Scrollbar_Type_Bottom
),
170 End
, /* VGroup right */
171 TAG_MORE
, (IPTR
) msg
->ops_AttrList
);
173 if (!obj
) return FALSE
;
175 data
= INST_DATA(cl
, obj
);
178 DoMethod(d
.gadget_type_cycle
, MUIM_Notify
, MUIA_Cycle_Active
, 2, (IPTR
) obj
,
179 6, MUIM_MultiSet
, MUIA_Disabled
, FALSE
,
180 (IPTR
) d
.background_popimage
, (IPTR
) d
.knob_popimage
, (IPTR
) NULL
);
181 DoMethod(d
.gadget_type_cycle
, MUIM_Notify
, MUIA_Cycle_Active
, 0, (IPTR
) obj
,
182 6, MUIM_MultiSet
, MUIA_Disabled
, TRUE
,
183 (IPTR
) d
.background_popimage
, (IPTR
) d
.knob_popimage
, (IPTR
) NULL
);
184 DoMethod(d
.gadget_type_cycle
, MUIM_Notify
, MUIA_Cycle_Active
, 1, (IPTR
) obj
,
185 6, MUIM_MultiSet
, MUIA_Disabled
, TRUE
,
186 (IPTR
) d
.background_popimage
, (IPTR
) d
.knob_popimage
, (IPTR
) NULL
);
188 DoMethod(d
.pos_radios
[0], MUIM_Notify
, MUIA_Selected
, MUIV_EveryTime
,
189 (IPTR
) d
.pos_radios
[1], 3, MUIM_NoNotifySet
, MUIA_Selected
, FALSE
);
190 DoMethod(d
.pos_radios
[0], MUIM_Notify
, MUIA_Selected
, MUIV_EveryTime
,
191 (IPTR
) d
.pos_radios
[2], 3, MUIM_NoNotifySet
, MUIA_Selected
, FALSE
);
192 DoMethod(d
.pos_radios
[1], MUIM_Notify
, MUIA_Selected
, MUIV_EveryTime
,
193 (IPTR
) d
.pos_radios
[0], 3, MUIM_NoNotifySet
, MUIA_Selected
, FALSE
);
194 DoMethod(d
.pos_radios
[1], MUIM_Notify
, MUIA_Selected
, MUIV_EveryTime
,
195 (IPTR
) d
.pos_radios
[2], 3, MUIM_NoNotifySet
, MUIA_Selected
, FALSE
);
196 DoMethod(d
.pos_radios
[2], MUIM_Notify
, MUIA_Selected
, MUIV_EveryTime
,
197 (IPTR
) d
.pos_radios
[0], 3, MUIM_NoNotifySet
, MUIA_Selected
, FALSE
);
198 DoMethod(d
.pos_radios
[2], MUIM_Notify
, MUIA_Selected
, MUIV_EveryTime
,
199 (IPTR
) d
.pos_radios
[1], 3, MUIM_NoNotifySet
, MUIA_Selected
, FALSE
);
206 * MUIM_Settingsgroup_ConfigToGadgets
208 static IPTR
ScrollbarsP_ConfigToGadgets(struct IClass
*cl
, Object
*obj
,
209 struct MUIP_Settingsgroup_ConfigToGadgets
*msg
)
211 struct MUI_ScrollbarsPData
*data
= INST_DATA(cl
, obj
);
216 spec
= (STRPTR
)DoMethod(msg
->configdata
, MUIM_Configdata_GetString
,
217 MUICFG_Image_ArrowUp
);
218 set(data
->arrow_up_popimage
,MUIA_Imagedisplay_Spec
, (IPTR
)spec
);
219 spec
= (STRPTR
)DoMethod(msg
->configdata
, MUIM_Configdata_GetString
,
220 MUICFG_Image_ArrowDown
);
221 set(data
->arrow_down_popimage
,MUIA_Imagedisplay_Spec
, (IPTR
)spec
);
222 spec
= (STRPTR
)DoMethod(msg
->configdata
, MUIM_Configdata_GetString
,
223 MUICFG_Image_ArrowLeft
);
224 set(data
->arrow_left_popimage
,MUIA_Imagedisplay_Spec
, (IPTR
)spec
);
225 spec
= (STRPTR
)DoMethod(msg
->configdata
, MUIM_Configdata_GetString
,
226 MUICFG_Image_ArrowRight
);
227 set(data
->arrow_right_popimage
,MUIA_Imagedisplay_Spec
, (IPTR
)spec
);
229 spec
= (STRPTR
)DoMethod(msg
->configdata
, MUIM_Configdata_GetString
,
230 MUICFG_Image_PropKnob
);
231 set(data
->knob_popimage
,MUIA_Imagedisplay_Spec
, (IPTR
)spec
);
233 spec
= (STRPTR
)DoMethod(msg
->configdata
, MUIM_Configdata_GetString
,
234 MUICFG_Background_Prop
);
235 set(data
->background_popimage
,MUIA_Imagedisplay_Spec
, (IPTR
)spec
);
238 setcycle(data
->gadget_type_cycle
,
239 DoMethod(msg
->configdata
, MUIM_Configdata_GetULong
,
240 MUICFG_Scrollbar_Type
));
243 spec
= (STRPTR
)DoMethod(msg
->configdata
, MUIM_Configdata_GetString
,
245 set(data
->popframe
, MUIA_Framedisplay_Spec
, (IPTR
)spec
);
247 /* Radio (Arrangement) */
248 pos
= DoMethod(msg
->configdata
, MUIM_Configdata_GetULong
,
249 MUICFG_Scrollbar_Arrangement
);
250 if (pos
< 0 || pos
> 2)
252 set(data
->pos_radios
[pos
], MUIA_Selected
, TRUE
);
259 * MUIM_Settingsgroup_ConfigToGadgets
261 static IPTR
ScrollbarsP_GadgetsToConfig(struct IClass
*cl
, Object
*obj
,
262 struct MUIP_Settingsgroup_GadgetsToConfig
*msg
)
264 struct MUI_ScrollbarsPData
*data
= INST_DATA(cl
, obj
);
270 str
= (STRPTR
)XGET(data
->popframe
, MUIA_Framedisplay_Spec
);
271 DoMethod(msg
->configdata
, MUIM_Configdata_SetFramespec
, MUICFG_Frame_Prop
,
275 DoMethod(msg
->configdata
, MUIM_Configdata_SetULong
, MUICFG_Scrollbar_Type
,
276 XGET(data
->gadget_type_cycle
, MUIA_Cycle_Active
));
279 for (i
= 0; i
< 3; i
++)
281 if (XGET(data
->pos_radios
[i
], MUIA_Selected
))
285 DoMethod(msg
->configdata
, MUIM_Configdata_SetULong
,
286 MUICFG_Scrollbar_Arrangement
, pos
);
289 str
= (STRPTR
)XGET(data
->background_popimage
, MUIA_Imagedisplay_Spec
);
290 DoMethod(msg
->configdata
, MUIM_Configdata_SetImspec
, MUICFG_Background_Prop
,
292 str
= (STRPTR
)XGET(data
->knob_popimage
, MUIA_Imagedisplay_Spec
);
293 DoMethod(msg
->configdata
, MUIM_Configdata_SetImspec
, MUICFG_Image_PropKnob
,
295 str
= (STRPTR
)XGET(data
->arrow_up_popimage
, MUIA_Imagedisplay_Spec
);
296 DoMethod(msg
->configdata
, MUIM_Configdata_SetImspec
, MUICFG_Image_ArrowUp
,
298 str
= (STRPTR
)XGET(data
->arrow_down_popimage
, MUIA_Imagedisplay_Spec
);
299 DoMethod(msg
->configdata
, MUIM_Configdata_SetImspec
, MUICFG_Image_ArrowDown
,
301 str
= (STRPTR
)XGET(data
->arrow_left_popimage
, MUIA_Imagedisplay_Spec
);
302 DoMethod(msg
->configdata
, MUIM_Configdata_SetImspec
, MUICFG_Image_ArrowLeft
,
304 str
= (STRPTR
)XGET(data
->arrow_right_popimage
, MUIA_Imagedisplay_Spec
);
305 DoMethod(msg
->configdata
, MUIM_Configdata_SetImspec
, MUICFG_Image_ArrowRight
,
311 BOOPSI_DISPATCHER(IPTR
, ScrollbarsP_Dispatcher
, cl
, obj
, msg
)
313 switch (msg
->MethodID
)
315 case OM_NEW
: return ScrollbarsP_New(cl
, obj
, (struct opSet
*)msg
);
316 case MUIM_Settingsgroup_ConfigToGadgets
: return ScrollbarsP_ConfigToGadgets(cl
,obj
,(APTR
)msg
);break;
317 case MUIM_Settingsgroup_GadgetsToConfig
: return ScrollbarsP_GadgetsToConfig(cl
,obj
,(APTR
)msg
);break;
320 return DoSuperMethodA(cl
, obj
, msg
);
322 BOOPSI_DISPATCHER_END
327 const struct __MUIBuiltinClass _MUIP_Scrollbars_desc
= {
330 sizeof(struct MUI_ScrollbarsPData
),
331 (void*)ScrollbarsP_Dispatcher