2 Copyright © 2013, The AROS Development Team. All rights reserved.
7 #include <aros/debug.h>
9 #define MUIMASTER_YES_INLINE_STDARG
11 #include <zune/customclasses.h>
12 #include <zune/prefseditor.h>
14 #include <proto/graphics.h>
15 #include <proto/intuition.h>
16 #include <proto/muimaster.h>
17 #include <proto/utility.h>
19 #include <proto/alib.h>
21 #ifndef GRAPHICS_RASTPORT_H
22 # include <graphics/rastport.h>
28 #include "themepreview.h"
31 static CONST_STRPTR PREVIEWFILE_BASE
= "THEME:preview";
32 static CONST_STRPTR PREVIEWFILE_WIN
= "THEME:preview.win";
33 static CONST_STRPTR PREVIEWFILE_ZUNE
= "THEME:preview.zune";
34 static CONST_STRPTR PREVIEWFILE_WAND
= "THEME:preview.wand";
37 #define PREVIEW_WIDTH 256
38 #define PREVIEW_HEIGHT 150
40 /*** Instance Data **********************************************************/
42 struct ThemePreview_DATA
45 struct RastPort
*tp_Buffer
;
48 /*** Macros *****************************************************************/
49 #define SETUP_INST_DATA struct ThemePreview_DATA *data = INST_DATA(CLASS, self)
51 /*** Methods ****************************************************************/
52 Object
*ThemePreview__OM_NEW(Class
*CLASS
, Object
*self
, struct opSet
*message
)
54 D(bug("[ThemePreview] %s()\n", __PRETTY_FUNCTION__
));
56 self
= (Object
*) DoSuperNewTags
60 MUIA_Frame
, MUIV_Frame_ReadList
,
61 MUIA_FrameTitle
, _(MSG_PREVIEW
),
76 IPTR
ThemePreview__OM_DISPOSE(Class
*CLASS
, Object
*self
, Msg message
)
82 D(bug("[ThemePreview] %s()\n", __PRETTY_FUNCTION__
));
84 return DoSuperMethodA(CLASS
, self
, message
);
87 IPTR
ThemePreview__OM_SET(Class
*CLASS
, Object
*self
, struct opSet
*message
)
92 struct TagItem
*tags
, *tag
;
94 for (tags
= message
->ops_AttrList
; (tag
= NextTagItem(&tags
)); )
98 case MUIA_ThemePreview_Theme
:
100 D(bug("[ThemePreview] %s: Theme '%s'\n", __PRETTY_FUNCTION__
, tag
->ti_Data
));
101 // TODO: Composite preview if available..
107 return DoSuperMethodA(CLASS
, self
, message
);
110 IPTR
ThemePreview__OM_GET(Class
*CLASS
, Object
*self
, struct opGet
*message
)
114 switch (message
->opg_AttrID
)
116 case MUIA_ThemePreview_Theme
:
117 *message
->opg_Storage
= (IPTR
)data
->tp_Theme
;
120 return DoSuperMethodA(CLASS
, self
, (Msg
)message
);
126 IPTR
ThemePreview__MUIM_AskMinMax(struct IClass
*CLASS
, Object
*self
, struct MUIP_AskMinMax
*message
)
128 ULONG rc
= DoSuperMethodA(CLASS
, self
, (Msg
) message
);
130 D(bug("[ThemePreview] %s()\n", __PRETTY_FUNCTION__
));
132 message
->MinMaxInfo
->MinWidth
+= PREVIEW_WIDTH
;
133 message
->MinMaxInfo
->MinHeight
+= PREVIEW_HEIGHT
;
135 message
->MinMaxInfo
->DefWidth
+= PREVIEW_WIDTH
;
136 message
->MinMaxInfo
->DefHeight
+= PREVIEW_HEIGHT
;
138 message
->MinMaxInfo
->MaxWidth
= MUI_MAXMAX
;
139 message
->MinMaxInfo
->MaxHeight
= MUI_MAXMAX
;
144 IPTR
ThemePreview__MUIM_Draw(struct IClass
*CLASS
, Object
*self
, struct MUIP_Draw
*message
)
150 D(bug("[ThemePreview] %s()\n", __PRETTY_FUNCTION__
));
152 DoSuperMethodA(CLASS
, self
, (Msg
)message
);
157 clip
= MUI_AddClipping(muiRenderInfo(self
), _mleft(self
), _mtop(self
), _mright(self
) - _mleft(self
) + 1, _mbottom(self
) - _mtop(self
) + 1);
158 BltBitMapRastPort(data
->tp_Buffer
->BitMap
,
159 _mleft(self
), _mtop(self
),
162 PREVIEW_WIDTH
, PREVIEW_HEIGHT
,
164 MUI_RemoveClipping(muiRenderInfo(self
), clip
);
168 char *unavailableStr
= (char *)_(MSG_NOPREVIEW
);
169 int len
= strlen(unavailableStr
);
170 struct TextExtent te
;
172 len
= TextFit(_rp(self
), unavailableStr
, len
, &te
, NULL
, 1, _mright(self
) - _mleft(self
) + 1, _mbottom(self
) - _mtop(self
) + 1);
174 SetDrMd(_rp(self
), JAM1
);
175 Move(_rp(self
), _mleft(self
) + ((_mright(self
) - _mleft(self
) + 1) >> 1) - (te
.te_Width
>> 1), _mtop(self
) + ((_mbottom(self
) - _mtop(self
) + 1) >> 1) - (te
.te_Height
>> 1));
176 Text(_rp(self
), unavailableStr
, len
);
181 /*** Setup ******************************************************************/
184 ThemePreview
, NULL
, MUIC_Area
, NULL
,
185 MUIM_Draw
, struct MUIP_Draw
*,
186 MUIM_AskMinMax
, struct MUIP_AskMinMax
*,
187 OM_GET
, struct opGet
*,
188 OM_SET
, struct opSet
*,
189 OM_NEW
, struct opSet
*,