revert between 56095 -> 55830 in arch
[AROS.git] / workbench / classes / gadgets / colorwheel / library.c
blobac15e5bf8addea38c73deefafb13b3cfb4edcda8
2 /*
3 **
4 ** library code colorwheel
5 ** AMIGA version
6 **
7 */
9 #include <exec/resident.h>
10 #include <exec/initializers.h>
11 #include <exec/execbase.h>
12 #include <exec/libraries.h>
13 #include <graphics/gfxbase.h>
15 #ifdef __GNUC__
16 #ifndef __MORPHOS__
17 #include <inline/exec.h>
18 #include <inline/intuition.h>
19 #include <inline/dos.h>
20 #endif
21 #else
22 #include <pragma/exec_lib.h>
23 #include <pragma/intuition_lib.h>
24 #include <pragma/dos_lib.h>
26 #define REG( x, a ) register __## x a
27 #define __regargs
28 #endif
30 #ifdef __GNUC__
31 #include "BoopsiStubs.h"
32 #endif
34 #define ColorWheelBase ColorWheelBase_intern
36 #include "colorwheel_intern.h"
38 /****************************************************************************/
40 #ifndef BPTR
41 #define BPTR ULONG
42 #endif
44 /****************************************************************************/
46 STATIC struct Library *LibInit(REG(a0, ULONG seglist), REG(d0, struct ColorWheelBase_intern *ClassBase), REG(a6, struct Library *) );
47 STATIC struct Library *LibOpen( REG(a6, struct ColorWheelBase_intern *ClassBase ) );
48 STATIC ULONG LibExpunge( REG(a6, struct ColorWheelBase_intern *ClassBase ) );
49 STATIC ULONG LibClose( REG(a6, struct ColorWheelBase_intern *ClassBase ) );
50 STATIC LONG LibExtFunc(void);
53 BOOL __regargs L_OpenLibs(struct ColorWheelBase_intern *);
54 void __regargs L_CloseLibs(struct ColorWheelBase_intern *);
55 Class * __regargs initClass (struct ColorWheelBase_intern *);
56 Class * ObtainClass(REG(a6, struct ColorWheelBase_intern *) );
58 extern ULONG dispatch_colorwheelclass(REG(a0, Class *), REG(a2, Object *), REG(a1, Msg ) );
60 /****************************************************************************/
62 UBYTE LibName[] = NAME_STRING,
63 LibID[] = VERSION_STRING;
65 LONG LibVersion = VERSION_NUMBER,
66 LibRevision = REVISION_NUMBER;
68 extern void ConvertHSBToRGB( void ), ConvertRGBToHSB( void );
70 APTR LibVectors[] =
72 (APTR) LibOpen,
73 (APTR) LibClose,
74 (APTR) LibExpunge,
75 (APTR) LibExtFunc,
76 (APTR) ConvertHSBToRGB,
77 (APTR) ConvertRGBToHSB,
78 (APTR) -1L
81 ULONG LibInitTab[] =
83 (ULONG) sizeof(struct ColorWheelBase_intern),
84 (ULONG) LibVectors,
85 (ULONG) NULL,
86 (ULONG) LibInit
89 struct Resident ROMTag = /* do not change */
91 RTC_MATCHWORD,
92 &ROMTag,
93 &ROMTag + sizeof(ROMTag),
94 RTF_AUTOINIT,
95 VERSION_NUMBER,
96 NT_LIBRARY,
98 LibName,
99 LibID,
100 (APTR)&LibInitTab
103 /****************************************************************************/
105 LONG LibExtFunc(void)
107 return(-1L);
110 /****************************************************************************/
112 struct Library *
113 __saveds LibInit( REG(a0, ULONG seglist), REG(d0, struct ColorWheelBase_intern *ColorWheelBase), REG(a6, struct Library *ExecBase ) )
115 SysBase = (struct ExecBase *) ExecBase;
116 ColorWheelBase->seglist = seglist;
117 ColorWheelBase->library.lib_Revision = REVISION_NUMBER;
119 if( ( ExecBase->lib_Version >= 39L ) && ( ((struct ExecBase *)SysBase)->AttnFlags & AFF_68020 ) )
121 if(L_OpenLibs(ColorWheelBase))
123 if(ColorWheelBase->classptr = InitColorWheelClass(ColorWheelBase))
125 return((struct Library *)ColorWheelBase);
129 L_CloseLibs( ColorWheelBase );
132 FreeMem((BYTE *)ColorWheelBase-ColorWheelBase->library.lib_NegSize,
133 ColorWheelBase->library.lib_NegSize + ColorWheelBase->library.lib_PosSize);
135 return(NULL);
138 /****************************************************************************/
140 struct Library * __saveds LibOpen(REG(a6, struct ColorWheelBase_intern *ColorWheelBase ) )
142 ColorWheelBase->library.lib_Flags &= ~LIBF_DELEXP;
143 ColorWheelBase->library.lib_OpenCnt++;
145 return((struct Library *)ColorWheelBase);
148 /****************************************************************************/
150 ULONG __saveds LibExpunge(REG(a6, struct ColorWheelBase_intern *ColorWheelBase) )
152 if(!ColorWheelBase->library.lib_OpenCnt)
154 if(ColorWheelBase->classptr)
156 if( ! FreeClass(ColorWheelBase->classptr) )
158 AddClass( ColorWheelBase->classptr );
159 return NULL;
163 L_CloseLibs(ColorWheelBase);
165 Remove((struct Node *)ColorWheelBase);
167 FreeMem((BYTE *)ColorWheelBase-ColorWheelBase->library.lib_NegSize,
168 ColorWheelBase->library.lib_NegSize + ColorWheelBase->library.lib_PosSize);
170 return( ColorWheelBase->seglist );
172 else
174 ColorWheelBase->library.lib_Flags |= LIBF_DELEXP;
177 return( NULL );
180 /****************************************************************************/
182 ULONG __saveds LibClose(REG(a6, struct ColorWheelBase_intern *ColorWheelBase) )
184 if(ColorWheelBase->library.lib_OpenCnt)
186 ColorWheelBase->library.lib_OpenCnt--;
189 return((!ColorWheelBase->library.lib_OpenCnt &&
190 ColorWheelBase->library.lib_Flags & LIBF_DELEXP)?LibExpunge(ColorWheelBase):NULL);
193 /****************************************************************************/
195 struct GfxBase *GfxBase;
196 struct IntuitionBase *IntuitionBase;
197 struct Library *LayersBase;
198 struct UtilityBase *UtilityBase;
199 struct Library *CyberGfxBase;
201 BOOL __regargs L_OpenLibs( struct ColorWheelBase_intern *ColorWheelBase )
203 if( ( GfxBase = OpenLibrary( "graphics.library", 39L ) ) &&
204 ( IntuitionBase = OpenLibrary( "intuition.library", 39L ) ) &&
205 ( LayersBase = OpenLibrary( "layers.library", 39L ) ) &&
206 ( UtilityBase = OpenLibrary( "utility.library", 39L ) ) )
208 CyberGfxBase = OpenLibrary( "cybergraphics.library", 40L );
210 return( TRUE );
213 return FALSE;
216 /****************************************************************************/
218 void __regargs L_CloseLibs( struct ColorWheelBase_intern *ColorWheelBase )
220 CloseLibrary( (struct Library *)GfxBase );
221 CloseLibrary( (struct Library *)IntuitionBase );
222 CloseLibrary( UtilityBase );
223 CloseLibrary( CyberGfxBase );
224 CloseLibrary( LayersBase );
227 /***************************************************************************************************/
229 IPTR dispatch_colorwheelclass( REG(a0, Class *cl), REG(a2, Object *o), REG(a1, Msg msg ) )
231 IPTR retval = 0UL;
233 switch(msg->MethodID)
235 case GM_HANDLEINPUT:
236 retval = colorwheel_handleinput(cl, o, (struct gpInput *)msg);
237 break;
239 case GM_RENDER:
240 colorwheel_render(cl, o, (struct gpRender *)msg);
241 break;
243 case OM_SET:
244 case OM_UPDATE:
245 retval = colorwheel_set(cl, o, (struct opSet *)msg);
246 break;
248 case GM_HITTEST:
249 retval = colorwheel_hittest(cl, o, (struct gpHitTest *)msg);
250 break;
252 case GM_GOACTIVE:
253 retval = colorwheel_goactive(cl, o, (struct gpInput *)msg);
254 break;
256 case OM_GET:
257 retval = colorwheel_get(cl, o, (struct opGet *)msg);
258 break;
260 case GM_DOMAIN:
261 retval = colorwheel_domain(cl, o, (struct gpDomain *)msg);
262 break;
264 case OM_NEW:
265 retval = (IPTR)colorwheel_new(cl, o, (struct opSet *)msg);
266 break;
268 case OM_DISPOSE:
269 colorwheel_dispose(cl, o, msg);
270 break;
272 default:
273 retval = DoSuperMethodA(cl, o, (Msg)msg);
274 break;
276 } /* switch */
278 return (retval);
279 } /* dispatch_colorwheelclass */
281 /***************************************************************************************************/
283 struct IClass *InitColorWheelClass (struct ColorWheelBase_intern * ColorWheelBase)
285 struct IClass *cl = NULL;
287 if ((cl = MakeClass("colorwheel.gadget", GADGETCLASS, NULL, sizeof(struct ColorWheelData), 0)))
289 cl->cl_Dispatcher.h_Entry = (HOOKFUNC) dispatch_colorwheelclass;
290 cl->cl_Dispatcher.h_SubEntry = NULL;
291 cl->cl_UserData = (IPTR)ColorWheelBase;
293 AddClass (cl);
296 return (cl);
299 /****************************************************************************/