Don't keep asking for S2EVENT_CONNECT reports if driver doen't
[AROS.git] / workbench / prefs / screenmode / smeditor.c
blob869564ed45413857c530b111679dc48e2601e867
1 /*
2 Copyright © 2003-2011, 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 if (XGET(data->selector, MUIA_List_Active) == MUIV_List_Active_Off)
53 // No active list entry? Reset to defaults
54 Prefs_Default();
56 else
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;
65 else
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));
75 return TRUE;
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);
90 SetAttrs
92 data->properties,
93 MUIA_NoNotify, TRUE,
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,
99 TAG_DONE
102 SetAttrs
104 data->attributes,
105 MUIA_ScreenModeAttributes_DisplayID, screenmodeprefs.smp_DisplayID,
106 TAG_DONE
109 return TRUE;
112 static Object *SMEditor__OM_NEW(Class *CLASS, Object *self, struct opSet *message)
114 Object *selector, *properties, *attributes;
115 self = (Object *) DoSuperNewTags
117 CLASS, self, NULL,
119 MUIA_PrefsEditor_Name, __(MSG_NAME),
120 MUIA_PrefsEditor_Path, (IPTR)"SYS/screenmode.prefs",
121 MUIA_PrefsEditor_IconTool, (IPTR)"SYS:Prefs/Screenmode",
123 Child, (IPTR)HGroup,
125 Child, (IPTR)VGroup,
126 MUIA_Weight, 70,
127 Child, (IPTR) CLabel(_(MSG_DISPLAY_MODE)),
128 Child, (IPTR)(selector = (Object *)ScreenModeSelectorObject, End),
129 Child, (IPTR)(properties = (Object *)ScreenModePropertiesObject, GroupFrame, End),
130 End,
132 Child, (IPTR)VGroup,
133 MUIA_Weight, 30,
134 Child, (IPTR) CLabel(_(MSG_MODE_ATTRIBUTES)),
135 Child, (IPTR)(attributes = (Object *)ScreenModeAttributesObject, GroupFrame, End),
136 End,
138 End,
140 TAG_DONE
143 if (self)
145 SETUP_INST_DATA;
147 data->selector = selector;
148 data->properties = properties;
149 data->attributes = attributes;
151 /*-- Setup notifications -------------------------------------------*/
152 DoMethod
154 selector, MUIM_Notify, MUIA_ScreenModeSelector_Active, MUIV_EveryTime,
155 (IPTR)properties, 3,
156 MUIM_Set, MUIA_ScreenModeProperties_DisplayID, MUIV_TriggerValue
159 DoMethod
161 selector, MUIM_Notify, MUIA_ScreenModeSelector_Active, MUIV_EveryTime,
162 (IPTR)attributes, 3,
163 MUIM_Set, MUIA_ScreenModeAttributes_DisplayID, MUIV_TriggerValue
166 DoMethod
168 properties, MUIM_Notify, MUIA_ScreenModeProperties_DisplayID, MUIV_EveryTime,
169 (IPTR)self, 3,
170 MUIM_Set, MUIA_PrefsEditor_Changed, TRUE
173 DoMethod
175 properties, MUIM_Notify, MUIA_ScreenModeProperties_Width, MUIV_EveryTime,
176 (IPTR)self, 3,
177 MUIM_Set, MUIA_PrefsEditor_Changed, TRUE
180 DoMethod
182 properties, MUIM_Notify, MUIA_ScreenModeProperties_Height, MUIV_EveryTime,
183 (IPTR)self, 3,
184 MUIM_Set, MUIA_PrefsEditor_Changed, TRUE
187 DoMethod
189 properties, MUIM_Notify, MUIA_ScreenModeProperties_Depth, MUIV_EveryTime,
190 (IPTR)self, 3,
191 MUIM_Set, MUIA_PrefsEditor_Changed, TRUE
194 DoMethod
196 properties, MUIM_Notify, MUIA_ScreenModeProperties_Autoscroll, MUIV_EveryTime,
197 (IPTR)self, 3,
198 MUIM_Set, MUIA_PrefsEditor_Changed, TRUE
202 return self;
205 static IPTR SMEditor__MUIM_PrefsEditor_ImportFH
207 Class *CLASS, Object *self,
208 struct MUIP_PrefsEditor_ImportFH *message
211 SETUP_INST_DATA;
212 BOOL success = TRUE;
214 success = Prefs_ImportFH(message->fh);
216 if (success)
218 ScreenmodePrefs2Gadgets(data);
221 return success;
224 static IPTR SMEditor__MUIM_PrefsEditor_ExportFH
226 Class *CLASS, Object *self,
227 struct MUIP_PrefsEditor_ExportFH *message
230 SETUP_INST_DATA;
231 BOOL success = TRUE;
233 Gadgets2ScreenmodePrefs(data);
234 success = Prefs_ExportFH(message->fh);
236 return success;
239 static IPTR SMEditor__MUIM_PrefsEditor_SetDefaults
241 Class *CLASS, Object *self,
242 Msg message
245 SETUP_INST_DATA;
246 BOOL success = TRUE;
248 success = Prefs_Default();
249 if (success)
251 ScreenmodePrefs2Gadgets(data);
252 SET(data->selector, MUIA_List_Active, MUIV_List_Active_Off);
255 return success;
258 ZUNE_CUSTOMCLASS_4
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