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 struct TagItem
*tag
= NULL
, *tstate
= message
->ops_AttrList
;
38 struct DiskObject
*diskObject
= NULL
;
39 CONST_STRPTR file
= NULL
;
41 while ((tag
= NextTagItem(&tstate
)) != NULL
)
45 case MUIA_IconImage_DiskObject
:
46 diskObject
= (struct DiskObject
*) tag
->ti_Data
;
49 case MUIA_IconImage_File
:
50 file
= (CONST_STRPTR
) tag
->ti_Data
;
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
69 TAG_MORE
, (IPTR
) message
->ops_AttrList
72 if (self
== NULL
) goto error
;
74 data
= INST_DATA(CLASS
, self
);
75 data
->iid_DiskObject
= diskObject
;
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
);
94 self
, MUIM_DrawParentBackground
,
95 _mleft(self
), _mtop(self
), _mwidth(self
), _mheight(self
), 0, 0, 0
98 get(self
, MUIA_Selected
, &selected
);
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
,
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
));
129 _rp(self
), data
->iid_DiskObject
, NULL
, &size
,
131 ICONDRAWA_Borderless
, TRUE
,
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
;