Test kernel compiler for -iquote instead of target compiler script that
[tangerine.git] / workbench / c / DamageList.c
blob8e3fc46ea1763d92882c942610aab253f1a522b2
1 /*
2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc:
6 Lang: English
7 */
9 #include <exec/exec.h>
10 #include <dos/dos.h>
11 #include <intuition/intuition.h>
12 #include <intuition/intuitionbase.h>
13 #include <intuition/screens.h>
14 #include <graphics/clip.h>
15 #include <graphics/rastport.h>
16 #include <graphics/regions.h>
17 #include <proto/exec.h>
18 #include <proto/dos.h>
19 #include <proto/graphics.h>
21 #include <stdio.h>
22 #include <string.h>
23 #include <stdlib.h>
25 #define ARG_TEMPLATE "FAST=F/S,NUMBERS=N/S,RECTFILL=RF/S"
27 #define ARG_FAST 0
28 #define ARG_NUMBERS 1
29 #define ARG_RECTFILL 2
30 #define NUM_ARGS 3
32 extern struct IntuitionBase *IntuitionBase;
34 static struct Screen *scr;
35 static struct Window *win;
36 static struct Layer *lay;
37 static struct RDArgs *MyArgs;
38 static IPTR Args[NUM_ARGS];
39 static char s[256];
41 static void Cleanup(char *msg)
43 WORD rc;
45 if (msg)
47 printf("damagelist: %s\n",msg);
48 rc = RETURN_WARN;
49 } else {
50 rc = RETURN_OK;
53 if (MyArgs) FreeArgs(MyArgs);
55 exit(rc);
58 static void GetArguments(void)
60 if (!(MyArgs = ReadArgs(ARG_TEMPLATE,Args,0)))
62 Fault(IoErr(),0,s,255);
63 Cleanup(s);
67 static void Action(void)
69 struct RastPort *rp;
70 struct Region *dr;
71 struct RegionRectangle *rr;
72 WORD x, y, x1, y1, x2, y2, i, count = 0;
74 puts("Activate the window whose damagelist you want to see.\n");
75 puts("You have 3 seconds of time!\n\n");
77 Delay(3*50);
79 win = IntuitionBase->ActiveWindow;
80 if (!win) Cleanup("No active window!");
82 scr = win->WScreen;
84 lay = win->WLayer;
86 dr = lay->DamageList;
87 if (!dr) Cleanup("Layer does not have a damagelist!");
88 rr = dr->RegionRectangle;
89 if (!rr) Cleanup("Damagelist is empty!");
91 if (!(rp = CloneRastPort(&win->WScreen->RastPort)))
93 Cleanup("Can´t clone screen rastport!");
95 SetDrMd(rp,JAM1);
97 while(rr)
99 x1 = lay->bounds.MinX + dr->bounds.MinX + rr->bounds.MinX;
100 y1 = lay->bounds.MinY + dr->bounds.MinY + rr->bounds.MinY;
101 x2 = lay->bounds.MinX + dr->bounds.MinX + rr->bounds.MaxX;
102 y2 = lay->bounds.MinY + dr->bounds.MinY + rr->bounds.MaxY;
104 printf("#%04d (%4d,%4d) - (%4d, %4d) Size: %4d x %4d\n",
105 ++count,
110 x2 - x1 + 1,
111 y2 - y1 + 1);
114 for(i = 0; i < (Args[ARG_FAST] ? 1 : 8);i++)
116 SetAPen(rp,1 + (i & 1));
118 if (Args[ARG_RECTFILL])
120 RectFill(rp,x1,y1,x2,y2);
121 } else {
122 RectFill(rp,x1,y1,x2,y1);
123 RectFill(rp,x2,y1,x2,y2);
124 RectFill(rp,x1,y2,x2,y2);
125 RectFill(rp,x1,y1,x1,y2);
128 if (!Args[ARG_FAST]) Delay(10);
131 if (Args[ARG_NUMBERS])
133 sprintf(s,"%d",count);
134 i = TextLength(rp,s,strlen(s));
136 x = (x1 + x2 - i) / 2;
137 y = (y1 + y2 - rp->TxHeight) / 2;
139 if (x < 0)
141 x = 0;
142 } else if (x >= scr->Width - i)
144 x = scr->Width - i - 1;
147 if (y < 0)
149 y = 0;
150 } else if (y >= scr->Height - rp->TxHeight)
152 y = scr->Height - rp->TxHeight - 1;
155 i = strlen(s);
157 SetAPen(rp,1);
158 Move(rp,x + 1, y + 1 + rp->TxBaseline);
159 Text(rp,s,i);
161 SetAPen(rp,2);
162 Move(rp,x, y + rp->TxBaseline);
163 Text(rp,s,i);
165 rr = rr->Next;
168 FreeRastPort(rp);
171 int main(void)
173 GetArguments();
174 Action();
175 Cleanup(0);
177 return 0;