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.
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>
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>
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
)
46 case MUIA_IconImage_DiskObject
:
47 diskObject
= (struct DiskObject
*) tag
->ti_Data
;
50 case MUIA_IconImage_File
:
51 file
= (CONST_STRPTR
) tag
->ti_Data
;
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
70 TAG_MORE
, (IPTR
) message
->ops_AttrList
73 if (self
== NULL
) goto error
;
75 data
= INST_DATA(CLASS
, self
);
76 data
->iid_DiskObject
= diskObject
;
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
);
95 self
, MUIM_DrawParentBackground
,
96 _mleft(self
), _mtop(self
), _mwidth(self
), _mheight(self
), 0, 0, 0
99 get(self
, MUIA_Selected
, &selected
);
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
,
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
));
130 _rp(self
), data
->iid_DiskObject
, NULL
, &size
,
132 ICONDRAWA_Borderless
, TRUE
,
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
;