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.
9 #define MUIMASTER_YES_INLINE_STDARG
11 #include <utility/tagitem.h>
12 #include <libraries/mui.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>
24 #include "prefswindow.h"
25 #include "prefswindow_private.h"
31 #include <aros/debug.h>
33 /*** Locale functions *******************************************************/
34 CONST_STRPTR
MSG(struct Catalog
*catalog
, ULONG id
)
38 return GetCatalogStr(catalog
, id
, CatCompArray
[id
].cca_Str
);
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
);
66 tag
->ti_Tag
= TAG_IGNORE
;
67 contents
= (Object
*) tag
->ti_Data
;
70 self
= (Object
*) DoSuperNewTags
74 MUIA_Window_CloseGadget
, FALSE
,
76 WindowContents
, (IPTR
) VGroup
,
77 Child
, (IPTR
) contents
,
78 Child
, (IPTR
) RectangleObject
,
79 MUIA_Rectangle_HBar
, TRUE
,
84 MUIA_Group_SameWidth
, TRUE
,
87 Child
, (IPTR
) (testButton
= ImageButton(_(MSG_TEST
), "THEME:Images/Gadgets/Test")),
88 Child
, (IPTR
) (revertButton
= ImageButton(_(MSG_REVERT
), "THEME:Images/Gadgets/Revert")),
90 Child
, (IPTR
) RectangleObject
,
93 Child
, (IPTR
) RectangleObject
,
96 Child
, (IPTR
) RectangleObject
,
100 MUIA_Group_SameWidth
, TRUE
,
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")),
110 TAG_MORE
, (IPTR
) message
->ops_AttrList
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 -------------------------------------------*/
129 self
, MUIM_Notify
, MUIA_Window_CloseRequest
, TRUE
,
130 (IPTR
) self
, 1, MUIM_PrefsWindow_Cancel
135 testButton
, MUIM_Notify
, MUIA_Pressed
, FALSE
,
136 (IPTR
) self
, 1, MUIM_PrefsWindow_Test
140 revertButton
, MUIM_Notify
, MUIA_Pressed
, FALSE
,
141 (IPTR
) self
, 1, MUIM_PrefsWindow_Revert
145 saveButton
, MUIM_Notify
, MUIA_Pressed
, FALSE
,
146 (IPTR
) self
, 1, MUIM_PrefsWindow_Save
150 useButton
, MUIM_Notify
, MUIA_Pressed
, FALSE
,
151 (IPTR
) self
, 1, MUIM_PrefsWindow_Use
155 cancelButton
, MUIM_Notify
, MUIA_Pressed
, FALSE
,
156 (IPTR
) self
, 1, MUIM_PrefsWindow_Cancel
161 if (catalog
!= NULL
) CloseCatalog(catalog
);
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
;
188 while ((tag
= NextTagItem(&tstate
)) != NULL
)
192 case MUIA_PrefsWindow_Test_Disabled
:
193 SET(data
->pwd_TestButton
, MUIA_Disabled
, tag
->ti_Data
);
196 case MUIA_PrefsWindow_Revert_Disabled
:
197 SET(data
->pwd_RevertButton
, MUIA_Disabled
, tag
->ti_Data
);
200 case MUIA_PrefsWindow_Save_Disabled
:
201 SET(data
->pwd_SaveButton
, MUIA_Disabled
, tag
->ti_Data
);
204 case MUIA_PrefsWindow_Use_Disabled
:
205 SET(data
->pwd_UseButton
, MUIA_Disabled
, tag
->ti_Data
);
208 case MUIA_PrefsWindow_Cancel_Disabled
:
209 SET(data
->pwd_CancelButton
, MUIA_Disabled
, tag
->ti_Data
);
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
;
226 switch (message
->opg_AttrID
)
228 case MUIA_PrefsWindow_Test_Disabled
:
229 *store
= XGET(data
->pwd_TestButton
, MUIA_Disabled
);
232 case MUIA_PrefsWindow_Revert_Disabled
:
233 *store
= XGET(data
->pwd_RevertButton
, MUIA_Disabled
);
236 case MUIA_PrefsWindow_Save_Disabled
:
237 *store
= XGET(data
->pwd_SaveButton
, MUIA_Disabled
);
240 case MUIA_PrefsWindow_Use_Disabled
:
241 *store
= XGET(data
->pwd_UseButton
, MUIA_Disabled
);
244 case MUIA_PrefsWindow_Cancel_Disabled
:
245 *store
= XGET(data
->pwd_CancelButton
, MUIA_Disabled
);
249 rv
= DoSuperMethodA(CLASS
, self
, (Msg
) message
);