define __KERNEL_STRICT_NAMES to avoid inclusion of kernel types on systems that carry...
[cake.git] / rom / intuition / fillrectclass.c
blob2b9ba66a83c2abad02b2232af1ac927c83b59da3
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$
6 AROS fillrectclass implementation.
7 */
9 #include <exec/types.h>
11 #include <intuition/intuition.h>
12 #include <intuition/intuitionbase.h>
13 #include <intuition/classes.h>
14 #include <intuition/classusr.h>
15 #include <intuition/imageclass.h>
17 #include <graphics/gfxbase.h>
18 #include <graphics/gfxmacros.h>
20 #include <utility/tagitem.h>
21 #include <utility/hooks.h>
23 #include <clib/macros.h>
25 #include <proto/exec.h>
26 #include <proto/intuition.h>
27 #include <proto/graphics.h>
28 #include <proto/utility.h>
30 #include <string.h>
32 #ifndef __MORPHOS__
33 #include <aros/asmcall.h>
34 #include <proto/alib.h>
35 #include "intuition_intern.h"
36 #endif /* !__MORPHOS__ */
38 #ifdef IntuitionBase
39 # undef IntuitionBase
40 #endif
42 #define IntuitionBase ((struct IntuitionBase *)(cl->cl_UserData))
44 /****************************************************************************/
46 IPTR fillrect_set(Class *cl, Object *obj, struct opSet *msg)
48 const struct TagItem *tstate = msg->ops_AttrList;
49 struct TagItem *tag;
50 struct FillRectData *data = INST_DATA(cl, obj);
52 IPTR retval = 0;
54 while((tag = NextTagItem(&tstate)))
56 switch(tag->ti_Tag)
58 case IA_APattern:
59 ((struct Image *)obj)->ImageData = (APTR)tag->ti_Data;
60 retval = 1;
61 break;
63 case IA_APatSize:
64 data->apatsize = (WORD)tag->ti_Data;
65 retval = 1;
66 break;
68 case IA_Mode:
69 data->mode = (WORD)tag->ti_Data;
70 retval = 1;
71 break;
75 return retval;
78 /****************************************************************************/
80 IPTR FillRectClass__IM_DRAW(Class *cl, Object *obj, struct impDraw *msg)
82 struct FillRectData *data = INST_DATA(cl, obj);
83 struct RastPort rp;
84 WORD x1, y1, x2, y2;
86 if (!((struct impDraw *)msg)->imp_RPort) return 0;
88 memcpy(&rp,((struct impDraw *)msg)->imp_RPort,sizeof (struct RastPort));
90 SetABPenDrMd(&rp, IM_FGPEN((struct Image *)obj),
91 IM_BGPEN((struct Image *)obj),
92 data->mode);
94 SetAfPt(&rp, (APTR)((struct Image *)obj)->ImageData, data->apatsize);
96 x1 = ((struct Image *)obj)->LeftEdge + ((struct impDraw *)msg)->imp_Offset.X;
97 y1 = ((struct Image *)obj)->TopEdge + ((struct impDraw *)msg)->imp_Offset.Y;
99 if (msg->MethodID == IM_DRAW)
101 x2 = x1 + ((struct Image *)obj)->Width - 1;
102 y2 = y1 + ((struct Image *)obj)->Height - 1;
104 else
106 x2 = x1 + msg->imp_Dimensions.Width - 1;
107 y2 = y1 + msg->imp_Dimensions.Height - 1;
110 RectFill(&rp, x1, y1, x2, y2);
112 return 0;
115 /****************************************************************************/
117 IPTR FillRectClass__OM_NEW(Class *cl, Object *obj, struct opSet *msg)
119 obj = (Object *)DoSuperMethodA(cl, obj, (Msg)msg);
120 if (obj)
121 fillrect_set(cl, obj, msg);
123 return (IPTR)obj;
126 /****************************************************************************/
128 IPTR FillRectClass__OM_SET(Class *cl, Object *obj, struct opSet *msg)
130 return fillrect_set(cl, obj, msg) + DoSuperMethodA(cl, obj, (Msg)msg);
133 /****************************************************************************/