2 Copyright © 1995-2005, The AROS Development Team. All rights reserved.
3 Copyright © 2001-2003, The MorphOS Development Team. All Rights Reserved.
10 #define USE_BUILTIN_MATH
11 #define INTUI_V36_NAMES_ONLY
15 #include <exec/types.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>
38 #include <proto/exec.h>
39 #include <proto/intuition.h>
40 #include <proto/graphics.h>
41 #include <proto/utility.h>
44 #include "intuition_intern.h"
45 #include <aros/asmcall.h>
46 #include <proto/alib.h>
47 #endif /* !__MORPHOS__ */
49 /***********************************************************************************/
51 /* Set if to 1 to enable kprintf debugging
59 #define DEBUG_HIT(x) ;
61 /***********************************************************************************/
64 #define IntuitionBase ((struct IntuitionBase *)(cl->cl_UserData))
66 /***********************************************************************************/
68 IPTR
_om_set(Class
*cl
, struct Image
*im
, struct TagItem
*tags
)
70 struct TagItem
*tstate
= tags
;
73 BOOL unsupported
= FALSE
;
75 while ((tag
= NextTagItem((const struct TagItem
**)&tstate
)))
77 tidata
= tag
->ti_Data
;
82 im
->LeftEdge
= (WORD
) tidata
;
86 im
->TopEdge
= (WORD
) tidata
;
90 im
->Width
= (WORD
) tidata
;
94 im
->Height
= (WORD
) tidata
;
98 im
->PlanePick
= (WORD
) tidata
;
102 im
->PlaneOnOff
= (WORD
) tidata
;
106 im
->ImageData
= (UWORD
*) tidata
;
118 * If all attributes were supported and there is no retval yet,
127 IPTR
ImageClass__OM_NEW(Class
*cl
, Object
*o
, struct opSet
*msg
)
131 D(kprintf("ImageClass OM_NEW\n"));
135 im
= (struct Image
*)DoSuperMethodA(cl
, o
, (Msg
)msg
);
140 * This is how Intuition knows an image is a boopsi
144 * The instance object is contains cleared memory!
145 * memset ((void *)retval, 0, (cl->cl_InstOffset + cl->cl_InstSize));
149 im
->Depth
= CUSTOMIMAGEDEPTH
;
151 _om_set(cl
, im
, msg
->ops_AttrList
);
162 IPTR
ImageClass__OM_SET(Class
*cl
, struct Image
*im
, struct opSet
*msg
)
164 D( kprintf("ImageClass OM_SET\n") );
167 * Because we are a direct subclass of rootclass
168 * which has no settable/gettable attributes we
169 * we will NOT pass this method to our superclass!
171 return _om_set(cl
, im
, msg
->ops_AttrList
);
174 IPTR
ImageClass__OM_GET(Class
*cl
, struct Image
*im
, struct opGet
*msg
)
176 D( kprintf("ImageClass OM_GET\n") );
178 switch (msg
->opg_AttrID
)
181 *msg
->opg_Storage
= (IPTR
) im
->LeftEdge
;
185 *msg
->opg_Storage
= (IPTR
) im
->TopEdge
;
189 *msg
->opg_Storage
= (IPTR
) im
->Width
;
193 *msg
->opg_Storage
= (IPTR
) im
->Height
;
197 *msg
->opg_Storage
= (IPTR
) im
->PlanePick
;
201 *msg
->opg_Storage
= (IPTR
) im
->PlaneOnOff
;
205 *msg
->opg_Storage
= (IPTR
) im
->ImageData
;
213 * Because we are a direct subclass of rootclass
214 * which has no settable/gettable attributes we
215 * we will NOT pass this method to our superclass!
220 IPTR
ImageClass__IM_ERASE(Class
*cl
, struct Image
*im
, struct impErase
*msg
)
223 * Both erase methods are documented as handled the same
224 * at this level, so we will fall thru...
226 WORD left
, top
, width
, height
;
228 D(kprintf("ImageClass IM_ERASE(FRAME)\n") );
230 left
= im
->LeftEdge
+ msg
->imp_Offset
.X
;
231 top
= im
->TopEdge
+ msg
->imp_Offset
.Y
;
232 width
= im
->Width
- 1;
233 height
= im
->Height
- 1;
237 EraseRect(msg
->imp_RPort
,
239 left
+ width
, top
+ height
246 IPTR
ImageClass__IM_HITTEST(Class
*cl
, struct Image
*im
, struct impHitTest
*imp
)
251 * Loosing my sanity, better check that I do not
252 * have my X/Y mixed up here. :)
254 hit
= (imp
->imp_Point
.X
>= im
->LeftEdge
&& imp
->imp_Point
.X
< im
->LeftEdge
+ im
->Width
)
255 && (imp
->imp_Point
.Y
>= im
->TopEdge
&& imp
->imp_Point
.Y
< im
->TopEdge
+ im
->Height
)
258 DEBUG_HIT(dprintf("image: HITTEST %d %d (%d,%d) %d×%d = %d\n", imp
->imp_Point
.X
, imp
->imp_Point
.Y
,
259 im
->LeftEdge
, im
->TopEdge
, im
->Width
, im
->Height
, hit
));
264 /***********************************************************************************/