revert between 56095 -> 55830 in arch
[AROS.git] / workbench / classes / zune / betterstring / mcp / library.c
bloba04eba30adbe3c3fed4bef3ce53f6abd20d299c8
1 /***************************************************************************
3 BetterString.mcc - A better String gadget MUI Custom Class
4 Copyright (C) 1997-2000 Allan Odgaard
5 Copyright (C) 2005-2010 by BetterString.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 BetterString class Support Site: http://www.sf.net/projects/bstring-mcc/
19 $Id$
21 ***************************************************************************/
23 #include <proto/exec.h>
24 #include <proto/intuition.h>
25 #include <proto/muimaster.h>
27 /******************************************************************************/
28 /* */
29 /* MCC/MCP name and version */
30 /* */
31 /* ATTENTION: The FIRST LETTER of NAME MUST be UPPERCASE */
32 /* */
33 /******************************************************************************/
35 #include "private.h"
36 #include "version.h"
38 /******************************************************************************/
39 /* include the minimal startup code to be able to start the class from a */
40 /* shell without crashing the system */
41 /******************************************************************************/
42 #include "shellstart.c"
44 #define VERSION LIB_VERSION
45 #define REVISION LIB_REVISION
47 #define CLASS MUIC_BetterString_mcp
48 #define SUPERCLASSP MUIC_Mccprefs
50 #define INSTDATAP InstData_MCP
52 #define USERLIBID CLASS " " LIB_REV_STRING " [" SYSTEMSHORT "/" CPU "] (" LIB_DATE ") " LIB_COPYRIGHT
53 #define MASTERVERSION 19
55 #define CLASSINIT
56 #define CLASSEXPUNGE
58 #define USEDCLASSES used_mccs
59 static const char *used_mccs[] = { "BetterString.mcc", NULL };
61 #define MIN_STACKSIZE 8192
63 #include "locale.h"
65 #if defined(__amigaos4__) || defined(__MORPHOS__)
66 struct Library *LocaleBase = NULL;
67 #else
68 struct LocaleBase *LocaleBase = NULL;
69 #endif
71 #if defined(__amigaos4__)
72 struct LocaleIFace *ILocale = NULL;
73 #endif
75 #if !defined(__MORPHOS__) && !defined(__AROS__)
76 static BOOL nbitmapCanHandleRawData;
77 #endif
79 /******************************************************************************/
80 /* define the functions used by the startup code ahead of including mccinit.c */
81 /******************************************************************************/
82 static BOOL ClassInit(UNUSED struct Library *base);
83 static VOID ClassExpunge(UNUSED struct Library *base);
85 /******************************************************************************/
86 /* include the lib startup code for the mcc/mcp (and muimaster inlines) */
87 /******************************************************************************/
88 #define USE_ICON8_COLORS
89 #define USE_ICON8_BODY
91 #include "icon.h"
93 #if defined(__MORPHOS__) || defined(__AROS__)
94 #include <mui/Rawimage_mcc.h>
95 #else
96 #include <mui/NBitmap_mcc.h>
97 #endif
99 static Object *get_prefs_image(void)
101 Object *obj;
103 #if !defined(__MORPHOS__) && !defined(__AROS__)
104 if(nbitmapCanHandleRawData == TRUE)
106 obj = NBitmapObject,
107 MUIA_FixWidth, ICON32_WIDTH,
108 MUIA_FixHeight, ICON32_HEIGHT,
109 MUIA_NBitmap_Type, MUIV_NBitmap_Type_ARGB32,
110 MUIA_NBitmap_Normal, icon32,
111 MUIA_NBitmap_Width, ICON32_WIDTH,
112 MUIA_NBitmap_Height, ICON32_HEIGHT,
113 End;
115 else
117 obj = NULL;
119 #else
120 obj = RawimageObject,
121 MUIA_Rawimage_Data, icon32,
122 End;
123 #endif
125 // if the 32bit image data couldn't be loaded
126 // we fall back to the 8bit icon
127 if(obj == NULL)
129 obj = BodychunkObject,\
130 MUIA_FixWidth, ICON8_WIDTH,\
131 MUIA_FixHeight, ICON8_HEIGHT,\
132 MUIA_Bitmap_Width, ICON8_WIDTH ,\
133 MUIA_Bitmap_Height, ICON8_HEIGHT,\
134 MUIA_Bodychunk_Depth, ICON8_DEPTH,\
135 MUIA_Bodychunk_Body, (UBYTE *)icon8_body,\
136 MUIA_Bodychunk_Compression, ICON8_COMPRESSION,\
137 MUIA_Bodychunk_Masking, ICON8_MASKING,\
138 MUIA_Bitmap_SourceColors, (ULONG *)icon8_colors,\
139 MUIA_Bitmap_Transparent, 0,\
140 End;
143 return obj;
146 #define PREFSIMAGEOBJECT get_prefs_image()
148 #include "mccinit.c"
150 /******************************************************************************/
151 /* define all implementations of our user functions */
152 /******************************************************************************/
153 static BOOL ClassInit(UNUSED struct Library *base)
155 if((LocaleBase = (APTR)OpenLibrary("locale.library", 38)) &&
156 GETINTERFACE(ILocale, struct LocaleIFace *, LocaleBase))
158 // open the TextEditor.mcp catalog
159 OpenCat();
161 #if !defined(__MORPHOS__) && ! defined(__AROS__)
163 struct Library *nbitmapMcc;
165 nbitmapCanHandleRawData = FALSE;
167 // we need at least NBitmap.mcc V15.8 to be able to let it handle raw image data
168 if((nbitmapMcc = OpenLibrary("mui/NBitmap.mcc", 0)) != NULL)
170 SHOWVALUE(DBF_ALWAYS, nbitmapMcc->lib_Version);
171 SHOWVALUE(DBF_ALWAYS, nbitmapMcc->lib_Revision);
173 if(nbitmapMcc->lib_Version > 15 || (nbitmapMcc->lib_Version == 15 && nbitmapMcc->lib_Revision >= 8))
174 nbitmapCanHandleRawData = TRUE;
176 CloseLibrary(nbitmapMcc);
179 SHOWVALUE(DBF_ALWAYS, nbitmapCanHandleRawData);
181 #endif
183 return TRUE;
186 return FALSE;
190 static VOID ClassExpunge(UNUSED struct Library *base)
192 CloseCat();
194 if(LocaleBase)
196 DROPINTERFACE(ILocale);
197 CloseLibrary((APTR)LocaleBase);
198 LocaleBase = NULL;