Updated PCI IDs to latest snapshot.
[tangerine.git] / workbench / classes / zune / prefswindow / prefswindow.c
bloba554a2697710f1fdc9c648d71314f90da7f93c20
1 /*
2 Copyright © 2003-2004, 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/muimaster.h>
16 #include <proto/intuition.h>
17 #include <proto/utility.h>
18 #include <proto/locale.h>
19 #include <proto/dos.h>
21 #include <string.h>
23 #include "prefswindow.h"
24 #include "prefswindow_private.h"
26 #define CATCOMP_ARRAY
27 #include "strings.h"
29 #define DEBUG 1
30 #include <aros/debug.h>
32 /*** Locale functions *******************************************************/
33 CONST_STRPTR MSG(struct Catalog *catalog, ULONG id)
35 if (catalog != NULL)
37 return GetCatalogStr(catalog, id, CatCompArray[id].cca_Str);
39 else
41 return CatCompArray[id].cca_Str;
45 #define _(id) MSG(catalog, id)
47 /*** Methods ****************************************************************/
48 Object *PrefsWindow__OM_NEW
50 Class *CLASS, Object *self, struct opSet *message
53 struct PrefsWindow_DATA *data = NULL;
54 struct TagItem *tag = NULL;
55 struct Catalog *catalog = NULL;
56 Object *contents = NULL;
57 Object *testButton, *revertButton,
58 *saveButton, *useButton, *cancelButton;
60 catalog = OpenCatalogA(NULL, "System/Classes/Zune/PrefsWindow.catalog", NULL);
62 tag = FindTagItem(WindowContents, message->ops_AttrList);
63 if (tag != NULL)
65 tag->ti_Tag = TAG_IGNORE;
66 contents = (Object *) tag->ti_Data;
69 self = (Object *) DoSuperNewTags
71 CLASS, self, NULL,
73 MUIA_Window_CloseGadget, FALSE,
75 WindowContents, (IPTR) VGroup,
76 Child, (IPTR) contents,
77 Child, (IPTR) RectangleObject,
78 MUIA_Rectangle_HBar, TRUE,
79 MUIA_FixHeight, 2,
80 End,
81 Child, (IPTR) HGroup,
82 Child, (IPTR) HGroup,
83 MUIA_Group_SameWidth, TRUE,
84 MUIA_Weight, 0,
86 Child, (IPTR) (testButton = ImageButton(_(MSG_TEST), "THEME:Images/Gadgets/Prefs/Test")),
87 Child, (IPTR) (revertButton = ImageButton(_(MSG_REVERT), "THEME:Images/Gadgets/Prefs/Revert")),
88 End,
89 Child, (IPTR) RectangleObject,
90 MUIA_Weight, 50,
91 End,
92 Child, (IPTR) RectangleObject,
93 MUIA_Weight, 50,
94 End,
95 Child, (IPTR) RectangleObject,
96 MUIA_Weight, 50,
97 End,
98 Child, (IPTR) HGroup,
99 MUIA_Group_SameWidth, TRUE,
100 MUIA_Weight, 0,
102 Child, (IPTR) (saveButton = ImageButton(_(MSG_SAVE), "THEME:Images/Gadgets/Prefs/Save")),
103 Child, (IPTR) (useButton = ImageButton(_(MSG_USE), "THEME:Images/Gadgets/Prefs/Use")),
104 Child, (IPTR) (cancelButton = ImageButton(_(MSG_CANCEL), "THEME:Images/Gadgets/Prefs/Cancel")),
105 End,
106 End,
107 End,
109 TAG_MORE, (IPTR) message->ops_AttrList
112 if (self != NULL)
114 data = INST_DATA(CLASS, self);
115 data->pwd_Catalog = catalog;
116 data->pwd_TestButton = testButton;
117 data->pwd_RevertButton = revertButton;
118 data->pwd_SaveButton = saveButton;
119 data->pwd_UseButton = useButton;
120 data->pwd_CancelButton = cancelButton;
122 /*-- Handle initial attribute values -------------------------------*/
123 SetAttrsA(self, message->ops_AttrList);
125 /*-- Setup notifications -------------------------------------------*/
126 DoMethod
128 self, MUIM_Notify, MUIA_Window_CloseRequest, TRUE,
129 (IPTR) self, 1, MUIM_PrefsWindow_Cancel
132 DoMethod
134 testButton, MUIM_Notify, MUIA_Pressed, FALSE,
135 (IPTR) self, 1, MUIM_PrefsWindow_Test
137 DoMethod
139 revertButton, MUIM_Notify, MUIA_Pressed, FALSE,
140 (IPTR) self, 1, MUIM_PrefsWindow_Revert
142 DoMethod
144 saveButton, MUIM_Notify, MUIA_Pressed, FALSE,
145 (IPTR) self, 1, MUIM_PrefsWindow_Save
147 DoMethod
149 useButton, MUIM_Notify, MUIA_Pressed, FALSE,
150 (IPTR) self, 1, MUIM_PrefsWindow_Use
152 DoMethod
154 cancelButton, MUIM_Notify, MUIA_Pressed, FALSE,
155 (IPTR) self, 1, MUIM_PrefsWindow_Cancel
158 else
160 if (catalog != NULL) CloseCatalog(catalog);
163 return self;
166 IPTR PrefsWindow__OM_DISPOSE
168 Class *CLASS, Object *self, Msg message
171 struct PrefsWindow_DATA *data = INST_DATA(CLASS, self);
173 if (data->pwd_Catalog != NULL) CloseCatalog(data->pwd_Catalog);
175 return DoSuperMethodA(CLASS, self, message);
178 IPTR PrefsWindow__OM_SET
180 Class *CLASS, Object *self, struct opSet *message
183 struct PrefsWindow_DATA *data = INST_DATA(CLASS, self);
184 const struct TagItem *tstate = message->ops_AttrList;
185 struct TagItem *tag;
187 while ((tag = NextTagItem(&tstate)) != NULL)
189 switch (tag->ti_Tag)
191 case MUIA_PrefsWindow_Test_Disabled:
192 SET(data->pwd_TestButton, MUIA_Disabled, tag->ti_Data);
193 break;
195 case MUIA_PrefsWindow_Revert_Disabled:
196 SET(data->pwd_RevertButton, MUIA_Disabled, tag->ti_Data);
197 break;
199 case MUIA_PrefsWindow_Save_Disabled:
200 SET(data->pwd_SaveButton, MUIA_Disabled, tag->ti_Data);
201 break;
203 case MUIA_PrefsWindow_Use_Disabled:
204 SET(data->pwd_UseButton, MUIA_Disabled, tag->ti_Data);
205 break;
207 case MUIA_PrefsWindow_Cancel_Disabled:
208 SET(data->pwd_CancelButton, MUIA_Disabled, tag->ti_Data);
209 break;
213 return DoSuperMethodA(CLASS, self, (Msg) message);
216 IPTR PrefsWindow__OM_GET
218 Class *CLASS, Object *self, struct opGet *message
221 struct PrefsWindow_DATA *data = INST_DATA(CLASS, self);
222 IPTR *store = message->opg_Storage;
223 IPTR rv = TRUE;
225 switch (message->opg_AttrID)
227 case MUIA_PrefsWindow_Test_Disabled:
228 *store = XGET(data->pwd_TestButton, MUIA_Disabled);
229 break;
231 case MUIA_PrefsWindow_Revert_Disabled:
232 *store = XGET(data->pwd_RevertButton, MUIA_Disabled);
233 break;
235 case MUIA_PrefsWindow_Save_Disabled:
236 *store = XGET(data->pwd_SaveButton, MUIA_Disabled);
237 break;
239 case MUIA_PrefsWindow_Use_Disabled:
240 *store = XGET(data->pwd_UseButton, MUIA_Disabled);
241 break;
243 case MUIA_PrefsWindow_Cancel_Disabled:
244 *store = XGET(data->pwd_CancelButton, MUIA_Disabled);
245 break;
247 default:
248 rv = DoSuperMethodA(CLASS, self, (Msg) message);
251 return rv;