2 Copyright © 1995-2005, The AROS Development Team. All rights reserved.
5 Internal GadTools arrow class.
9 #include <proto/exec.h>
10 #include <exec/libraries.h>
11 #include <exec/memory.h>
12 #include <proto/dos.h>
13 #include <intuition/classes.h>
14 #include <intuition/classusr.h>
15 #include <intuition/gadgetclass.h>
16 #include <intuition/imageclass.h>
17 #include <intuition/intuition.h>
18 #include <intuition/cghooks.h>
19 #include <graphics/rastport.h>
20 #include <graphics/text.h>
21 #include <utility/tagitem.h>
22 #include <devices/inputevent.h>
23 #include <proto/alib.h>
24 #include <proto/utility.h>
26 #include <string.h> /* memset() */
32 #include <aros/debug.h>
34 #include "gadtools_intern.h"
36 /**********************************************************************************************/
38 #define GadToolsBase ((struct GadToolsBase_intern *)cl->cl_UserData)
40 /**********************************************************************************************/
42 Object
*GTArrow__OM_NEW(Class
* cl
, Object
* o
, struct opSet
*msg
)
44 struct DrawInfo
*dri
= (struct DrawInfo
*)GetTagData(GA_DrawInfo
, (IPTR
) NULL
, msg
->ops_AttrList
);
45 Object
*frame
= NULL
, *arrowimage
= NULL
;
46 struct TagItem fitags
[] =
50 {IA_Resolution
, 0UL },
51 {IA_FrameType
, FRAME_BUTTON
},
55 struct TagItem itags
[] =
58 {SYSIA_DrawInfo
, 0 },
63 {SYSIA_WithBorder
, FALSE
},
64 {SYSIA_Style
, SYSISTYLE_GADTOOLS
},
67 struct TagItem atags
[] =
69 {GA_LabelImage
, 0UL },
75 EnterFunc(bug("Arrow::New()\n"));
77 fitags
[0].ti_Data
= itags
[4].ti_Data
= GetTagData(GA_Width
, 0, msg
->ops_AttrList
);
78 fitags
[1].ti_Data
= itags
[5].ti_Data
= GetTagData(GA_Height
, 0, msg
->ops_AttrList
);
79 fitags
[2].ti_Data
= (dri
->dri_Resolution
.X
<< 16) + dri
->dri_Resolution
.Y
;
81 D(bug("Arrow::New(): create dims=(%d, %d, %d, %d)\n",itags
[2].ti_Data
,itags
[3].ti_Data
,itags
[4].ti_Data
,itags
[5].ti_Data
));
83 frame
= NewObjectA(NULL
, FRAMEICLASS
, fitags
);
87 D(dprintf("Arrow::New(): frame 0x%lx\n", frame
));
93 * we need to to tell the frame that the given coordinates are the max
94 * We should probably also set the new IA_Width,IA_Height in the frameclass
96 struct IBox contentbox
, framebox
;
97 struct impFrameBox method
;
99 struct TagItem setfitags
[] =
108 contentbox
.Width
= fitags
[0].ti_Data
;
109 contentbox
.Height
= fitags
[1].ti_Data
;
110 method
.MethodID
= IM_FRAMEBOX
;
111 method
.imp_ContentsBox
= &contentbox
;
112 method
.imp_FrameBox
= &framebox
;
113 method
.imp_DrInfo
= dri
;
114 method
.imp_FrameFlags
= 0;
116 D(dprintf("Arrow::New(): get real framesize\n"));
118 if (DoMethodA(frame
, (Msg
)&method
))
120 D(dprintf("Arrow::New: FrameSize w=%d h=%d l=%d t=%d\n", framebox
.Width
, framebox
.Height
, framebox
.Left
, framebox
.Top
));
121 setfitags
[0].ti_Data
= itags
[4].ti_Data
= itags
[4].ti_Data
- (framebox
.Width
- itags
[4].ti_Data
);
122 setfitags
[1].ti_Data
= itags
[5].ti_Data
= itags
[5].ti_Data
- (framebox
.Height
- itags
[5].ti_Data
);
123 D(dprintf("Arrow::New: New Arrow Size w=%d h=%d\n", setfitags
[0].ti_Data
, setfitags
[1].ti_Data
));
124 SetAttrsA(frame
,setfitags
);
129 itags
[0].ti_Data
= arrowtype
= GetTagData(GTA_Arrow_Type
, LEFTIMAGE
, msg
->ops_AttrList
);
130 itags
[1].ti_Data
= (IPTR
)dri
;
132 arrowimage
= NewObjectA(NULL
, SYSICLASS
, itags
);
136 #define IM(o) ((struct Image *)o)
137 D(bug("Arrow::New(): arrowimage %p, dims=(%d, %d, %d, %d)\n",
138 arrowimage
, IM(arrowimage
)->LeftEdge
, IM(arrowimage
)->TopEdge
, IM(arrowimage
)->Width
, IM(arrowimage
)->Height
));
140 atags
[0].ti_Data
= (IPTR
)arrowimage
;
141 atags
[1].ti_Data
= (IPTR
)frame
;
142 atags
[2].ti_Data
= (IPTR
)msg
->ops_AttrList
;
144 o
= (Object
*)DoSuperMethod(cl
, o
, OM_NEW
, (IPTR
) atags
, (IPTR
) NULL
);
147 struct ArrowData
*data
= INST_DATA(cl
, o
);
149 D(bug("Arrow::New(): Got object from superclass: %p\n", o
));
150 data
->gadgetkind
= GetTagData(GTA_GadgetKind
, 0, msg
->ops_AttrList
);
151 data
->arrowtype
= arrowtype
;
152 data
->scroller
= (Object
*)GetTagData(GTA_Arrow_Scroller
, (IPTR
) NULL
, msg
->ops_AttrList
);
156 data
->arrowimage
= arrowimage
;
160 ReturnPtr("Arrow::New", Object
*, o
);
164 DisposeObject(frame
);
166 DisposeObject(arrowimage
);
168 CoerceMethod(cl
, o
, OM_DISPOSE
);
170 ReturnPtr("Arrow::New", Object
*, NULL
);
174 /**********************************************************************************************/
176 IPTR
GTArrow__OM_GET(Class
* cl
, Object
* o
, struct opGet
*msg
)
178 struct ArrowData
*data
= INST_DATA(cl
, o
);
181 switch(msg
->opg_AttrID
)
184 *(msg
->opg_Storage
) = data
->gadgetkind
;
188 case GTA_ChildGadgetKind
:
189 *(msg
->opg_Storage
) = _ARROW_KIND
;
194 *(msg
->opg_Storage
) = data
->arrowtype
;
198 case GTA_Arrow_Scroller
:
199 *(msg
->opg_Storage
) = (IPTR
)data
->scroller
;
204 retval
= DoSuperMethodA(cl
, o
, (Msg
)msg
);
211 /**********************************************************************************************/
213 IPTR
GTArrow__OM_DISPOSE(Class
* cl
, Object
* o
, Msg msg
)
215 struct ArrowData
*data
= INST_DATA(cl
, o
);
217 if (data
->frame
) DisposeObject(data
->frame
);
218 if (data
->arrowimage
) DisposeObject(data
->arrowimage
);
220 return DoSuperMethodA(cl
, o
, msg
);
223 /**********************************************************************************************/