disable float support on m68k to prevent unwanted symbols being used in rom code...
[AROS.git] / workbench / prefs / screenmode / smeditor.c
blob1585d3bb5722149e4040a3f8a4f1599e7296da78
1 /*
2 Copyright © 2003-2017, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #define MUIMASTER_YES_INLINE_STDARG
7 #define DEBUG 0
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>
27 #include <stdio.h>
29 #include "locale.h"
31 #include "prefs.h"
32 #include "smeditor.h"
33 #include "smselector.h"
34 #include "smproperties.h"
35 #include "smattributes.h"
38 struct SMEditor_DATA
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 UWORD width, height;
53 if (XGET(data->selector, MUIA_List_Active) == MUIV_List_Active_Off)
55 // No active list entry? Reset to defaults
56 Prefs_Default();
58 else
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))
64 width = ~0;
65 screenmodeprefs.smp_Width = width;
67 height = XGET(data->properties, MUIA_ScreenModeProperties_Height);
68 if (height == XGET(data->properties, MUIA_ScreenModeProperties_DefHeight))
69 height = ~0;
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;
76 else
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));
86 return TRUE;
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);
101 SetAttrs
103 data->properties,
104 MUIA_NoNotify, TRUE,
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,
110 TAG_DONE
113 SetAttrs
115 data->attributes,
116 MUIA_ScreenModeAttributes_DisplayID, screenmodeprefs.smp_DisplayID,
117 TAG_DONE
120 return TRUE;
123 static Object *SMEditor__OM_NEW(Class *CLASS, Object *self, struct opSet *message)
125 Object *selector, *properties, *attributes;
126 self = (Object *) DoSuperNewTags
128 CLASS, self, NULL,
130 MUIA_PrefsEditor_Name, __(MSG_NAME),
131 MUIA_PrefsEditor_Path, (IPTR)"SYS/screenmode.prefs",
132 MUIA_PrefsEditor_IconTool, (IPTR)"SYS:Prefs/Screenmode",
134 Child, (IPTR)HGroup,
136 Child, (IPTR)VGroup,
137 MUIA_Weight, 70,
138 Child, (IPTR) CLabel(_(MSG_DISPLAY_MODE)),
139 Child, (IPTR)(selector = (Object *)ScreenModeSelectorObject, End),
140 Child, (IPTR)(properties = (Object *)ScreenModePropertiesObject, GroupFrame, End),
141 End,
143 Child, (IPTR)VGroup,
144 MUIA_Weight, 30,
145 Child, (IPTR) CLabel(_(MSG_MODE_ATTRIBUTES)),
146 Child, (IPTR)(attributes = (Object *)ScreenModeAttributesObject, GroupFrame, End),
147 End,
149 End,
151 TAG_DONE
154 if (self)
156 SETUP_INST_DATA;
158 data->selector = selector;
159 data->properties = properties;
160 data->attributes = attributes;
162 /*-- Setup notifications -------------------------------------------*/
163 DoMethod
165 selector, MUIM_Notify, MUIA_ScreenModeSelector_Active, MUIV_EveryTime,
166 (IPTR)properties, 3,
167 MUIM_Set, MUIA_ScreenModeProperties_DisplayID, MUIV_TriggerValue
170 DoMethod
172 selector, MUIM_Notify, MUIA_ScreenModeSelector_Active, MUIV_EveryTime,
173 (IPTR)attributes, 3,
174 MUIM_Set, MUIA_ScreenModeAttributes_DisplayID, MUIV_TriggerValue
177 DoMethod
179 properties, MUIM_Notify, MUIA_ScreenModeProperties_DisplayID, MUIV_EveryTime,
180 (IPTR)self, 3,
181 MUIM_Set, MUIA_PrefsEditor_Changed, TRUE
184 DoMethod
186 properties, MUIM_Notify, MUIA_ScreenModeProperties_Width, MUIV_EveryTime,
187 (IPTR)self, 3,
188 MUIM_Set, MUIA_PrefsEditor_Changed, TRUE
191 DoMethod
193 properties, MUIM_Notify, MUIA_ScreenModeProperties_Height, MUIV_EveryTime,
194 (IPTR)self, 3,
195 MUIM_Set, MUIA_PrefsEditor_Changed, TRUE
198 DoMethod
200 properties, MUIM_Notify, MUIA_ScreenModeProperties_Depth, MUIV_EveryTime,
201 (IPTR)self, 3,
202 MUIM_Set, MUIA_PrefsEditor_Changed, TRUE
205 DoMethod
207 properties, MUIM_Notify, MUIA_ScreenModeProperties_Autoscroll, MUIV_EveryTime,
208 (IPTR)self, 3,
209 MUIM_Set, MUIA_PrefsEditor_Changed, TRUE
213 return self;
216 static IPTR SMEditor__MUIM_PrefsEditor_ImportFH
218 Class *CLASS, Object *self,
219 struct MUIP_PrefsEditor_ImportFH *message
222 SETUP_INST_DATA;
223 BOOL success = TRUE;
225 success = Prefs_ImportFH(message->fh);
227 if (success)
229 ScreenmodePrefs2Gadgets(data);
232 return success;
235 static IPTR SMEditor__MUIM_PrefsEditor_ExportFH
237 Class *CLASS, Object *self,
238 struct MUIP_PrefsEditor_ExportFH *message
241 SETUP_INST_DATA;
242 BOOL success = TRUE;
244 Gadgets2ScreenmodePrefs(data);
245 success = Prefs_ExportFH(message->fh);
247 return success;
250 static IPTR SMEditor__MUIM_PrefsEditor_SetDefaults
252 Class *CLASS, Object *self,
253 Msg message
256 SETUP_INST_DATA;
257 BOOL success = TRUE;
259 success = Prefs_Default();
260 if (success)
262 ScreenmodePrefs2Gadgets(data);
263 SET(data->selector, MUIA_List_Active, MUIV_List_Active_Off);
266 return success;
269 ZUNE_CUSTOMCLASS_4
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