Updated PCI IDs to latest snapshot.
[tangerine.git] / workbench / classes / gadgets / gradientslider / library.c
blob903646b20058808ee4eb13e3fd0d828ba73f3866
2 /*
3 **
4 ** library code gradientslider
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 #include <inline/exec.h>
17 #include <inline/intuition.h>
18 #include <inline/dos.h>
19 #else
20 #include <pragma/exec_lib.h>
21 #include <pragma/intuition_lib.h>
22 #include <pragma/dos_lib.h>
24 #define REG( x, a ) register __## x a
25 #define __regargs
26 #endif
28 #ifdef __GNUC__
29 #include "BoopsiStubs.h"
30 #endif
32 #define GradientSliderBase GradientSliderBase_intern
34 #include "gradientslider_intern.h"
36 /****************************************************************************/
38 #ifndef BPTR
39 #define BPTR ULONG
40 #endif
42 /****************************************************************************/
44 STATIC struct Library *LibInit(REG(a0, ULONG seglist), REG(d0, struct GradientSliderBase_intern *ClassBase), REG(a6, struct Library *) );
45 STATIC struct Library *LibOpen( REG(a6, struct GradientSliderBase_intern *ClassBase ) );
46 STATIC ULONG LibExpunge( REG(a6, struct GradientSliderBase_intern *ClassBase ) );
47 STATIC ULONG LibClose( REG(a6, struct GradientSliderBase_intern *ClassBase ) );
48 STATIC LONG LibExtFunc(void);
51 BOOL __regargs L_OpenLibs(struct GradientSliderBase_intern *);
52 void __regargs L_CloseLibs(struct GradientSliderBase_intern *);
53 Class * __regargs initClass (struct GradientSliderBase_intern *);
54 Class * ObtainClass(REG(a6, struct GradientSliderBase_intern *) );
56 extern ULONG dispatch_gradientsliderclass(REG(a0, Class *), REG(a2, Object *), REG(a1, Msg ) );
58 /****************************************************************************/
60 UBYTE LibName[] = NAME_STRING,
61 LibID[] = VERSION_STRING;
63 LONG LibVersion = VERSION_NUMBER,
64 LibRevision = REVISION_NUMBER;
66 APTR LibVectors[] =
68 (APTR) LibOpen,
69 (APTR) LibClose,
70 (APTR) LibExpunge,
71 (APTR) LibExtFunc,
72 (APTR) ObtainClass,
73 (APTR) -1L
76 ULONG LibInitTab[] =
78 (ULONG) sizeof(struct GradientSliderBase_intern),
79 (ULONG) LibVectors,
80 (ULONG) NULL,
81 (ULONG) LibInit
84 struct Resident ROMTag = /* do not change */
86 RTC_MATCHWORD,
87 &ROMTag,
88 &ROMTag + sizeof(ROMTag),
89 RTF_AUTOINIT,
90 VERSION_NUMBER,
91 NT_LIBRARY,
93 LibName,
94 LibID,
95 (APTR)&LibInitTab
98 /****************************************************************************/
100 LONG LibExtFunc(void)
102 return(-1L);
105 /****************************************************************************/
107 struct Library *
108 __saveds LibInit( REG(a0, ULONG seglist), REG(d0, struct GradientSliderBase_intern *GradientSliderBase), REG(a6, struct Library *ExecBase ) )
110 SysBase = (struct ExecBase *) ExecBase;
111 GradientSliderBase->seglist = seglist;
112 GradientSliderBase->library.lib_Revision = REVISION_NUMBER;
114 if( ( ExecBase->lib_Version >= 39L ) && ( ((struct ExecBase *)SysBase)->AttnFlags & AFF_68020 ) )
116 if(L_OpenLibs(GradientSliderBase))
118 if(GradientSliderBase->classptr = InitGradientSliderClass(GradientSliderBase))
120 return((struct Library *)GradientSliderBase);
124 L_CloseLibs( GradientSliderBase );
127 FreeMem((BYTE *)GradientSliderBase-GradientSliderBase->library.lib_NegSize,
128 GradientSliderBase->library.lib_NegSize + GradientSliderBase->library.lib_PosSize);
130 ROMTag.rt_Version = VERSION_NUMBER;
132 return(NULL);
135 /****************************************************************************/
137 struct Library * __saveds LibOpen(REG(a6, struct GradientSliderBase_intern *GradientSliderBase ) )
139 GradientSliderBase->library.lib_Flags &= ~LIBF_DELEXP;
140 GradientSliderBase->library.lib_OpenCnt++;
142 return((struct Library *)GradientSliderBase);
145 /****************************************************************************/
147 ULONG __saveds LibExpunge(REG(a6, struct GradientSliderBase_intern *GradientSliderBase) )
149 if(!GradientSliderBase->library.lib_OpenCnt)
151 if(GradientSliderBase->classptr)
153 if( ! FreeClass(GradientSliderBase->classptr) )
155 AddClass( GradientSliderBase->classptr );
156 return NULL;
160 L_CloseLibs(GradientSliderBase);
162 Remove((struct Node *)GradientSliderBase);
164 FreeMem((BYTE *)GradientSliderBase-GradientSliderBase->library.lib_NegSize,
165 GradientSliderBase->library.lib_NegSize + GradientSliderBase->library.lib_PosSize);
167 return( GradientSliderBase->seglist );
169 else
171 GradientSliderBase->library.lib_Flags |= LIBF_DELEXP;
174 return( NULL );
177 /****************************************************************************/
179 ULONG __saveds LibClose(REG(a6, struct GradientSliderBase_intern *GradientSliderBase) )
181 if(GradientSliderBase->library.lib_OpenCnt)
183 GradientSliderBase->library.lib_OpenCnt--;
186 return((!GradientSliderBase->library.lib_OpenCnt &&
187 GradientSliderBase->library.lib_Flags & LIBF_DELEXP)?LibExpunge(GradientSliderBase):NULL);
190 /****************************************************************************/
192 struct GfxBase *GfxBase;
193 struct IntuitionBase *IntuitionBase;
194 struct Library *LayersBase;
195 struct UtilityBase *UtilityBase;
196 struct Library *CyberGfxBase;
198 BOOL __regargs L_OpenLibs( struct GradientSliderBase_intern *GradientSliderBase )
200 if( ( GfxBase = OpenLibrary( "graphics.library", 39L ) ) &&
201 ( IntuitionBase = OpenLibrary( "intuition.library", 39L ) ) &&
202 ( LayersBase = OpenLibrary( "layers.library", 39L ) ) &&
203 ( UtilityBase = OpenLibrary( "utility.library", 39L ) ) )
205 CyberGfxBase = OpenLibrary( "cybergraphics.library", 40L );
207 return( TRUE );
210 return FALSE;
213 /****************************************************************************/
215 void __regargs L_CloseLibs( struct GradientSliderBase_intern *GradientSliderBase )
217 CloseLibrary( (struct Library *)GfxBase );
218 CloseLibrary( (struct Library *)IntuitionBase );
219 CloseLibrary( UtilityBase );
220 CloseLibrary( CyberGfxBase );
221 CloseLibrary( LayersBase );
224 /****************************************************************************/
226 Class * __saveds ObtainClass(REG(a6, struct GradientSliderBase_intern *GradientSliderBase) )
228 return(GradientSliderBase->classptr);
231 /****************************************************************************/
233 ULONG __saveds dispatch_gradientsliderclass( REG(a0, Class *cl), REG(a2, Object *o), REG(a1, Msg msg ) )
235 IPTR retval = 0UL;
237 switch(msg->MethodID)
239 case GM_HANDLEINPUT:
240 retval = GradientSlider__GM_HANDLEINPUT(cl, o, (struct gpInput *)msg);
241 break;
243 case OM_SET:
244 case OM_UPDATE:
245 retval = (IPTR)GradientSlider__OM_SET(cl, o, (struct opSet *)msg);
246 break;
248 case GM_RENDER:
249 GradientSlider__GM_RENDER(cl, o, (struct gpRender *)msg);
250 break;
252 case GM_HITTEST:
253 retval = GradientSlider__GM_HITTEST(cl, o, (struct gpHitTest *)msg);
254 break;
256 case GM_GOACTIVE:
257 retval = GradientSlider__GM_GOACTIVE(cl, o, (struct gpInput *)msg);
258 break;
260 case OM_GET:
261 retval = GradientSlider__OM_GET(cl, o, (struct opGet *)msg);
262 break;
264 case OM_NEW:
265 retval = (IPTR)GradientSlider__OM_NEW(cl, o, (struct opSet *)msg);
266 break;
268 case OM_DISPOSE:
269 GradientSlider__OM_DISPOSE(cl, o, msg);
270 break;
272 case GM_DOMAIN:
273 retval = GradientSlider__GM_DOMAIN(cl, o, (struct gpDomain *)msg);
274 break;
276 default:
277 retval = DoSuperMethodA(cl, o, msg);
278 break;
280 } /* switch */
282 return (retval);
283 } /* dispatch_gradientsliderclass */
285 /***************************************************************************************************/
287 struct IClass *InitGradientSliderClass (struct GradientSliderBase_intern * GradientSliderBase)
289 struct IClass *cl = NULL;
291 if ((cl = MakeClass("gradientslider.gadget", GADGETCLASS, NULL, sizeof(struct GradientSliderData), 0)))
293 cl->cl_Dispatcher.h_Entry = (HOOKFUNC)dispatch_gradientsliderclass;
294 cl->cl_Dispatcher.h_SubEntry = NULL;
295 cl->cl_UserData = (IPTR)GradientSliderBase;
297 AddClass (cl);
300 return (cl);
303 /***************************************************************************************************/