Prefs/ScreenMode: change the way depth is selected
[AROS.git] / test / graphics / gfx.c
blobd8c6a082cd5ee723c56def793e93a782a9ba2795
1 /*
2 Copyright © 1995-2014, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include <proto/exec.h>
7 #include <proto/graphics.h>
8 #include <proto/layers.h>
9 #include <exec/types.h>
10 #include <intuition/intuition.h>
11 #include <aros/oldprograms.h>
12 #include <graphics/gfxbase.h>
13 #include <graphics/rastport.h>
14 #include <graphics/regions.h>
15 #include <stdio.h>
17 struct NewWindow MyWin =
19 20,20,300,200,-1,-1,IDCMP_CLOSEWINDOW|/*IDCMP_DELTAMOVE|*/IDCMP_MOUSEMOVE,
20 WINDOWCLOSE|WINDOWDRAG|WINDOWDEPTH|WINDOWSIZING|WFLG_SMART_REFRESH|WFLG_REPORTMOUSE,
21 NULL,NULL,(char *)"Testwindow",
22 NULL,NULL,0,0,0,0,WBENCHSCREEN
25 struct GfxBase * GfxBase;
26 struct Library * LayersBase;
28 void installClipRegion(struct Window * w)
30 int width, height;
31 struct Rectangle Rect;
32 ULONG x,y,line;
33 struct Region * R = NewRegion();
34 printf("Width of ClipRegion Rectangles: ");
35 scanf("%i",&width);
36 printf("Height of ClipRegion Rectangles: ");
37 scanf("%i",&height);
39 if (height == 0 || width == 0)
40 return;
41 y = 0;
42 line = 0;
43 while (y < w->Height)
45 x = (line & 1) * width;
46 while (x < w->Width)
48 Rect.MinX = x;
49 Rect.MinY = y;
50 Rect.MaxX = x+width-1;
51 Rect.MaxY = y+height-1;
52 OrRectRegion(R,&Rect);
54 x += (2*width);
56 y += height;
57 line ++;
60 InstallClipRegion(w->WLayer, R);
64 void uninstallClipRegion(struct Window * w)
66 struct Region * R = InstallClipRegion(w->WLayer, NULL);
67 if (NULL != R)
68 DisposeRegion(R);
71 int main(void)
73 LayersBase = OpenLibrary("layers.library",0);
74 GfxBase = (struct GfxBase *)OpenLibrary("graphics.library",0);
75 if (NULL != GfxBase)
77 struct IntuitionBase * IntuitionBase =
78 (struct IntuitionBase *)OpenLibrary("intuition.library",0);
79 if (NULL != IntuitionBase)
81 struct Window * TheDude = OpenWindow(&MyWin);
82 if (NULL != TheDude)
84 struct RastPort * rp = TheDude->RPort;
85 struct TmpRas tmpras;
86 struct IntuiMessage * Msg;
87 UWORD areabuffer[250];
88 char c;
89 struct AreaInfo myAreaInfo;
90 installClipRegion(TheDude);
91 InitArea(&myAreaInfo, &areabuffer[0], 50);
92 rp->AreaInfo = &myAreaInfo;
93 InitTmpRas(&tmpras, AllocRaster(320,200),RASSIZE(320,200));
94 rp->TmpRas = &tmpras;
96 /* Let's draw something */
97 SetAPen(rp,1);
98 SetOutlinePen(rp,3);
101 AreaMove(rp,10,20);
102 AreaDraw(rp,110,30);
103 AreaDraw(rp,110,100);
104 AreaDraw(rp,10,110);
105 AreaEnd(rp);
108 /**/
109 AreaMove(rp,10,20);
110 AreaDraw(rp,110,30);
111 AreaDraw(rp,110,100);
112 AreaDraw(rp,10,50);
113 AreaEnd(rp);
114 /**/
116 AreaEllipse(rp, 110, 30, 50, 20);
117 AreaEnd(rp);
120 Move(rp,0,0);
121 Draw(rp,0,100);
122 Draw(rp,100,110);
123 Draw(rp,100,0);
124 Draw(rp,0,0);
125 SetAPen(rp, 1);
126 Flood(rp,0,50,50);
129 ScrollRaster(&IntuitionBase->ActiveScreen->RastPort,
134 100,
135 100);
137 printf("press a key and hit return!");
138 scanf("%c",&c);
139 ScrollRaster(rp,
140 -10,
141 -10,
144 100,
145 100);
148 while (TRUE)
150 WaitPort(TheDude->UserPort);
151 Msg = (struct IntuiMessage *)GetMsg(TheDude->UserPort);
152 if (IDCMP_CLOSEWINDOW == Msg->Class)
153 break;
154 if (IDCMP_MOUSEMOVE == Msg->Class)
156 printf("Received a delta move message! (%i,%i)\n",Msg->MouseX,Msg->MouseY);
158 ReplyMsg((struct Message *)Msg);
160 uninstallClipRegion(TheDude);
161 CloseWindow(TheDude);
163 CloseLibrary((struct Library *)IntuitionBase);
165 CloseLibrary((struct Library *)GfxBase);
168 return 0;