2 Copyright 2010, The AROS Development Team. All rights reserved.
6 #define MUIMASTER_YES_INLINE_STDARG
8 #include <exec/types.h>
9 #include <utility/tagitem.h>
10 #include <libraries/asl.h>
11 #include <libraries/mui.h>
12 #include <prefs/palette.h>
13 #include <prefs/prefhdr.h>
15 #include <zune/customclasses.h>
16 #include <zune/prefseditor.h>
18 #include <proto/alib.h>
19 #include <proto/exec.h>
20 #include <proto/intuition.h>
21 #include <proto/utility.h>
22 #include <proto/muimaster.h>
23 #include <proto/dos.h>
24 #include <proto/iffparse.h>
30 #include <aros/debug.h>
33 #include "paleditor.h"
36 STATIC CONST_STRPTR pennames
[9];
39 without this initial palette we can't later set MUIA_Palette_Entries.
40 This is probably a bug in Zune.
42 STATIC
const struct MUI_Palette_Entry initialpens
[9] =
52 {MUIV_Palette_Entry_End
, 0, 0, 0, 0}
55 /*** Instance Data **********************************************************/
58 Object
*palpe_palette
;
61 STATIC VOID
PalPrefs2Gadgets(struct PalEditor_DATA
*data
);
62 STATIC VOID
Gadgets2PalPrefs(struct PalEditor_DATA
*data
);
64 /*** Macros *****************************************************************/
65 #define SETUP_INST_DATA struct PalEditor_DATA *data = INST_DATA(CLASS, self)
67 /*** Methods ****************************************************************/
68 Object
*PalEditor__OM_NEW(Class
*CLASS
, Object
*self
, struct opSet
*message
)
70 Object
*palpe_palette
;
72 pennames
[0] = _(MSG_PEN0
);
73 pennames
[1] = _(MSG_PEN1
);
74 pennames
[2] = _(MSG_PEN2
);
75 pennames
[3] = _(MSG_PEN3
);
76 pennames
[4] = _(MSG_PEN4
);
77 pennames
[5] = _(MSG_PEN5
);
78 pennames
[6] = _(MSG_PEN6
);
79 pennames
[7] = _(MSG_PEN7
);
81 self
= (Object
*) DoSuperNewTags
84 MUIA_PrefsEditor_Name
, _(MSG_WINTITLE
),
85 MUIA_PrefsEditor_Path
, (IPTR
) "SYS/palette.prefs",
86 MUIA_PrefsEditor_IconTool
, (IPTR
) "SYS:Prefs/Palette",
88 Child
, (IPTR
)(palpe_palette
= (Object
*)PaletteObject
,
89 MUIA_Palette_Entries
, (IPTR
)initialpens
,
90 MUIA_Palette_Names
, (IPTR
)pennames
,
100 data
->palpe_palette
= palpe_palette
;
104 data
->palpe_palette
, MUIM_Notify
, MUIA_Palette_Entries
, MUIV_EveryTime
,
105 (IPTR
) self
, 3, MUIM_Set
, MUIA_PrefsEditor_Changed
, TRUE
112 STATIC VOID
Gadgets2PalPrefs (struct PalEditor_DATA
*data
)
115 struct MUI_Palette_Entry
*currentpens
=
116 (struct MUI_Palette_Entry
*)XGET(data
->palpe_palette
, MUIA_Palette_Entries
);
118 for (i
= 0; i
< 8; i
++)
120 paletteprefs
.pap_Colors
[i
].ColorIndex
= currentpens
[i
].mpe_ID
;
121 paletteprefs
.pap_Colors
[i
].Red
= currentpens
[i
].mpe_Red
>> 16;
122 paletteprefs
.pap_Colors
[i
].Green
= currentpens
[i
].mpe_Green
>> 16;
123 paletteprefs
.pap_Colors
[i
].Blue
= currentpens
[i
].mpe_Blue
>> 16;
127 STATIC VOID
PalPrefs2Gadgets(struct PalEditor_DATA
*data
)
130 struct MUI_Palette_Entry currentpens
[9];
132 for (i
= 0; i
< 8; i
++)
134 currentpens
[i
].mpe_ID
= paletteprefs
.pap_Colors
[i
].ColorIndex
;
135 currentpens
[i
].mpe_Red
= paletteprefs
.pap_Colors
[i
].Red
<< 16;
136 currentpens
[i
].mpe_Green
= paletteprefs
.pap_Colors
[i
].Green
<< 16;
137 currentpens
[i
].mpe_Blue
= paletteprefs
.pap_Colors
[i
].Blue
<< 16;
139 currentpens
[8].mpe_ID
= MUIV_Palette_Entry_End
;
140 NNSET(data
->palpe_palette
, MUIA_Palette_Entries
, currentpens
);
143 IPTR PalEditor__MUIM_PrefsEditor_ImportFH
145 Class
*CLASS
, Object
*self
,
146 struct MUIP_PrefsEditor_ImportFH
*message
152 success
= Prefs_ImportFH(message
->fh
);
153 if (success
) PalPrefs2Gadgets(data
);
158 IPTR PalEditor__MUIM_PrefsEditor_ExportFH
160 Class
*CLASS
, Object
*self
,
161 struct MUIP_PrefsEditor_ExportFH
*message
167 Gadgets2PalPrefs(data
);
168 success
= Prefs_ExportFH(message
->fh
);
173 IPTR PalEditor__MUIM_PrefsEditor_SetDefaults
175 Class
*CLASS
, Object
*self
, Msg message
181 success
= Prefs_Default();
182 if (success
) PalPrefs2Gadgets(data
);
187 /*** Setup ******************************************************************/
190 PalEditor
, NULL
, MUIC_PrefsEditor
, NULL
,
191 OM_NEW
, struct opSet
*,
192 MUIM_PrefsEditor_ImportFH
, struct MUIP_PrefsEditor_ImportFH
*,
193 MUIM_PrefsEditor_ExportFH
, struct MUIP_PrefsEditor_ExportFH
*,
194 MUIM_PrefsEditor_SetDefaults
, Msg