Fix IO memory access .. SB128 driver makes noises in VMWare - CMI is untested (Curren...
[AROS.git] / workbench / c / CRList.c
blobbebb58e8dea26723970033eafcc055151b26c64b
1 /*
2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include <exec/exec.h>
7 #include <dos/dos.h>
8 #include <intuition/intuition.h>
9 #include <intuition/intuitionbase.h>
10 #include <intuition/screens.h>
11 #include <graphics/clip.h>
12 #include <graphics/rastport.h>
13 #include <proto/exec.h>
14 #include <proto/dos.h>
15 #include <proto/graphics.h>
16 #include <proto/alib.h>
18 #include <string.h>
19 #include <setjmp.h>
21 #define ARG_TEMPLATE "FAST=F/S,NUMBERS=N/S"
23 #define ARG_FAST 0
24 #define ARG_NUMBERS 1
25 #define NUM_ARGS 2
27 static struct Screen *scr;
28 static struct Window *win;
29 static struct Layer *lay;
30 static struct RDArgs *MyArgs;
31 static IPTR Args[NUM_ARGS];
32 static char s[256];
33 static jmp_buf exit_buf;
35 static void Cleanup(char *msg)
37 WORD rc;
39 if (msg)
41 Printf("crlist: %s\n",msg);
42 rc = RETURN_WARN;
43 } else {
44 rc = RETURN_OK;
47 if (MyArgs) FreeArgs(MyArgs);
49 if (rc != RETURN_OK)
50 longjmp(exit_buf, rc);
53 static void GetArguments(void)
55 if (!(MyArgs = ReadArgs(ARG_TEMPLATE,Args,0)))
57 Fault(IoErr(),0,s,255);
58 Cleanup(s);
62 static void Action(void)
64 extern struct IntuitionBase *IntuitionBase;
65 struct RastPort *rp;
66 struct ClipRect *cr;
67 WORD x, y, i, count = 0;
69 PutStr("Activate the window whose cliprects you want to see.\n");
70 PutStr("You have 3 seconds of time!\n\n");
72 Delay(3*50);
74 win = IntuitionBase->ActiveWindow;
76 if (!win) Cleanup("No active window!");
78 scr = win->WScreen;
80 if (!(rp = CloneRastPort(&scr->RastPort)))
82 Cleanup("Can´t clone screen rastport!");
84 SetDrMd(rp,JAM1);
86 lay = win->WLayer;
88 cr = lay->ClipRect;
89 while(cr)
91 Printf("#%04ld (%4ld,%4ld) - (%4ld, %4ld) Size: %4ld x %4ld %s%s\n",
92 ++count,
93 cr->bounds.MinX,
94 cr->bounds.MinY,
95 cr->bounds.MaxX,
96 cr->bounds.MaxY,
97 cr->bounds.MaxX - cr->bounds.MinX + 1,
98 cr->bounds.MaxY - cr->bounds.MinY + 1,
99 (cr->lobs ? "HIDDEN " : ""),
100 (cr->BitMap ? "BITMAP ": ""));
102 for(i = 0; i < (Args[ARG_FAST] ? 1 : 8);i++)
104 SetAPen(rp,1 + (i & 1));
105 RectFill(rp,cr->bounds.MinX,cr->bounds.MinY,cr->bounds.MaxX,cr->bounds.MinY);
106 RectFill(rp,cr->bounds.MaxX,cr->bounds.MinY,cr->bounds.MaxX,cr->bounds.MaxY);
107 RectFill(rp,cr->bounds.MinX,cr->bounds.MaxY,cr->bounds.MaxX,cr->bounds.MaxY);
108 RectFill(rp,cr->bounds.MinX,cr->bounds.MinY,cr->bounds.MinX,cr->bounds.MaxY);
110 if (!Args[ARG_FAST]) Delay(10);
113 if (Args[ARG_NUMBERS])
115 __sprintf(s,"%d",count);
116 i = TextLength(rp,s,strlen(s));
118 x = (cr->bounds.MinX + cr->bounds.MaxX - i) / 2;
119 y = (cr->bounds.MinY + cr->bounds.MaxY - rp->TxHeight) / 2;
121 if (x < 0)
123 x = 0;
124 } else if (x >= scr->Width - i)
126 x = scr->Width - i - 1;
129 if (y < 0)
131 y = 0;
132 } else if (y >= scr->Height - rp->TxHeight)
134 y = scr->Height - rp->TxHeight - 1;
137 i = strlen(s);
139 SetAPen(rp,1);
140 Move(rp,x + 1, y + 1 + rp->TxBaseline);
141 Text(rp,s,i);
143 SetAPen(rp,2);
144 Move(rp,x, y + rp->TxBaseline);
145 Text(rp,s,i);
147 cr = cr->Next;
150 FreeRastPort(rp);
153 int main(void)
155 int rc;
157 if ((rc = setjmp(exit_buf)) != 0)
158 return rc;
160 GetArguments();
161 Action();
162 Cleanup(0);
164 return 0;