Updated PCI IDs to latest snapshot.
[tangerine.git] / workbench / libs / gadtools / arrowclass.c
blobb1b58898c63b343bc6db91b2a6ac2fd2ddc10949
1 /*
2 Copyright © 1995-2005, The AROS Development Team. All rights reserved.
3 $Id$
5 Internal GadTools arrow class.
6 */
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() */
28 #if 0
29 #define SDEBUG 1
30 #define DEBUG 1
31 #endif
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[] =
48 {IA_Width , 0UL },
49 {IA_Height , 0UL },
50 {IA_Resolution , 0UL },
51 {IA_FrameType , FRAME_BUTTON },
52 {TAG_DONE }
55 struct TagItem itags[] =
57 {SYSIA_Which , 0 },
58 {SYSIA_DrawInfo , 0 },
59 {IA_Left , 0 },
60 {IA_Top , 0 },
61 {IA_Width , 0 },
62 {IA_Height , 0 },
63 {SYSIA_WithBorder, FALSE },
64 {SYSIA_Style , SYSISTYLE_GADTOOLS },
65 {TAG_DONE }
67 struct TagItem atags[] =
69 {GA_LabelImage , 0UL },
70 {GA_Image , 0UL },
71 {TAG_MORE }
73 WORD arrowtype;
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);
84 if (!frame)
85 return NULL;
87 D(dprintf("Arrow::New(): frame 0x%lx\n", frame));
89 #ifdef __MORPHOS__
92 * R.Schmidt
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;
98 int width, height;
99 struct TagItem setfitags[] =
101 {IA_Width , 0UL },
102 {IA_Height , 0UL },
103 {TAG_DONE }
106 contentbox.Left = 0;
107 contentbox.Top = 0;
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);
127 #endif
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);
133 if (!arrowimage)
134 goto failure;
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);
145 if (o)
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);
153 if (!data->scroller)
154 goto failure;
156 data->arrowimage = arrowimage;
157 data->frame = frame;
160 ReturnPtr("Arrow::New", Object *, o);
162 failure:
163 if (frame)
164 DisposeObject(frame);
165 if (arrowimage)
166 DisposeObject(arrowimage);
167 if (o)
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);
179 IPTR retval;
181 switch(msg->opg_AttrID)
183 case GTA_GadgetKind:
184 *(msg->opg_Storage) = data->gadgetkind;
185 retval = 1UL;
186 break;
188 case GTA_ChildGadgetKind:
189 *(msg->opg_Storage) = _ARROW_KIND;
190 retval = 1UL;
191 break;
193 case GTA_Arrow_Type:
194 *(msg->opg_Storage) = data->arrowtype;
195 retval = 1UL;
196 break;
198 case GTA_Arrow_Scroller:
199 *(msg->opg_Storage) = (IPTR)data->scroller;
200 retval = 1UL;
201 break;
203 default:
204 retval = DoSuperMethodA(cl, o, (Msg)msg);
205 break;
208 return retval;
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 /**********************************************************************************************/