Fixed binary search: no more infinite loops when vendor is unknown.
[tangerine.git] / workbench / libs / asl / eraserclass.c
blob2479df2c8429958a5fd52f40fa4241246dc76bd6
1 /*
2 Copyright © 1995-2005, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc:
6 Lang: english
7 */
9 #include <proto/exec.h>
10 #include <proto/utility.h>
11 #include <proto/intuition.h>
12 #include <proto/graphics.h>
13 #include <proto/layers.h>
15 #include <exec/memory.h>
16 #include <intuition/screens.h>
17 #include <intuition/cghooks.h>
18 #include <intuition/imageclass.h>
19 #include <intuition/gadgetclass.h>
20 #include <graphics/gfx.h>
22 #include <string.h>
24 #include "asl_intern.h"
25 #include "layout.h"
27 #define SDEBUG 0
28 #define DEBUG 0
30 #include <aros/debug.h>
33 #ifdef __MORPHOS__
34 #ifndef NewRectRegion
35 #define NewRectRegion(_MinX,_MinY,_MaxX,_MaxY) \
36 ({ struct Region *_region; \
37 if ((_region = NewRegion())) \
38 { struct Rectangle _rect; \
39 _rect.MinX = _MinX; \
40 _rect.MinY = _MinY; \
41 _rect.MaxX = _MaxX; \
42 _rect.MaxY = _MaxY; \
43 if (!OrRectRegion(_region, &_rect)) { DisposeRegion(_region); _region = NULL; } \
44 } \
45 _region; \
47 #endif
48 #endif
51 #define CLASS_ASLBASE ((struct AslBase_intern *)cl->cl_UserData)
52 #define HOOK_ASLBASE ((struct AslBase_intern *)hook->h_Data)
54 #define AslBase CLASS_ASLBASE
56 /********************** ASL ERASER CLASS **************************************************/
58 IPTR AslEraser__OM_NEW(Class * cl, Object * o, struct opSet * msg)
60 struct Gadget *g = (struct Gadget *)DoSuperMethodA(cl, o, (Msg)msg);
62 if (g)
64 g->Flags |= GFLG_RELSPECIAL;
66 g->LeftEdge = 20000;
67 g->TopEdge = 20000;
68 g->Width = 1;
69 g->Height = 1;
71 } /* if (g) */
73 return (IPTR)g;
76 /***********************************************************************************/
78 IPTR AslEraser__GM_HITTEST(Class *cl, Object *o, struct gpHitTest *msg)
80 return 0;
84 /***********************************************************************************/
86 IPTR AslEraser__GM_RENDER(Class *cl, Object *o, struct gpRender *msg)
88 WORD x, y, w, h, x2, y2;
90 if (msg->gpr_Redraw == GREDRAW_REDRAW)
92 struct Window *win = msg->gpr_GInfo->gi_Window;
93 struct RastPort *rp = msg->gpr_RPort;
94 struct Region *clip;
96 if ((clip = NewRectRegion(win->BorderLeft,
97 win->BorderTop,
98 win->Width - 1 - win->BorderRight,
99 win->Height - 1 - win->BorderBottom)))
101 struct Gadget *g = win->FirstGadget;
102 struct RegionRectangle *rr;
104 while(g)
106 struct Rectangle rect;
108 getgadgetbounds(g, msg->gpr_GInfo, &x, &y, &w, &h);
110 rect.MinX = x;
111 rect.MinY = y;
112 rect.MaxX = x + w - 1;
113 rect.MaxY = y + h - 1;
115 ClearRectRegion(clip, &rect);
117 g = g->NextGadget;
121 SetABPenDrMd(rp, msg->gpr_GInfo->gi_DrInfo->dri_Pens[BACKGROUNDPEN], 0, JAM2);
122 rr = clip->RegionRectangle;
123 while(rr)
125 x = clip->bounds.MinX + rr->bounds.MinX;
126 y = clip->bounds.MinY + rr->bounds.MinY;
127 x2 = clip->bounds.MinX + rr->bounds.MaxX;
128 y2 = clip->bounds.MinY + rr->bounds.MaxY;
130 RectFill(rp, x, y, x2, y2);
132 rr = rr->Next;
135 DisposeRegion(clip);
139 } /* if (msg->gpr_Redraw == GREDRAW_REDRAW) */
141 return 0;
144 /***********************************************************************************/