2 Copyright © 2003-2017, 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
53 if (XGET(data
->selector
, MUIA_List_Active
) == MUIV_List_Active_Off
)
55 // No active list entry? Reset to defaults
60 screenmodeprefs
.smp_DisplayID
= XGET(data
->properties
, MUIA_ScreenModeProperties_DisplayID
);
62 width
= XGET(data
->properties
, MUIA_ScreenModeProperties_Width
);
63 if (width
== XGET(data
->properties
, MUIA_ScreenModeProperties_DefWidth
))
65 screenmodeprefs
.smp_Width
= width
;
67 height
= XGET(data
->properties
, MUIA_ScreenModeProperties_Height
);
68 if (height
== XGET(data
->properties
, MUIA_ScreenModeProperties_DefHeight
))
70 screenmodeprefs
.smp_Height
= height
;
72 screenmodeprefs
.smp_Depth
= XGET(data
->properties
, MUIA_ScreenModeProperties_Depth
);
74 if (XGET(data
->properties
, MUIA_ScreenModeProperties_Autoscroll
))
75 screenmodeprefs
.smp_Control
= SMF_AUTOSCROLL
;
77 screenmodeprefs
.smp_Control
= 0;
80 D(bug("[smeditor] Gadgets2Prefs:\n"));
81 D(bug("[smeditor] DisplayID 0x%08lX\n", screenmodeprefs
.smp_DisplayID
));
82 D(bug("[smeditor] Size %ldx%ld\n", screenmodeprefs
.smp_Width
, screenmodeprefs
.smp_Height
));
83 D(bug("[smeditor] Depth %ld\n", screenmodeprefs
.smp_Depth
));
84 D(bug("[smeditor] Control 0x%08lX\n", screenmodeprefs
.smp_Control
));
89 static BOOL ScreenmodePrefs2Gadgets
91 struct SMEditor_DATA
*data
94 D(bug("[smeditor] Prefs2Gadgets:\n"));
95 D(bug("[smeditor] DisplayID 0x%08lX\n", screenmodeprefs
.smp_DisplayID
));
96 D(bug("[smeditor] Size %ldx%ld\n", screenmodeprefs
.smp_Width
, screenmodeprefs
.smp_Height
));
97 D(bug("[smeditor] Depth %ld\n", screenmodeprefs
.smp_Depth
));
98 D(bug("[smeditor] Control 0x%08lX\n", screenmodeprefs
.smp_Control
));
100 NNSET(data
->selector
, MUIA_ScreenModeSelector_Active
, screenmodeprefs
.smp_DisplayID
);
105 MUIA_ScreenModeProperties_DisplayID
, screenmodeprefs
.smp_DisplayID
,
106 MUIA_ScreenModeProperties_Width
, screenmodeprefs
.smp_Width
,
107 MUIA_ScreenModeProperties_Height
, screenmodeprefs
.smp_Height
,
108 MUIA_ScreenModeProperties_Depth
, screenmodeprefs
.smp_Depth
,
109 MUIA_ScreenModeProperties_Autoscroll
, screenmodeprefs
.smp_Control
& SMF_AUTOSCROLL
,
116 MUIA_ScreenModeAttributes_DisplayID
, screenmodeprefs
.smp_DisplayID
,
123 static Object
*SMEditor__OM_NEW(Class
*CLASS
, Object
*self
, struct opSet
*message
)
125 Object
*selector
, *properties
, *attributes
;
126 self
= (Object
*) DoSuperNewTags
130 MUIA_PrefsEditor_Name
, __(MSG_NAME
),
131 MUIA_PrefsEditor_Path
, (IPTR
)"SYS/screenmode.prefs",
132 MUIA_PrefsEditor_IconTool
, (IPTR
)"SYS:Prefs/Screenmode",
138 Child
, (IPTR
) CLabel(_(MSG_DISPLAY_MODE
)),
139 Child
, (IPTR
)(selector
= (Object
*)ScreenModeSelectorObject
, End
),
140 Child
, (IPTR
)(properties
= (Object
*)ScreenModePropertiesObject
, GroupFrame
, End
),
145 Child
, (IPTR
) CLabel(_(MSG_MODE_ATTRIBUTES
)),
146 Child
, (IPTR
)(attributes
= (Object
*)ScreenModeAttributesObject
, GroupFrame
, End
),
158 data
->selector
= selector
;
159 data
->properties
= properties
;
160 data
->attributes
= attributes
;
162 /*-- Setup notifications -------------------------------------------*/
165 selector
, MUIM_Notify
, MUIA_ScreenModeSelector_Active
, MUIV_EveryTime
,
167 MUIM_Set
, MUIA_ScreenModeProperties_DisplayID
, MUIV_TriggerValue
172 selector
, MUIM_Notify
, MUIA_ScreenModeSelector_Active
, MUIV_EveryTime
,
174 MUIM_Set
, MUIA_ScreenModeAttributes_DisplayID
, MUIV_TriggerValue
179 properties
, MUIM_Notify
, MUIA_ScreenModeProperties_DisplayID
, MUIV_EveryTime
,
181 MUIM_Set
, MUIA_PrefsEditor_Changed
, TRUE
186 properties
, MUIM_Notify
, MUIA_ScreenModeProperties_Width
, MUIV_EveryTime
,
188 MUIM_Set
, MUIA_PrefsEditor_Changed
, TRUE
193 properties
, MUIM_Notify
, MUIA_ScreenModeProperties_Height
, MUIV_EveryTime
,
195 MUIM_Set
, MUIA_PrefsEditor_Changed
, TRUE
200 properties
, MUIM_Notify
, MUIA_ScreenModeProperties_Depth
, MUIV_EveryTime
,
202 MUIM_Set
, MUIA_PrefsEditor_Changed
, TRUE
207 properties
, MUIM_Notify
, MUIA_ScreenModeProperties_Autoscroll
, MUIV_EveryTime
,
209 MUIM_Set
, MUIA_PrefsEditor_Changed
, TRUE
216 static IPTR SMEditor__MUIM_PrefsEditor_ImportFH
218 Class
*CLASS
, Object
*self
,
219 struct MUIP_PrefsEditor_ImportFH
*message
225 success
= Prefs_ImportFH(message
->fh
);
229 ScreenmodePrefs2Gadgets(data
);
235 static IPTR SMEditor__MUIM_PrefsEditor_ExportFH
237 Class
*CLASS
, Object
*self
,
238 struct MUIP_PrefsEditor_ExportFH
*message
244 Gadgets2ScreenmodePrefs(data
);
245 success
= Prefs_ExportFH(message
->fh
);
250 static IPTR SMEditor__MUIM_PrefsEditor_SetDefaults
252 Class
*CLASS
, Object
*self
,
259 success
= Prefs_Default();
262 ScreenmodePrefs2Gadgets(data
);
263 SET(data
->selector
, MUIA_List_Active
, MUIV_List_Active_Off
);
271 SMEditor
, NULL
, MUIC_PrefsEditor
, NULL
,
272 OM_NEW
, struct opSet
*,
273 MUIM_PrefsEditor_ImportFH
, struct MUIP_PrefsEditor_ImportFH
*,
274 MUIM_PrefsEditor_ExportFH
, struct MUIP_PrefsEditor_ExportFH
*,
275 MUIM_PrefsEditor_SetDefaults
, Msg