Initial import of Scalos. To decrease size I have
[AROS-Contrib.git] / scalos / main / SeparatorGadgetClass.c
blobc75080ee440d6bad19cc8341b05e03196c4fa21b
1 // SeparatorGadgetClass.c
2 // $Date$
3 // $Revision$
6 #include <exec/types.h>
7 #include <graphics/gfxmacros.h>
8 #include <graphics/gfxbase.h>
9 #include <graphics/text.h>
10 #include <graphics/rpattr.h>
11 #include <libraries/dos.h>
12 #include <workbench/startup.h>
13 #include <intuition/intuition.h>
14 #include <intuition/intuitionbase.h>
15 #include <intuition/gadgetclass.h>
16 #include <intuition/screens.h>
18 #define __USE_SYSBASE
20 #include <proto/dos.h>
21 #include <proto/exec.h>
22 #include <proto/layers.h>
23 #include <proto/intuition.h>
24 #include <proto/graphics.h>
25 #include <proto/utility.h>
26 #include <proto/iconobject.h>
27 #include "debug.h"
28 #include <proto/scalos.h>
30 #include <clib/alib_protos.h>
32 #include <assert.h>
33 #include <stdio.h>
34 #include <stdlib.h>
35 #include <string.h>
36 #include <ctype.h>
37 #include <limits.h>
38 #include <stddef.h>
39 #include <stdarg.h>
41 #include <defs.h>
43 #include "scalos_structures.h"
44 #include "functions.h"
45 #include "Variables.h"
47 //----------------------------------------------------------------------------
49 // The functions in this module
51 static SAVEDS(ULONG) INTERRUPT dispatchSeparatorGadgetClass(Class *cl, Object *o, Msg msg);
52 static ULONG SeparatorGadget_Set(Class *cl, Object *o, Msg msg);
53 static ULONG SeparatorGadget_Get(Class *cl, Object *o, Msg msg);
55 //----------------------------------------------------------------------------
57 /***********************************************************/
58 /** Make the class and set up the dispatcher's hook **/
59 /***********************************************************/
60 struct ScalosClass *initSeparatorGadgetClass(const struct PluginClass *plug)
62 struct ScalosClass *SeparatorGadgetClass;
64 SeparatorGadgetClass = SCA_MakeScalosClass(plug->plug_classname,
65 plug->plug_superclassname,
67 0 );
68 d1(KPrintF("%s/%s/%ld SeparatorGadgetClass=%08lx plug_classname=<%s> plug_superclassname=<%s>\n",
69 __FILE__, __FUNC__, __LINE__, SeparatorGadgetClass, plug->plug_classname, plug->plug_superclassname));
71 if (SeparatorGadgetClass)
73 // initialize the cl_Dispatcher Hook
74 SETHOOKFUNC(SeparatorGadgetClass->sccl_class->cl_Dispatcher, dispatchSeparatorGadgetClass);
77 return SeparatorGadgetClass;
80 //----------------------------------------------------------------------------
82 /**************************************************************************/
83 /********** The SeparatorGadgetCLASS class dispatcher *********/
84 /**************************************************************************/
85 static SAVEDS(ULONG) INTERRUPT dispatchSeparatorGadgetClass(Class *cl, Object *o, Msg msg)
87 ULONG Result;
89 d1(KPrintF("%s/%s/%ld Class=%l08x SuperClass=%08lx Method=%08lx\n", __FILE__, __FUNC__, __LINE__, cl, cl->cl_Super, msg->MethodID));
91 switch (msg->MethodID)
93 case OM_SET:
94 Result = SeparatorGadget_Set(cl, o, msg);
95 break;
96 case OM_GET:
97 Result = SeparatorGadget_Get(cl, o, msg);
98 break;
99 default:
100 Result = DoSuperMethodA(cl, o, msg);
101 break;
104 return Result;
107 //----------------------------------------------------------------------------
109 static ULONG SeparatorGadget_Get(Class *cl, Object *o, Msg msg)
111 struct opGet *opg = (struct opGet *) msg;
112 struct Gadget *gg = (struct Gadget *) o;
113 ULONG Success = TRUE;
115 if (NULL == opg->opg_Storage)
116 return 0;
118 *(opg->opg_Storage) = 0;
120 switch (opg->opg_AttrID)
122 case GA_Left: // required since gadgetclass attribute is [IS] - no support for [G]
123 *(opg->opg_Storage) = (ULONG) gg->LeftEdge;
124 break;
125 case GA_Top: // required since gadgetclass attribute is [IS] - no support for [G]
126 *(opg->opg_Storage) = (ULONG) gg->TopEdge;
127 break;
128 case GA_Width: // required since gadgetclass attribute is [IS] - no support for [G]
129 *(opg->opg_Storage) = (ULONG) gg->Width;
130 break;
131 case GA_Height: // required since gadgetclass attribute is [IS] - no support for [G]
132 *(opg->opg_Storage) = (ULONG) gg->Height;
133 break;
134 default:
135 Success = DoSuperMethodA(cl, o, msg);
136 break;
139 return Success;
142 //----------------------------------------------------------------------------
144 static ULONG SeparatorGadget_Set(Class *cl, Object *o, Msg msg)
146 // struct CycleGadgetInstance *inst = INST_DATA(cl, o);
147 struct opSet *ops = (struct opSet *) msg;
148 struct TagItem *TagList = ops->ops_AttrList;
149 struct TagItem *tag;
150 struct Gadget *gg = (struct Gadget *) o;
151 BOOL NeedRerender = FALSE;
152 ULONG Result;
154 while ((tag = NextTagItem(&TagList)))
156 switch (tag->ti_Tag)
158 case GA_Disabled:
159 if ((tag->ti_Data && !(gg->Flags & GFLG_DISABLED)) ||
160 (!tag->ti_Data && (gg->Flags & GFLG_DISABLED)))
162 d1(KPrintF("%s/%s/%ld o=%l08x Flags=%08lx\n", __FILE__, __FUNC__, __LINE__, o, gg->Flags));
163 NeedRerender = TRUE;
165 break;
166 default:
167 break;
171 Result = DoSuperMethodA(cl, o, msg);
173 if (NeedRerender)
175 struct RastPort *rp;
177 rp = ObtainGIRPort(ops->ops_GInfo);
178 d1(KPrintF("%s/%s/%ld: o=%08lx rp=%08lx\n", __FILE__, __FUNC__, __LINE__, o, rp));
179 if (rp)
181 DoMethod(o,
182 GM_RENDER,
183 ops->ops_GInfo,
185 GREDRAW_UPDATE);
186 ReleaseGIRPort(rp);
190 return Result;
193 //----------------------------------------------------------------------------