use the locations specified in the bcm2708_boot header
[AROS.git] / test / showvisshape.c
blob24c710ed2e54ab3052e03d8c8ede9a7e46006f0f
1 /*
2 Copyright © 1995-2014, 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/layers.h>
17 #include <clib/arossupport_protos.h>
19 #include <stdio.h>
20 #include <string.h>
21 #include <stdlib.h>
23 #define ARG_TEMPLATE "FAST=F/S,NUMBERS=N/S"
25 #define ARG_FAST 0
26 #define ARG_NUMBERS 1
27 #define NUM_ARGS 2
29 struct IntuitionBase *IntuitionBase = NULL;
30 struct GfxBase *GfxBase = NULL;
32 static struct Screen *scr;
33 static struct Window *win;
34 static struct Layer *lay;
35 static struct RDArgs *MyArgs;
36 static IPTR Args[NUM_ARGS];
37 static char s[256];
39 static void Cleanup(char *msg)
41 WORD rc;
43 if (msg)
45 printf("crlist: %s\n",msg);
46 rc = RETURN_WARN;
47 } else {
48 rc = RETURN_OK;
51 if (MyArgs) FreeArgs(MyArgs);
53 if (GfxBase) CloseLibrary((struct Library *)GfxBase);
54 if (IntuitionBase) CloseLibrary((struct Library *)IntuitionBase);
56 exit(rc);
59 static void OpenLibs(void)
61 if (!(IntuitionBase = (struct IntuitionBase *)OpenLibrary("intuition.library",0)))
63 Cleanup("Can´t open intuition.library!");
66 if (!(GfxBase = (struct GfxBase *)OpenLibrary("graphics.library",0)))
68 Cleanup("Can´t open graphics.library!");
72 static void GetArguments(void)
74 if (!(MyArgs = ReadArgs(ARG_TEMPLATE,Args,0)))
76 Fault(IoErr(),0,s,255);
77 Cleanup(s);
81 static void Action(void)
83 struct RastPort *rp;
84 struct Region *reg;
85 struct RegionRectangle *rr;
86 WORD x, y, i, count = 0;
88 puts("Activate the window whose visible region you want to see.\n");
89 puts("You have 3 seconds of time!\n\n");
91 Delay(3*50);
93 win = IntuitionBase->ActiveWindow;
94 scr = win->WScreen;
96 if (!win) Cleanup("No active window!");
98 if (!(rp = CloneRastPort(&win->WScreen->RastPort)))
100 Cleanup("Can´t clone screen rastport!");
102 SetDrMd(rp,JAM1);
104 lay = win->WLayer;
106 reg = lay->visibleshape;
107 rr = reg->RegionRectangle;
108 while(rr)
110 WORD x1 = reg->bounds.MinX + rr->bounds.MinX;
111 WORD y1 = reg->bounds.MinY + rr->bounds.MinY;
112 WORD x2 = reg->bounds.MinX + rr->bounds.MaxX;
113 WORD y2 = reg->bounds.MinY + rr->bounds.MaxY;
115 printf("#%04d (%4d,%4d) - (%4d, %4d) Size: %4d x %4d\n",
116 ++count,
121 x2 - x1 + 1,
122 y2 - y1 + 1);
124 for(i = 0; i < (Args[ARG_FAST] ? 1 : 8);i++)
126 SetAPen(rp,1 + (i & 1));
127 RectFill(rp,x1,y1,x2,y1);
128 RectFill(rp,x2,y1,x2,y2);
129 RectFill(rp,x1,y2,x2,y2);
130 RectFill(rp,x1,y1,x1,y2);
132 if (!Args[ARG_FAST]) Delay(10);
135 if (Args[ARG_NUMBERS])
137 sprintf(s,"%d",count);
138 i = TextLength(rp,s,strlen(s));
140 x = (x1 + x2 - i) / 2;
141 y = (y1 + y2 - rp->TxHeight) / 2;
143 if (x < 0)
145 x = 0;
146 } else if (x >= scr->Width - i)
148 x = scr->Width - i - 1;
151 if (y < 0)
153 y = 0;
154 } else if (y >= scr->Height - rp->TxHeight)
156 y = scr->Height - rp->TxHeight - 1;
159 i = strlen(s);
161 SetAPen(rp,1);
162 Move(rp,x + 1, y + 1 + rp->TxBaseline);
163 Text(rp,s,i);
165 SetAPen(rp,2);
166 Move(rp,x, y + rp->TxBaseline);
167 Text(rp,s,i);
169 rr = rr->Next;
172 FreeRastPort(rp);
175 int main(void)
177 OpenLibs();
178 GetArguments();
179 Action();
180 Cleanup(0);
182 return 0;