added concrete implementations of putc(), getc(), getchar() and gets()
[tangerine.git] / workbench / classes / gadgets / colorwheel / library.c
blobaa81df01b6760c0feb290f1a7ae3ea9790dc67cf
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 #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 ColorWheelBase ColorWheelBase_intern
34 #include "colorwheel_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 ColorWheelBase_intern *ClassBase), REG(a6, struct Library *) );
45 STATIC struct Library *LibOpen( REG(a6, struct ColorWheelBase_intern *ClassBase ) );
46 STATIC ULONG LibExpunge( REG(a6, struct ColorWheelBase_intern *ClassBase ) );
47 STATIC ULONG LibClose( REG(a6, struct ColorWheelBase_intern *ClassBase ) );
48 STATIC LONG LibExtFunc(void);
51 BOOL __regargs L_OpenLibs(struct ColorWheelBase_intern *);
52 void __regargs L_CloseLibs(struct ColorWheelBase_intern *);
53 Class * __regargs initClass (struct ColorWheelBase_intern *);
54 Class * ObtainClass(REG(a6, struct ColorWheelBase_intern *) );
56 extern ULONG dispatch_colorwheelclass(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 extern void ConvertHSBToRGB( void ), ConvertRGBToHSB( void );
68 APTR LibVectors[] =
70 (APTR) LibOpen,
71 (APTR) LibClose,
72 (APTR) LibExpunge,
73 (APTR) LibExtFunc,
74 (APTR) ConvertHSBToRGB,
75 (APTR) ConvertRGBToHSB,
76 (APTR) -1L
79 ULONG LibInitTab[] =
81 (ULONG) sizeof(struct ColorWheelBase_intern),
82 (ULONG) LibVectors,
83 (ULONG) NULL,
84 (ULONG) LibInit
87 struct Resident ROMTag = /* do not change */
89 RTC_MATCHWORD,
90 &ROMTag,
91 &ROMTag + sizeof(ROMTag),
92 RTF_AUTOINIT,
93 VERSION_NUMBER,
94 NT_LIBRARY,
96 LibName,
97 LibID,
98 (APTR)&LibInitTab
101 /****************************************************************************/
103 LONG LibExtFunc(void)
105 return(-1L);
108 /****************************************************************************/
110 struct Library *
111 __saveds LibInit( REG(a0, ULONG seglist), REG(d0, struct ColorWheelBase_intern *ColorWheelBase), REG(a6, struct Library *ExecBase ) )
113 SysBase = (struct ExecBase *) ExecBase;
114 ColorWheelBase->seglist = seglist;
115 ColorWheelBase->library.lib_Revision = REVISION_NUMBER;
117 if( ( ExecBase->lib_Version >= 39L ) && ( ((struct ExecBase *)SysBase)->AttnFlags & AFF_68020 ) )
119 if(L_OpenLibs(ColorWheelBase))
121 if(ColorWheelBase->classptr = InitColorWheelClass(ColorWheelBase))
123 return((struct Library *)ColorWheelBase);
127 L_CloseLibs( ColorWheelBase );
130 FreeMem((BYTE *)ColorWheelBase-ColorWheelBase->library.lib_NegSize,
131 ColorWheelBase->library.lib_NegSize + ColorWheelBase->library.lib_PosSize);
133 return(NULL);
136 /****************************************************************************/
138 struct Library * __saveds LibOpen(REG(a6, struct ColorWheelBase_intern *ColorWheelBase ) )
140 ColorWheelBase->library.lib_Flags &= ~LIBF_DELEXP;
141 ColorWheelBase->library.lib_OpenCnt++;
143 return((struct Library *)ColorWheelBase);
146 /****************************************************************************/
148 ULONG __saveds LibExpunge(REG(a6, struct ColorWheelBase_intern *ColorWheelBase) )
150 if(!ColorWheelBase->library.lib_OpenCnt)
152 if(ColorWheelBase->classptr)
154 if( ! FreeClass(ColorWheelBase->classptr) )
156 AddClass( ColorWheelBase->classptr );
157 return NULL;
161 L_CloseLibs(ColorWheelBase);
163 Remove((struct Node *)ColorWheelBase);
165 FreeMem((BYTE *)ColorWheelBase-ColorWheelBase->library.lib_NegSize,
166 ColorWheelBase->library.lib_NegSize + ColorWheelBase->library.lib_PosSize);
168 return( ColorWheelBase->seglist );
170 else
172 ColorWheelBase->library.lib_Flags |= LIBF_DELEXP;
175 return( NULL );
178 /****************************************************************************/
180 ULONG __saveds LibClose(REG(a6, struct ColorWheelBase_intern *ColorWheelBase) )
182 if(ColorWheelBase->library.lib_OpenCnt)
184 ColorWheelBase->library.lib_OpenCnt--;
187 return((!ColorWheelBase->library.lib_OpenCnt &&
188 ColorWheelBase->library.lib_Flags & LIBF_DELEXP)?LibExpunge(ColorWheelBase):NULL);
191 /****************************************************************************/
193 struct GfxBase *GfxBase;
194 struct IntuitionBase *IntuitionBase;
195 struct Library *LayersBase;
196 struct UtilityBase *UtilityBase;
197 struct Library *CyberGfxBase;
199 BOOL __regargs L_OpenLibs( struct ColorWheelBase_intern *ColorWheelBase )
201 if( ( GfxBase = OpenLibrary( "graphics.library", 39L ) ) &&
202 ( IntuitionBase = OpenLibrary( "intuition.library", 39L ) ) &&
203 ( LayersBase = OpenLibrary( "layers.library", 39L ) ) &&
204 ( UtilityBase = OpenLibrary( "utility.library", 39L ) ) )
206 CyberGfxBase = OpenLibrary( "cybergraphics.library", 40L );
208 return( TRUE );
211 return FALSE;
214 /****************************************************************************/
216 void __regargs L_CloseLibs( struct ColorWheelBase_intern *ColorWheelBase )
218 CloseLibrary( (struct Library *)GfxBase );
219 CloseLibrary( (struct Library *)IntuitionBase );
220 CloseLibrary( UtilityBase );
221 CloseLibrary( CyberGfxBase );
222 CloseLibrary( LayersBase );
225 /***************************************************************************************************/
227 IPTR dispatch_colorwheelclass( REG(a0, Class *cl), REG(a2, Object *o), REG(a1, Msg msg ) )
229 IPTR retval = 0UL;
231 switch(msg->MethodID)
233 case GM_HANDLEINPUT:
234 retval = colorwheel_handleinput(cl, o, (struct gpInput *)msg);
235 break;
237 case GM_RENDER:
238 colorwheel_render(cl, o, (struct gpRender *)msg);
239 break;
241 case OM_SET:
242 case OM_UPDATE:
243 retval = colorwheel_set(cl, o, (struct opSet *)msg);
244 break;
246 case GM_HITTEST:
247 retval = colorwheel_hittest(cl, o, (struct gpHitTest *)msg);
248 break;
250 case GM_GOACTIVE:
251 retval = colorwheel_goactive(cl, o, (struct gpInput *)msg);
252 break;
254 case OM_GET:
255 retval = colorwheel_get(cl, o, (struct opGet *)msg);
256 break;
258 case GM_DOMAIN:
259 retval = colorwheel_domain(cl, o, (struct gpDomain *)msg);
260 break;
262 case OM_NEW:
263 retval = (IPTR)colorwheel_new(cl, o, (struct opSet *)msg);
264 break;
266 case OM_DISPOSE:
267 colorwheel_dispose(cl, o, msg);
268 break;
270 default:
271 retval = DoSuperMethodA(cl, o, (Msg)msg);
272 break;
274 } /* switch */
276 return (retval);
277 } /* dispatch_colorwheelclass */
279 /***************************************************************************************************/
281 struct IClass *InitColorWheelClass (struct ColorWheelBase_intern * ColorWheelBase)
283 struct IClass *cl = NULL;
285 if ((cl = MakeClass("colorwheel.gadget", GADGETCLASS, NULL, sizeof(struct ColorWheelData), 0)))
287 cl->cl_Dispatcher.h_Entry = (HOOKFUNC) dispatch_colorwheelclass;
288 cl->cl_Dispatcher.h_SubEntry = NULL;
289 cl->cl_UserData = (IPTR)ColorWheelBase;
291 AddClass (cl);
294 return (cl);
297 /****************************************************************************/