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>
20 //#include <aros/debug.h>
23 #include "zunestuff.h"
26 extern struct Library
*MUIMasterBase
;
28 struct MUI_WindowPData
30 Object
*positions_cycle
;
31 Object
*refresh_cycle
;
33 Object
*font_normal_string
;
34 Object
*font_tiny_string
;
35 Object
*font_big_string
;
36 Object
*background_window_popimage
;
37 Object
*background_requester_popimage
;
38 Object
*spacing_left_slider
;
39 Object
*spacing_right_slider
;
40 Object
*spacing_top_slider
;
41 Object
*spacing_bottom_slider
;
48 static CONST_STRPTR positions_labels
[4];
49 static CONST_STRPTR refresh_labels
[3];
50 static CONST_STRPTR redraw_labels
[3];
52 #define _Button(name)\
55 MUIA_Font, MUIV_Font_Button,\
56 MUIA_Text_Contents, name,\
57 MUIA_Text_PreParse, "\33c",\
58 MUIA_InputMode , MUIV_InputMode_Toggle,\
59 MUIA_Background , MUII_ButtonBack,\
62 static IPTR
WindowP_New(struct IClass
*cl
, Object
*obj
, struct opSet
*msg
)
64 struct MUI_WindowPData
*data
;
65 struct MUI_WindowPData d
;
67 positions_labels
[0] = _(MSG_FORGET_ON_EXIT
);
68 positions_labels
[1] = _(MSG_REMEMBER_ON_EXIT
);
69 positions_labels
[2] = _(MSG_SAVE_ON_EXIT
);
71 refresh_labels
[0] = _(MSG_SMART
);
72 refresh_labels
[1] = _(MSG_SIMPLE
);
74 redraw_labels
[0] = _(MSG_WITHOUT_CLEAR
);
75 redraw_labels
[1] = _(MSG_WITH_CLEAR
);
77 obj
= (Object
*) DoSuperNewTags
84 GroupFrameT(_(MSG_CONTROL
)),
85 Child
, (IPTR
) VSpace(0),
86 Child
, (IPTR
) ColGroup(2),
87 MUIA_Group_VertSpacing
, 2,
88 Child
, (IPTR
) Label(_(MSG_POSITIONS
)),
89 Child
, (IPTR
) (d
.positions_cycle
= MakeCycle(_(MSG_POSITIONS
), positions_labels
)),
90 Child
, (IPTR
) Label(_(MSG_REFRESH
)),
91 Child
, (IPTR
) (d
.refresh_cycle
= MakeCycle(_(MSG_REFRESH
), refresh_labels
)),
92 Child
, (IPTR
) Label(_(MSG_REDRAW
)),
93 Child
, (IPTR
) (d
.redraw_cycle
= MakeCycle(_(MSG_REDRAW
), redraw_labels
)),
94 Child
, (IPTR
) Label(_(MSG_BUTTONS
)),
100 Child
, d
.mui
= _Button("M"),
102 Child
, d
.snapshot
= _Button("S"),
104 Child
, d
.popup
= _Button("P"),
106 Child
, d
.iconify
= _Button("I"),
110 Child
, (IPTR
) VSpace(0),
112 Child
, (IPTR
) VGroup
,
113 GroupFrameT(_(MSG_FONTS
)),
114 Child
, (IPTR
) VSpace(0),
115 Child
, (IPTR
) ColGroup(2),
116 MUIA_Group_VertSpacing
, 2,
117 Child
, (IPTR
) Label(_(MSG_NORMAL_COLON
)),
118 Child
, (IPTR
) (d
.font_normal_string
= MakePopfont(FALSE
)),
119 Child
, (IPTR
) Label(_(MSG_TINY
)),
120 Child
, (IPTR
) (d
.font_tiny_string
= MakePopfont(FALSE
)),
121 Child
, (IPTR
) Label(_(MSG_BIG
)),
122 Child
, (IPTR
) (d
.font_big_string
= MakePopfont(FALSE
)),
124 Child
, (IPTR
) VSpace(0),
127 Child
, (IPTR
) VGroup
,
128 Child
, (IPTR
) HGroup
,
129 GroupFrameT(_(MSG_BACKGROUND
)),
130 MUIA_Group_SameWidth
, TRUE
,
131 Child
, (IPTR
) VGroup
,
132 MUIA_Group_VertSpacing
, 1,
133 Child
, (IPTR
) (d
.background_window_popimage
= MakeBackgroundPopimage()),
134 Child
, (IPTR
) CLabel(_(MSG_WINDOW
)),
136 Child
, (IPTR
) VGroup
,
137 MUIA_Group_VertSpacing
, 1,
138 Child
, (IPTR
) (d
.background_requester_popimage
= MakeBackgroundPopimage()),
139 Child
, (IPTR
) CLabel(_(MSG_REQUESTER
)),
142 Child
, (IPTR
) ColGroup(4),
143 GroupFrameT(_(MSG_SPACING
)),
144 MUIA_Group_Spacing
, 2,
145 Child
, (IPTR
) Label(_(MSG_L
)),
146 Child
, (IPTR
) (d
.spacing_left_slider
= MakeSpacingSlider()),
147 Child
, (IPTR
) (d
.spacing_top_slider
= MakeSpacingSlider()),
148 Child
, (IPTR
) Label(_(MSG_T
)),
149 Child
, (IPTR
) Label(_(MSG_R
)),
150 Child
, (IPTR
) (d
.spacing_right_slider
= MakeSpacingSlider()),
151 Child
, (IPTR
) (d
.spacing_bottom_slider
= MakeSpacingSlider()),
152 Child
, (IPTR
) Label(_(MSG_B
)),
156 TAG_MORE
, (IPTR
) msg
->ops_AttrList
);
158 if (!obj
) return FALSE
;
160 data
= INST_DATA(cl
, obj
);
163 set(data
->refresh_cycle
, MUIA_Disabled
, TRUE
);
164 //set(data->positions_cycle, MUIA_Disabled, TRUE);
170 static IPTR
WindowP_ConfigToGadgets(struct IClass
*cl
, Object
*obj
,
171 struct MUIP_Settingsgroup_ConfigToGadgets
*msg
)
173 struct MUI_WindowPData
*data
= INST_DATA(cl
, obj
);
177 setstring(data
->font_normal_string
, (IPTR
)FindFont(MUICFG_Font_Normal
));
178 setstring(data
->font_tiny_string
, (IPTR
)FindFont(MUICFG_Font_Tiny
));
179 setstring(data
->font_big_string
, (IPTR
)FindFont(MUICFG_Font_Big
));
182 spec
= (STRPTR
)DoMethod(msg
->configdata
, MUIM_Configdata_GetString
,
183 MUICFG_Background_Window
);
184 set(data
->background_window_popimage
,MUIA_Imagedisplay_Spec
, (IPTR
)spec
);
186 spec
= (STRPTR
)DoMethod(msg
->configdata
, MUIM_Configdata_GetString
,
187 MUICFG_Background_Requester
);
188 set(data
->background_requester_popimage
,MUIA_Imagedisplay_Spec
, (IPTR
)spec
);
191 setslider(data
->spacing_left_slider
,
192 DoMethod(msg
->configdata
, MUIM_Configdata_GetULong
,
193 MUICFG_Window_Spacing_Left
));
194 setslider(data
->spacing_right_slider
,
195 DoMethod(msg
->configdata
, MUIM_Configdata_GetULong
,
196 MUICFG_Window_Spacing_Right
));
197 setslider(data
->spacing_top_slider
,
198 DoMethod(msg
->configdata
, MUIM_Configdata_GetULong
,
199 MUICFG_Window_Spacing_Top
));
200 setslider(data
->spacing_bottom_slider
,
201 DoMethod(msg
->configdata
, MUIM_Configdata_GetULong
,
202 MUICFG_Window_Spacing_Bottom
));
205 setcycle(data
->redraw_cycle
,
206 DoMethod(msg
->configdata
, MUIM_Configdata_GetULong
,
207 MUICFG_Window_Redraw
));
208 setcycle(data
->positions_cycle
,
209 DoMethod(msg
->configdata
, MUIM_Configdata_GetULong
,
210 MUICFG_Window_Positions
));
212 ULONG buttons
= DoMethod(msg
->configdata
, MUIM_Configdata_GetULong
, MUICFG_Window_Buttons
);
214 if ((buttons
& MUIV_Window_Button_MUI
) != 0) set(data
->mui
, MUIA_Selected
, TRUE
); else set(data
->mui
, MUIA_Selected
, FALSE
);
215 if ((buttons
& MUIV_Window_Button_Popup
) != 0) set(data
->popup
, MUIA_Selected
, TRUE
); else set(data
->popup
, MUIA_Selected
, FALSE
);
216 if ((buttons
& MUIV_Window_Button_Iconify
) != 0) set(data
->iconify
, MUIA_Selected
, TRUE
); else set(data
->iconify
, MUIA_Selected
, FALSE
);
217 if ((buttons
& MUIV_Window_Button_Snapshot
) != 0) set(data
->snapshot
, MUIA_Selected
, TRUE
); else set(data
->snapshot
, MUIA_Selected
, FALSE
);
223 static IPTR
WindowP_GadgetsToConfig(struct IClass
*cl
, Object
*obj
,
224 struct MUIP_Settingsgroup_GadgetsToConfig
*msg
)
226 struct MUI_WindowPData
*data
= INST_DATA(cl
, obj
);
230 str
= getstring(data
->font_normal_string
);
231 DoMethod(msg
->configdata
, MUIM_Configdata_SetFont
, MUICFG_Font_Normal
, (IPTR
)str
);
233 str
= getstring(data
->font_tiny_string
);
234 DoMethod(msg
->configdata
, MUIM_Configdata_SetFont
, MUICFG_Font_Tiny
, (IPTR
)str
);
236 str
= getstring(data
->font_big_string
);
237 DoMethod(msg
->configdata
, MUIM_Configdata_SetFont
, MUICFG_Font_Big
, (IPTR
)str
);
240 str
= (STRPTR
)XGET(data
->background_window_popimage
,MUIA_Imagedisplay_Spec
);
241 DoMethod(msg
->configdata
, MUIM_Configdata_SetImspec
, MUICFG_Background_Window
,
244 str
= (STRPTR
)XGET(data
->background_requester_popimage
,MUIA_Imagedisplay_Spec
);
245 DoMethod(msg
->configdata
, MUIM_Configdata_SetImspec
, MUICFG_Background_Requester
,
249 DoMethod(msg
->configdata
, MUIM_Configdata_SetULong
, MUICFG_Window_Spacing_Left
,
250 XGET(data
->spacing_left_slider
, MUIA_Numeric_Value
));
251 DoMethod(msg
->configdata
, MUIM_Configdata_SetULong
, MUICFG_Window_Spacing_Right
,
252 XGET(data
->spacing_right_slider
, MUIA_Numeric_Value
));
253 DoMethod(msg
->configdata
, MUIM_Configdata_SetULong
, MUICFG_Window_Spacing_Top
,
254 XGET(data
->spacing_top_slider
, MUIA_Numeric_Value
));
255 DoMethod(msg
->configdata
, MUIM_Configdata_SetULong
, MUICFG_Window_Spacing_Bottom
,
256 XGET(data
->spacing_bottom_slider
, MUIA_Numeric_Value
));
259 DoMethod(msg
->configdata
, MUIM_Configdata_SetULong
, MUICFG_Window_Redraw
,
260 XGET(data
->redraw_cycle
, MUIA_Cycle_Active
));
261 DoMethod(msg
->configdata
, MUIM_Configdata_SetULong
, MUICFG_Window_Positions
,
262 XGET(data
->positions_cycle
, MUIA_Cycle_Active
));
266 if (XGET(data
->mui
, MUIA_Selected
) != FALSE
) buttons
|= MUIV_Window_Button_MUI
;
267 if (XGET(data
->popup
, MUIA_Selected
) != FALSE
) buttons
|= MUIV_Window_Button_Popup
;
268 if (XGET(data
->snapshot
, MUIA_Selected
) != FALSE
) buttons
|= MUIV_Window_Button_Snapshot
;
269 if (XGET(data
->iconify
, MUIA_Selected
) != FALSE
) buttons
|= MUIV_Window_Button_Iconify
;
271 DoMethod(msg
->configdata
, MUIM_Configdata_SetULong
, MUICFG_Window_Buttons
, buttons
);
276 BOOPSI_DISPATCHER(IPTR
, WindowP_Dispatcher
, cl
, obj
, msg
)
278 switch (msg
->MethodID
)
280 case OM_NEW
: return WindowP_New(cl
, obj
, (struct opSet
*)msg
);
281 case MUIM_Settingsgroup_ConfigToGadgets
: return WindowP_ConfigToGadgets(cl
,obj
,(APTR
)msg
);break;
282 case MUIM_Settingsgroup_GadgetsToConfig
: return WindowP_GadgetsToConfig(cl
,obj
,(APTR
)msg
);break;
285 return DoSuperMethodA(cl
, obj
, msg
);
287 BOOPSI_DISPATCHER_END
292 const struct __MUIBuiltinClass _MUIP_Windows_desc
= {
295 sizeof(struct MUI_WindowPData
),
296 (void*)WindowP_Dispatcher