alsa.audio: init/deinit connection to ALSA
[AROS.git] / workbench / demos / strtest.c
blob9f4b210951c16c2f4732ff4da0693bd19a0f3dbc
1 /*
2 Copyright © 1995-2006, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Demo/test for AROS stringgadgets.
6 Lang: english
7 */
9 #include <proto/exec.h>
10 #include <proto/intuition.h>
11 #include <intuition/intuition.h>
13 #define DEBUG 1
14 #include <aros/debug.h>
16 VOID HandleEvents(struct Window *);
18 /***************
19 ** Gadgetry **
20 ***************/
21 #define STRBUFSIZE 100
22 #define STRGADWIDTH 100
23 #define STRGADHEIGHT 20
26 UBYTE strbuf[STRBUFSIZE];
27 UBYTE undobuf[STRBUFSIZE];
29 UWORD strborderdata[] = { 0,0, STRGADWIDTH + 3,0, STRGADWIDTH + 3,STRGADHEIGHT +3,
30 0,STRGADHEIGHT + 3, 0,0};
32 struct Border strborder = { -2, -2, 1, 0, JAM1, 5, strborderdata, };
34 struct StringInfo strinfo = {strbuf, undobuf, 0, STRBUFSIZE, };
35 struct Gadget strgad = {NULL, 20, 20, STRGADWIDTH, STRGADHEIGHT,
36 GFLG_GADGHCOMP, GACT_RELVERIFY|GACT_STRINGLEFT, GTYP_STRGADGET,
37 &strborder, NULL, NULL, 0, &strinfo, 0, NULL, };
39 struct IntuitionBase *IntuitionBase;
41 /*************
42 ** main() **
43 *************/
44 int main(int argc, char **argv)
46 IntuitionBase = (struct IntuitionBase *)OpenLibrary("intuition.library", 37);
47 if (IntuitionBase)
49 struct Window *window = OpenWindowTags(NULL,
50 WA_Width, 200,
51 WA_Height, 100,
52 WA_Title, (IPTR)"Stringgadget Demo",
53 WA_Gadgets, (IPTR)&strgad,
54 WA_IDCMP, IDCMP_GADGETUP|IDCMP_RAWKEY|IDCMP_CLOSEWINDOW,
55 WA_DragBar, TRUE,
56 WA_CloseGadget, TRUE,
57 TAG_END);
58 if (window)
60 HandleEvents(window);
61 CloseWindow(window);
64 CloseLibrary((struct Library *)IntuitionBase);
67 return (0);
70 /*******************
71 ** HandleEvents **
72 *******************/
73 VOID HandleEvents(struct Window *win)
75 struct IntuiMessage *imsg;
76 struct MsgPort *port = win->UserPort;
77 BOOL terminated = FALSE;
79 while (!terminated)
81 if ((imsg = (struct IntuiMessage *)GetMsg(port)) != NULL)
84 switch (imsg->Class)
87 case IDCMP_GADGETUP:
88 break;
90 case IDCMP_RAWKEY:
91 if(imsg->Code == 0x10)
92 terminated = TRUE;
94 break;
96 case IDCMP_CLOSEWINDOW:
97 terminated = TRUE;
98 break;
100 } /* switch (imsg->Class) */
101 ReplyMsg((struct Message *)imsg);
104 } /* if ((imsg = GetMsg(port)) != NULL) */
105 else
107 Wait(1L << port->mp_SigBit);
109 } /* while (!terminated) */
111 return;
112 } /* HandleEvents() */