added concrete implementations of putc(), getc(), getchar() and gets()
[tangerine.git] / workbench / classes / zune / systemprefswindow / systemprefswindow.c
blob4c0c8f08ea12aef2197313ba8a83a74c1c21233d
1 /*
2 Copyright © 2004, The AROS Development Team. All rights reserved.
3 This file is part of the SystemPrefsWindow class, which is distributed under
4 the terms of version 2.1 of the GNU Lesser General Public License.
6 $Id$
7 */
9 #define MUIMASTER_YES_INLINE_STDARG
11 #include <proto/muimaster.h>
12 #include <proto/intuition.h>
13 #include <proto/utility.h>
14 #include <proto/locale.h>
16 #include <utility/tagitem.h>
17 #include <libraries/gadtools.h>
18 #include <libraries/mui.h>
19 #include <zune/prefseditor.h>
20 #include <zune/prefswindow.h>
22 #include "systemprefswindow.h"
23 #include "systemprefswindow_private.h"
25 #define CATCOMP_ARRAY
26 #include "strings.h"
28 #define DEBUG 1
29 #include <aros/debug.h>
31 /*** Macros *****************************************************************/
32 #define SETUP_INST_DATA struct SystemPrefsWindow_DATA *data = INST_DATA(CLASS, self)
34 /*** Locale functions *******************************************************/
35 CONST_STRPTR MSG(struct Catalog *catalog, ULONG id)
37 if (catalog != NULL)
39 return GetCatalogStr(catalog, id, CatCompArray[id].cca_Str);
41 else
43 return CatCompArray[id].cca_Str;
47 #define _(id) MSG(catalog, (id))
48 #define __(id) (IPTR) MSG(catalog, (id))
50 /*** Utility functions ******************************************************/
51 Object *MakeMenuitem(CONST_STRPTR text)
53 CONST_STRPTR title = NULL,
54 shortcut = NULL;
56 if (text != NM_BARLABEL && text[1] == '\0')
58 title = text + 2;
59 shortcut = text;
61 else
63 title = text;
64 shortcut = NULL;
67 return MenuitemObject,
68 MUIA_Menuitem_Title, (IPTR) title,
69 shortcut != NULL ?
70 MUIA_Menuitem_Shortcut :
71 TAG_IGNORE, (IPTR) shortcut,
72 End;
75 /*** Methods ****************************************************************/
76 Object *SystemPrefsWindow__OM_NEW
78 Class *CLASS, Object *self, struct opSet *message
81 struct SystemPrefsWindow_DATA *data = NULL;
82 struct TagItem *tag = NULL;
83 struct Catalog *catalog = NULL;
84 Object *editor, /* *importMI, *exportMI, */ *testMI, *revertMI,
85 *saveMI, *useMI, *cancelMI;
87 tag = FindTagItem(WindowContents, message->ops_AttrList);
88 if (tag != NULL) editor = (Object *) tag->ti_Data;
89 if (editor == NULL) return NULL;
91 /*--- Initialize locale ------------------------------------------------*/
92 catalog = OpenCatalogA
94 NULL, "System/Classes/Zune/SystemPrefsWindow.catalog", NULL
97 /*--- Create object ----------------------------------------------------*/
98 self = (Object *) DoSuperNewTags
100 CLASS, self, NULL,
102 MUIA_Window_Title, XGET(editor, MUIA_PrefsEditor_Name),
104 MUIA_Window_Menustrip, (IPTR) MenustripObject,
105 Child, (IPTR) MenuObject,
106 MUIA_Menu_Title, __(MSG_MENU_PREFS),
108 /* FIXME: implement
109 Child, (IPTR) importMI = MakeMenuitem(_(MSG_MENU_PREFS_IMPORT)),
110 Child, (IPTR) exportMI = MakeMenuitem(_(MSG_MENU_PREFS_EXPORT)),
111 Child, (IPTR) MakeMenuitem(NM_BARLABEL),
114 Child, (IPTR)(testMI = MakeMenuitem(_(MSG_MENU_PREFS_TEST))),
115 Child, (IPTR)(revertMI = MakeMenuitem(_(MSG_MENU_PREFS_REVERT))),
116 Child, MakeMenuitem(NM_BARLABEL),
117 Child, (IPTR)(saveMI = MakeMenuitem(_(MSG_MENU_PREFS_SAVE))),
118 Child, (IPTR)(useMI = MakeMenuitem(_(MSG_MENU_PREFS_USE))),
119 Child, (IPTR)(cancelMI = MakeMenuitem(_(MSG_MENU_PREFS_CANCEL))),
120 End,
121 End,
123 TAG_MORE, (IPTR) message->ops_AttrList
127 if (self != NULL)
129 data = INST_DATA(CLASS, self);
130 data->spwd_Catalog = catalog;
131 data->spwd_Editor = editor;
133 /*-- Handle initial attribute values -------------------------------*/
134 SetAttrsA(self, message->ops_AttrList);
136 /*-- Setup initial button states -----------------------------------*/
137 SET(self, MUIA_PrefsWindow_Test_Disabled, TRUE);
138 SET(self, MUIA_PrefsWindow_Revert_Disabled, TRUE);
139 SET(self, MUIA_PrefsWindow_Save_Disabled, TRUE);
140 SET(self, MUIA_PrefsWindow_Use_Disabled, TRUE);
142 /*-- Setup notifications -------------------------------------------*/
143 DoMethod
145 editor, MUIM_Notify, MUIA_PrefsEditor_Changed, MUIV_EveryTime,
146 (IPTR) self, 1, MUIM_SystemPrefsWindow_UpdateButtons
148 DoMethod
150 editor, MUIM_Notify, MUIA_PrefsEditor_Testing, MUIV_EveryTime,
151 (IPTR) self, 1, MUIM_SystemPrefsWindow_UpdateButtons
154 DoMethod
156 testMI, MUIM_Notify, MUIA_Menuitem_Trigger, MUIV_EveryTime,
157 (IPTR) self, 1, MUIM_PrefsWindow_Test
159 DoMethod
161 revertMI, MUIM_Notify, MUIA_Menuitem_Trigger, MUIV_EveryTime,
162 (IPTR) self, 1, MUIM_PrefsWindow_Revert
164 DoMethod
166 saveMI, MUIM_Notify, MUIA_Menuitem_Trigger, MUIV_EveryTime,
167 (IPTR) self, 1, MUIM_PrefsWindow_Save
169 DoMethod
171 useMI, MUIM_Notify, MUIA_Menuitem_Trigger, MUIV_EveryTime,
172 (IPTR) self, 1, MUIM_PrefsWindow_Use
174 DoMethod
176 cancelMI, MUIM_Notify, MUIA_Menuitem_Trigger, MUIV_EveryTime,
177 (IPTR) self, 1, MUIM_PrefsWindow_Cancel
180 else
182 if (catalog != NULL) CloseCatalog(catalog);
185 return self;
188 IPTR SystemPrefsWindow__OM_DISPOSE
190 Class *CLASS, Object *self, Msg message
193 SETUP_INST_DATA;
195 if (data->spwd_Catalog != NULL) CloseCatalog(data->spwd_Catalog);
197 return DoSuperMethodA(CLASS, self, message);
200 IPTR SystemPrefsWindow__MUIM_SystemPrefsWindow_UpdateButtons
202 Class *CLASS, Object *self, Msg message
205 SETUP_INST_DATA;
207 BOOL changed = XGET(data->spwd_Editor, MUIA_PrefsEditor_Changed);
208 BOOL testing = XGET(data->spwd_Editor, MUIA_PrefsEditor_Testing);
210 SET(self, MUIA_PrefsWindow_Test_Disabled, !changed);
211 SET(self, MUIA_PrefsWindow_Revert_Disabled, !testing);
213 SET(self, MUIA_PrefsWindow_Save_Disabled, !(changed || testing));
214 SET(self, MUIA_PrefsWindow_Use_Disabled, !(changed || testing));
216 return 0;
219 IPTR SystemPrefsWindow__OM_SET
221 Class *CLASS, Object *self, struct opSet *message
224 SETUP_INST_DATA;
225 struct TagItem *tstate = message->ops_AttrList, *tag;
227 while ((tag = NextTagItem(&tstate)) != NULL)
229 switch (tag->ti_Tag)
231 case MUIA_PrefsWindow_Save_Disabled:
232 if (!XGET(data->spwd_Editor, MUIA_PrefsEditor_CanSave))
234 tag->ti_Tag = TAG_IGNORE;
236 break;
238 case MUIA_PrefsWindow_Test_Disabled:
239 case MUIA_PrefsWindow_Revert_Disabled:
240 if (!XGET(data->spwd_Editor, MUIA_PrefsEditor_CanTest))
242 tag->ti_Tag = TAG_IGNORE;
244 break;
248 return DoSuperMethodA(CLASS, self, (Msg) message);
251 IPTR SystemPrefsWindow__MUIM_PrefsWindow_Test
253 Class *CLASS, Object *self, Msg message
256 SETUP_INST_DATA;
258 if (!DoMethod(data->spwd_Editor, MUIM_PrefsEditor_Test))
260 // FIXME: error reporting
261 return FALSE;
264 return TRUE;
267 IPTR SystemPrefsWindow__MUIM_PrefsWindow_Revert
269 Class *CLASS, Object *self, Msg message
272 SETUP_INST_DATA;
274 if (!DoMethod(data->spwd_Editor, MUIM_PrefsEditor_Revert))
276 // FIXME: error reporting
277 return FALSE;
280 return TRUE;
283 IPTR SystemPrefsWindow__MUIM_PrefsWindow_Save
285 Class *CLASS, Object *self, Msg message
288 SETUP_INST_DATA;
290 if (!DoMethod(data->spwd_Editor, MUIM_PrefsEditor_Save))
292 // FIXME: error reporting
293 return FALSE;
296 DoMethod
298 _app(self), MUIM_Application_ReturnID, MUIV_Application_ReturnID_Quit
301 return TRUE;
304 IPTR SystemPrefsWindow__MUIM_PrefsWindow_Use
306 Class *CLASS, Object *self, Msg message
309 SETUP_INST_DATA;
311 if (!DoMethod(data->spwd_Editor, MUIM_PrefsEditor_Use))
313 // FIXME: error reporting
314 return FALSE;
317 DoMethod
319 _app(self), MUIM_Application_ReturnID, MUIV_Application_ReturnID_Quit
322 return TRUE;
325 IPTR SystemPrefsWindow__MUIM_PrefsWindow_Cancel
327 Class *CLASS, Object *self, Msg message
330 SETUP_INST_DATA;
332 if (!DoMethod(data->spwd_Editor, MUIM_PrefsEditor_Cancel))
334 // FIXME: error reporting
335 return FALSE;
338 DoMethod
340 _app(self), MUIM_Application_ReturnID, MUIV_Application_ReturnID_Quit
343 return TRUE;