workbench/classes/zune: WIP - Unsorted -Wall fixes
[AROS.git] / workbench / classes / zune / iconimage / iconimage.c
blobec621055b14aa50975ef00ad8f0682a743d4499a
1 /*
2 Copyright © 2003-2004, 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/muimaster.h>
18 #include <proto/intuition.h>
19 #include <proto/utility.h>
20 #include <proto/locale.h>
21 #include <proto/dos.h>
22 #include <proto/icon.h>
24 #include <string.h>
26 #include "iconimage.h"
27 #include "iconimage_private.h"
30 /*** Methods ****************************************************************/
31 Object *IconImage__OM_NEW
33 Class *CLASS, Object *self, struct opSet *message
36 struct IconImage_DATA *data = NULL;
37 const struct TagItem *tstate = message->ops_AttrList;
38 struct TagItem *tag = NULL;
39 struct DiskObject *diskObject = NULL;
40 CONST_STRPTR file = NULL;
42 while ((tag = NextTagItem(&tstate)) != NULL)
44 switch (tag->ti_Tag)
46 case MUIA_IconImage_DiskObject:
47 diskObject = (struct DiskObject *) tag->ti_Data;
48 break;
50 case MUIA_IconImage_File:
51 file = (CONST_STRPTR) tag->ti_Data;
52 break;
56 if (diskObject == NULL && file == NULL) goto error; /* Must specify one */
57 if (diskObject != NULL && file != NULL) goto error; /* Cannot specify both */
59 if (diskObject == NULL && file != NULL)
61 diskObject = GetDiskObjectNew(file);
62 if (diskObject == NULL) goto error;
65 self = (Object *) DoSuperNewTags
67 CLASS, self, NULL,
69 MUIA_FillArea, FALSE,
70 TAG_MORE, (IPTR) message->ops_AttrList
73 if (self == NULL) goto error;
75 data = INST_DATA(CLASS, self);
76 data->iid_DiskObject = diskObject;
78 return self;
80 error:
81 return NULL;
84 IPTR IconImage__MUIM_Draw
86 Class *CLASS, Object *self, struct MUIP_Draw *message
89 struct IconImage_DATA *data = INST_DATA(CLASS, self);
90 IPTR rc = DoSuperMethodA(CLASS, self, (Msg) message);
91 IPTR selected = 0;
93 DoMethod
95 self, MUIM_DrawParentBackground,
96 _mleft(self), _mtop(self), _mwidth(self), _mheight(self), 0, 0, 0
99 get(self, MUIA_Selected, &selected);
101 DrawIconState
103 _rp(self), data->iid_DiskObject, NULL,
104 _mleft(self), _mtop(self), selected ? IDS_SELECTED : IDS_NORMAL,
106 ICONDRAWA_Frameless, TRUE,
107 ICONDRAWA_Borderless, TRUE,
108 ICONDRAWA_EraseBackground, FALSE,
109 TAG_DONE
112 return rc;
115 IPTR IconImage__MUIM_AskMinMax
117 Class *CLASS, Object *self, struct MUIP_AskMinMax *message
120 struct IconImage_DATA *data = INST_DATA(CLASS, self);
121 IPTR rc = DoSuperMethodA(CLASS, self, (Msg) message);
122 struct Rectangle size;
124 memset(&size, 0, sizeof(struct Rectangle));
128 GetIconRectangle
130 _rp(self), data->iid_DiskObject, NULL, &size,
132 ICONDRAWA_Borderless, TRUE,
133 TAG_DONE
137 WORD w = size.MaxX - size.MinX + 1;
138 WORD h = size.MaxY - size.MinY + 1;
140 message->MinMaxInfo->MinWidth += w;
141 message->MinMaxInfo->MaxWidth += w;
142 message->MinMaxInfo->DefWidth += w;
143 message->MinMaxInfo->MinHeight += h;
144 message->MinMaxInfo->MaxHeight += h;
145 message->MinMaxInfo->DefHeight += h;
148 return rc;