1 /***************************************************************************
3 TheBar.mcc - Next Generation Toolbar MUI Custom Class
4 Copyright (C) 2003-2005 Alfonso Ranieri
5 Copyright (C) 2005-2013 by TheBar.mcc Open Source Team
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either
10 version 2.1 of the License, or (at your option) any later version.
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
17 TheBar class Support Site: http://www.sf.net/projects/thebar
21 ***************************************************************************/
26 #include <mcc_common.h>
28 /******************************************************************************/
29 /* include the minimal startup code to be able to start the class from a */
30 /* shell without crashing the system */
31 /******************************************************************************/
32 #include "shellstart.c"
34 #define VERSION LIB_VERSION
35 #define REVISION LIB_REVISION
37 #define CLASS "TheBar.mcp"
38 #define SUPERCLASSP MUIC_Mccprefs
40 #define INSTDATAP InstData
42 #define USERLIBID CLASS " " LIB_REV_STRING " [" SYSTEMSHORT "/" CPU "] (" LIB_DATE ") " LIB_COPYRIGHT
43 #define MASTERVERSION 19
48 #define USEDCLASSES used_mccs
49 static const char *used_mccs
[] = { "TheBar.mcc", "TheBarVirt.mcc", "TheButton.mcc", NULL
};
51 #define MIN_STACKSIZE 8192
53 /******************************************************************************/
55 struct Library
*DataTypesBase
= NULL
;
56 struct Library
*IFFParseBase
= NULL
;
57 #if !defined(__amigaos4__)
58 struct Library
*CyberGfxBase
= NULL
;
61 #if !defined(__amigaos4__) && !defined(__MORPHOS__)
62 struct LocaleBase
*LocaleBase
= NULL
;
64 struct Library
*LocaleBase
= NULL
;
67 #if defined(__amigaos4__)
68 struct DataTypesIFace
*IDataTypes
= NULL
;
69 //struct CyberGfxIFace *ICyberGfx = NULL;
70 struct IFFParseIFace
*IIFFParse
= NULL
;
71 struct LocaleIFace
*ILocale
= NULL
;
74 // some variables we carry for the whole lifetime of the lib
75 #if !defined(__MORPHOS__) && !defined(__amigaos4__)
76 struct MUI_CustomClass
*lib_coloradjust
= NULL
;
77 struct MUI_CustomClass
*lib_penadjust
= NULL
;
78 struct MUI_CustomClass
*lib_backgroundadjust
= NULL
;
79 struct MUI_CustomClass
*lib_poppen
= NULL
;
80 struct MUI_CustomClass
*lib_popbackground
= NULL
;
82 struct Catalog
*lib_cat
= NULL
;
85 #if !defined(__MORPHOS__)
86 static BOOL nbitmapCanHandleRawData
;
89 /******************************************************************************/
91 static BOOL
ClassInit(UNUSED
struct Library
*base
);
92 static BOOL
ClassExpunge(UNUSED
struct Library
*base
);
94 /******************************************************************************/
95 #define USE_ICON8_COLORS
96 #define USE_ICON8_BODY
100 #if defined(__MORPHOS__)
101 #include <mui/Rawimage_mcc.h>
103 #include <mui/NBitmap_mcc.h>
106 static Object
*get_prefs_image(void)
110 #if !defined(__MORPHOS__)
111 if(nbitmapCanHandleRawData
== TRUE
)
114 MUIA_FixWidth
, ICON32_WIDTH
,
115 MUIA_FixHeight
, ICON32_HEIGHT
,
116 MUIA_NBitmap_Type
, MUIV_NBitmap_Type_ARGB32
,
117 MUIA_NBitmap_Normal
, icon32
,
118 MUIA_NBitmap_Width
, ICON32_WIDTH
,
119 MUIA_NBitmap_Height
, ICON32_HEIGHT
,
128 no truecolor image data for MorphOS yet
129 obj = RawimageObject,
130 MUIA_Rawimage_Data, icon32,
136 // if the 32bit image data couldn't be loaded
137 // we fall back to the 8bit icon
140 obj
= BodychunkObject
,\
141 MUIA_FixWidth
, ICON8_WIDTH
,\
142 MUIA_FixHeight
, ICON8_HEIGHT
,\
143 MUIA_Bitmap_Width
, ICON8_WIDTH
,\
144 MUIA_Bitmap_Height
, ICON8_HEIGHT
,\
145 MUIA_Bodychunk_Depth
, ICON8_DEPTH
,\
146 MUIA_Bodychunk_Body
, (UBYTE
*)icon8_body
,\
147 MUIA_Bodychunk_Compression
, ICON8_COMPRESSION
,\
148 MUIA_Bodychunk_Masking
, ICON8_MASKING
,\
149 MUIA_Bitmap_SourceColors
, (ULONG
*)icon8_colors
,\
150 MUIA_Bitmap_Transparent
, 0,\
157 #define PREFSIMAGEOBJECT get_prefs_image()
161 /******************************************************************************/
163 static BOOL
ClassInit(UNUSED
struct Library
*base
)
167 if((DataTypesBase
= OpenLibrary("datatypes.library",37)) &&
168 GETINTERFACE(IDataTypes
,struct DataTypesIFace
*,DataTypesBase
) &&
169 (IFFParseBase
= OpenLibrary("iffparse.library",37)) &&
170 GETINTERFACE(IIFFParse
,struct IFFParseIFace
*,IFFParseBase
) &&
171 (LocaleBase
= (APTR
)OpenLibrary("locale.library",36)) &&
172 GETINTERFACE(ILocale
,struct LocaleIFace
*,LocaleBase
))
176 // check for MUI 3.9+
177 if(LIB_VERSION_IS_AT_LEAST(MUIMasterBase
, 20, 0))
179 lib_flags
|= BASEFLG_MUI20
;
181 // check for MUI 4.0+
182 if(LIB_VERSION_IS_AT_LEAST(MUIMasterBase
, 20, 5500))
183 lib_flags
|= BASEFLG_MUI4
;
186 // on MUI 3.1 system's we do have to
187 // initialize our subclasses as well
188 #if !defined(__MORPHOS__) && !defined(__amigaos4__) && !defined(__AROS__)
189 if(!(lib_flags
& BASEFLG_MUI20
))
191 if(!initColoradjust() ||
193 !initBackgroundadjust() ||
195 !initPopbackground())
206 // we open the cybgraphics.library but without failing if
208 #if !defined(__amigaos4__)
209 CyberGfxBase
= OpenLibrary("cybergraphics.library", 41);
211 if(!GETINTERFACE(ICyberGfx, struct CyberGfxIFace *, CyberGfxBase))
213 CloseLibrary(CyberGfxBase);
219 #if !defined(__MORPHOS__)
221 struct Library
*nbitmapMcc
;
223 nbitmapCanHandleRawData
= FALSE
;
225 // we need at least NBitmap.mcc V15.8 to be able to let it handle raw image data
226 if((nbitmapMcc
= OpenLibrary("mui/NBitmap.mcc", 0)) != NULL
)
228 SHOWVALUE(DBF_ALWAYS
, nbitmapMcc
->lib_Version
);
229 SHOWVALUE(DBF_ALWAYS
, nbitmapMcc
->lib_Revision
);
231 if(nbitmapMcc
->lib_Version
> 15 || (nbitmapMcc
->lib_Version
== 15 && nbitmapMcc
->lib_Revision
>= 8))
232 nbitmapCanHandleRawData
= TRUE
;
234 CloseLibrary(nbitmapMcc
);
237 SHOWVALUE(DBF_ALWAYS
, nbitmapCanHandleRawData
);
241 lib_flags
|= BASEFLG_Init
;
254 /******************************************************************************/
257 ClassExpunge(UNUSED
struct Library
*base
)
261 #if !defined(__MORPHOS__) && !defined(__amigaos4__) && !defined(__AROS__)
262 if(!(lib_flags
& BASEFLG_MUI20
))
266 freeBackgroundadjust();
272 #if !defined(__amigaos4__)
273 if(CyberGfxBase
!= NULL
)
275 DROPINTERFACE(ICyberGfx
);
276 CloseLibrary(CyberGfxBase
);
281 if(LocaleBase
!= NULL
)
285 CloseCatalog(lib_cat
);
288 DROPINTERFACE(ILocale
);
289 CloseLibrary((struct Library
*)LocaleBase
);
293 if(IFFParseBase
!= NULL
)
295 DROPINTERFACE(IIFFParse
);
296 CloseLibrary(IFFParseBase
);
300 if(DataTypesBase
!= NULL
)
302 DROPINTERFACE(IDataTypes
);
303 CloseLibrary(DataTypesBase
);
304 DataTypesBase
= NULL
;
307 lib_flags
&= ~(BASEFLG_Init
|BASEFLG_MUI20
|BASEFLG_MUI4
);
313 /******************************************************************************/