try to make sure compiler/include/mmakefile is always refreshed correctly.
[AROS.git] / rom / intuition / imageclass.c
blob153ff809ed96ae8ac57cf4b3683e0413f9335d15
1 /*
2 Copyright © 1995-2011, The AROS Development Team. All rights reserved.
3 Copyright © 2001-2003, The MorphOS Development Team. All Rights Reserved.
4 $Id$
5 */
7 #ifdef _SASC
9 #define USE_SYSBASE
10 #define USE_BUILTIN_MATH
11 #define INTUI_V36_NAMES_ONLY
13 #endif
15 #include <exec/types.h>
17 #include <dos/dos.h>
18 #include <dos/dosextens.h>
20 #include <intuition/intuition.h>
21 #include <intuition/intuitionbase.h>
22 #include <intuition/classes.h>
23 #include <intuition/classusr.h>
24 #include <intuition/imageclass.h>
25 #include <intuition/cghooks.h>
26 #include <intuition/icclass.h>
28 #include <graphics/gfxbase.h>
29 #include <graphics/gfxmacros.h>
31 #include <utility/tagitem.h>
32 #include <utility/hooks.h>
34 #include <clib/macros.h>
36 #include <string.h>
38 #include <proto/exec.h>
39 #include <proto/intuition.h>
40 #include <proto/graphics.h>
41 #include <proto/utility.h>
43 #ifndef __MORPHOS__
44 #include "intuition_intern.h"
45 #include <aros/asmcall.h>
46 #include <proto/alib.h>
47 #endif /* !__MORPHOS__ */
49 /***********************************************************************************/
51 #define DEBUG_HIT(x) ;
53 /***********************************************************************************/
55 IPTR _om_set(Class *cl, struct Image *im, struct TagItem *tags)
57 struct IntuitionBase *IntuitionBase = (struct IntuitionBase *)cl->cl_UserData;
58 struct Library *UtilityBase = GetPrivIBase(IntuitionBase)->UtilityBase;
59 struct TagItem *tstate = tags;
60 struct TagItem *tag;
61 IPTR tidata;
62 BOOL unsupported = FALSE;
64 while ((tag = NextTagItem(&tstate)))
66 tidata = tag->ti_Data;
68 switch (tag->ti_Tag)
70 case IA_Left:
71 im->LeftEdge = (WORD) tidata;
72 break;
74 case IA_Top:
75 im->TopEdge = (WORD) tidata;
76 break;
78 case IA_Width:
79 im->Width = (WORD) tidata;
80 break;
82 case IA_Height:
83 im->Height = (WORD) tidata;
84 break;
86 case IA_FGPen:
87 im->PlanePick = (WORD) tidata;
88 break;
90 case IA_BGPen:
91 im->PlaneOnOff = (WORD) tidata;
92 break;
94 case IA_Data:
95 im->ImageData = (UWORD *) tidata;
96 break;
98 default:
99 unsupported = TRUE;
100 break;
102 } /* switch (Tag) */
104 } /* while (Tag) */
107 * If all attributes were supported and there is no retval yet,
108 * set retval to 1.
110 if (!unsupported)
111 return (IPTR)1;
112 else
113 return (IPTR)0;
116 IPTR ImageClass__OM_NEW(Class *cl, Object *o, struct opSet *msg)
118 struct Image *im;
120 D(kprintf("ImageClass OM_NEW\n"));
122 if (cl)
124 im = (struct Image *)DoSuperMethodA(cl, o, (Msg)msg);
126 if(im)
129 * This is how Intuition knows an image is a boopsi
130 * object!
133 * The instance object is contains cleared memory!
134 * memset ((void *)retval, 0, (cl->cl_InstOffset + cl->cl_InstSize));
136 im->Width = 80;
137 im->Height = 40;
138 im->Depth = CUSTOMIMAGEDEPTH;
140 _om_set(cl, im, msg->ops_AttrList);
142 return (IPTR)im;
144 else
145 return (IPTR)NULL;
147 else
148 return (IPTR)NULL;
151 IPTR ImageClass__OM_SET(Class *cl, struct Image *im, struct opSet *msg)
153 D( kprintf("ImageClass OM_SET\n") );
156 * Because we are a direct subclass of rootclass
157 * which has no settable/gettable attributes we
158 * we will NOT pass this method to our superclass!
160 return _om_set(cl, im, msg->ops_AttrList);
163 IPTR ImageClass__OM_GET(Class *cl, struct Image *im, struct opGet *msg)
165 D( kprintf("ImageClass OM_GET\n") );
167 switch (msg->opg_AttrID)
169 case IA_Left:
170 *msg->opg_Storage = (IPTR) im->LeftEdge;
171 break;
173 case IA_Top:
174 *msg->opg_Storage = (IPTR) im->TopEdge;
175 break;
177 case IA_Width:
178 *msg->opg_Storage = (IPTR) im->Width;
179 break;
181 case IA_Height:
182 *msg->opg_Storage = (IPTR) im->Height;
183 break;
185 case IA_FGPen:
186 *msg->opg_Storage = (IPTR) im->PlanePick;
187 break;
189 case IA_BGPen:
190 *msg->opg_Storage = (IPTR) im->PlaneOnOff;
191 break;
193 case IA_Data:
194 *msg->opg_Storage = (IPTR) im->ImageData;
195 break;
197 default:
198 return (IPTR)0;
199 } /* switch */
202 * Because we are a direct subclass of rootclass
203 * which has no settable/gettable attributes we
204 * we will NOT pass this method to our superclass!
206 return (IPTR)1;
209 IPTR ImageClass__IM_ERASE(Class *cl, struct Image *im, struct impErase *msg)
212 * Both erase methods are documented as handled the same
213 * at this level, so we will fall thru...
215 struct IntuitionBase *IntuitionBase = (struct IntuitionBase *)cl->cl_UserData;
216 struct GfxBase *GfxBase = GetPrivIBase(IntuitionBase)->GfxBase;
217 WORD left, top, width, height;
219 D(kprintf("ImageClass IM_ERASE(FRAME)\n") );
221 left = im->LeftEdge + msg->imp_Offset.X;
222 top = im->TopEdge + msg->imp_Offset.Y;
223 width = im->Width - 1;
224 height = im->Height - 1;
226 if (msg->imp_RPort)
228 EraseRect(msg->imp_RPort,
229 left, top,
230 left + width, top + height
234 return (IPTR)0;
237 IPTR ImageClass__IM_HITTEST(Class *cl, struct Image *im, struct impHitTest *imp)
239 int hit;
242 * Loosing my sanity, better check that I do not
243 * have my X/Y mixed up here. :)
245 hit = (imp->imp_Point.X >= im->LeftEdge && imp->imp_Point.X < im->LeftEdge + im->Width)
246 && (imp->imp_Point.Y >= im->TopEdge && imp->imp_Point.Y < im->TopEdge + im->Height)
249 DEBUG_HIT(dprintf("image: HITTEST %d %d (%d,%d) %d×%d = %d\n", imp->imp_Point.X, imp->imp_Point.Y,
250 im->LeftEdge, im->TopEdge, im->Width, im->Height, hit));
252 return (IPTR)hit;
255 /***********************************************************************************/