Update to lasso handling. Adjust scroll amount based on difference between mouse...
[AROS.git] / rom / boopsi / makeclass.c
blob8d2dff2091bc7d55c6b3c0c472564d3dfa61648e
1 /*
2 Copyright © 1995-2007, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Initialize a BOOPSI class
6 Lang: english
7 */
8 #include <exec/lists.h>
9 #include <exec/memory.h>
10 #include <proto/exec.h>
11 #include "intern.h"
13 /*****************************************************************************
15 NAME */
16 #include <intuition/classes.h>
17 #include <proto/boopsi.h>
19 AROS_LH5(struct IClass *, MakeClass,
21 /* SYNOPSIS */
22 AROS_LHA(UBYTE *, classID, A0),
23 AROS_LHA(UBYTE *, superClassID, A1),
24 AROS_LHA(struct IClass *, superClassPtr, A2),
25 AROS_LHA(ULONG , instanceSize, D0),
26 AROS_LHA(ULONG , flags, D1),
28 /* LOCATION */
29 struct Library *, BOOPSIBase, 10, BOOPSI)
31 /* FUNCTION
32 Only for class implementators.
34 This function creates a new public BOOPSI class. The SuperClass
35 should be another BOOPSI class; all BOOPSI classes are subclasses
36 of the ROOTCLASS.
38 SuperClasses can by private or public. You can specify a name/ID
39 for the class if you want it to become a public class. For public
40 classes, you must call AddClass() afterwards to make it public
41 accessible.
43 The return value contains a pointer to the IClass structure of your
44 class. You must specify your dispatcher in cl_Dispatcher. You can
45 also store shared data in cl_UserData.
47 To get rid of the class, you must call FreeClass().
49 INPUTS
50 classID - NULL for private classes otherwise the name/ID of the
51 public class.
52 superClassID - Name/ID of a public SuperClass. NULL is you don't
53 want to use a public SuperClass or if you have the pointer
54 your SuperClass.
55 superClassPtr - Pointer to the SuperClass. If this is non-NULL,
56 then superClassID is ignored.
57 instanceSize - The amount of memory which your objects need (in
58 addition to the memory which is needed by the SuperClass(es))
59 flags - For future extensions. To maintain comaptibility, use 0
60 for now.
62 RESULT
63 Pointer to the new class or NULL if
64 - There wasn't enough memory
65 - The superclass couldn't be found
66 - There already is a class with the same name/ID.
68 NOTES
69 No copy is made of classID. So make sure the lifetime of the contents
70 of classID is at least the same as the lifetime of the class itself.
72 EXAMPLE
74 BUGS
76 SEE ALSO
78 INTERNALS
80 HISTORY
81 29-10-95 digulla automatically created from
82 intuition_lib.fd and clib/intuition_protos.h
84 *****************************************************************************/
86 AROS_LIBFUNC_INIT
87 Class * iclass;
89 /* trust the user ;-) */
90 if (!superClassID && !superClassPtr)
91 return (NULL);
93 /* Does this class already exist ? */
94 if (FindClass (classID))
95 return (NULL);
97 /* Has the user specified a classPtr ? */
98 if (!superClassPtr)
100 /* Search for the class ... */
101 superClassPtr = FindClass (superClassID);
103 if (!superClassPtr)
104 return (NULL); /* nothing found */
107 /* Get some memory */
108 if ((iclass = (Class *) AllocMem (sizeof (Class), MEMF_PUBLIC|MEMF_CLEAR)))
110 /* Felder init */
111 iclass->cl_Super = superClassPtr;
112 iclass->cl_ID = classID;
113 iclass->cl_InstOffset = superClassPtr->cl_InstOffset +
114 superClassPtr->cl_InstSize;
115 iclass->cl_InstSize = instanceSize;
116 iclass->cl_Flags = flags;
118 /* SuperClass is used one more time now */
119 superClassPtr->cl_SubclassCount ++;
122 return (iclass);
123 AROS_LIBFUNC_EXIT
124 } /* MakeClass */