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.
9 #define MUIMASTER_YES_INLINE_STDARG
11 #include <utility/tagitem.h>
12 #include <libraries/mui.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>
23 #include "prefswindow.h"
24 #include "prefswindow_private.h"
30 #include <aros/debug.h>
32 /*** Locale functions *******************************************************/
33 CONST_STRPTR
MSG(struct Catalog
*catalog
, ULONG id
)
37 return GetCatalogStr(catalog
, id
, CatCompArray
[id
].cca_Str
);
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
);
65 tag
->ti_Tag
= TAG_IGNORE
;
66 contents
= (Object
*) tag
->ti_Data
;
69 self
= (Object
*) DoSuperNewTags
73 MUIA_Window_CloseGadget
, FALSE
,
75 WindowContents
, (IPTR
) VGroup
,
76 Child
, (IPTR
) contents
,
77 Child
, (IPTR
) RectangleObject
,
78 MUIA_Rectangle_HBar
, TRUE
,
83 MUIA_Group_SameWidth
, TRUE
,
86 Child
, (IPTR
) (testButton
= ImageButton(_(MSG_TEST
), "THEME:Images/Gadgets/Prefs/Test")),
87 Child
, (IPTR
) (revertButton
= ImageButton(_(MSG_REVERT
), "THEME:Images/Gadgets/Prefs/Revert")),
89 Child
, (IPTR
) RectangleObject
,
92 Child
, (IPTR
) RectangleObject
,
95 Child
, (IPTR
) RectangleObject
,
99 MUIA_Group_SameWidth
, TRUE
,
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")),
109 TAG_MORE
, (IPTR
) message
->ops_AttrList
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 -------------------------------------------*/
128 self
, MUIM_Notify
, MUIA_Window_CloseRequest
, TRUE
,
129 (IPTR
) self
, 1, MUIM_PrefsWindow_Cancel
134 testButton
, MUIM_Notify
, MUIA_Pressed
, FALSE
,
135 (IPTR
) self
, 1, MUIM_PrefsWindow_Test
139 revertButton
, MUIM_Notify
, MUIA_Pressed
, FALSE
,
140 (IPTR
) self
, 1, MUIM_PrefsWindow_Revert
144 saveButton
, MUIM_Notify
, MUIA_Pressed
, FALSE
,
145 (IPTR
) self
, 1, MUIM_PrefsWindow_Save
149 useButton
, MUIM_Notify
, MUIA_Pressed
, FALSE
,
150 (IPTR
) self
, 1, MUIM_PrefsWindow_Use
154 cancelButton
, MUIM_Notify
, MUIA_Pressed
, FALSE
,
155 (IPTR
) self
, 1, MUIM_PrefsWindow_Cancel
160 if (catalog
!= NULL
) CloseCatalog(catalog
);
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
;
187 while ((tag
= NextTagItem(&tstate
)) != NULL
)
191 case MUIA_PrefsWindow_Test_Disabled
:
192 SET(data
->pwd_TestButton
, MUIA_Disabled
, tag
->ti_Data
);
195 case MUIA_PrefsWindow_Revert_Disabled
:
196 SET(data
->pwd_RevertButton
, MUIA_Disabled
, tag
->ti_Data
);
199 case MUIA_PrefsWindow_Save_Disabled
:
200 SET(data
->pwd_SaveButton
, MUIA_Disabled
, tag
->ti_Data
);
203 case MUIA_PrefsWindow_Use_Disabled
:
204 SET(data
->pwd_UseButton
, MUIA_Disabled
, tag
->ti_Data
);
207 case MUIA_PrefsWindow_Cancel_Disabled
:
208 SET(data
->pwd_CancelButton
, MUIA_Disabled
, tag
->ti_Data
);
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
;
225 switch (message
->opg_AttrID
)
227 case MUIA_PrefsWindow_Test_Disabled
:
228 *store
= XGET(data
->pwd_TestButton
, MUIA_Disabled
);
231 case MUIA_PrefsWindow_Revert_Disabled
:
232 *store
= XGET(data
->pwd_RevertButton
, MUIA_Disabled
);
235 case MUIA_PrefsWindow_Save_Disabled
:
236 *store
= XGET(data
->pwd_SaveButton
, MUIA_Disabled
);
239 case MUIA_PrefsWindow_Use_Disabled
:
240 *store
= XGET(data
->pwd_UseButton
, MUIA_Disabled
);
243 case MUIA_PrefsWindow_Cancel_Disabled
:
244 *store
= XGET(data
->pwd_CancelButton
, MUIA_Disabled
);
248 rv
= DoSuperMethodA(CLASS
, self
, (Msg
) message
);