Use TARGET_STRIP instead of STRIP. Needed on OS X.
[AROS.git] / test / layers / DamageList.c
blob53b72f9355a79e761cdb607cb4763a25494094bf
1 /*
2 Copyright © 1995-2011, 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/arossupport.h>
18 #include <proto/exec.h>
19 #include <proto/dos.h>
20 #include <proto/graphics.h>
21 #include <proto/alib.h>
23 #include <string.h>
24 #include <setjmp.h>
26 #define ARG_TEMPLATE "FAST=F/S,NUMBERS=N/S,RECTFILL=RF/S"
28 #define ARG_FAST 0
29 #define ARG_NUMBERS 1
30 #define ARG_RECTFILL 2
31 #define NUM_ARGS 3
33 extern struct IntuitionBase *IntuitionBase;
35 static struct Screen *scr;
36 static struct Window *win;
37 static struct Layer *lay;
38 static struct RDArgs *MyArgs;
39 static IPTR Args[NUM_ARGS];
40 static char s[256];
41 static jmp_buf exit_buf;
43 static void Cleanup(char *msg)
45 WORD rc;
47 if (msg)
49 Printf("damagelist: %s\n",msg);
50 rc = RETURN_WARN;
51 } else {
52 rc = RETURN_OK;
55 if (MyArgs) FreeArgs(MyArgs);
57 if (rc != RETURN_OK)
58 longjmp(exit_buf, rc);
61 static void GetArguments(void)
63 if (!(MyArgs = ReadArgs(ARG_TEMPLATE,Args,0)))
65 Fault(IoErr(),0,s,255);
66 Cleanup(s);
70 static void Action(void)
72 struct RastPort *rp;
73 struct Region *dr;
74 struct RegionRectangle *rr;
75 WORD x, y, x1, y1, x2, y2, i, count = 0;
77 PutStr("Activate the window whose damagelist you want to see.\n");
78 PutStr("You have 3 seconds of time!\n\n");
80 Delay(3*50);
82 win = IntuitionBase->ActiveWindow;
83 if (!win) Cleanup("No active window!");
85 scr = win->WScreen;
87 lay = win->WLayer;
89 dr = lay->DamageList;
90 if (!dr) Cleanup("Layer does not have a damagelist!");
91 rr = dr->RegionRectangle;
92 if (!rr) Cleanup("Damagelist is empty!");
94 if (!(rp = CloneRastPort(&win->WScreen->RastPort)))
96 Cleanup("Can´t clone screen rastport!");
98 SetDrMd(rp,JAM1);
100 while(rr)
102 x1 = lay->bounds.MinX + dr->bounds.MinX + rr->bounds.MinX;
103 y1 = lay->bounds.MinY + dr->bounds.MinY + rr->bounds.MinY;
104 x2 = lay->bounds.MinX + dr->bounds.MinX + rr->bounds.MaxX;
105 y2 = lay->bounds.MinY + dr->bounds.MinY + rr->bounds.MaxY;
107 Printf("#%04d (%4d,%4d) - (%4d, %4d) Size: %4d x %4d\n",
108 ++count,
113 x2 - x1 + 1,
114 y2 - y1 + 1);
117 for(i = 0; i < (Args[ARG_FAST] ? 1 : 8);i++)
119 SetAPen(rp,1 + (i & 1));
121 if (Args[ARG_RECTFILL])
123 RectFill(rp,x1,y1,x2,y2);
124 } else {
125 RectFill(rp,x1,y1,x2,y1);
126 RectFill(rp,x2,y1,x2,y2);
127 RectFill(rp,x1,y2,x2,y2);
128 RectFill(rp,x1,y1,x1,y2);
131 if (!Args[ARG_FAST]) Delay(10);
134 if (Args[ARG_NUMBERS])
136 __sprintf(s,"%d",count);
137 i = TextLength(rp,s,strlen(s));
139 x = (x1 + x2 - i) / 2;
140 y = (y1 + y2 - rp->TxHeight) / 2;
142 if (x < 0)
144 x = 0;
145 } else if (x >= scr->Width - i)
147 x = scr->Width - i - 1;
150 if (y < 0)
152 y = 0;
153 } else if (y >= scr->Height - rp->TxHeight)
155 y = scr->Height - rp->TxHeight - 1;
158 i = strlen(s);
160 SetAPen(rp,1);
161 Move(rp,x + 1, y + 1 + rp->TxBaseline);
162 Text(rp,s,i);
164 SetAPen(rp,2);
165 Move(rp,x, y + rp->TxBaseline);
166 Text(rp,s,i);
168 rr = rr->Next;
171 FreeRastPort(rp);
174 int main(void)
176 int rc;
178 if ((rc = setjmp(exit_buf)) != 0)
179 return rc;
181 GetArguments();
182 Action();
183 Cleanup(0);
185 return 0;