5 Copyright © 1995-2013, The AROS Development Team. All rights reserved.
9 #include <exec/memory.h>
10 #include <exec/libraries.h>
11 #include <aros/asmcall.h>
13 #include <libraries/iffparse.h>
14 #include <cybergraphx/cybergraphics.h>
15 #include <workbench/workbench.h>
16 #include <workbench/icon.h>
17 #include <graphics/view.h>
19 #include <proto/alib.h>
20 #include <proto/exec.h>
21 #include <proto/intuition.h>
22 #include <proto/graphics.h>
23 #include <proto/icon.h>
24 #include <proto/iffparse.h>
25 #include <proto/utility.h>
26 #include <proto/cybergraphics.h>
27 #include <proto/dos.h>
32 #include <aros/libcall.h>
33 #include <aros/asmcall.h>
35 /****************************************************************************************/
38 #define MAX_DEFICON_FILEPATH 256
40 /* Number of entries in the mementrys in the freelists */
41 #define FREELIST_MEMLISTENTRIES 10
43 /* This must be a power of 2 */
45 #define ICONLIST_HASHSIZE 32 /* Save space on small memory m68k machines */
47 #define ICONLIST_HASHSIZE 256
50 /****************************************************************************************/
53 To get right alignment we make our very own memlist structure.
54 Look at the original struct MemList in <exec/memory.h> to see why.
57 struct IconInternalMemList
59 struct Node iiml_Node
;
60 UWORD iiml_NumEntries
;
61 struct MemEntry iiml_ME
[FREELIST_MEMLISTENTRIES
];
64 #define IMAGE35F_HASTRANSPARENTCOLOR 1
65 #define IMAGE35F_HASPALETTE 2
67 #define ICON35F_FRAMELESS 1
71 struct MinNode ni_Node
;
72 struct DiskObject ni_DiskObject
;
73 struct FreeList ni_FreeList
;
74 ULONG ni_ReadStruct_State
;
76 /* Source icon data */
78 APTR Data
; /* Raw IFF or PNG stream */
91 /* The 'laid out' icon. The laid out data will
92 * also be resized for the screen's aspect ratio,
93 * so the nil_Width and nil_Height will probably
94 * be different than the original image on some
97 struct Screen
*ni_Screen
; /* Screen for the layout */
98 ULONG ni_Width
; /* Dimension of the aspect */
99 ULONG ni_Height
; /* ratio corrected icon */
101 /* Pens for drawing the border and frame */
102 UWORD ni_Pens
[NUMDRIPENS
]; /* Copied from DrawInfo for the screen */
104 struct NativeIconFace
{
105 UBYTE Aspect
; /* Source aspect ratio */
110 struct NativeIconImage
{
111 /* This data was either allocated during icon load
112 * (and is in the ni_FreeList), or was provided by
113 * the user via IconControlA().
115 LONG TransparentColor
;
116 ULONG Pens
; /* Pens allocated for the layout */
117 const struct ColorRegister
*Palette
; /* one entry per pen */
118 const UBYTE
*ImageData
; /* 'ChunkyPixels' image */
119 const ULONG
*ARGB
; /* RGB+Alpha (A 0=transparent) */
121 /* Dynamically allocated by LayoutIconA(), and are
122 * _not_ in the ni_FreeList.
124 * You must call LayoutIconA(icon, NULL, NULL) or
125 * FreeDiskObject() to free this memory.
127 ULONG
*Pen
; /* Palette n to Pen m mapping */
128 struct BitMap
*BitMap
; /* 'friend' of the Screen */
129 PLANEPTR BitMask
; /* TransparentColor >= 0 bitmask */
130 APTR ARGBMap
; /* ARGB, rescaled version */
132 /* For m68k legacy support, the struct Image render
139 #define RSS_OLDDRAWERDATA_READ (1 << 0)
140 #define RSS_GADGETIMAGE_READ (1 << 1)
141 #define RSS_SELECTIMAGE_READ (1 << 2)
142 #define RSS_DEFAULTTOOL_READ (1 << 3)
143 #define RSS_TOOLWINDOW_READ (1 << 4)
144 #define RSS_TOOLTYPES_READ (1 << 5)
146 #define NATIVEICON(icon) ((struct NativeIcon *)((UBYTE *)(icon) - offsetof(struct NativeIcon, ni_DiskObject)))
150 struct Library ib_Lib
;
153 struct SignalSemaphore iconlistlock
;
154 struct MinList iconlists
[ICONLIST_HASHSIZE
];
158 /* Global settings -----------------------------------------------------*/
159 struct Screen
*ib_Screen
;
161 struct Rectangle ib_EmbossRectangle
;
164 struct Hook
*ib_IdentifyHook
;
165 LONG ib_MaxNameLength
;
166 BOOL ib_NewIconsSupport
;
167 BOOL ib_ColorIconSupport
;
170 /* Required External libraries */
173 APTR ib_IntuitionBase
;
176 /* Optional external libraries */
177 APTR ib_CyberGfxBase
;
178 APTR ib_IFFParseBase
;
179 APTR ib_DataTypesBase
;
180 APTR ib_WorkbenchBase
;
183 typedef struct IconBase IconBase_T
;
185 /* FIXME: Remove these #define xxxBase hacks
186 Do not use this in new code !
188 #define DOSBase (IconBase->ib_DOSBase)
189 #define GfxBase (IconBase->ib_GfxBase)
190 #define IntuitionBase (IconBase->ib_IntuitionBase)
191 #define UtilityBase (IconBase->ib_UtilityBase)
193 /****************************************************************************************/
195 extern struct ExecBase
*SysBase
;
197 /****************************************************************************************/
198 /* On-demand open of optional libraries. Just that is
199 * non-NULL before you use it!
201 extern const LONG IFFParseBase_version
,
203 CyberGfxBase_version
,
204 DataTypesBase_version
;
206 static inline APTR
DemandOpenLibrary(struct Library
**libp
, CONST_STRPTR libname
, ULONG version
)
209 *libp
= OpenLibrary(libname
, version
);
214 #define IFFParseBase DemandOpenLibrary((struct Library **)&IconBase->ib_IFFParseBase, "iffparse.library", IFFParseBase_version)
215 #define CyberGfxBase DemandOpenLibrary((struct Library **)&IconBase->ib_CyberGfxBase, "cybergraphics.library", CyberGfxBase_version)
216 #define DataTypesBase DemandOpenLibrary((struct Library **)&IconBase->ib_DataTypesBase, "datatypes.library", DataTypesBase_version)
217 #define WorkbenchBase DemandOpenLibrary((struct Library **)&IconBase->ib_WorkbenchBase, "workbench.library", 0)
219 /****************************************************************************************/
221 /* Internal prototypes */
222 AROS_UFP3(LONG
, dosstreamhook
,
223 AROS_UFPA(struct Hook
*, hook
, A0
),
224 AROS_UFPA(BPTR
, file
, A2
),
225 AROS_UFPA(ULONG
*, msg
, A1
)
230 UBYTE
* WriteValue (LONG
, UBYTE
*);
232 BOOL
ReadIcon35(struct NativeIcon
*icon
, struct Hook
*streamhook
, void *stream
, struct IconBase
*IconBase
);
233 BOOL
WriteIcon35(struct NativeIcon
*icon
, struct Hook
*streamhook
, void *stream
, struct IconBase
*IconBase
);
234 VOID
FreeIcon35(struct NativeIcon
*icon
, struct IconBase
*IconBase
);
235 VOID
MakeMask35(UBYTE
*imgdata
, UBYTE
*imgmask
, UBYTE transpcolor
, LONG imagew
, LONG imageh
);
237 BOOL
ReadIconNI(struct NativeIcon
*icon
, struct Hook
*streamhook
, void *stream
, struct IconBase
*IconBase
);
238 BOOL
WriteIconNI(struct NativeIcon
*icon
, struct Hook
*streamhook
, void *stream
, struct IconBase
*IconBase
);
239 VOID
FreeIconNI(struct NativeIcon
*icon
, struct IconBase
*IconBase
);
241 /* Returns an ARGB image.
242 * Set &width == ~0 and &height == ~0 to get the size.
243 * Otherwise, sets the image size of width & height
245 ULONG
*ReadMemPNG(struct DiskObject
*icon
, APTR stream
, LONG
*width
, LONG
*height
, const CONST_STRPTR
*chunknames
, APTR
*chunkpointer
, struct IconBase
*IconBase
);
247 BOOL
ReadIconPNG(struct DiskObject
*dobj
, BPTR file
, struct IconBase
*IconBase
);
248 BOOL
WriteIconPNG(BPTR file
, struct DiskObject
*dobj
, struct IconBase
*IconBase
);
249 VOID
FreeIconPNG(struct DiskObject
*dobj
, struct IconBase
*IconBase
);
252 #define LB(ib) ((struct IconBase *) (ib))
254 #endif /* ICON_INTERN_H */