Added kernel module for starting the usb stack at boot time. It's not activated thoug...
[cake.git] / rom / intuition / imageclass.c
blob1de307890cab561dcf521e49d73642360f7ca808
1 /*
2 Copyright © 1995-2005, 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 /* Set if to 1 to enable kprintf debugging
53 #if 0
54 #define D(x) x
55 #else
56 #define D(x)
57 #endif
59 #define DEBUG_HIT(x) ;
61 /***********************************************************************************/
63 #undef IntuitionBase
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;
71 struct TagItem *tag;
72 IPTR tidata;
73 BOOL unsupported = FALSE;
75 while ((tag = NextTagItem((const struct TagItem **)&tstate)))
77 tidata = tag->ti_Data;
79 switch (tag->ti_Tag)
81 case IA_Left:
82 im->LeftEdge = (WORD) tidata;
83 break;
85 case IA_Top:
86 im->TopEdge = (WORD) tidata;
87 break;
89 case IA_Width:
90 im->Width = (WORD) tidata;
91 break;
93 case IA_Height:
94 im->Height = (WORD) tidata;
95 break;
97 case IA_FGPen:
98 im->PlanePick = (WORD) tidata;
99 break;
101 case IA_BGPen:
102 im->PlaneOnOff = (WORD) tidata;
103 break;
105 case IA_Data:
106 im->ImageData = (UWORD *) tidata;
107 break;
109 default:
110 unsupported = TRUE;
111 break;
113 } /* switch (Tag) */
115 } /* while (Tag) */
118 * If all attributes were supported and there is no retval yet,
119 * set retval to 1.
121 if (!unsupported)
122 return (IPTR)1;
123 else
124 return (IPTR)0;
127 IPTR ImageClass__OM_NEW(Class *cl, Object *o, struct opSet *msg)
129 struct Image *im;
131 D(kprintf("ImageClass OM_NEW\n"));
133 if (cl)
135 im = (struct Image *)DoSuperMethodA(cl, o, (Msg)msg);
137 if(im)
140 * This is how Intuition knows an image is a boopsi
141 * object!
144 * The instance object is contains cleared memory!
145 * memset ((void *)retval, 0, (cl->cl_InstOffset + cl->cl_InstSize));
147 im->Width = 80;
148 im->Height = 40;
149 im->Depth = CUSTOMIMAGEDEPTH;
151 _om_set(cl, im, msg->ops_AttrList);
153 return (IPTR)im;
155 else
156 return (IPTR)NULL;
158 else
159 return (IPTR)NULL;
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)
180 case IA_Left:
181 *msg->opg_Storage = (IPTR) im->LeftEdge;
182 break;
184 case IA_Top:
185 *msg->opg_Storage = (IPTR) im->TopEdge;
186 break;
188 case IA_Width:
189 *msg->opg_Storage = (IPTR) im->Width;
190 break;
192 case IA_Height:
193 *msg->opg_Storage = (IPTR) im->Height;
194 break;
196 case IA_FGPen:
197 *msg->opg_Storage = (IPTR) im->PlanePick;
198 break;
200 case IA_BGPen:
201 *msg->opg_Storage = (IPTR) im->PlaneOnOff;
202 break;
204 case IA_Data:
205 *msg->opg_Storage = (IPTR) im->ImageData;
206 break;
208 default:
209 return (IPTR)0;
210 } /* switch */
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!
217 return (IPTR)1;
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;
235 if (msg->imp_RPort)
237 EraseRect(msg->imp_RPort,
238 left, top,
239 left + width, top + height
243 return (IPTR)0;
246 IPTR ImageClass__IM_HITTEST(Class *cl, struct Image *im, struct impHitTest *imp)
248 int hit;
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));
261 return (IPTR)hit;
264 /***********************************************************************************/