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
24 ***************************************************************************/
26 /******************************************************************************/
30 /******************************************************************************/
32 #include <proto/exec.h>
33 #include <proto/intuition.h>
34 #include <proto/muimaster.h>
36 /******************************************************************************/
38 /* MCC/MCP name and version */
40 /* ATTENTION: The FIRST LETTER of NAME MUST be UPPERCASE */
42 /******************************************************************************/
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
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
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
;
88 static struct IOStdReq ioreq
;
90 #if !defined(__MORPHOS__)
91 static BOOL nbitmapCanHandleRawData
;
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
108 #if defined(__MORPHOS__)
109 #include <mui/Rawimage_mcc.h>
111 #include <mui/NBitmap_mcc.h>
114 static Object
*get_prefs_image(void)
118 #if !defined(__MORPHOS__)
119 if(nbitmapCanHandleRawData
== TRUE
)
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
,
135 obj
= RawimageObject
,
136 MUIA_Rawimage_Data
, icon32
,
140 // if the 32bit image data couldn't be loaded
141 // we fall back to the 8bit icon
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,\
161 #define PREFSIMAGEOBJECT get_prefs_image()
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
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
);
210 DROPINTERFACE(IConsole
);
213 CloseDevice((struct IORequest
*)&ioreq
);
216 DROPINTERFACE(ICommodities
);
217 CloseLibrary(CxBase
);
225 static VOID
ClassExpunge(UNUSED
struct Library
*base
)
230 if(LocaleBase
!= NULL
)
232 DROPINTERFACE(ILocale
);
233 CloseLibrary(LocaleBase
);
237 if(ConsoleDevice
!= NULL
)
239 DROPINTERFACE(IConsole
);
240 CloseDevice((struct IORequest
*)&ioreq
);
241 ConsoleDevice
= NULL
;
246 DROPINTERFACE(ICommodities
);
247 CloseLibrary(CxBase
);