Fixed binary search: no more infinite loops when vendor is unknown.
[tangerine.git] / workbench / hidds / graphics / GC_Class.c
blob8ad24f04ae0144cbbdcae1c111cb81b1280afd7a
1 /*
2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Graphics gc class implementation.
6 Lang: english
7 */
9 /****************************************************************************************/
11 #include <string.h>
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>
20 #include <oop/oop.h>
22 #include <hidd/graphics.h>
24 #include "graphics_intern.h"
26 #undef SDEBUG
27 #define SDEBUG 0
28 #undef DEBUG
29 #define DEBUG 0
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);
48 if(obj)
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); */
69 } /* if(obj) */
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;
80 ULONG idx;
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))
89 switch(idx)
91 case aoHidd_GC_Foreground:
92 data->fg = tag->ti_Data;
93 break;
95 case aoHidd_GC_Background:
96 data->bg = tag->ti_Data;
97 break;
99 case aoHidd_GC_DrawMode:
100 data->drMode = tag->ti_Data;
101 break;
103 case aoHidd_GC_Font:
104 data->font = (APTR) tag->ti_Data;
105 break;
107 case aoHidd_GC_ColorMask:
108 data->colMask = tag->ti_Data;
109 break;
111 case aoHidd_GC_LinePattern:
112 data->linePat = (UWORD) tag->ti_Data;
113 break;
115 case aoHidd_GC_LinePatternCnt:
116 data->linePatCnt = (UWORD) tag->ti_Data;
117 break;
119 case aoHidd_GC_PlaneMask:
120 data->planeMask = (APTR) tag->ti_Data;
121 break;
123 case aoHidd_GC_ColorExpansionMode:
124 data->colExp = tag->ti_Data;
125 break;
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);
138 ULONG idx;
140 EnterFunc(bug("GC::Get() attrID: %i storage: %p\n", msg->attrID, msg->storage));
142 if(IS_GC_ATTR(msg->attrID, idx))
144 switch(idx)
146 case aoHidd_GC_Foreground:
147 *msg->storage = data->fg;
148 break;
150 case aoHidd_GC_Background:
151 *msg->storage = data->bg;
152 break;
154 case aoHidd_GC_DrawMode:
155 *msg->storage = data->drMode;
156 break;
158 case aoHidd_GC_Font:
159 *msg->storage = (ULONG) data->font;
160 break;
162 case aoHidd_GC_ColorMask:
163 *msg->storage = data->colMask;
164 break;
166 case aoHidd_GC_LinePattern:
167 *msg->storage = data->linePat;
168 break;
170 case aoHidd_GC_LinePatternCnt:
171 *msg->storage = data->linePatCnt;
172 break;
174 case aoHidd_GC_PlaneMask:
175 *msg->storage = (ULONG) data->planeMask;
176 break;
178 case aoHidd_GC_ColorExpansionMode:
179 *msg->storage = data->colExp;
180 break;
182 default:
183 OOP_DoSuperMethod(cl, obj, (OOP_Msg) msg);
184 break;
187 else
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;
207 data->doClip = TRUE;
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 /****************************************************************************************/