Merged in v 26.12.
[AROS-Contrib.git] / mui / classes / thebar / mcc / button / library.c
blob8e7344c94491828d16077e16c5ff5a379b154e8d
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
19 $Id$
21 ***************************************************************************/
23 #include "class.h"
24 #include "private.h"
25 #include "SetPatch.h"
26 #include "version.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 SUPERCLASS MUIC_Area
38 #define CLASS MUIC_TheButton
40 #define INSTDATA InstData
42 #define USERLIBID CLASS " " LIB_REV_STRING " [" SYSTEMSHORT "/" CPU "] (" LIB_DATE ") " LIB_COPYRIGHT
43 #define MASTERVERSION 19
45 #define CLASSINIT
46 #define CLASSEXPUNGE
48 #define USEDCLASSES used_mccs
49 static const char *used_mccs[] = { "TheBar.mcc", "TheBarVirt.mcc", NULL };
51 #define USEDCLASSESP used_mcps
52 static const char *used_mcps[] = { "TheBar.mcp", NULL };
54 #define MIN_STACKSIZE 8192
56 /******************************************************************************/
58 struct Library *DataTypesBase = NULL;
59 struct Library *CyberGfxBase = NULL;
60 struct Library *DiskfontBase = NULL;
61 struct Library *PictureDTBase = NULL;
63 #if defined(__amigaos4__)
64 struct DataTypesIFace *IDataTypes = NULL;
65 struct CyberGfxIFace *ICyberGfx = NULL;
66 struct DiskfontIFace *IDiskfont = NULL;
67 #endif
69 ULONG lib_flags = 0;
70 ULONG lib_alpha = 0xffffffff;
72 /******************************************************************************/
74 static BOOL ClassInit(UNUSED struct Library *base);
75 static BOOL ClassExpunge(UNUSED struct Library *base);
77 /******************************************************************************/
79 #include <mccinit.c>
81 /******************************************************************************/
83 static BOOL ClassInit(UNUSED struct Library *base)
85 ENTER();
87 if ((DataTypesBase = OpenLibrary("datatypes.library", 37)) &&
88 GETINTERFACE(IDataTypes, struct DataTypesIFace *, DataTypesBase))
90 if ((DiskfontBase = OpenLibrary("diskfont.library", 37)) &&
91 GETINTERFACE(IDiskfont, struct DiskfontIFace *, DiskfontBase))
93 if(CreateSharedPool() == TRUE)
95 // we open the cybgraphics.library but without failing if
96 // it doesn't exist
97 if ((CyberGfxBase = OpenLibrary("cybergraphics.library", 41)) &&
98 GETINTERFACE(ICyberGfx, struct CyberGfxIFace *, CyberGfxBase))
99 { }
101 PictureDTBase = OpenLibrary("picture.datatype",0);
103 // check the version of MUI)
104 if (MUIMasterBase->lib_Version>=20)
106 setFlag(lib_flags,BASEFLG_MUI20);
108 if (MUIMasterBase->lib_Version>20 || MUIMasterBase->lib_Revision>=5341)
109 setFlag(lib_flags,BASEFLG_MUI4);
112 GetSetPatchVersion();
114 setFlag(lib_flags, BASEFLG_Init);
116 RETURN(TRUE);
117 return(TRUE);
122 ClassExpunge(base);
124 RETURN(FALSE);
125 return(FALSE);
128 /******************************************************************************/
130 static BOOL ClassExpunge(UNUSED struct Library *base)
132 ENTER();
134 DeleteSharedPool();
136 if (PictureDTBase)
138 CloseLibrary(PictureDTBase);
139 PictureDTBase = NULL;
142 if (CyberGfxBase)
144 DROPINTERFACE(ICyberGfx);
145 CloseLibrary(CyberGfxBase);
146 CyberGfxBase = NULL;
149 if (DiskfontBase)
151 DROPINTERFACE(IDiskfont);
152 CloseLibrary(DiskfontBase);
153 DiskfontBase = NULL;
156 if (DataTypesBase)
158 DROPINTERFACE(IDataTypes);
159 CloseLibrary(DataTypesBase);
160 DataTypesBase = NULL;
163 clearFlag(lib_flags, BASEFLG_Init|BASEFLG_MUI20|BASEFLG_MUI4);
165 RETURN(TRUE);
166 return(TRUE);
169 /******************************************************************************/