1 #include <intuition/intuition.h>
2 #include <intuition/intuitionbase.h>
3 #include <graphics/gfx.h>
4 #include <graphics/gfxbase.h>
5 #include <proto/exec.h>
7 #include <proto/intuition.h>
8 #include <proto/graphics.h>
9 #include <proto/layers.h>
14 #define ARG_TEMPLATE "SIMPLE/S"
19 struct IntuitionBase
*IntuitionBase
;
20 struct GfxBase
*GfxBase
;
21 struct Library
*LayersBase
;
23 static struct Window
*win
;
24 static struct RastPort
*rp
;
25 static struct Layer
*lay
;
27 static struct RDArgs
*myargs
;
28 static IPTR args
[NUM_ARGS
];
31 static void Cleanup(char *msg
)
35 printf("clippingtest: %s\n",msg
);
38 if (win
) CloseWindow(win
);
40 if (myargs
) FreeArgs(myargs
);
42 if (LayersBase
) CloseLibrary(LayersBase
);
43 if (GfxBase
) CloseLibrary((struct Library
*)GfxBase
);
44 if (IntuitionBase
) CloseLibrary((struct Library
*)IntuitionBase
);
49 static void DosError(void)
51 Fault(IoErr(),0,s
,255);
55 static void OpenLibs(void)
57 if (!(IntuitionBase
= (struct IntuitionBase
*)OpenLibrary("intuition.library",39)))
59 Cleanup("Can't open intuition.library V39!");
62 if (!(GfxBase
= (struct GfxBase
*)OpenLibrary("graphics.library",39)))
64 Cleanup("Can't open graphics.library V39!");
67 if (!(LayersBase
= OpenLibrary("layers.library",39)))
69 Cleanup("Can't open layers.library V39!");
73 static void GetArguments(void)
75 if (!(myargs
= ReadArgs(ARG_TEMPLATE
, args
, 0)))
81 static void MakeWin(void)
83 win
= OpenWindowTags(0,WA_Left
,10,
87 WA_Title
,(IPTR
)"Press key to flip color!",
92 args
[ARG_SIMPLE
] ? WA_SimpleRefresh
: TAG_IGNORE
, TRUE
,
93 WA_IDCMP
,IDCMP_CLOSEWINDOW
|
98 if (!win
) Cleanup("Can't open window!");
104 static void Action(void)
106 struct Region
*clip
, *oldclip
;
107 struct Rectangle rect1
;
108 struct Rectangle rect2
;
109 struct IntuiMessage
*msg
;
113 rect1
.MinX
= 20;rect1
.MinY
= 80;
114 rect1
.MaxX
= 180;rect1
.MaxY
= 120;
115 rect2
.MinX
= 80;rect2
.MinY
= 20;
116 rect2
.MaxX
= 120;rect2
.MaxY
= 180;
119 if (!clip
) Cleanup("Can't create clip region!");
121 OrRectRegion(clip
, &rect1
);
122 OrRectRegion(clip
, &rect2
);
124 oldclip
= InstallClipRegion(lay
, clip
);
127 RectFill(rp
,0,0,1000,1000);
131 WaitPort(win
->UserPort
);
132 while ((msg
= (struct IntuiMessage
*)GetMsg(win
->UserPort
)))
136 case IDCMP_CLOSEWINDOW
:
140 case IDCMP_VANILLAKEY
:
143 RectFill(rp
,0,0,1000,1000);
146 case IDCMP_REFRESHWINDOW
:
149 RectFill(rp
,0,0,1000,1000);
150 EndRefresh(win
,TRUE
);
154 ReplyMsg((struct Message
*)msg
);
158 InstallClipRegion(lay
, oldclip
);