2 Copyright © 1995-2011, The AROS Development Team. All rights reserved.
11 #include <intuition/intuition.h>
12 #include <intuition/intuitionbase.h>
13 #include <intuition/screens.h>
14 #include <graphics/clip.h>
15 #include <graphics/rastport.h>
16 #include <graphics/regions.h>
17 #include <proto/arossupport.h>
18 #include <proto/exec.h>
19 #include <proto/dos.h>
20 #include <proto/graphics.h>
21 #include <proto/alib.h>
26 #define ARG_TEMPLATE "FAST=F/S,NUMBERS=N/S,RECTFILL=RF/S"
30 #define ARG_RECTFILL 2
33 extern struct IntuitionBase
*IntuitionBase
;
35 static struct Screen
*scr
;
36 static struct Window
*win
;
37 static struct Layer
*lay
;
38 static struct RDArgs
*MyArgs
;
39 static IPTR Args
[NUM_ARGS
];
41 static jmp_buf exit_buf
;
43 static void Cleanup(char *msg
)
49 Printf("damagelist: %s\n",msg
);
55 if (MyArgs
) FreeArgs(MyArgs
);
58 longjmp(exit_buf
, rc
);
61 static void GetArguments(void)
63 if (!(MyArgs
= ReadArgs(ARG_TEMPLATE
,Args
,0)))
65 Fault(IoErr(),0,s
,255);
70 static void Action(void)
74 struct RegionRectangle
*rr
;
75 WORD x
, y
, x1
, y1
, x2
, y2
, i
, count
= 0;
77 PutStr("Activate the window whose damagelist you want to see.\n");
78 PutStr("You have 3 seconds of time!\n\n");
82 win
= IntuitionBase
->ActiveWindow
;
83 if (!win
) Cleanup("No active window!");
90 if (!dr
) Cleanup("Layer does not have a damagelist!");
91 rr
= dr
->RegionRectangle
;
92 if (!rr
) Cleanup("Damagelist is empty!");
94 if (!(rp
= CloneRastPort(&win
->WScreen
->RastPort
)))
96 Cleanup("Can´t clone screen rastport!");
102 x1
= lay
->bounds
.MinX
+ dr
->bounds
.MinX
+ rr
->bounds
.MinX
;
103 y1
= lay
->bounds
.MinY
+ dr
->bounds
.MinY
+ rr
->bounds
.MinY
;
104 x2
= lay
->bounds
.MinX
+ dr
->bounds
.MinX
+ rr
->bounds
.MaxX
;
105 y2
= lay
->bounds
.MinY
+ dr
->bounds
.MinY
+ rr
->bounds
.MaxY
;
107 Printf("#%04d (%4d,%4d) - (%4d, %4d) Size: %4d x %4d\n",
117 for(i
= 0; i
< (Args
[ARG_FAST
] ? 1 : 8);i
++)
119 SetAPen(rp
,1 + (i
& 1));
121 if (Args
[ARG_RECTFILL
])
123 RectFill(rp
,x1
,y1
,x2
,y2
);
125 RectFill(rp
,x1
,y1
,x2
,y1
);
126 RectFill(rp
,x2
,y1
,x2
,y2
);
127 RectFill(rp
,x1
,y2
,x2
,y2
);
128 RectFill(rp
,x1
,y1
,x1
,y2
);
131 if (!Args
[ARG_FAST
]) Delay(10);
134 if (Args
[ARG_NUMBERS
])
136 __sprintf(s
,"%d",count
);
137 i
= TextLength(rp
,s
,strlen(s
));
139 x
= (x1
+ x2
- i
) / 2;
140 y
= (y1
+ y2
- rp
->TxHeight
) / 2;
145 } else if (x
>= scr
->Width
- i
)
147 x
= scr
->Width
- i
- 1;
153 } else if (y
>= scr
->Height
- rp
->TxHeight
)
155 y
= scr
->Height
- rp
->TxHeight
- 1;
161 Move(rp
,x
+ 1, y
+ 1 + rp
->TxBaseline
);
165 Move(rp
,x
, y
+ rp
->TxBaseline
);
178 if ((rc
= setjmp(exit_buf
)) != 0)