grub2: bring back build of aros-side grub2 tools
[AROS.git] / workbench / classes / gadgets / gradientslider / library.c
blobd71f09cf4d2a7d14fe2b9bd35ac8fa4b0d528a3d
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 /****************************************************************************/
58 UBYTE LibName[] = NAME_STRING,
59 LibID[] = VERSION_STRING;
61 LONG LibVersion = VERSION_NUMBER,
62 LibRevision = REVISION_NUMBER;
64 APTR LibVectors[] =
66 (APTR) LibOpen,
67 (APTR) LibClose,
68 (APTR) LibExpunge,
69 (APTR) LibExtFunc,
70 (APTR) ObtainClass,
71 (APTR) -1L
74 ULONG LibInitTab[] =
76 (ULONG) sizeof(struct GradientSliderBase_intern),
77 (ULONG) LibVectors,
78 (ULONG) NULL,
79 (ULONG) LibInit
82 struct Resident ROMTag = /* do not change */
84 RTC_MATCHWORD,
85 &ROMTag,
86 &ROMTag + sizeof(ROMTag),
87 RTF_AUTOINIT,
88 VERSION_NUMBER,
89 NT_LIBRARY,
91 LibName,
92 LibID,
93 (APTR)&LibInitTab
96 /****************************************************************************/
98 LONG LibExtFunc(void)
100 return(-1L);
103 /****************************************************************************/
105 struct Library *
106 __saveds LibInit( REG(a0, ULONG seglist), REG(d0, struct GradientSliderBase_intern *GradientSliderBase), REG(a6, struct Library *ExecBase ) )
108 SysBase = (struct ExecBase *) ExecBase;
109 GradientSliderBase->seglist = seglist;
110 GradientSliderBase->library.lib_Revision = REVISION_NUMBER;
112 if( ( ExecBase->lib_Version >= 39L ) && ( ((struct ExecBase *)SysBase)->AttnFlags & AFF_68020 ) )
114 if(L_OpenLibs(GradientSliderBase))
116 if(GradientSliderBase->classptr = InitGradientSliderClass(GradientSliderBase))
118 return((struct Library *)GradientSliderBase);
122 L_CloseLibs( GradientSliderBase );
125 FreeMem((BYTE *)GradientSliderBase-GradientSliderBase->library.lib_NegSize,
126 GradientSliderBase->library.lib_NegSize + GradientSliderBase->library.lib_PosSize);
128 ROMTag.rt_Version = VERSION_NUMBER;
130 return(NULL);
133 /****************************************************************************/
135 struct Library * __saveds LibOpen(REG(a6, struct GradientSliderBase_intern *GradientSliderBase ) )
137 GradientSliderBase->library.lib_Flags &= ~LIBF_DELEXP;
138 GradientSliderBase->library.lib_OpenCnt++;
140 return((struct Library *)GradientSliderBase);
143 /****************************************************************************/
145 ULONG __saveds LibExpunge(REG(a6, struct GradientSliderBase_intern *GradientSliderBase) )
147 if(!GradientSliderBase->library.lib_OpenCnt)
149 if(GradientSliderBase->classptr)
151 if( ! FreeClass(GradientSliderBase->classptr) )
153 AddClass( GradientSliderBase->classptr );
154 return NULL;
158 L_CloseLibs(GradientSliderBase);
160 Remove((struct Node *)GradientSliderBase);
162 FreeMem((BYTE *)GradientSliderBase-GradientSliderBase->library.lib_NegSize,
163 GradientSliderBase->library.lib_NegSize + GradientSliderBase->library.lib_PosSize);
165 return( GradientSliderBase->seglist );
167 else
169 GradientSliderBase->library.lib_Flags |= LIBF_DELEXP;
172 return( NULL );
175 /****************************************************************************/
177 ULONG __saveds LibClose(REG(a6, struct GradientSliderBase_intern *GradientSliderBase) )
179 if(GradientSliderBase->library.lib_OpenCnt)
181 GradientSliderBase->library.lib_OpenCnt--;
184 return((!GradientSliderBase->library.lib_OpenCnt &&
185 GradientSliderBase->library.lib_Flags & LIBF_DELEXP)?LibExpunge(GradientSliderBase):NULL);
188 /****************************************************************************/
190 struct GfxBase *GfxBase;
191 struct IntuitionBase *IntuitionBase;
192 struct Library *LayersBase;
193 struct UtilityBase *UtilityBase;
194 struct Library *CyberGfxBase;
196 BOOL __regargs L_OpenLibs( struct GradientSliderBase_intern *GradientSliderBase )
198 if( ( GfxBase = OpenLibrary( "graphics.library", 39L ) ) &&
199 ( IntuitionBase = OpenLibrary( "intuition.library", 39L ) ) &&
200 ( LayersBase = OpenLibrary( "layers.library", 39L ) ) &&
201 ( UtilityBase = OpenLibrary( "utility.library", 39L ) ) )
203 CyberGfxBase = OpenLibrary( "cybergraphics.library", 40L );
205 return( TRUE );
208 return FALSE;
211 /****************************************************************************/
213 void __regargs L_CloseLibs( struct GradientSliderBase_intern *GradientSliderBase )
215 CloseLibrary( (struct Library *)GfxBase );
216 CloseLibrary( (struct Library *)IntuitionBase );
217 CloseLibrary( UtilityBase );
218 CloseLibrary( CyberGfxBase );
219 CloseLibrary( LayersBase );
222 /****************************************************************************/
224 Class * __saveds ObtainClass(REG(a6, struct GradientSliderBase_intern *GradientSliderBase) )
226 return(GradientSliderBase->classptr);
229 /****************************************************************************/
231 #ifdef __AROS__
232 AROS_UFH3(IPTR, dispatch_gradientsliderclass,
233 AROS_UFHA(Class *, cl, A0),
234 AROS_UFHA(Object *, o, A2),
235 AROS_UFHA(Msg, msg, A1))
236 #else
237 ULONG __saveds dispatch_gradientsliderclass( REG(a0, Class *cl), REG(a2, Object *o), REG(a1, Msg msg ) )
238 #endif
240 AROS_USERFUNC_INIT
242 IPTR retval = 0UL;
244 switch(msg->MethodID)
246 case GM_HANDLEINPUT:
247 retval = GradientSlider__GM_HANDLEINPUT(cl, o, (struct gpInput *)msg);
248 break;
250 case OM_SET:
251 case OM_UPDATE:
252 retval = (IPTR)GradientSlider__OM_SET(cl, o, (struct opSet *)msg);
253 break;
255 case GM_RENDER:
256 GradientSlider__GM_RENDER(cl, o, (struct gpRender *)msg);
257 break;
259 case GM_HITTEST:
260 retval = GradientSlider__GM_HITTEST(cl, o, (struct gpHitTest *)msg);
261 break;
263 case GM_GOACTIVE:
264 retval = GradientSlider__GM_GOACTIVE(cl, o, (struct gpInput *)msg);
265 break;
267 case OM_GET:
268 retval = GradientSlider__OM_GET(cl, o, (struct opGet *)msg);
269 break;
271 case OM_NEW:
272 retval = (IPTR)GradientSlider__OM_NEW(cl, o, (struct opSet *)msg);
273 break;
275 case OM_DISPOSE:
276 GradientSlider__OM_DISPOSE(cl, o, msg);
277 break;
279 case GM_DOMAIN:
280 retval = GradientSlider__GM_DOMAIN(cl, o, (struct gpDomain *)msg);
281 break;
283 default:
284 retval = DoSuperMethodA(cl, o, msg);
285 break;
287 } /* switch */
289 return (retval);
291 AROS_USERFUNC_EXIT
292 } /* dispatch_gradientsliderclass */
294 /***************************************************************************************************/
296 struct IClass *InitGradientSliderClass (struct GradientSliderBase_intern * GradientSliderBase)
298 struct IClass *cl = NULL;
300 if ((cl = MakeClass("gradientslider.gadget", GADGETCLASS, NULL, sizeof(struct GradientSliderData), 0)))
302 cl->cl_Dispatcher.h_Entry = (HOOKFUNC)dispatch_gradientsliderclass;
303 cl->cl_Dispatcher.h_SubEntry = NULL;
304 cl->cl_UserData = (IPTR)GradientSliderBase;
306 AddClass (cl);
309 return (cl);
312 /***************************************************************************************************/