- Give PCI controllers lower unit numbers than legacy controllers.
[cake.git] / test / clippingtest.c
blobb72e28c7e079ea8d36597d1c950983098a2a3f9c
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>
6 #include <proto/dos.h>
7 #include <proto/intuition.h>
8 #include <proto/graphics.h>
9 #include <proto/layers.h>
11 #include <stdio.h>
12 #include <stdlib.h>
14 #define ARG_TEMPLATE "SIMPLE/S"
16 #define ARG_SIMPLE 0
17 #define NUM_ARGS 1
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 LONG args[NUM_ARGS];
29 static char s[256];
31 static void Cleanup(char *msg)
33 if (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);
46 exit(0);
49 static void DosError(void)
51 Fault(IoErr(),0,s,255);
52 Cleanup(s);
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)))
77 DosError();
81 static void MakeWin(void)
83 win = OpenWindowTags(0,WA_Left,10,
84 WA_Top,20,
85 WA_Width,200,
86 WA_Height,200,
87 WA_Title,(IPTR)"Press key to flip color!",
88 WA_CloseGadget,TRUE,
89 WA_DepthGadget,TRUE,
90 WA_DragBar,TRUE,
91 WA_Activate,TRUE,
92 args[ARG_SIMPLE] ? WA_SimpleRefresh : TAG_IGNORE, TRUE,
93 WA_IDCMP,IDCMP_CLOSEWINDOW |
94 IDCMP_VANILLAKEY |
95 IDCMP_REFRESHWINDOW,
96 TAG_DONE);
98 if (!win) Cleanup("Can't open window!");
100 rp = win->RPort;
101 lay = win->WLayer;
104 static void Action(void)
106 struct Region *clip, *oldclip;
107 struct Rectangle rect1;
108 struct Rectangle rect2;
109 struct IntuiMessage *msg;
110 WORD col = 1;
111 BOOL quitme = FALSE;
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;
118 clip = NewRegion();
119 if (!clip) Cleanup("Can't create clip region!");
121 OrRectRegion(clip, &rect1);
122 OrRectRegion(clip, &rect2);
124 oldclip = InstallClipRegion(lay, clip);
126 SetAPen(rp,col);
127 RectFill(rp,0,0,1000,1000);
129 while(!quitme)
131 WaitPort(win->UserPort);
132 while ((msg = (struct IntuiMessage *)GetMsg(win->UserPort)))
134 switch(msg->Class)
136 case IDCMP_CLOSEWINDOW:
137 quitme = TRUE;
138 break;
140 case IDCMP_VANILLAKEY:
141 col = 3 - col;
142 SetAPen(rp,col);
143 RectFill(rp,0,0,1000,1000);
144 break;
146 case IDCMP_REFRESHWINDOW:
147 BeginRefresh(win);
148 SetAPen(rp,col);
149 RectFill(rp,0,0,1000,1000);
150 EndRefresh(win,TRUE);
151 break;
154 ReplyMsg((struct Message *)msg);
158 InstallClipRegion(lay, oldclip);
162 int main(void)
164 OpenLibs();
165 GetArguments();
166 MakeWin();
167 Action();
168 Cleanup(0);
169 return 0;