4 ** library code gradientslider
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>
16 #include <inline/exec.h>
17 #include <inline/intuition.h>
18 #include <inline/dos.h>
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
29 #include "BoopsiStubs.h"
32 #define GradientSliderBase GradientSliderBase_intern
34 #include "gradientslider_intern.h"
36 /****************************************************************************/
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
;
78 (ULONG
) sizeof(struct GradientSliderBase_intern
),
84 struct Resident ROMTag
= /* do not change */
88 &ROMTag
+ sizeof(ROMTag
),
98 /****************************************************************************/
100 LONG
LibExtFunc(void)
105 /****************************************************************************/
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
;
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
);
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
);
171 GradientSliderBase
->library
.lib_Flags
|= LIBF_DELEXP
;
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 );
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
) )
237 switch(msg
->MethodID
)
240 retval
= GradientSlider__GM_HANDLEINPUT(cl
, o
, (struct gpInput
*)msg
);
245 retval
= (IPTR
)GradientSlider__OM_SET(cl
, o
, (struct opSet
*)msg
);
249 GradientSlider__GM_RENDER(cl
, o
, (struct gpRender
*)msg
);
253 retval
= GradientSlider__GM_HITTEST(cl
, o
, (struct gpHitTest
*)msg
);
257 retval
= GradientSlider__GM_GOACTIVE(cl
, o
, (struct gpInput
*)msg
);
261 retval
= GradientSlider__OM_GET(cl
, o
, (struct opGet
*)msg
);
265 retval
= (IPTR
)GradientSlider__OM_NEW(cl
, o
, (struct opSet
*)msg
);
269 GradientSlider__OM_DISPOSE(cl
, o
, msg
);
273 retval
= GradientSlider__GM_DOMAIN(cl
, o
, (struct gpDomain
*)msg
);
277 retval
= DoSuperMethodA(cl
, o
, msg
);
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
;
303 /***************************************************************************************************/