grub2: bring back build of aros-side grub2 tools
[AROS.git] / workbench / classes / zune / iconimage / iconimage.c
blobb92e6c73652e1659edc38b51075b741e7eb2d154
1 /*
2 Copyright © 2003-2011, The AROS Development Team. All rights reserved.
3 This file is part of the IconImage 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 <workbench/workbench.h>
12 #include <workbench/icon.h>
13 #include <utility/tagitem.h>
14 #include <libraries/mui.h>
15 #include <dos/dos.h>
17 #include <proto/alib.h>
18 #include <proto/muimaster.h>
19 #include <proto/intuition.h>
20 #include <proto/utility.h>
21 #include <proto/locale.h>
22 #include <proto/dos.h>
23 #include <proto/icon.h>
25 #include <string.h>
27 #include "iconimage.h"
28 #include "iconimage_private.h"
31 /*** Methods ****************************************************************/
32 Object *IconImage__OM_NEW
34 Class *CLASS, Object *self, struct opSet *message
37 struct IconImage_DATA *data = NULL;
38 struct TagItem *tstate = message->ops_AttrList;
39 struct TagItem *tag = NULL;
40 struct DiskObject *diskObject = NULL;
41 CONST_STRPTR file = NULL;
43 while ((tag = NextTagItem(&tstate)) != NULL)
45 switch (tag->ti_Tag)
47 case MUIA_IconImage_DiskObject:
48 diskObject = (struct DiskObject *) tag->ti_Data;
49 break;
51 case MUIA_IconImage_File:
52 file = (CONST_STRPTR) tag->ti_Data;
53 break;
57 if (diskObject == NULL && file == NULL) goto error; /* Must specify one */
58 if (diskObject != NULL && file != NULL) goto error; /* Cannot specify both */
60 if (diskObject == NULL && file != NULL)
62 diskObject = GetDiskObjectNew(file);
63 if (diskObject == NULL) goto error;
66 self = (Object *) DoSuperNewTags
68 CLASS, self, NULL,
70 MUIA_FillArea, FALSE,
71 TAG_MORE, (IPTR) message->ops_AttrList
74 if (self == NULL) goto error;
76 data = INST_DATA(CLASS, self);
77 data->iid_DiskObject = diskObject;
79 return self;
81 error:
82 return NULL;
85 IPTR IconImage__MUIM_Draw
87 Class *CLASS, Object *self, struct MUIP_Draw *message
90 struct IconImage_DATA *data = INST_DATA(CLASS, self);
91 IPTR rc = DoSuperMethodA(CLASS, self, (Msg) message);
92 IPTR selected = 0;
94 DoMethod
96 self, MUIM_DrawParentBackground,
97 _mleft(self), _mtop(self), _mwidth(self), _mheight(self), 0, 0, 0
100 get(self, MUIA_Selected, &selected);
102 LayoutIcon(data->iid_DiskObject, _screen(self), TAG_END);
104 DrawIconState
106 _rp(self), data->iid_DiskObject, NULL,
107 _mleft(self), _mtop(self), selected ? IDS_SELECTED : IDS_NORMAL,
109 ICONDRAWA_Frameless, TRUE,
110 ICONDRAWA_Borderless, TRUE,
111 ICONDRAWA_EraseBackground, FALSE,
112 TAG_DONE
115 return rc;
118 IPTR IconImage__MUIM_AskMinMax
120 Class *CLASS, Object *self, struct MUIP_AskMinMax *message
123 struct IconImage_DATA *data = INST_DATA(CLASS, self);
124 IPTR rc = DoSuperMethodA(CLASS, self, (Msg) message);
125 struct Rectangle size;
127 memset(&size, 0, sizeof(struct Rectangle));
129 LayoutIcon(data->iid_DiskObject, _screen(self), TAG_END);
132 GetIconRectangle
134 _rp(self), data->iid_DiskObject, NULL, &size,
136 ICONDRAWA_Borderless, TRUE,
137 TAG_DONE
141 WORD w = size.MaxX - size.MinX + 1;
142 WORD h = size.MaxY - size.MinY + 1;
144 message->MinMaxInfo->MinWidth += w;
145 message->MinMaxInfo->MaxWidth += w;
146 message->MinMaxInfo->DefWidth += w;
147 message->MinMaxInfo->MinHeight += h;
148 message->MinMaxInfo->MaxHeight += h;
149 message->MinMaxInfo->DefHeight += h;
152 return rc;