added concrete implementations of putc(), getc(), getchar() and gets()
[tangerine.git] / workbench / demos / window.c
blobebdf59ab623bfc778379e93fb4cee1d991dba4c7
1 /*
2 Copyright © 1999, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Demo showing moving and sizing of windows
6 Lang: English.
7 */
9 #include <stdio.h>
10 #include <string.h>
11 #include <exec/types.h>
12 #include <graphics/rastport.h>
13 #include <graphics/gfxmacros.h>
14 #include <intuition/intuition.h>
15 #include <proto/dos.h>
16 #include <proto/exec.h>
17 #include <proto/graphics.h>
18 #include <proto/intuition.h>
20 struct IntuitionBase *IntuitionBase;
21 struct GfxBase *GfxBase;
22 struct Library *LayersBase;
23 struct DosLibrary *DOSBase;
25 struct IntuiMessage *msg;
27 struct Window *openwindow(LONG x, LONG y, LONG w, LONG h);
30 int main(int argc, char **argv)
32 int x, y;
34 if ((IntuitionBase = (struct IntuitionBase *) OpenLibrary("intuition.library", 0)))
36 if ((GfxBase = (struct GfxBase *)OpenLibrary("graphics.library", 0)))
38 if ((DOSBase = (struct DosLibrary *) OpenLibrary("dos.library",0)))
40 struct Window *w1;
42 w1 = openwindow(100, 100, 100, 100);
44 if (w1)
46 printf( "MoveWindow()...\n" );
47 for( x=0 ; x<50 ; x++ )
49 MoveWindow(w1,1,0);
50 // RefreshWindowFrame(w1);
52 for( y=0 ; y<50 ; y++ )
54 MoveWindow(w1,0,1);
55 // RefreshWindowFrame(w1);
58 printf( "ChangeWindowBox()...\n" );
59 for( x=0 ; x<50 ; x++ )
61 ChangeWindowBox(w1,150-x,150-x,100+x,100+x);
62 RefreshWindowFrame(w1);
65 printf( "SizeWindow()...\n" );
66 for( y=0 ; y<50 ; y++ )
68 SizeWindow(w1,-1,-1);
69 RefreshWindowFrame(w1);
72 printf( "Done!\nPress a key or click closegadget to quit.\n" );
74 Wait(1L<<w1->UserPort->mp_SigBit);
75 msg = (struct IntuiMessage *)GetMsg(w1->UserPort);
76 /* Catch any message to quit */
77 ReplyMsg((struct Message *)msg);
79 CloseWindow(w1);
81 CloseLibrary((struct Library *)DOSBase);
83 CloseLibrary((struct Library *)GfxBase);
85 CloseLibrary((struct Library *) IntuitionBase);
87 return 0;
88 } /* main */
92 struct Window *openwindow(LONG x, LONG y, LONG w, LONG h)
95 struct Window *window;
96 struct Rectangle R;
97 R.MinX = 10;
98 R.MinY = 10;
99 R.MaxX = 100;
100 R.MaxY = 100;
102 window = OpenWindowTags(NULL,
103 WA_IDCMP, IDCMP_RAWKEY|IDCMP_CLOSEWINDOW,
104 WA_Left, x,
105 WA_Top, y,
106 WA_Height, w,
107 WA_Width, h,
108 WA_Activate, TRUE,
109 WA_DepthGadget, TRUE,
110 WA_Zoom, (IPTR)&R,
111 WA_CloseGadget, TRUE,
112 WA_Title, (IPTR)"Windowing demo",
113 TAG_END);
115 printf("Window opened\n");
117 return window;