grub2: bring back build of aros-side grub2 tools
[AROS.git] / workbench / classes / zune / prefswindow / prefswindow.c
blobaee6e39122e9ef77476f5eb4c92b751a6fdc9a04
1 /*
2 Copyright © 2003-2011, The AROS Development Team. All rights reserved.
3 This file is part of the PrefsWindow 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 <utility/tagitem.h>
12 #include <libraries/mui.h>
13 #include <dos/dos.h>
15 #include <proto/alib.h>
16 #include <proto/muimaster.h>
17 #include <proto/intuition.h>
18 #include <proto/utility.h>
19 #include <proto/locale.h>
20 #include <proto/dos.h>
22 #include <string.h>
24 #include "prefswindow.h"
25 #include "prefswindow_private.h"
27 #define CATCOMP_ARRAY
28 #include "strings.h"
30 #define DEBUG 1
31 #include <aros/debug.h>
33 /*** Locale functions *******************************************************/
34 CONST_STRPTR MSG(struct Catalog *catalog, ULONG id)
36 if (catalog != NULL)
38 return GetCatalogStr(catalog, id, CatCompArray[id].cca_Str);
40 else
42 return CatCompArray[id].cca_Str;
46 #define _(id) MSG(catalog, id)
48 /*** Methods ****************************************************************/
49 Object *PrefsWindow__OM_NEW
51 Class *CLASS, Object *self, struct opSet *message
54 struct PrefsWindow_DATA *data = NULL;
55 struct TagItem *tag = NULL;
56 struct Catalog *catalog = NULL;
57 Object *contents = NULL;
58 Object *testButton, *revertButton,
59 *saveButton, *useButton, *cancelButton;
61 catalog = OpenCatalogA(NULL, "System/Classes/Zune/PrefsWindow.catalog", NULL);
63 tag = FindTagItem(WindowContents, message->ops_AttrList);
64 if (tag != NULL)
66 tag->ti_Tag = TAG_IGNORE;
67 contents = (Object *) tag->ti_Data;
70 self = (Object *) DoSuperNewTags
72 CLASS, self, NULL,
74 MUIA_Window_CloseGadget, FALSE,
76 WindowContents, (IPTR) VGroup,
77 Child, (IPTR) contents,
78 Child, (IPTR) RectangleObject,
79 MUIA_Rectangle_HBar, TRUE,
80 MUIA_FixHeight, 2,
81 End,
82 Child, (IPTR) HGroup,
83 Child, (IPTR) HGroup,
84 MUIA_Group_SameWidth, TRUE,
85 MUIA_Weight, 0,
87 Child, (IPTR) (testButton = ImageButton(_(MSG_TEST), "THEME:Images/Gadgets/Test")),
88 Child, (IPTR) (revertButton = ImageButton(_(MSG_REVERT), "THEME:Images/Gadgets/Revert")),
89 End,
90 Child, (IPTR) RectangleObject,
91 MUIA_Weight, 50,
92 End,
93 Child, (IPTR) RectangleObject,
94 MUIA_Weight, 50,
95 End,
96 Child, (IPTR) RectangleObject,
97 MUIA_Weight, 50,
98 End,
99 Child, (IPTR) HGroup,
100 MUIA_Group_SameWidth, TRUE,
101 MUIA_Weight, 0,
103 Child, (IPTR) (saveButton = ImageButton(_(MSG_SAVE), "THEME:Images/Gadgets/Save")),
104 Child, (IPTR) (useButton = ImageButton(_(MSG_USE), "THEME:Images/Gadgets/Use")),
105 Child, (IPTR) (cancelButton = ImageButton(_(MSG_CANCEL), "THEME:Images/Gadgets/Cancel")),
106 End,
107 End,
108 End,
110 TAG_MORE, (IPTR) message->ops_AttrList
113 if (self != NULL)
115 data = INST_DATA(CLASS, self);
116 data->pwd_Catalog = catalog;
117 data->pwd_TestButton = testButton;
118 data->pwd_RevertButton = revertButton;
119 data->pwd_SaveButton = saveButton;
120 data->pwd_UseButton = useButton;
121 data->pwd_CancelButton = cancelButton;
123 /*-- Handle initial attribute values -------------------------------*/
124 SetAttrsA(self, message->ops_AttrList);
126 /*-- Setup notifications -------------------------------------------*/
127 DoMethod
129 self, MUIM_Notify, MUIA_Window_CloseRequest, TRUE,
130 (IPTR) self, 1, MUIM_PrefsWindow_Cancel
133 DoMethod
135 testButton, MUIM_Notify, MUIA_Pressed, FALSE,
136 (IPTR) self, 1, MUIM_PrefsWindow_Test
138 DoMethod
140 revertButton, MUIM_Notify, MUIA_Pressed, FALSE,
141 (IPTR) self, 1, MUIM_PrefsWindow_Revert
143 DoMethod
145 saveButton, MUIM_Notify, MUIA_Pressed, FALSE,
146 (IPTR) self, 1, MUIM_PrefsWindow_Save
148 DoMethod
150 useButton, MUIM_Notify, MUIA_Pressed, FALSE,
151 (IPTR) self, 1, MUIM_PrefsWindow_Use
153 DoMethod
155 cancelButton, MUIM_Notify, MUIA_Pressed, FALSE,
156 (IPTR) self, 1, MUIM_PrefsWindow_Cancel
159 else
161 if (catalog != NULL) CloseCatalog(catalog);
164 return self;
167 IPTR PrefsWindow__OM_DISPOSE
169 Class *CLASS, Object *self, Msg message
172 struct PrefsWindow_DATA *data = INST_DATA(CLASS, self);
174 if (data->pwd_Catalog != NULL) CloseCatalog(data->pwd_Catalog);
176 return DoSuperMethodA(CLASS, self, message);
179 IPTR PrefsWindow__OM_SET
181 Class *CLASS, Object *self, struct opSet *message
184 struct PrefsWindow_DATA *data = INST_DATA(CLASS, self);
185 struct TagItem *tstate = message->ops_AttrList;
186 struct TagItem *tag;
188 while ((tag = NextTagItem(&tstate)) != NULL)
190 switch (tag->ti_Tag)
192 case MUIA_PrefsWindow_Test_Disabled:
193 SET(data->pwd_TestButton, MUIA_Disabled, tag->ti_Data);
194 break;
196 case MUIA_PrefsWindow_Revert_Disabled:
197 SET(data->pwd_RevertButton, MUIA_Disabled, tag->ti_Data);
198 break;
200 case MUIA_PrefsWindow_Save_Disabled:
201 SET(data->pwd_SaveButton, MUIA_Disabled, tag->ti_Data);
202 break;
204 case MUIA_PrefsWindow_Use_Disabled:
205 SET(data->pwd_UseButton, MUIA_Disabled, tag->ti_Data);
206 break;
208 case MUIA_PrefsWindow_Cancel_Disabled:
209 SET(data->pwd_CancelButton, MUIA_Disabled, tag->ti_Data);
210 break;
214 return DoSuperMethodA(CLASS, self, (Msg) message);
217 IPTR PrefsWindow__OM_GET
219 Class *CLASS, Object *self, struct opGet *message
222 struct PrefsWindow_DATA *data = INST_DATA(CLASS, self);
223 IPTR *store = message->opg_Storage;
224 IPTR rv = TRUE;
226 switch (message->opg_AttrID)
228 case MUIA_PrefsWindow_Test_Disabled:
229 *store = XGET(data->pwd_TestButton, MUIA_Disabled);
230 break;
232 case MUIA_PrefsWindow_Revert_Disabled:
233 *store = XGET(data->pwd_RevertButton, MUIA_Disabled);
234 break;
236 case MUIA_PrefsWindow_Save_Disabled:
237 *store = XGET(data->pwd_SaveButton, MUIA_Disabled);
238 break;
240 case MUIA_PrefsWindow_Use_Disabled:
241 *store = XGET(data->pwd_UseButton, MUIA_Disabled);
242 break;
244 case MUIA_PrefsWindow_Cancel_Disabled:
245 *store = XGET(data->pwd_CancelButton, MUIA_Disabled);
246 break;
248 default:
249 rv = DoSuperMethodA(CLASS, self, (Msg) message);
252 return rv;