3 #include <intuition/intuition.h>
4 #include <intuition/intuitionbase.h>
5 #include <intuition/screens.h>
6 #include <graphics/clip.h>
7 #include <graphics/rastport.h>
8 #include <proto/exec.h>
10 #include <proto/graphics.h>
11 #include <proto/layers.h>
17 #ifndef CreateLayerTagList
21 printf("showvisregion only works with hyperlayers.library!\n");
27 #define ARG_TEMPLATE "FAST=F/S,NUMBERS=N/S"
33 struct IntuitionBase
*IntuitionBase
= NULL
;
34 struct GfxBase
*GfxBase
= NULL
;
36 static struct Screen
*scr
;
37 static struct Window
*win
;
38 static struct Layer
*lay
;
39 static struct RDArgs
*MyArgs
;
40 static LONG Args
[NUM_ARGS
];
43 static void Cleanup(char *msg
)
49 printf("crlist: %s\n",msg
);
55 if (MyArgs
) FreeArgs(MyArgs
);
57 if (GfxBase
) CloseLibrary((struct Library
*)GfxBase
);
58 if (IntuitionBase
) CloseLibrary((struct Library
*)IntuitionBase
);
63 static void OpenLibs(void)
65 if (!(IntuitionBase
= (struct IntuitionBase
*)OpenLibrary("intuition.library",0)))
67 Cleanup("Can´t open intuition.library!");
70 if (!(GfxBase
= (struct GfxBase
*)OpenLibrary("graphics.library",0)))
72 Cleanup("Can´t open graphics.library!");
76 static void GetArguments(void)
78 if (!(MyArgs
= ReadArgs(ARG_TEMPLATE
,Args
,0)))
80 Fault(IoErr(),0,s
,255);
85 static void Action(void)
89 struct RegionRectangle
*rr
;
90 WORD x
, y
, i
, count
= 0;
92 puts("Activate the window whose visible region you want to see.\n");
93 puts("You have 3 seconds of time!\n\n");
97 win
= IntuitionBase
->ActiveWindow
;
100 if (!win
) Cleanup("No active window!");
102 if (!(rp
= CloneRastPort(&win
->WScreen
->RastPort
)))
104 Cleanup("Can´t clone screen rastport!");
110 reg
= lay
->VisibleRegion
;
111 rr
= reg
->RegionRectangle
;
114 WORD x1
= reg
->bounds
.MinX
+ rr
->bounds
.MinX
;
115 WORD y1
= reg
->bounds
.MinY
+ rr
->bounds
.MinY
;
116 WORD x2
= reg
->bounds
.MinX
+ rr
->bounds
.MaxX
;
117 WORD y2
= reg
->bounds
.MinY
+ rr
->bounds
.MaxY
;
119 printf("#%04d (%4d,%4d) - (%4d, %4d) Size: %4d x %4d\n",
128 for(i
= 0; i
< (Args
[ARG_FAST
] ? 1 : 8);i
++)
130 SetAPen(rp
,1 + (i
& 1));
131 RectFill(rp
,x1
,y1
,x2
,y1
);
132 RectFill(rp
,x2
,y1
,x2
,y2
);
133 RectFill(rp
,x1
,y2
,x2
,y2
);
134 RectFill(rp
,x1
,y1
,x1
,y2
);
136 if (!Args
[ARG_FAST
]) Delay(10);
139 if (Args
[ARG_NUMBERS
])
141 sprintf(s
,"%d",count
);
142 i
= TextLength(rp
,s
,strlen(s
));
144 x
= (x1
+ x2
- i
) / 2;
145 y
= (y1
+ y2
- rp
->TxHeight
) / 2;
150 } else if (x
>= scr
->Width
- i
)
152 x
= scr
->Width
- i
- 1;
158 } else if (y
>= scr
->Height
- rp
->TxHeight
)
160 y
= scr
->Height
- rp
->TxHeight
- 1;
166 Move(rp
,x
+ 1, y
+ 1 + rp
->TxBaseline
);
170 Move(rp
,x
, y
+ rp
->TxBaseline
);