2 Copyright © 1995-2014, The AROS Development Team. All rights reserved.
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>
23 #define ARG_TEMPLATE "FAST=F/S,NUMBERS=N/S"
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
];
39 static void Cleanup(char *msg
)
45 printf("crlist: %s\n",msg
);
51 if (MyArgs
) FreeArgs(MyArgs
);
53 if (GfxBase
) CloseLibrary((struct Library
*)GfxBase
);
54 if (IntuitionBase
) CloseLibrary((struct Library
*)IntuitionBase
);
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);
81 static void Action(void)
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");
93 win
= IntuitionBase
->ActiveWindow
;
96 if (!win
) Cleanup("No active window!");
98 if (!(rp
= CloneRastPort(&win
->WScreen
->RastPort
)))
100 Cleanup("Can´t clone screen rastport!");
106 reg
= lay
->visibleshape
;
107 rr
= reg
->RegionRectangle
;
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",
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;
146 } else if (x
>= scr
->Width
- i
)
148 x
= scr
->Width
- i
- 1;
154 } else if (y
>= scr
->Height
- rp
->TxHeight
)
156 y
= scr
->Height
- rp
->TxHeight
- 1;
162 Move(rp
,x
+ 1, y
+ 1 + rp
->TxBaseline
);
166 Move(rp
,x
, y
+ rp
->TxBaseline
);