Merging NList MCC 0.119 into the main branch.
[AROS.git] / workbench / classes / zune / nlist / nlistviews_mcp / library.c
blobf046152aea81febc5a2889c7a8b5ae1641fd6fba
1 /***************************************************************************
3 NListviews.mcp - New Listview MUI Custom Class Preferences
4 Registered MUI class, Serial Number: 1d51 (0x9d510001 to 0x9d51001F
5 and 0x9d510101 to 0x9d51013F)
7 Copyright (C) 1996-2001 by Gilles Masson
8 Copyright (C) 2001-2014 NList Open Source Team
10 This library is free software; you can redistribute it and/or
11 modify it under the terms of the GNU Lesser General Public
12 License as published by the Free Software Foundation; either
13 version 2.1 of the License, or (at your option) any later version.
15 This library is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 Lesser General Public License for more details.
20 NList classes Support Site: http://www.sf.net/projects/nlist-classes
22 $Id$
24 ***************************************************************************/
26 /******************************************************************************/
27 /* */
28 /* includes */
29 /* */
30 /******************************************************************************/
32 #include <proto/exec.h>
33 #include <proto/intuition.h>
34 #include <proto/muimaster.h>
36 /******************************************************************************/
37 /* */
38 /* MCC/MCP name and version */
39 /* */
40 /* ATTENTION: The FIRST LETTER of NAME MUST be UPPERCASE */
41 /* */
42 /******************************************************************************/
44 #include "private.h"
45 #include "version.h"
47 /******************************************************************************/
48 /* include the minimal startup code to be able to start the class from a */
49 /* shell without crashing the system */
50 /******************************************************************************/
51 #include "shellstart.c"
53 #define VERSION LIB_VERSION
54 #define REVISION LIB_REVISION
56 #define CLASS MUIC_NListviews_mcp
57 #define SUPERCLASSP MUIC_Mccprefs
59 #define INSTDATAP NListviews_MCP_Data
61 #define USERLIBID CLASS " " LIB_REV_STRING " [" SYSTEMSHORT "/" CPU "] (" LIB_DATE ") " LIB_COPYRIGHT
62 #define MASTERVERSION 19
64 #define CLASSINIT
65 #define CLASSEXPUNGE
67 #define USEDCLASSES used_mccs
68 static const char *used_mccs[] = { "NList.mcc", "NListview.mcc", NULL };
70 #define USEDCLASSESP used_mcps
71 static const char *used_mcps[] = { "NListviews.mcp", NULL };
73 #define MIN_STACKSIZE 8192
75 #include "locale.h"
77 struct Library *CxBase = NULL;
78 struct Library *LocaleBase = NULL;
79 struct Device *ConsoleDevice = NULL;
80 //struct Catalog *catalog = NULL;
82 #if defined(__amigaos4__)
83 struct CommoditiesIFace *ICommodities = NULL;
84 struct LocaleIFace *ILocale = NULL;
85 struct ConsoleIFace *IConsole = NULL;
86 #endif
88 static struct IOStdReq ioreq;
90 #if !defined(__MORPHOS__)
91 static BOOL nbitmapCanHandleRawData;
92 #endif
94 /******************************************************************************/
95 /* define the functions used by the startup code ahead of including mccinit.c */
96 /******************************************************************************/
97 static BOOL ClassInit(UNUSED struct Library *base);
98 static VOID ClassExpunge(UNUSED struct Library *base);
100 /******************************************************************************/
101 /* include the lib startup code for the mcc/mcp (and muimaster inlines) */
102 /******************************************************************************/
103 #define USE_ICON8_COLORS
104 #define USE_ICON8_BODY
106 #include "icon.h"
108 #if defined(__MORPHOS__)
109 #include <mui/Rawimage_mcc.h>
110 #else
111 #include <mui/NBitmap_mcc.h>
112 #endif
114 static Object *get_prefs_image(void)
116 Object *obj;
118 #if !defined(__MORPHOS__)
119 if(nbitmapCanHandleRawData == TRUE)
121 obj = NBitmapObject,
122 MUIA_FixWidth, ICON32_WIDTH,
123 MUIA_FixHeight, ICON32_HEIGHT,
124 MUIA_NBitmap_Type, MUIV_NBitmap_Type_ARGB32,
125 MUIA_NBitmap_Normal, icon32,
126 MUIA_NBitmap_Width, ICON32_WIDTH,
127 MUIA_NBitmap_Height, ICON32_HEIGHT,
128 End;
130 else
132 obj = NULL;
134 #else
135 obj = RawimageObject,
136 MUIA_Rawimage_Data, icon32,
137 End;
138 #endif
140 // if the 32bit image data couldn't be loaded
141 // we fall back to the 8bit icon
142 if(obj == NULL)
144 obj = BodychunkObject,\
145 MUIA_FixWidth, ICON8_WIDTH,\
146 MUIA_FixHeight, ICON8_HEIGHT,\
147 MUIA_Bitmap_Width, ICON8_WIDTH ,\
148 MUIA_Bitmap_Height, ICON8_HEIGHT,\
149 MUIA_Bodychunk_Depth, ICON8_DEPTH,\
150 MUIA_Bodychunk_Body, (UBYTE *)icon8_body,\
151 MUIA_Bodychunk_Compression, ICON8_COMPRESSION,\
152 MUIA_Bodychunk_Masking, ICON8_MASKING,\
153 MUIA_Bitmap_SourceColors, (ULONG *)icon8_colors,\
154 MUIA_Bitmap_Transparent, 0,\
155 End;
158 return obj;
161 #define PREFSIMAGEOBJECT get_prefs_image()
163 #include "mccinit.c"
165 /******************************************************************************/
166 /* define all implementations of our user functions */
167 /******************************************************************************/
168 static BOOL ClassInit(UNUSED struct Library *base)
170 if((CxBase = OpenLibrary("commodities.library", 37L)) != NULL &&
171 GETINTERFACE(ICommodities, struct CommoditiesIFace *, CxBase))
173 ioreq.io_Message.mn_Length = sizeof(ioreq);
174 if(OpenDevice("console.device", -1L, (struct IORequest *)&ioreq, 0L) == 0)
176 ConsoleDevice = (struct Device *)ioreq.io_Device;
177 if(GETINTERFACE(IConsole, struct ConsoleIFace *, ConsoleDevice))
179 if((LocaleBase = OpenLibrary( "locale.library", 38)) != NULL &&
180 GETINTERFACE(ILocale, struct LocaleIFace *, LocaleBase))
182 // open the NListviews_mcp catalog
183 OpenCat();
185 #if !defined(__MORPHOS__)
187 struct Library *nbitmapMcc;
189 nbitmapCanHandleRawData = FALSE;
191 // we need at least NBitmap.mcc V15.8 to be able to let it handle raw image data
192 if((nbitmapMcc = OpenLibrary("mui/NBitmap.mcc", 0)) != NULL)
194 SHOWVALUE(DBF_ALWAYS, nbitmapMcc->lib_Version);
195 SHOWVALUE(DBF_ALWAYS, nbitmapMcc->lib_Revision);
197 if(nbitmapMcc->lib_Version > 15 || (nbitmapMcc->lib_Version == 15 && nbitmapMcc->lib_Revision >= 8))
198 nbitmapCanHandleRawData = TRUE;
200 CloseLibrary(nbitmapMcc);
203 SHOWVALUE(DBF_ALWAYS, nbitmapCanHandleRawData);
205 #endif
207 return TRUE;
210 DROPINTERFACE(IConsole);
213 CloseDevice((struct IORequest *)&ioreq);
216 DROPINTERFACE(ICommodities);
217 CloseLibrary(CxBase);
218 CxBase = NULL;
221 return FALSE;
225 static VOID ClassExpunge(UNUSED struct Library *base)
227 // close the catalog
228 CloseCat();
230 if(LocaleBase != NULL)
232 DROPINTERFACE(ILocale);
233 CloseLibrary(LocaleBase);
234 LocaleBase = NULL;
237 if(ConsoleDevice != NULL)
239 DROPINTERFACE(IConsole);
240 CloseDevice((struct IORequest *)&ioreq);
241 ConsoleDevice = NULL;
244 if(CxBase != NULL)
246 DROPINTERFACE(ICommodities);
247 CloseLibrary(CxBase);
248 CxBase = NULL;