2 Copyright © 1995-2011, 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 #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
;
62 BOOL unsupported
= FALSE
;
64 while ((tag
= NextTagItem(&tstate
)))
66 tidata
= tag
->ti_Data
;
71 im
->LeftEdge
= (WORD
) tidata
;
75 im
->TopEdge
= (WORD
) tidata
;
79 im
->Width
= (WORD
) tidata
;
83 im
->Height
= (WORD
) tidata
;
87 im
->PlanePick
= (WORD
) tidata
;
91 im
->PlaneOnOff
= (WORD
) tidata
;
95 im
->ImageData
= (UWORD
*) tidata
;
107 * If all attributes were supported and there is no retval yet,
116 IPTR
ImageClass__OM_NEW(Class
*cl
, Object
*o
, struct opSet
*msg
)
120 D(kprintf("ImageClass OM_NEW\n"));
124 im
= (struct Image
*)DoSuperMethodA(cl
, o
, (Msg
)msg
);
129 * This is how Intuition knows an image is a boopsi
133 * The instance object is contains cleared memory!
134 * memset ((void *)retval, 0, (cl->cl_InstOffset + cl->cl_InstSize));
138 im
->Depth
= CUSTOMIMAGEDEPTH
;
140 _om_set(cl
, im
, msg
->ops_AttrList
);
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
)
170 *msg
->opg_Storage
= (IPTR
) im
->LeftEdge
;
174 *msg
->opg_Storage
= (IPTR
) im
->TopEdge
;
178 *msg
->opg_Storage
= (IPTR
) im
->Width
;
182 *msg
->opg_Storage
= (IPTR
) im
->Height
;
186 *msg
->opg_Storage
= (IPTR
) im
->PlanePick
;
190 *msg
->opg_Storage
= (IPTR
) im
->PlaneOnOff
;
194 *msg
->opg_Storage
= (IPTR
) im
->ImageData
;
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!
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;
228 EraseRect(msg
->imp_RPort
,
230 left
+ width
, top
+ height
237 IPTR
ImageClass__IM_HITTEST(Class
*cl
, struct Image
*im
, struct impHitTest
*imp
)
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
));
255 /***********************************************************************************/