Updated PCI IDs to latest snapshot.
[tangerine.git] / workbench / libs / icon / iconcontrol.c
blobe6ef89c07eb48a44a47755a96f3b8373223a82d6
1 /*
2 Copyright © 1995-2007, The AROS Development Team. All rights reserved.
3 $Id$
4 */
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 /*****************************************************************************
17 NAME */
19 AROS_LH2(ULONG, IconControlA,
21 /* SYNOPSIS */
22 AROS_LHA(struct DiskObject *, icon, A0),
23 AROS_LHA(struct TagItem *, tags, A1),
25 /* LOCATION */
26 struct Library *, IconBase, 26, Icon)
28 /* FUNCTION
29 Set and get icon and icon.library options.
31 INPUTS
32 icon - icon to be queried
34 RESULT
35 Number of processed tags.
37 NOTES
39 EXAMPLE
41 BUGS
43 SEE ALSO
45 INTERNALS
47 *****************************************************************************/
49 AROS_LIBFUNC_INIT
51 const struct TagItem *tstate = tags;
52 struct TagItem *tag = NULL;
53 ULONG processed = 0;
55 LONG *errorCode = NULL;
56 struct TagItem **errorTagItem = NULL;
57 struct NativeIcon *nativeicon = NULL;
59 if (icon)
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);
70 SET_ERRORCODE(0);
72 errorTagItem = (struct TagItem **) GetTagData(ICONA_ErrorTagItem, 0, tags);
73 SET_ERRORTAGITEM(NULL);
75 /* Parse taglist -------------------------------------------------------*/
76 while ((tag = NextTagItem(&tstate)) != NULL)
78 switch (tag->ti_Tag)
80 /* Global tags -------------------------------------------------*/
81 case ICONCTRLA_SetGlobalScreen:
82 LB(IconBase)->ib_Screen = (struct Screen *) tag->ti_Data;
83 processed++;
84 break;
86 case ICONCTRLA_GetGlobalScreen:
87 STORE((struct Screen **) tag->ti_Data, LB(IconBase)->ib_Screen);
88 processed++;
89 break;
91 case ICONCTRLA_SetGlobalPrecision:
92 case OBP_Precision:
93 LB(IconBase)->ib_Precision = tag->ti_Data;
94 processed++;
95 break;
97 case ICONCTRLA_GetGlobalPrecision:
98 STORE((LONG *) tag->ti_Data, LB(IconBase)->ib_Precision);
99 processed++;
100 break;
102 case ICONCTRLA_SetGlobalEmbossRect:
103 // FIXME
104 break;
106 case ICONCTRLA_GetGlobalEmbossRect:
107 // FIXME
108 break;
110 case ICONCTRLA_SetGlobalFrameless:
111 LB(IconBase)->ib_Frameless = tag->ti_Data;
112 processed++;
113 break;
115 case ICONCTRLA_GetGlobalFrameless:
116 STORE((LONG *) tag->ti_Data, LB(IconBase)->ib_Frameless);
117 processed++;
118 break;
120 case ICONCTRLA_SetGlobalIdentifyHook:
121 LB(IconBase)->ib_IdentifyHook = (struct Hook *) tag->ti_Data;
122 processed++;
123 break;
125 case ICONCTRLA_GetGlobalIdentifyHook:
126 STORE((struct Hook **) tag->ti_Data, LB(IconBase)->ib_IdentifyHook);
127 processed++;
128 break;
130 case ICONCTRLA_SetGlobalMaxNameLength:
131 LB(IconBase)->ib_MaxNameLength = tag->ti_Data;
132 processed++;
133 break;
135 case ICONCTRLA_GetGlobalMaxNameLength:
136 STORE((LONG *) tag->ti_Data, LB(IconBase)->ib_MaxNameLength);
137 processed++;
138 break;
140 case ICONCTRLA_SetGlobalNewIconsSupport:
141 LB(IconBase)->ib_NewIconsSupport = tag->ti_Data;
142 processed++;
143 break;
145 case ICONCTRLA_GetGlobalNewIconsSupport:
146 STORE((LONG *) tag->ti_Data, LB(IconBase)->ib_NewIconsSupport);
147 processed++;
148 break;
150 case ICONCTRLA_SetGlobalColorIconSupport:
151 LB(IconBase)->ib_ColorIconSupport = tag->ti_Data;
152 processed++;
153 break;
155 case ICONCTRLA_GetGlobalColorIconSupport:
156 STORE((LONG *) tag->ti_Data, LB(IconBase)->ib_ColorIconSupport);
157 processed++;
158 break;
161 /* Local tags --------------------------------------------------*/
162 case ICONCTRLA_GetImageMask1:
163 if (nativeicon)
165 STORE((PLANEPTR *)tag->ti_Data, (PLANEPTR)nativeicon->icon35.img1.mask);
167 else
169 STORE((PLANEPTR *)tag->ti_Data, 0);
171 processed++;
172 break;
174 case ICONCTRLA_GetImageMask2:
175 if (nativeicon)
177 STORE((PLANEPTR *)tag->ti_Data, (PLANEPTR)nativeicon->icon35.img2.mask);
179 else
181 STORE((PLANEPTR *)tag->ti_Data, 0);
183 processed++;
184 break;
186 case ICONCTRLA_SetTransparentColor1:
187 break;
189 case ICONCTRLA_GetTransparentColor1:
190 if (nativeicon && (nativeicon->icon35.img1.flags & IMAGE35F_HASTRANSPARENTCOLOR))
192 STORE((LONG *)tag->ti_Data, (LONG)nativeicon->icon35.img1.transparentcolor);
194 else
196 STORE((LONG *)tag->ti_Data, -1);
198 processed++;
199 break;
201 case ICONCTRLA_SetTransparentColor2:
202 break;
204 case ICONCTRLA_GetTransparentColor2:
205 if (nativeicon && (nativeicon->icon35.img2.flags & IMAGE35F_HASTRANSPARENTCOLOR))
207 STORE((LONG *)tag->ti_Data, (LONG)nativeicon->icon35.img2.transparentcolor);
209 else
211 STORE((LONG *)tag->ti_Data, -1);
213 processed++;
214 break;
216 case ICONCTRLA_SetPalette1:
217 break;
219 case ICONCTRLA_GetPalette1:
220 if (nativeicon)
222 STORE((struct ColorRegister **)tag->ti_Data, (struct ColorRegister *)nativeicon->icon35.img1.palette);
224 else
226 STORE((struct ColorRegister **)tag->ti_Data, 0);
228 processed++;
229 break;
231 case ICONCTRLA_SetPalette2:
232 break;
234 case ICONCTRLA_GetPalette2:
235 if (nativeicon)
237 STORE((struct ColorRegister **)tag->ti_Data, (struct ColorRegister *)nativeicon->icon35.img2.palette);
239 else
241 STORE((struct ColorRegister **)tag->ti_Data, 0);
243 processed++;
244 break;
246 case ICONCTRLA_SetPaletteSize1:
247 break;
249 case ICONCTRLA_GetPaletteSize1:
250 if (nativeicon)
252 STORE((ULONG *)tag->ti_Data, nativeicon->icon35.img1.numcolors);
254 else
256 STORE((ULONG *)tag->ti_Data, 0);
258 processed++;
259 break;
261 case ICONCTRLA_SetPaletteSize2:
262 break;
264 case ICONCTRLA_GetPaletteSize2:
265 if (nativeicon)
267 STORE((ULONG *)tag->ti_Data, nativeicon->icon35.img2.numcolors);
269 else
271 STORE((ULONG *)tag->ti_Data, 0);
273 processed++;
274 break;
276 case ICONCTRLA_SetImageData1:
277 break;
279 case ICONCTRLA_GetImageData1:
280 if (nativeicon)
282 STORE((UBYTE **)tag->ti_Data, nativeicon->icon35.img1.imagedata);
284 else
286 STORE((UBYTE **)tag->ti_Data, 0);
288 processed++;
289 break;
291 case ICONCTRLA_SetImageData2:
292 break;
294 case ICONCTRLA_GetImageData2:
295 if (nativeicon)
297 STORE((UBYTE **)tag->ti_Data, nativeicon->icon35.img2.imagedata);
299 else
301 STORE((UBYTE **)tag->ti_Data, 0);
303 processed++;
304 break;
306 case ICONCTRLA_SetFrameless:
307 break;
309 case ICONCTRLA_GetFrameless:
310 break;
312 case ICONCTRLA_SetNewIconsSupport:
313 break;
315 case ICONCTRLA_GetNewIconsSupport:
316 break;
318 case ICONCTRLA_SetAspectRatio:
319 break;
321 case ICONCTRLA_GetAspectRatio:
322 break;
324 case ICONCTRLA_SetWidth:
325 break;
327 case ICONCTRLA_GetWidth:
328 processed++;
329 if (nativeicon)
331 if (nativeicon->iconPNG.img1)
333 STORE((ULONG *)tag->ti_Data, nativeicon->iconPNG.width);
334 break;
337 if (nativeicon->icon35.img1.imagedata)
339 STORE((ULONG *)tag->ti_Data, nativeicon->icon35.width);
340 break;
344 if (icon)
346 STORE((ULONG *)tag->ti_Data, icon->do_Gadget.Width);
348 else
350 STORE((ULONG *)tag->ti_Data, 0);
352 break;
354 case ICONCTRLA_SetHeight:
355 break;
357 case ICONCTRLA_GetHeight:
358 processed++;
359 if (nativeicon)
361 if (nativeicon->iconPNG.img1)
363 STORE((ULONG *)tag->ti_Data, nativeicon->iconPNG.height);
364 break;
367 if (nativeicon->icon35.img1.imagedata)
369 STORE((ULONG *)tag->ti_Data, nativeicon->icon35.height);
370 break;
374 if (icon)
376 STORE((ULONG *)tag->ti_Data, icon->do_Gadget.Height);
378 else
380 STORE((ULONG *)tag->ti_Data, 0);
382 break;
384 case ICONCTRLA_IsPaletteMapped:
385 if (nativeicon && nativeicon->icon35.img1.imagedata)
387 STORE((LONG *)tag->ti_Data, 1);
389 else
391 STORE((LONG *)tag->ti_Data, 0);
393 processed++;
394 break;
396 case ICONCTRLA_IsNewIcon:
397 break;
399 case ICONCTRLA_IsNativeIcon:
400 if (nativeicon)
402 STORE((LONG *)tag->ti_Data, 1);
404 else
406 STORE((LONG *)tag->ti_Data, 0);
408 processed++;
409 break;
411 case ICONGETA_IsDefaultIcon:
412 break;
414 case ICONCTRLA_GetScreen:
415 break;
417 case ICONCTRLA_HasRealImage2:
418 break;
420 case ICONCTRLA_GetARGBImageData1:
421 if (nativeicon)
423 STORE((ULONG **)tag->ti_Data, (ULONG *)nativeicon->iconPNG.img1);
425 else
427 STORE((ULONG **)tag->ti_Data, 0);
429 processed++;
430 break;
432 case ICONCTRLA_GetARGBImageData2:
433 if (nativeicon)
435 STORE((ULONG **)tag->ti_Data, (ULONG *)nativeicon->iconPNG.img2);
437 else
439 STORE((ULONG **)tag->ti_Data, 0);
441 processed++;
442 break;
447 return processed;
449 AROS_LIBFUNC_EXIT
451 # undef STORE
452 # undef SET_ERRORCODE
453 # undef SET_ERRORTAGITEM
455 } /* IconControlA() */