move additional libs under workbench/
[AROS-Contrib.git] / bgui / systemiclass.c
blobbc15e5e3ac89912a865b88f5c01639d9eb38060f
1 /*
2 * @(#) $Header$
4 * BGUI library
5 * systemiclass.c
7 * (C) Copyright 1998 Manuel Lemos.
8 * (C) Copyright 1996-1997 Ian J. Einman.
9 * (C) Copyright 1993-1996 Jaba Development.
10 * (C) Copyright 1993-1996 Jan van den Baard.
11 * All Rights Reserved.
13 * $Log$
14 * Revision 42.2 2004/06/16 20:16:48 verhaegs
15 * Use METHODPROTO, METHOD_END and REGFUNCPROTOn where needed.
17 * Revision 42.1 2000/05/15 19:27:02 stegerg
18 * another hundreds of REG() macro replacements in func headers/protos.
20 * Revision 42.0 2000/05/09 22:10:26 mlemos
21 * Bumped to revision 42.0 before handing BGUI to AROS team
23 * Revision 41.11 2000/05/09 19:55:17 mlemos
24 * Merged with the branch Manuel_Lemos_fixes.
26 * Revision 41.10.2.1 1999/07/31 01:55:22 mlemos
27 * Fixed superclass call to dispose the objects.
29 * Revision 41.10 1998/02/25 21:13:18 mlemos
30 * Bumping to 41.10
32 * Revision 1.1 1998/02/25 17:09:54 mlemos
33 * Ian sources
38 /// Class definitions.
40 #include "include/classdefs.h"
43 * Object instance data.
45 typedef struct {
46 Object *sd_Image; /* The sysiclass object. */
47 struct DrawInfo *sd_DrawInfo; /* Current drawinfo. */
48 UWORD sd_Which; /* Which image to render. */
49 } SD;
51 ///
53 /// OM_NEW
55 * Create a new object.
57 METHOD(SystemClassNew, struct opSet *, ops)
59 IPTR rc;
61 if ((rc = AsmDoSuperMethodA(cl, obj, (Msg)ops)))
63 AsmCoerceMethod(cl, (Object *)rc, OM_SET, ops->ops_AttrList, NULL);
65 return rc;
67 METHOD_END
68 ///
69 /// OM_SET
71 * Change one or more attrubutes.
73 METHOD(SystemClassSet, struct opSet *, ops)
75 SD *sd = INST_DATA(cl, obj);
76 struct TagItem *tag;
77 struct TagItem *tstate = ops->ops_AttrList;
78 ULONG data;
79 ULONG rc;
82 * First we let the superclass
83 * change the attributes it
84 * knows.
86 rc = AsmDoSuperMethodA(cl, obj, (Msg)ops);
89 * Get the attributes.
91 while ((tag = NextTagItem(&tstate)))
93 data = tag->ti_Data;
94 switch (tag->ti_Tag)
96 case VIT_BuiltIn:
97 switch (data)
99 case BUILTIN_CHECKMARK:
100 data = CHECKIMAGE;
101 break;
102 case BUILTIN_ARROW_LEFT:
103 data = LEFTIMAGE;
104 break;
105 case BUILTIN_ARROW_RIGHT:
106 data = RIGHTIMAGE;
107 break;
108 case BUILTIN_ARROW_UP:
109 data = UPIMAGE;
110 break;
111 case BUILTIN_ARROW_DOWN:
112 data = DOWNIMAGE;
113 break;
115 case SYSIA_Which:
116 sd->sd_Which = data;
117 sd->sd_DrawInfo = NULL;
118 break;
121 return rc;
123 METHOD_END
125 /// OM_GET
127 * Give an attribute value.
129 METHOD(SystemClassGet, struct opGet *, opg)
131 SD *sd = INST_DATA(cl, obj);
132 ULONG rc = 1;
133 IPTR *store = opg->opg_Storage;
136 * First we see if the attribute they want is known to us. If not
137 * we pass it onto the superclass.
139 switch (opg->opg_AttrID)
141 case SYSIA_Which:
142 STORE sd->sd_Which;
143 break;
145 default:
146 rc = AsmDoSuperMethodA(cl, obj, (Msg)opg);
147 break;
150 return rc;
152 METHOD_END
154 /// OM_DISPOSE
155 METHOD(SystemClassDispose, Msg, msg)
157 SD *sd = INST_DATA(cl, obj);
159 if (sd->sd_Image) DisposeObject(sd->sd_Image);
161 return AsmDoSuperMethodA(cl, obj, msg);
163 METHOD_END
165 /// IM_DRAW, IM_ERASE
167 * Render the vector image.
169 METHOD(SystemClassDrawErase, struct impDraw *, dr)
171 SD *sd = INST_DATA(cl, obj);
172 ULONG rc = 0;
174 if (sd->sd_Image) DisposeObject(sd->sd_Image);
176 sd->sd_Image = NewObject(NULL, "sysiclass", IA_Width, IMAGE(obj)->Width,
177 IA_Height, IMAGE(obj)->Height,
178 SYSIA_Which, sd->sd_Which,
179 SYSIA_DrawInfo, dr->imp_DrInfo,
180 TAG_DONE);
182 if (sd->sd_Image)
184 IMAGEBOX(sd->sd_Image)->Left = IMAGEBOX(obj)->Left;
185 IMAGEBOX(sd->sd_Image)->Top = IMAGEBOX(obj)->Top;
187 rc = AsmDoMethodA(sd->sd_Image, (Msg)dr);
190 return rc;
192 METHOD_END
195 /// Class initialization.
197 STATIC DPFUNC ClassFunc[] = {
198 { IM_DRAW, SystemClassDrawErase, },
199 { IM_ERASE, SystemClassDrawErase, },
200 { OM_NEW, SystemClassNew, },
201 { OM_SET, SystemClassSet, },
202 { OM_GET, SystemClassGet, },
203 { OM_DISPOSE, SystemClassDispose, },
204 { DF_END, NULL },
207 makeproto Class *InitSystemClass(void)
209 return BGUI_MakeClass(CLASS_SuperClassID, ImageClass,
210 CLASS_ObjectSize, sizeof(SD),
211 CLASS_DFTable, ClassFunc,
212 TAG_DONE);