Updated PCI IDs to latest snapshot.
[tangerine.git] / workbench / libs / icon / drawiconstate.c
blob4ec65244751535144fb0cd885fd4177d3083be9b
1 /*
2 Copyright © 1995-2007, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include <workbench/icon.h>
7 #include <intuition/imageclass.h>
8 #include "icon_intern.h"
10 /*****************************************************************************
12 NAME */
13 #include <proto/icon.h>
15 AROS_LH7(void, DrawIconStateA,
17 /* SYNOPSIS */
18 AROS_LHA(struct RastPort *, rp, A0),
19 AROS_LHA(struct DiskObject *, icon, A1),
20 AROS_LHA(STRPTR, label, A2),
21 AROS_LHA(LONG, leftEdge, D0),
22 AROS_LHA(LONG, topEdge, D1),
23 AROS_LHA(ULONG, state, D2),
24 AROS_LHA(struct TagItem *, tags, A3),
26 /* LOCATION */
27 struct Library *, IconBase, 27, Icon)
29 /* FUNCTION
30 Draw an icon like an image.
32 INPUTS
33 rp - rastport to draw into
34 icon - the icon
35 label - label string
36 leftEdge,
37 topEdge - drawing position
38 state - drawing state, see intuition/imageclass.h
40 RESULT
42 NOTES
43 Only very limited implemented.
45 EXAMPLE
47 BUGS
49 SEE ALSO
50 intuition/imageclass.h
52 INTERNALS
54 HISTORY
56 *****************************************************************************/
58 AROS_LIBFUNC_INIT
60 struct NativeIcon *nativeicon;
62 nativeicon = GetNativeIcon(icon, LB(IconBase));
63 if (nativeicon && GfxBase && CyberGfxBase)
65 ULONG bmdepth;
67 bmdepth = GetBitMapAttr(rp->BitMap, BMA_DEPTH);
69 if (nativeicon->iconPNG.img1 && CyberGfxBase && (bmdepth >= 15))
71 APTR img;
73 if ((state == IDS_SELECTED) && nativeicon->iconPNG.img2)
75 img = nativeicon->iconPNG.img2;
77 else
79 img = nativeicon->iconPNG.img1;
82 // OLD MODE
83 WritePixelArrayAlpha(
84 img,
87 nativeicon->iconPNG.width * sizeof(ULONG),
88 rp,
89 leftEdge,
90 topEdge,
91 nativeicon->iconPNG.width,
92 nativeicon->iconPNG.height,
95 return;
97 else if (nativeicon->icon35.img1.imagedata)
99 if (bmdepth >= 15)
101 struct Image35 *img;
102 ULONG *cgfxcoltab;
104 if (state == IDS_SELECTED && nativeicon->icon35.img2.imagedata)
106 img = &nativeicon->icon35.img2;
108 else
110 img = &nativeicon->icon35.img1;
113 if ((cgfxcoltab = AllocVecPooled(POOL, img->numcolors * sizeof(ULONG))))
115 struct ColorRegister *cr;
116 WORD i;
118 cr = (struct ColorRegister *)img->palette;
119 for(i = 0; i < img->numcolors; i++)
121 struct ColorRegister color = *cr;
123 if (state == IDS_SELECTED)
125 ChangeToSelectedIconColor(&color);
128 cgfxcoltab[i] = (color.red << 16) | (color.green << 8) | color.blue;
129 cr++;
132 if (img->mask)
134 struct BitMap *bm;
136 bm = AllocBitMap
138 nativeicon->icon35.width,
139 nativeicon->icon35.height,
140 0, 0, rp->BitMap
143 if (bm)
145 struct RastPort bmrp;
147 InitRastPort(&bmrp);
148 bmrp.BitMap = bm;
150 WriteLUTPixelArray
152 img->imagedata,
153 0, 0,
154 nativeicon->icon35.width,
155 &bmrp, cgfxcoltab,
156 0, 0,
157 nativeicon->icon35.width,
158 nativeicon->icon35.height,
159 CTABFMT_XRGB8
162 BltMaskBitMapRastPort
164 bm, 0, 0, rp, leftEdge, topEdge,
165 nativeicon->icon35.width,
166 nativeicon->icon35.height,
167 0xE0, img->mask
170 DeinitRastPort(&bmrp);
172 FreeBitMap(bm);
173 FreeVecPooled(POOL, cgfxcoltab);
175 return;
176 } /* if (bm) */
177 } /* if (img->mask) */
179 WriteLUTPixelArray
181 img->imagedata, 0, 0, nativeicon->icon35.width,
182 rp, cgfxcoltab, leftEdge, topEdge,
183 nativeicon->icon35.width,
184 nativeicon->icon35.height,
185 CTABFMT_XRGB8
188 FreeVecPooled(POOL, cgfxcoltab);
190 return;
192 } /* if (cgfxcoltab != NULL) */
194 } /* if (bmdepth >= 15) */
196 } /* if (nativeicon->icon35.img1.imagedata) */
198 } /* if (nativeicon && GfxBase && CyberGfxBase) */
200 if (state == IDS_SELECTED && icon->do_Gadget.SelectRender)
202 DrawImage
204 rp, (struct Image *) icon->do_Gadget.SelectRender,
205 leftEdge, topEdge
208 else if (icon->do_Gadget.GadgetRender)
210 if (icon->do_Gadget.Flags & GFLG_GADGIMAGE)
212 DrawImage
214 rp, (struct Image *) icon->do_Gadget.GadgetRender,
215 leftEdge, topEdge
220 #warning DrawIconStateA() is only very limited implemented
222 AROS_LIBFUNC_EXIT
223 } /* DrawIconStateA() */