add more arm feature flags
[AROS.git] / workbench / libs / gadtools / buttonclass.c
blob17dc22cb4ddf5117cd4b932d8403c7e7a283b151
1 /*
2 Copyright © 1995-2005, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Internal GadTools button class.
6 Lang: English
7 */
10 #include <proto/exec.h>
11 #include <exec/libraries.h>
12 #include <exec/memory.h>
13 #include <proto/dos.h>
14 #include <intuition/classes.h>
15 #include <intuition/classusr.h>
16 #include <intuition/gadgetclass.h>
17 #include <intuition/imageclass.h>
18 #include <intuition/intuition.h>
19 #include <intuition/cghooks.h>
20 #include <graphics/rastport.h>
21 #include <graphics/text.h>
22 #include <utility/tagitem.h>
23 #include <devices/inputevent.h>
24 #include <proto/alib.h>
25 #include <proto/utility.h>
27 #include <string.h> /* memset() */
29 #define SDEBUG 0
30 #define DEBUG 0
31 #include <aros/debug.h>
33 #include "gadtools_intern.h"
35 /**********************************************************************************************/
37 #define GadToolsBase ((struct GadToolsBase_intern *)cl->cl_UserData)
39 /**********************************************************************************************/
41 Object *GTButton__OM_NEW(Class * cl, Object * obj, struct opSet *msg)
43 struct ButtonData *data;
44 struct DrawInfo *dri;
45 struct Image *frame;
46 struct TagItem tags[] =
48 {IA_Width , 0UL },
49 {IA_Height , 0UL },
50 {IA_Resolution , 0UL },
51 {IA_FrameType , FRAME_BUTTON },
52 {TAG_DONE }
55 dri = (struct DrawInfo *) GetTagData(GA_DrawInfo, (IPTR) NULL, msg->ops_AttrList);
56 if (!dri)
57 return NULL;
59 tags[0].ti_Data = GetTagData(GA_Width, 0, msg->ops_AttrList);
60 tags[1].ti_Data = GetTagData(GA_Height, 0, msg->ops_AttrList);
61 tags[2].ti_Data = (dri->dri_Resolution.X << 16) + dri->dri_Resolution.Y;
62 frame = (struct Image *) NewObjectA(NULL, FRAMEICLASS, tags);
63 if (!frame)
64 return NULL;
66 tags[0].ti_Tag = GA_Image;
67 tags[0].ti_Data = (IPTR) frame;
68 tags[1].ti_Tag = TAG_MORE;
69 tags[1].ti_Data = (IPTR) msg->ops_AttrList;
70 obj = (Object *) DoSuperMethod(cl, obj, OM_NEW, (IPTR) tags, (IPTR) msg->ops_GInfo);
71 if (!obj) {
72 DisposeObject(frame);
73 return NULL;
75 data = INST_DATA(cl, obj);
76 data->dri = dri;
77 data->frame = frame;
79 return obj;
82 /**********************************************************************************************/
84 IPTR GTButton__OM_SET(Class * cl, Object * obj, struct opSet * msg)
86 IPTR retval = 0UL;
87 struct TagItem *tag, tags[2];
88 struct RastPort *rport;
90 /* Catch everything, but GA_Disabled. */
91 tag = FindTagItem(GA_Disabled, msg->ops_AttrList);
92 if (tag) {
93 tags[0].ti_Tag = GA_Disabled;
94 tags[0].ti_Data = tag->ti_Data;
95 tags[1].ti_Tag = TAG_DONE;
96 DoSuperMethod(cl, obj, OM_SET, (IPTR) tags, (IPTR) msg->ops_GInfo);
97 retval = TRUE;
100 /* Redraw the gadget, if an attribute was changed and if this is the
101 objects' base-class. */
102 if ((retval) && (OCLASS(obj) == cl)) {
103 rport = ObtainGIRPort(msg->ops_GInfo);
104 if (rport) {
105 DoMethod(obj, GM_RENDER, (IPTR) msg->ops_GInfo, (IPTR) rport, GREDRAW_UPDATE);
106 ReleaseGIRPort(rport);
107 retval = FALSE;
111 return retval;
114 /**********************************************************************************************/
116 IPTR GTButton__OM_GET(Class * cl, Object * obj, struct opGet *msg)
118 IPTR retval;
120 switch (msg->opg_AttrID)
122 case GTA_GadgetKind:
123 case GTA_ChildGadgetKind:
124 *(msg->opg_Storage) = BUTTON_KIND;
125 retval = 1UL;
126 break;
128 default:
129 retval = DoSuperMethodA(cl, obj, (Msg)msg);
130 break;
134 return retval;
137 /**********************************************************************************************/
139 IPTR GTButton__GM_RENDER(Class * cl, struct Gadget * g, struct gpRender * msg)
141 IPTR retval = 0UL;
142 UWORD old_gadgetflags;
143 struct IntuiText *old_gadgettext;
145 /* Georg Steger: Hack, because IntuiTexts are not centered
146 by button gadget class */
148 old_gadgetflags = g->Flags;
149 old_gadgettext = g->GadgetText;
151 g->Flags &= ~GFLG_LABELMASK;
152 g->Flags |= GFLG_LABELITEXT;
153 g->GadgetText = 0;
155 retval = DoSuperMethodA(cl, (Object *)g, (Msg)msg);
157 g->GadgetText = old_gadgettext;
158 g->Flags = old_gadgetflags;
160 renderlabel(GadToolsBase, g, msg->gpr_RPort, GV_LabelPlace_In);
162 return retval;
165 /**********************************************************************************************/
167 IPTR GTButton__OM_DISPOSE(Class * cl, Object * obj, Msg msg)
169 struct ButtonData *data = INST_DATA(cl, obj);
171 if (data->frame) DisposeObject(data->frame);
173 return DoSuperMethodA(cl, obj, msg);
176 /**********************************************************************************************/