arch/cpu.resource: remove dead code
[AROS.git] / workbench / classes / zune / texteditor / mcp / library.c
blob549f38535c2980fff5a06b6a207ead0a10e28bd4
1 /***************************************************************************
3 TextEditor.mcc - Textediting MUI Custom Class
4 Copyright (C) 1997-2000 Allan Odgaard
5 Copyright (C) 2005-2014 TextEditor.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 TextEditor class Support Site: http://www.sf.net/projects/texteditor-mcc
19 $Id$
21 ***************************************************************************/
23 #include <libraries/mui.h>
24 #include <proto/muimaster.h>
25 #include <proto/exec.h>
26 #include <proto/intuition.h>
28 /******************************************************************************/
29 /* */
30 /* MCC/MCP name and version */
31 /* */
32 /* ATTENTION: The FIRST LETTER of NAME MUST be UPPERCASE */
33 /* */
34 /******************************************************************************/
36 #include "private.h"
37 #include "version.h"
39 /******************************************************************************/
40 /* include the minimal startup code to be able to start the class from a */
41 /* shell without crashing the system */
42 /******************************************************************************/
43 #include "shellstart.c"
45 #define VERSION LIB_VERSION
46 #define REVISION LIB_REVISION
48 #define CLASS MUIC_TextEditor_mcp
49 #define SUPERCLASSP MUIC_Mccprefs
51 #define INSTDATAP InstData_MCP
53 #define USERLIBID CLASS " " LIB_REV_STRING " [" SYSTEMSHORT "/" CPU "] (" LIB_DATE ") " LIB_COPYRIGHT
54 #define MASTERVERSION 19
56 #define CLASSINIT
57 #define CLASSEXPUNGE
59 #define USEDCLASSES used_mccs
60 static const char *used_mccs[] = { "TextEditor.mcc", "BetterString.mcc", NULL };
62 #define MIN_STACKSIZE 8192
64 #include "locale.h"
66 #if defined(__amigaos4__) || defined(__MORPHOS__)
67 struct Library *LocaleBase = NULL;
68 #else
69 struct LocaleBase *LocaleBase = NULL;
70 #endif
72 #if defined(__amigaos4__)
73 struct LocaleIFace *ILocale = NULL;
74 #endif
76 #if !defined(__MORPHOS__) && !defined(__AROS__)
77 static BOOL nbitmapCanHandleRawData;
78 #endif
80 /******************************************************************************/
81 /* define the functions used by the startup code ahead of including mccinit.c */
82 /******************************************************************************/
83 static BOOL ClassInit(UNUSED struct Library *base);
84 static VOID ClassExpunge(UNUSED struct Library *base);
86 /******************************************************************************/
87 /* include the lib startup code for the mcc/mcp (and muimaster inlines) */
88 /******************************************************************************/
89 #define USE_ICON8_COLORS
90 #define USE_ICON8_BODY
92 #include "icon.h"
94 #if defined(__MORPHOS__) || defined(__AROS__)
95 #include <mui/Rawimage_mcc.h>
96 #else
97 #include <mui/NBitmap_mcc.h>
98 #endif
100 static Object *get_prefs_image(void)
102 Object *obj;
104 #if !defined(__MORPHOS__) && !defined(__AROS__)
105 if(nbitmapCanHandleRawData == TRUE)
107 obj = NBitmapObject,
108 MUIA_FixWidth, ICON32_WIDTH,
109 MUIA_FixHeight, ICON32_HEIGHT,
110 MUIA_NBitmap_Type, MUIV_NBitmap_Type_ARGB32,
111 MUIA_NBitmap_Normal, icon32,
112 MUIA_NBitmap_Width, ICON32_WIDTH,
113 MUIA_NBitmap_Height, ICON32_HEIGHT,
114 End;
116 else
118 obj = NULL;
120 #else
121 obj = RawimageObject,
122 MUIA_Rawimage_Data, icon32,
123 End;
124 #endif
126 // if the 32bit image data couldn't be loaded
127 // we fall back to the 8bit icon
128 if(obj == NULL)
130 obj = BodychunkObject,\
131 MUIA_FixWidth, ICON8_WIDTH,\
132 MUIA_FixHeight, ICON8_HEIGHT,\
133 MUIA_Bitmap_Width, ICON8_WIDTH ,\
134 MUIA_Bitmap_Height, ICON8_HEIGHT,\
135 MUIA_Bodychunk_Depth, ICON8_DEPTH,\
136 MUIA_Bodychunk_Body, (UBYTE *)icon8_body,\
137 MUIA_Bodychunk_Compression, ICON8_COMPRESSION,\
138 MUIA_Bodychunk_Masking, ICON8_MASKING,\
139 MUIA_Bitmap_SourceColors, (ULONG *)icon8_colors,\
140 MUIA_Bitmap_Transparent, 0,\
141 End;
144 return obj;
147 #define PREFSIMAGEOBJECT get_prefs_image()
149 #include "mccinit.c"
151 /******************************************************************************/
152 /* define all implementations of our user functions */
153 /******************************************************************************/
154 static BOOL ClassInit(UNUSED struct Library *base)
156 if((LocaleBase = (APTR)OpenLibrary("locale.library", 38)) &&
157 GETINTERFACE(ILocale, struct LocaleIFace *, LocaleBase))
159 // open the TextEditor.mcp catalog
160 OpenCat();
162 #if !defined(__MORPHOS__) && !defined(__AROS__)
164 struct Library *nbitmapMcc;
166 nbitmapCanHandleRawData = FALSE;
168 // we need at least NBitmap.mcc V15.8 to be able to let it handle raw image data
169 if((nbitmapMcc = OpenLibrary("mui/NBitmap.mcc", 0)) != NULL)
171 SHOWVALUE(DBF_ALWAYS, nbitmapMcc->lib_Version);
172 SHOWVALUE(DBF_ALWAYS, nbitmapMcc->lib_Revision);
174 if(nbitmapMcc->lib_Version > 15 || (nbitmapMcc->lib_Version == 15 && nbitmapMcc->lib_Revision >= 8))
175 nbitmapCanHandleRawData = TRUE;
177 CloseLibrary(nbitmapMcc);
180 SHOWVALUE(DBF_ALWAYS, nbitmapCanHandleRawData);
182 #endif
184 // Initialize the subclasses
185 if(CreateSubClasses())
186 return TRUE;
188 DROPINTERFACE(ILocale);
189 CloseLibrary((APTR)LocaleBase);
190 LocaleBase = NULL;
193 return FALSE;
197 static VOID ClassExpunge(UNUSED struct Library *base)
199 DeleteSubClasses();
201 CloseCat();
203 if(LocaleBase)
205 DROPINTERFACE(ILocale);
206 CloseLibrary((APTR)LocaleBase);
207 LocaleBase = NULL;