Replaced System by SYS because on "native" the volume name of the system partition...
[AROS-Contrib.git] / bgui / systemiclass.c
blob83d29c7b9599e258c323c08506f7e3dcaa45cfd6
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 SD *sd = INST_DATA(cl, obj);
60 ULONG rc;
62 if (rc = AsmDoSuperMethodA(cl, obj, (Msg)ops))
64 AsmCoerceMethod(cl, (Object *)rc, OM_SET, ops->ops_AttrList, NULL);
66 return rc;
68 METHOD_END
69 ///
70 /// OM_SET
72 * Change one or more attrubutes.
74 METHOD(SystemClassSet, struct opSet *, ops)
76 SD *sd = INST_DATA(cl, obj);
77 struct TagItem *tag, *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, *store = opg->opg_Storage;
135 * First we see if the attribute they want is known to us. If not
136 * we pass it onto the superclass.
138 switch (opg->opg_AttrID)
140 case SYSIA_Which:
141 STORE sd->sd_Which;
142 break;
144 default:
145 rc = AsmDoSuperMethodA(cl, obj, (Msg)opg);
146 break;
149 return rc;
151 METHOD_END
153 /// OM_DISPOSE
154 METHOD(SystemClassDispose, Msg, msg)
156 SD *sd = INST_DATA(cl, obj);
158 if (sd->sd_Image) DisposeObject(sd->sd_Image);
160 return AsmDoSuperMethodA(cl, obj, msg);
162 METHOD_END
164 /// IM_DRAW, IM_ERASE
166 * Render the vector image.
168 METHOD(SystemClassDrawErase, struct impDraw *, dr)
170 SD *sd = INST_DATA(cl, obj);
171 ULONG rc = 0;
173 if (sd->sd_Image) DisposeObject(sd->sd_Image);
175 sd->sd_Image = NewObject(NULL, "sysiclass", IA_Width, IMAGE(obj)->Width,
176 IA_Height, IMAGE(obj)->Height,
177 SYSIA_Which, sd->sd_Which,
178 SYSIA_DrawInfo, dr->imp_DrInfo,
179 TAG_DONE);
181 if (sd->sd_Image)
183 IMAGEBOX(sd->sd_Image)->Left = IMAGEBOX(obj)->Left;
184 IMAGEBOX(sd->sd_Image)->Top = IMAGEBOX(obj)->Top;
186 rc = AsmDoMethodA(sd->sd_Image, (Msg)dr);
189 return rc;
191 METHOD_END
194 /// Class initialization.
196 STATIC DPFUNC ClassFunc[] = {
197 IM_DRAW, (FUNCPTR)SystemClassDrawErase,
198 IM_ERASE, (FUNCPTR)SystemClassDrawErase,
199 OM_NEW, (FUNCPTR)SystemClassNew,
200 OM_SET, (FUNCPTR)SystemClassSet,
201 OM_GET, (FUNCPTR)SystemClassGet,
202 OM_DISPOSE, (FUNCPTR)SystemClassDispose,
203 DF_END, NULL
206 makeproto Class *InitSystemClass(void)
208 return BGUI_MakeClass(CLASS_SuperClassID, ImageClass,
209 CLASS_ObjectSize, sizeof(SD),
210 CLASS_DFTable, ClassFunc,
211 TAG_DONE);