2 Copyright © 1995-2007, The AROS Development Team. All rights reserved.
6 #include <exec/types.h>
7 #include <workbench/icon.h>
8 #include <utility/tagitem.h>
9 #include <proto/icon.h>
11 #include "icon_intern.h"
13 # include <aros/debug.h>
15 /*****************************************************************************
19 AROS_LH2(ULONG
, IconControlA
,
22 AROS_LHA(struct DiskObject
*, icon
, A0
),
23 AROS_LHA(struct TagItem
*, tags
, A1
),
26 struct Library
*, IconBase
, 26, Icon
)
29 Set and get icon and icon.library options.
32 icon - icon to be queried
35 Number of processed tags.
47 *****************************************************************************/
51 const struct TagItem
*tstate
= tags
;
52 struct TagItem
*tag
= NULL
;
55 LONG
*errorCode
= NULL
;
56 struct TagItem
**errorTagItem
= NULL
;
57 struct NativeIcon
*nativeicon
= NULL
;
61 nativeicon
= GetNativeIcon(icon
, LB(IconBase
));
64 # define STORE(pointer, value) (pointer != NULL ? *pointer = (value) : (value))
65 # define SET_ERRORCODE(value) STORE(errorCode, (value))
66 # define SET_ERRORTAGITEM(value) STORE(errorTagItem, (value))
68 /* The following tags need to be setup early ---------------------------*/
69 errorCode
= (LONG
*) GetTagData(ICONA_ErrorCode
, 0, tags
);
72 errorTagItem
= (struct TagItem
**) GetTagData(ICONA_ErrorTagItem
, 0, tags
);
73 SET_ERRORTAGITEM(NULL
);
75 /* Parse taglist -------------------------------------------------------*/
76 while ((tag
= NextTagItem(&tstate
)) != NULL
)
80 /* Global tags -------------------------------------------------*/
81 case ICONCTRLA_SetGlobalScreen
:
82 LB(IconBase
)->ib_Screen
= (struct Screen
*) tag
->ti_Data
;
86 case ICONCTRLA_GetGlobalScreen
:
87 STORE((struct Screen
**) tag
->ti_Data
, LB(IconBase
)->ib_Screen
);
91 case ICONCTRLA_SetGlobalPrecision
:
93 LB(IconBase
)->ib_Precision
= tag
->ti_Data
;
97 case ICONCTRLA_GetGlobalPrecision
:
98 STORE((LONG
*) tag
->ti_Data
, LB(IconBase
)->ib_Precision
);
102 case ICONCTRLA_SetGlobalEmbossRect
:
106 case ICONCTRLA_GetGlobalEmbossRect
:
110 case ICONCTRLA_SetGlobalFrameless
:
111 LB(IconBase
)->ib_Frameless
= tag
->ti_Data
;
115 case ICONCTRLA_GetGlobalFrameless
:
116 STORE((LONG
*) tag
->ti_Data
, LB(IconBase
)->ib_Frameless
);
120 case ICONCTRLA_SetGlobalIdentifyHook
:
121 LB(IconBase
)->ib_IdentifyHook
= (struct Hook
*) tag
->ti_Data
;
125 case ICONCTRLA_GetGlobalIdentifyHook
:
126 STORE((struct Hook
**) tag
->ti_Data
, LB(IconBase
)->ib_IdentifyHook
);
130 case ICONCTRLA_SetGlobalMaxNameLength
:
131 LB(IconBase
)->ib_MaxNameLength
= tag
->ti_Data
;
135 case ICONCTRLA_GetGlobalMaxNameLength
:
136 STORE((LONG
*) tag
->ti_Data
, LB(IconBase
)->ib_MaxNameLength
);
140 case ICONCTRLA_SetGlobalNewIconsSupport
:
141 LB(IconBase
)->ib_NewIconsSupport
= tag
->ti_Data
;
145 case ICONCTRLA_GetGlobalNewIconsSupport
:
146 STORE((LONG
*) tag
->ti_Data
, LB(IconBase
)->ib_NewIconsSupport
);
150 case ICONCTRLA_SetGlobalColorIconSupport
:
151 LB(IconBase
)->ib_ColorIconSupport
= tag
->ti_Data
;
155 case ICONCTRLA_GetGlobalColorIconSupport
:
156 STORE((LONG
*) tag
->ti_Data
, LB(IconBase
)->ib_ColorIconSupport
);
161 /* Local tags --------------------------------------------------*/
162 case ICONCTRLA_GetImageMask1
:
165 STORE((PLANEPTR
*)tag
->ti_Data
, (PLANEPTR
)nativeicon
->icon35
.img1
.mask
);
169 STORE((PLANEPTR
*)tag
->ti_Data
, 0);
174 case ICONCTRLA_GetImageMask2
:
177 STORE((PLANEPTR
*)tag
->ti_Data
, (PLANEPTR
)nativeicon
->icon35
.img2
.mask
);
181 STORE((PLANEPTR
*)tag
->ti_Data
, 0);
186 case ICONCTRLA_SetTransparentColor1
:
189 case ICONCTRLA_GetTransparentColor1
:
190 if (nativeicon
&& (nativeicon
->icon35
.img1
.flags
& IMAGE35F_HASTRANSPARENTCOLOR
))
192 STORE((LONG
*)tag
->ti_Data
, (LONG
)nativeicon
->icon35
.img1
.transparentcolor
);
196 STORE((LONG
*)tag
->ti_Data
, -1);
201 case ICONCTRLA_SetTransparentColor2
:
204 case ICONCTRLA_GetTransparentColor2
:
205 if (nativeicon
&& (nativeicon
->icon35
.img2
.flags
& IMAGE35F_HASTRANSPARENTCOLOR
))
207 STORE((LONG
*)tag
->ti_Data
, (LONG
)nativeicon
->icon35
.img2
.transparentcolor
);
211 STORE((LONG
*)tag
->ti_Data
, -1);
216 case ICONCTRLA_SetPalette1
:
219 case ICONCTRLA_GetPalette1
:
222 STORE((struct ColorRegister
**)tag
->ti_Data
, (struct ColorRegister
*)nativeicon
->icon35
.img1
.palette
);
226 STORE((struct ColorRegister
**)tag
->ti_Data
, 0);
231 case ICONCTRLA_SetPalette2
:
234 case ICONCTRLA_GetPalette2
:
237 STORE((struct ColorRegister
**)tag
->ti_Data
, (struct ColorRegister
*)nativeicon
->icon35
.img2
.palette
);
241 STORE((struct ColorRegister
**)tag
->ti_Data
, 0);
246 case ICONCTRLA_SetPaletteSize1
:
249 case ICONCTRLA_GetPaletteSize1
:
252 STORE((ULONG
*)tag
->ti_Data
, nativeicon
->icon35
.img1
.numcolors
);
256 STORE((ULONG
*)tag
->ti_Data
, 0);
261 case ICONCTRLA_SetPaletteSize2
:
264 case ICONCTRLA_GetPaletteSize2
:
267 STORE((ULONG
*)tag
->ti_Data
, nativeicon
->icon35
.img2
.numcolors
);
271 STORE((ULONG
*)tag
->ti_Data
, 0);
276 case ICONCTRLA_SetImageData1
:
279 case ICONCTRLA_GetImageData1
:
282 STORE((UBYTE
**)tag
->ti_Data
, nativeicon
->icon35
.img1
.imagedata
);
286 STORE((UBYTE
**)tag
->ti_Data
, 0);
291 case ICONCTRLA_SetImageData2
:
294 case ICONCTRLA_GetImageData2
:
297 STORE((UBYTE
**)tag
->ti_Data
, nativeicon
->icon35
.img2
.imagedata
);
301 STORE((UBYTE
**)tag
->ti_Data
, 0);
306 case ICONCTRLA_SetFrameless
:
309 case ICONCTRLA_GetFrameless
:
312 case ICONCTRLA_SetNewIconsSupport
:
315 case ICONCTRLA_GetNewIconsSupport
:
318 case ICONCTRLA_SetAspectRatio
:
321 case ICONCTRLA_GetAspectRatio
:
324 case ICONCTRLA_SetWidth
:
327 case ICONCTRLA_GetWidth
:
331 if (nativeicon
->iconPNG
.img1
)
333 STORE((ULONG
*)tag
->ti_Data
, nativeicon
->iconPNG
.width
);
337 if (nativeicon
->icon35
.img1
.imagedata
)
339 STORE((ULONG
*)tag
->ti_Data
, nativeicon
->icon35
.width
);
346 STORE((ULONG
*)tag
->ti_Data
, icon
->do_Gadget
.Width
);
350 STORE((ULONG
*)tag
->ti_Data
, 0);
354 case ICONCTRLA_SetHeight
:
357 case ICONCTRLA_GetHeight
:
361 if (nativeicon
->iconPNG
.img1
)
363 STORE((ULONG
*)tag
->ti_Data
, nativeicon
->iconPNG
.height
);
367 if (nativeicon
->icon35
.img1
.imagedata
)
369 STORE((ULONG
*)tag
->ti_Data
, nativeicon
->icon35
.height
);
376 STORE((ULONG
*)tag
->ti_Data
, icon
->do_Gadget
.Height
);
380 STORE((ULONG
*)tag
->ti_Data
, 0);
384 case ICONCTRLA_IsPaletteMapped
:
385 if (nativeicon
&& nativeicon
->icon35
.img1
.imagedata
)
387 STORE((LONG
*)tag
->ti_Data
, 1);
391 STORE((LONG
*)tag
->ti_Data
, 0);
396 case ICONCTRLA_IsNewIcon
:
399 case ICONCTRLA_IsNativeIcon
:
402 STORE((LONG
*)tag
->ti_Data
, 1);
406 STORE((LONG
*)tag
->ti_Data
, 0);
411 case ICONGETA_IsDefaultIcon
:
414 case ICONCTRLA_GetScreen
:
417 case ICONCTRLA_HasRealImage2
:
420 case ICONCTRLA_GetARGBImageData1
:
423 STORE((ULONG
**)tag
->ti_Data
, (ULONG
*)nativeicon
->iconPNG
.img1
);
427 STORE((ULONG
**)tag
->ti_Data
, 0);
432 case ICONCTRLA_GetARGBImageData2
:
435 STORE((ULONG
**)tag
->ti_Data
, (ULONG
*)nativeicon
->iconPNG
.img2
);
439 STORE((ULONG
**)tag
->ti_Data
, 0);
452 # undef SET_ERRORCODE
453 # undef SET_ERRORTAGITEM
455 } /* IconControlA() */