2 Copyright © 1995-2005, The AROS Development Team. All rights reserved.
5 Desc: Internal GadTools button class.
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() */
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
;
46 struct TagItem tags
[] =
50 {IA_Resolution
, 0UL },
51 {IA_FrameType
, FRAME_BUTTON
},
55 dri
= (struct DrawInfo
*) GetTagData(GA_DrawInfo
, (IPTR
) NULL
, msg
->ops_AttrList
);
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
);
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
);
75 data
= INST_DATA(cl
, obj
);
82 /**********************************************************************************************/
84 IPTR
GTButton__OM_SET(Class
* cl
, Object
* obj
, struct opSet
* msg
)
87 struct TagItem
*tag
, tags
[2];
88 struct RastPort
*rport
;
90 /* Catch everything, but GA_Disabled. */
91 tag
= FindTagItem(GA_Disabled
, msg
->ops_AttrList
);
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
);
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
);
105 DoMethod(obj
, GM_RENDER
, (IPTR
) msg
->ops_GInfo
, (IPTR
) rport
, GREDRAW_UPDATE
);
106 ReleaseGIRPort(rport
);
114 /**********************************************************************************************/
116 IPTR
GTButton__OM_GET(Class
* cl
, Object
* obj
, struct opGet
*msg
)
120 switch (msg
->opg_AttrID
)
123 case GTA_ChildGadgetKind
:
124 *(msg
->opg_Storage
) = BUTTON_KIND
;
129 retval
= DoSuperMethodA(cl
, obj
, (Msg
)msg
);
137 /**********************************************************************************************/
139 IPTR
GTButton__GM_RENDER(Class
* cl
, struct Gadget
* g
, struct gpRender
* msg
)
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
;
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
);
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 /**********************************************************************************************/