2 Copyright © 1995-2007, The AROS Development Team. All rights reserved.
6 #include <aros/debug.h>
8 #include <exec/types.h>
9 #include <workbench/icon.h>
10 #include <utility/tagitem.h>
11 #include <proto/icon.h>
13 #include "icon_intern.h"
15 /*****************************************************************************
19 AROS_LH3(BOOL
, LayoutIconA
,
22 AROS_LHA(struct DiskObject
*, icon
, A0
),
23 AROS_LHA(struct Screen
*, screen
, A1
),
24 AROS_LHA(struct TagItem
*, tags
, A2
),
27 struct IconBase
*, IconBase
, 32, Icon
)
30 Adapt a palette-mapped icon for display.
47 *****************************************************************************/
51 struct NativeIcon
*nativeicon
;
55 ULONG sizex
= 0, sizey
= 0;
56 const ULONG bflags
= BMF_CLEAR
| BMF_DISPLAYABLE
| BMF_MINPLANES
| BMF_INTERLEAVED
;
58 nativeicon
= GetNativeIcon(icon
, LB(IconBase
));
62 /* Already mapped to this screen?
64 if (screen
== nativeicon
->iconscr
)
67 if (nativeicon
->iconbm1
) {
68 FreeBitMap(nativeicon
->iconbm1
);
69 nativeicon
->iconbm1
= NULL
;
71 if (nativeicon
->iconbm2
) {
72 FreeBitMap(nativeicon
->iconbm2
);
73 nativeicon
->iconbm2
= NULL
;
75 nativeicon
->iconscr
= NULL
;
78 screen
= GetDefaultPubScreen(NULL
);
80 dri
= GetScreenDrawInfo(screen
);
86 /* Get the sizex and sizey */
87 IconControl(icon
, ICONCTRLA_GetWidth
, (IPTR
)&sizex
,
88 ICONCTRLA_GetHeight
, (IPTR
)&sizey
,
91 D(bug("%s: Screen %p, Depth %d\n", __func__
, screen
, dri
->dri_Depth
));
92 nativeicon
->iconbm1
= AllocBitMap(sizex
, sizey
, dri
->dri_Depth
, bflags
, screen
->RastPort
.BitMap
);
93 if (nativeicon
->iconbm1
) {
94 nativeicon
->iconbm2
= AllocBitMap(sizex
, sizey
, dri
->dri_Depth
, bflags
, screen
->RastPort
.BitMap
);
95 if (nativeicon
->iconbm2
) {
97 /* Draw the normal state */
99 rp
.BitMap
= nativeicon
->iconbm1
;
100 DrawIconStateA(&rp
, icon
, NULL
, 0, 0, IDS_NORMAL
, tags
);
102 /* Draw the selected state */
104 rp
.BitMap
= nativeicon
->iconbm2
;
105 DrawIconStateA(&rp
, icon
, NULL
, 0, 0, IDS_SELECTED
, tags
);
107 nativeicon
->iconscr
= screen
;
111 FreeBitMap(nativeicon
->iconbm1
);
112 nativeicon
->iconbm1
= NULL
;
116 FreeScreenDrawInfo(screen
, dri
);
121 } /* LayoutIconA() */