New bitmap method SetRGBConversionFunction which can be used to
[tangerine.git] / workbench / c / CRList.c
blob4909a26611d0b42a493eb6b7c64d77c989484007
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>
17 #include <stdio.h>
18 #include <string.h>
19 #include <stdlib.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];
34 static void Cleanup(char *msg)
36 WORD rc;
38 if (msg)
40 Printf("crlist: %s\n",msg);
41 rc = RETURN_WARN;
42 } else {
43 rc = RETURN_OK;
46 if (MyArgs) FreeArgs(MyArgs);
47 exit(rc);
50 static void GetArguments(void)
52 if (!(MyArgs = ReadArgs(ARG_TEMPLATE,Args,0)))
54 Fault(IoErr(),0,s,255);
55 Cleanup(s);
59 static void Action(void)
61 extern struct IntuitionBase *IntuitionBase;
62 struct RastPort *rp;
63 struct ClipRect *cr;
64 WORD x, y, i, count = 0;
66 puts("Activate the window whose cliprects you want to see.\n");
67 puts("You have 3 seconds of time!\n\n");
69 Delay(3*50);
71 win = IntuitionBase->ActiveWindow;
73 if (!win) Cleanup("No active window!");
75 scr = win->WScreen;
77 if (!(rp = CloneRastPort(&scr->RastPort)))
79 Cleanup("Can´t clone screen rastport!");
81 SetDrMd(rp,JAM1);
83 lay = win->WLayer;
85 cr = lay->ClipRect;
86 while(cr)
88 Printf("#%04ld (%4ld,%4ld) - (%4ld, %4ld) Size: %4ld x %4ld %s%s\n",
89 ++count,
90 cr->bounds.MinX,
91 cr->bounds.MinY,
92 cr->bounds.MaxX,
93 cr->bounds.MaxY,
94 cr->bounds.MaxX - cr->bounds.MinX + 1,
95 cr->bounds.MaxY - cr->bounds.MinY + 1,
96 (cr->lobs ? "HIDDEN " : ""),
97 (cr->BitMap ? "BITMAP ": ""));
99 for(i = 0; i < (Args[ARG_FAST] ? 1 : 8);i++)
101 SetAPen(rp,1 + (i & 1));
102 RectFill(rp,cr->bounds.MinX,cr->bounds.MinY,cr->bounds.MaxX,cr->bounds.MinY);
103 RectFill(rp,cr->bounds.MaxX,cr->bounds.MinY,cr->bounds.MaxX,cr->bounds.MaxY);
104 RectFill(rp,cr->bounds.MinX,cr->bounds.MaxY,cr->bounds.MaxX,cr->bounds.MaxY);
105 RectFill(rp,cr->bounds.MinX,cr->bounds.MinY,cr->bounds.MinX,cr->bounds.MaxY);
107 if (!Args[ARG_FAST]) Delay(10);
110 if (Args[ARG_NUMBERS])
112 sprintf(s,"%d",count);
113 i = TextLength(rp,s,strlen(s));
115 x = (cr->bounds.MinX + cr->bounds.MaxX - i) / 2;
116 y = (cr->bounds.MinY + cr->bounds.MaxY - rp->TxHeight) / 2;
118 if (x < 0)
120 x = 0;
121 } else if (x >= scr->Width - i)
123 x = scr->Width - i - 1;
126 if (y < 0)
128 y = 0;
129 } else if (y >= scr->Height - rp->TxHeight)
131 y = scr->Height - rp->TxHeight - 1;
134 i = strlen(s);
136 SetAPen(rp,1);
137 Move(rp,x + 1, y + 1 + rp->TxBaseline);
138 Text(rp,s,i);
140 SetAPen(rp,2);
141 Move(rp,x, y + rp->TxBaseline);
142 Text(rp,s,i);
144 cr = cr->Next;
147 FreeRastPort(rp);
150 int main(void)
152 GetArguments();
153 Action();
154 Cleanup(0);
156 return 0;