2 Copyright © 1995-2014, The AROS Development Team. All rights reserved.
6 #include <intuition/intuition.h>
7 #include <intuition/intuitionbase.h>
8 #include <graphics/gfx.h>
9 #include <graphics/gfxbase.h>
10 #include <proto/exec.h>
11 #include <proto/dos.h>
12 #include <proto/intuition.h>
13 #include <proto/graphics.h>
14 #include <proto/layers.h>
19 #define ARG_TEMPLATE "SIMPLE/S"
24 struct IntuitionBase
*IntuitionBase
;
25 struct GfxBase
*GfxBase
;
26 struct Library
*LayersBase
;
28 static struct Window
*win
;
29 static struct RastPort
*rp
;
30 static struct Layer
*lay
;
32 static struct RDArgs
*myargs
;
33 static IPTR args
[NUM_ARGS
];
36 static void Cleanup(char *msg
)
40 printf("clippingtest: %s\n",msg
);
43 if (win
) CloseWindow(win
);
45 if (myargs
) FreeArgs(myargs
);
47 if (LayersBase
) CloseLibrary(LayersBase
);
48 if (GfxBase
) CloseLibrary((struct Library
*)GfxBase
);
49 if (IntuitionBase
) CloseLibrary((struct Library
*)IntuitionBase
);
54 static void DosError(void)
56 Fault(IoErr(),0,s
,255);
60 static void OpenLibs(void)
62 if (!(IntuitionBase
= (struct IntuitionBase
*)OpenLibrary("intuition.library",39)))
64 Cleanup("Can't open intuition.library V39!");
67 if (!(GfxBase
= (struct GfxBase
*)OpenLibrary("graphics.library",39)))
69 Cleanup("Can't open graphics.library V39!");
72 if (!(LayersBase
= OpenLibrary("layers.library",39)))
74 Cleanup("Can't open layers.library V39!");
78 static void GetArguments(void)
80 if (!(myargs
= ReadArgs(ARG_TEMPLATE
, args
, 0)))
86 static void MakeWin(void)
88 win
= OpenWindowTags(0,WA_Left
,10,
92 WA_Title
,(IPTR
)"Press key to flip color!",
97 args
[ARG_SIMPLE
] ? WA_SimpleRefresh
: TAG_IGNORE
, TRUE
,
98 WA_IDCMP
,IDCMP_CLOSEWINDOW
|
103 if (!win
) Cleanup("Can't open window!");
109 static void Action(void)
111 struct Region
*clip
, *oldclip
;
112 struct Rectangle rect1
;
113 struct Rectangle rect2
;
114 struct IntuiMessage
*msg
;
116 BOOL installed
= TRUE
;
119 rect1
.MinX
= 20;rect1
.MinY
= 80;
120 rect1
.MaxX
= 180;rect1
.MaxY
= 120;
121 rect2
.MinX
= 80;rect2
.MinY
= 20;
122 rect2
.MaxX
= 120;rect2
.MaxY
= 180;
128 if (!clip
) Cleanup("Can't create clip region!");
130 OrRectRegion(clip
, &rect1
);
131 OrRectRegion(clip
, &rect2
);
133 oldclip
= InstallClipRegion(lay
, clip
);
136 RectFill(rp
,0,0,1000,1000);
140 WaitPort(win
->UserPort
);
141 while ((msg
= (struct IntuiMessage
*)GetMsg(win
->UserPort
)))
145 case IDCMP_CLOSEWINDOW
:
149 case IDCMP_VANILLAKEY
:
156 InstallClipRegion(lay
, oldclip
);
161 oldclip
= InstallClipRegion(lay
, clip
);
169 RectFill(rp
,0,0,1000,1000);
173 case IDCMP_REFRESHWINDOW
:
176 RectFill(rp
,0,0,1000,1000);
177 EndRefresh(win
,TRUE
);
181 ReplyMsg((struct Message
*)msg
);
186 InstallClipRegion(lay
, oldclip
);