2 Copyright © 2003-2011, The AROS Development Team. All rights reserved.
6 #define MUIMASTER_YES_INLINE_STDARG
9 #include <libraries/mui.h>
11 #include <proto/alib.h>
12 #include <proto/dos.h>
13 #include <proto/exec.h>
14 #include <proto/muimaster.h>
15 #include <proto/intuition.h>
16 #include <proto/graphics.h>
17 #include <proto/utility.h>
18 #include <proto/iffparse.h>
20 #include <zune/customclasses.h>
21 #include <zune/prefseditor.h>
22 #include <zune/systemprefswindow.h>
24 #include <prefs/screenmode.h>
25 #include <prefs/prefhdr.h>
33 #include "smselector.h"
34 #include "smproperties.h"
35 #include "smattributes.h"
40 Object
*selector
, *properties
, *attributes
;
43 #define SMEditorObject BOOPSIOBJMACRO_START(SMEditor_CLASS->mcc_Class)
44 #define SETUP_INST_DATA struct SMEditor_DATA *data = INST_DATA(CLASS, self)
46 static BOOL Gadgets2ScreenmodePrefs
48 struct SMEditor_DATA
*data
51 if (XGET(data
->selector
, MUIA_List_Active
) == MUIV_List_Active_Off
)
53 // No active list entry? Reset to defaults
58 screenmodeprefs
.smp_DisplayID
= XGET(data
->properties
, MUIA_ScreenModeProperties_DisplayID
);
59 screenmodeprefs
.smp_Width
= XGET(data
->properties
, MUIA_ScreenModeProperties_Width
);
60 screenmodeprefs
.smp_Height
= XGET(data
->properties
, MUIA_ScreenModeProperties_Height
);
61 screenmodeprefs
.smp_Depth
= XGET(data
->properties
, MUIA_ScreenModeProperties_Depth
);
63 if (XGET(data
->properties
, MUIA_ScreenModeProperties_Autoscroll
))
64 screenmodeprefs
.smp_Control
= SMF_AUTOSCROLL
;
66 screenmodeprefs
.smp_Control
= 0;
69 D(bug("[smeditor] Gadgets2Prefs:\n"));
70 D(bug("[smeditor] DisplayID 0x%08lX\n", screenmodeprefs
.smp_DisplayID
));
71 D(bug("[smeditor] Size %ldx%ld\n", screenmodeprefs
.smp_Width
, screenmodeprefs
.smp_Height
));
72 D(bug("[smeditor] Depth %ld\n", screenmodeprefs
.smp_Depth
));
73 D(bug("[smeditor] Control 0x%08lX\n", screenmodeprefs
.smp_Control
));
78 static BOOL ScreenmodePrefs2Gadgets
80 struct SMEditor_DATA
*data
83 D(bug("[smeditor] Prefs2Gadgets:\n"));
84 D(bug("[smeditor] DisplayID 0x%08lX\n", screenmodeprefs
.smp_DisplayID
));
85 D(bug("[smeditor] Size %ldx%ld\n", screenmodeprefs
.smp_Width
, screenmodeprefs
.smp_Height
));
86 D(bug("[smeditor] Depth %ld\n", screenmodeprefs
.smp_Depth
));
87 D(bug("[smeditor] Control 0x%08lX\n", screenmodeprefs
.smp_Control
));
89 NNSET(data
->selector
, MUIA_ScreenModeSelector_Active
, screenmodeprefs
.smp_DisplayID
);
94 MUIA_ScreenModeProperties_DisplayID
, screenmodeprefs
.smp_DisplayID
,
95 MUIA_ScreenModeProperties_Width
, screenmodeprefs
.smp_Width
,
96 MUIA_ScreenModeProperties_Height
, screenmodeprefs
.smp_Height
,
97 MUIA_ScreenModeProperties_Depth
, screenmodeprefs
.smp_Depth
,
98 MUIA_ScreenModeProperties_Autoscroll
, screenmodeprefs
.smp_Control
& SMF_AUTOSCROLL
,
105 MUIA_ScreenModeAttributes_DisplayID
, screenmodeprefs
.smp_DisplayID
,
112 static Object
*SMEditor__OM_NEW(Class
*CLASS
, Object
*self
, struct opSet
*message
)
114 Object
*selector
, *properties
, *attributes
;
115 self
= (Object
*) DoSuperNewTags
119 MUIA_PrefsEditor_Name
, __(MSG_NAME
),
120 MUIA_PrefsEditor_Path
, (IPTR
)"SYS/screenmode.prefs",
121 MUIA_PrefsEditor_IconTool
, (IPTR
)"SYS:Prefs/Screenmode",
127 Child
, (IPTR
) CLabel(_(MSG_DISPLAY_MODE
)),
128 Child
, (IPTR
)(selector
= (Object
*)ScreenModeSelectorObject
, End
),
129 Child
, (IPTR
)(properties
= (Object
*)ScreenModePropertiesObject
, GroupFrame
, End
),
134 Child
, (IPTR
) CLabel(_(MSG_MODE_ATTRIBUTES
)),
135 Child
, (IPTR
)(attributes
= (Object
*)ScreenModeAttributesObject
, GroupFrame
, End
),
147 data
->selector
= selector
;
148 data
->properties
= properties
;
149 data
->attributes
= attributes
;
151 /*-- Setup notifications -------------------------------------------*/
154 selector
, MUIM_Notify
, MUIA_ScreenModeSelector_Active
, MUIV_EveryTime
,
156 MUIM_Set
, MUIA_ScreenModeProperties_DisplayID
, MUIV_TriggerValue
161 selector
, MUIM_Notify
, MUIA_ScreenModeSelector_Active
, MUIV_EveryTime
,
163 MUIM_Set
, MUIA_ScreenModeAttributes_DisplayID
, MUIV_TriggerValue
168 properties
, MUIM_Notify
, MUIA_ScreenModeProperties_DisplayID
, MUIV_EveryTime
,
170 MUIM_Set
, MUIA_PrefsEditor_Changed
, TRUE
175 properties
, MUIM_Notify
, MUIA_ScreenModeProperties_Width
, MUIV_EveryTime
,
177 MUIM_Set
, MUIA_PrefsEditor_Changed
, TRUE
182 properties
, MUIM_Notify
, MUIA_ScreenModeProperties_Height
, MUIV_EveryTime
,
184 MUIM_Set
, MUIA_PrefsEditor_Changed
, TRUE
189 properties
, MUIM_Notify
, MUIA_ScreenModeProperties_Depth
, MUIV_EveryTime
,
191 MUIM_Set
, MUIA_PrefsEditor_Changed
, TRUE
196 properties
, MUIM_Notify
, MUIA_ScreenModeProperties_Autoscroll
, MUIV_EveryTime
,
198 MUIM_Set
, MUIA_PrefsEditor_Changed
, TRUE
205 static IPTR SMEditor__MUIM_PrefsEditor_ImportFH
207 Class
*CLASS
, Object
*self
,
208 struct MUIP_PrefsEditor_ImportFH
*message
214 success
= Prefs_ImportFH(message
->fh
);
218 ScreenmodePrefs2Gadgets(data
);
224 static IPTR SMEditor__MUIM_PrefsEditor_ExportFH
226 Class
*CLASS
, Object
*self
,
227 struct MUIP_PrefsEditor_ExportFH
*message
233 Gadgets2ScreenmodePrefs(data
);
234 success
= Prefs_ExportFH(message
->fh
);
239 static IPTR SMEditor__MUIM_PrefsEditor_SetDefaults
241 Class
*CLASS
, Object
*self
,
248 success
= Prefs_Default();
251 ScreenmodePrefs2Gadgets(data
);
252 SET(data
->selector
, MUIA_List_Active
, MUIV_List_Active_Off
);
260 SMEditor
, NULL
, MUIC_PrefsEditor
, NULL
,
261 OM_NEW
, struct opSet
*,
262 MUIM_PrefsEditor_ImportFH
, struct MUIP_PrefsEditor_ImportFH
*,
263 MUIM_PrefsEditor_ExportFH
, struct MUIP_PrefsEditor_ExportFH
*,
264 MUIM_PrefsEditor_SetDefaults
, Msg