added concrete implementations of putc(), getc(), getchar() and gets()
[tangerine.git] / workbench / classes / zune / iconimage / iconimage.c
blob26b42610df9f86f1f8e037cf3777920b041a50bc
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 struct TagItem *tag = NULL, *tstate = message->ops_AttrList;
38 struct DiskObject *diskObject = NULL;
39 CONST_STRPTR file = NULL;
41 while ((tag = NextTagItem(&tstate)) != NULL)
43 switch (tag->ti_Tag)
45 case MUIA_IconImage_DiskObject:
46 diskObject = (struct DiskObject *) tag->ti_Data;
47 break;
49 case MUIA_IconImage_File:
50 file = (CONST_STRPTR) tag->ti_Data;
51 break;
55 if (diskObject == NULL && file == NULL) goto error; /* Must specify one */
56 if (diskObject != NULL && file != NULL) goto error; /* Cannot specify both */
58 if (diskObject == NULL && file != NULL)
60 diskObject = GetDiskObjectNew(file);
61 if (diskObject == NULL) goto error;
64 self = (Object *) DoSuperNewTags
66 CLASS, self, NULL,
68 MUIA_FillArea, FALSE,
69 TAG_MORE, (IPTR) message->ops_AttrList
72 if (self == NULL) goto error;
74 data = INST_DATA(CLASS, self);
75 data->iid_DiskObject = diskObject;
77 return self;
79 error:
80 return NULL;
83 IPTR IconImage__MUIM_Draw
85 Class *CLASS, Object *self, struct MUIP_Draw *message
88 struct IconImage_DATA *data = INST_DATA(CLASS, self);
89 IPTR rc = DoSuperMethodA(CLASS, self, (Msg) message);
90 IPTR selected;
92 DoMethod
94 self, MUIM_DrawParentBackground,
95 _mleft(self), _mtop(self), _mwidth(self), _mheight(self), 0, 0, 0
98 get(self, MUIA_Selected, &selected);
100 DrawIconState
102 _rp(self), data->iid_DiskObject, NULL,
103 _mleft(self), _mtop(self), selected ? IDS_SELECTED : IDS_NORMAL,
105 ICONDRAWA_Frameless, TRUE,
106 ICONDRAWA_Borderless, TRUE,
107 ICONDRAWA_EraseBackground, FALSE,
108 TAG_DONE
111 return rc;
114 IPTR IconImage__MUIM_AskMinMax
116 Class *CLASS, Object *self, struct MUIP_AskMinMax *message
119 struct IconImage_DATA *data = INST_DATA(CLASS, self);
120 IPTR rc = DoSuperMethodA(CLASS, self, (Msg) message);
121 struct Rectangle size;
123 memset(&size, 0, sizeof(struct Rectangle));
127 GetIconRectangle
129 _rp(self), data->iid_DiskObject, NULL, &size,
131 ICONDRAWA_Borderless, TRUE,
132 TAG_DONE
136 WORD w = size.MaxX - size.MinX + 1;
137 WORD h = size.MaxY - size.MinY + 1;
139 message->MinMaxInfo->MinWidth += w;
140 message->MinMaxInfo->MaxWidth += w;
141 message->MinMaxInfo->DefWidth += w;
142 message->MinMaxInfo->MinHeight += h;
143 message->MinMaxInfo->MaxHeight += h;
144 message->MinMaxInfo->DefHeight += h;
147 return rc;