2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
5 Desc: Graphics gc class implementation.
9 /****************************************************************************************/
13 #include <proto/exec.h>
14 #include <proto/utility.h>
15 #include <proto/oop.h>
17 #include <exec/memory.h>
18 #include <graphics/text.h>
19 #include <utility/tagitem.h>
22 #include <hidd/graphics.h>
24 #include "graphics_intern.h"
30 #include <aros/debug.h>
32 /****************************************************************************************/
34 VOID
GC__Root__Set(OOP_Class
*cl
, OOP_Object
*obj
, struct pRoot_Set
*msg
);
36 #define IS_GC_ATTR(attr, idx) ( ( (idx) = (attr) - HiddGCAttrBase) < num_Hidd_GC_Attrs)
38 /****************************************************************************************/
40 OOP_Object
*GC__Root__New(OOP_Class
*cl
, OOP_Object
*obj
, struct pRoot_New
*msg
)
42 HIDDT_GC_Intern
*data
;
44 EnterFunc(bug("GC::New()\n"));
46 obj
= (OOP_Object
*) OOP_DoSuperMethod(cl
, obj
, (OOP_Msg
) msg
);
50 data
= OOP_INST_DATA(cl
, obj
);
52 /* clear all data and set some default values */
54 memset(data
, 0, sizeof (*data
));
56 data
->fg
= 1; /* foreground color */
57 data
->bg
= 0; /* background color */
58 data
->drMode
= vHidd_GC_DrawMode_Copy
; /* drawmode */
59 data
->font
= NULL
; /* current fonts */
60 data
->colMask
= ~0; /* ColorMask prevents some color bits from changing*/
61 data
->linePat
= ~0; /* LinePattern */
62 data
->planeMask
= NULL
; /* Pointer to a shape bitMap */
64 /* Override defaults with user suplied attrs */
66 OOP_SetAttrs(obj
, msg
->attrList
);
67 /* GC__Root__Set(cl, obj, &set_msg); */
71 ReturnPtr("GC::New", OOP_Object
*, obj
);
74 /****************************************************************************************/
76 VOID
GC__Root__Set(OOP_Class
*cl
, OOP_Object
*obj
, struct pRoot_Set
*msg
)
78 HIDDT_GC_Intern
*data
= OOP_INST_DATA(cl
, obj
);
79 struct TagItem
*tag
, *tstate
;
82 EnterFunc(bug("GC::Set()\n"));
84 tstate
= msg
->attrList
;
85 while((tag
= NextTagItem((const struct TagItem
**)&tstate
)))
87 if(IS_GC_ATTR(tag
->ti_Tag
, idx
))
91 case aoHidd_GC_Foreground
:
92 data
->fg
= tag
->ti_Data
;
95 case aoHidd_GC_Background
:
96 data
->bg
= tag
->ti_Data
;
99 case aoHidd_GC_DrawMode
:
100 data
->drMode
= tag
->ti_Data
;
104 data
->font
= (APTR
) tag
->ti_Data
;
107 case aoHidd_GC_ColorMask
:
108 data
->colMask
= tag
->ti_Data
;
111 case aoHidd_GC_LinePattern
:
112 data
->linePat
= (UWORD
) tag
->ti_Data
;
115 case aoHidd_GC_LinePatternCnt
:
116 data
->linePatCnt
= (UWORD
) tag
->ti_Data
;
119 case aoHidd_GC_PlaneMask
:
120 data
->planeMask
= (APTR
) tag
->ti_Data
;
123 case aoHidd_GC_ColorExpansionMode
:
124 data
->colExp
= tag
->ti_Data
;
130 ReturnVoid("GC::Set");
133 /****************************************************************************************/
135 VOID
GC__Root__Get(OOP_Class
*cl
, OOP_Object
*obj
, struct pRoot_Get
*msg
)
137 HIDDT_GC_Intern
*data
= OOP_INST_DATA(cl
, obj
);
140 EnterFunc(bug("GC::Get() attrID: %i storage: %p\n", msg
->attrID
, msg
->storage
));
142 if(IS_GC_ATTR(msg
->attrID
, idx
))
146 case aoHidd_GC_Foreground
:
147 *msg
->storage
= data
->fg
;
150 case aoHidd_GC_Background
:
151 *msg
->storage
= data
->bg
;
154 case aoHidd_GC_DrawMode
:
155 *msg
->storage
= data
->drMode
;
159 *msg
->storage
= (ULONG
) data
->font
;
162 case aoHidd_GC_ColorMask
:
163 *msg
->storage
= data
->colMask
;
166 case aoHidd_GC_LinePattern
:
167 *msg
->storage
= data
->linePat
;
170 case aoHidd_GC_LinePatternCnt
:
171 *msg
->storage
= data
->linePatCnt
;
174 case aoHidd_GC_PlaneMask
:
175 *msg
->storage
= (ULONG
) data
->planeMask
;
178 case aoHidd_GC_ColorExpansionMode
:
179 *msg
->storage
= data
->colExp
;
183 OOP_DoSuperMethod(cl
, obj
, (OOP_Msg
) msg
);
189 OOP_DoSuperMethod(cl
, obj
, (OOP_Msg
) msg
);
194 /****************************************************************************************/
196 VOID
GC__Hidd_GC__SetClipRect(OOP_Class
*cl
, OOP_Object
*o
, struct pHidd_GC_SetClipRect
*msg
)
198 HIDDT_GC_Intern
*data
;
200 data
= OOP_INST_DATA(cl
, o
);
202 data
->clipX1
= msg
->x1
;
203 data
->clipY1
= msg
->y1
;
204 data
->clipX2
= msg
->x2
;
205 data
->clipY2
= msg
->y2
;
210 /****************************************************************************************/
212 VOID
GC__Hidd_GC__UnsetClipRect(OOP_Class
*cl
, OOP_Object
*o
, struct pHidd_GC_UnsetClipRect
*msg
)
214 HIDDT_GC_Intern
*data
;
216 data
= OOP_INST_DATA(cl
, o
);
218 data
->doClip
= FALSE
;
222 /****************************************************************************************/