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/
21 ***************************************************************************/
23 #include <proto/exec.h>
24 #include <proto/intuition.h>
25 #include <proto/muimaster.h>
27 /******************************************************************************/
29 /* MCC/MCP name and version */
31 /* ATTENTION: The FIRST LETTER of NAME MUST be UPPERCASE */
33 /******************************************************************************/
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
58 #define USEDCLASSES used_mccs
59 static const char *used_mccs
[] = { "BetterString.mcc", NULL
};
61 #define MIN_STACKSIZE 8192
65 #if defined(__amigaos4__) || defined(__MORPHOS__)
66 struct Library
*LocaleBase
= NULL
;
68 struct LocaleBase
*LocaleBase
= NULL
;
71 #if defined(__amigaos4__)
72 struct LocaleIFace
*ILocale
= NULL
;
75 #if !defined(__MORPHOS__) && !defined(__AROS__)
76 static BOOL nbitmapCanHandleRawData
;
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
93 #if defined(__MORPHOS__) || defined(__AROS__)
94 #include <mui/Rawimage_mcc.h>
96 #include <mui/NBitmap_mcc.h>
99 static Object
*get_prefs_image(void)
103 #if !defined(__MORPHOS__) && !defined(__AROS__)
104 if(nbitmapCanHandleRawData
== TRUE
)
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
,
120 obj
= RawimageObject
,
121 MUIA_Rawimage_Data
, icon32
,
125 // if the 32bit image data couldn't be loaded
126 // we fall back to the 8bit icon
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,\
146 #define PREFSIMAGEOBJECT get_prefs_image()
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
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
);
190 static VOID
ClassExpunge(UNUSED
struct Library
*base
)
196 DROPINTERFACE(ILocale
);
197 CloseLibrary((APTR
)LocaleBase
);