Squashed commit of 'x11-hostlib' branch
[tangerine.git] / workbench / demos / Zune / mui_input1.c
blobdd86b5566de353b9dfea2a200731980b16a3e554
1 /*
2 Copyright © 1999, David Le Corfec.
3 Copyright © 2002-2003, The AROS Development Team.
4 All rights reserved.
6 $Id$
7 */
9 #define MUIMASTER_NO_INLINE_STDARG
11 #include <exec/types.h>
12 #include <dos/dos.h>
14 //#include <libraries/mui.h>
15 #include <proto/exec.h>
16 #include <proto/intuition.h>
17 #include <proto/muimaster.h>
18 #ifdef __AROS__
19 #include <libraries/mui.h>
20 #endif
22 #include <clib/alib_protos.h>
23 #include <stdio.h>
24 #include <aros/debug.h>
26 struct Library *MUIMasterBase;
28 #define _U(s) ((IPTR)(s))
30 #ifndef __AROS__
32 #include <mui.h> /* Should be somewhen libraries/mui.h */
33 #undef SysBase
35 /* On AmigaOS we build a fake library base, because it's not compiled as sharedlibrary yet */
36 #include "muimaster_intern.h"
38 int openmuimaster(void)
40 static struct MUIMasterBase_intern MUIMasterBase_instance;
41 MUIMasterBase = (struct Library*)&MUIMasterBase_instance;
43 MUIMasterBase_instance.sysbase = *((struct ExecBase **)4);
44 MUIMasterBase_instance.dosbase = OpenLibrary("dos.library",37);
45 MUIMasterBase_instance.utilitybase = OpenLibrary("utility.library",37);
46 MUIMasterBase_instance.aslbase = OpenLibrary("asl.library",37);
47 MUIMasterBase_instance.gfxbase = OpenLibrary("graphics.library",37);
48 MUIMasterBase_instance.layersbase = OpenLibrary("layers.library",37);
49 MUIMasterBase_instance.intuibase = OpenLibrary("intuition.library",37);
50 MUIMasterBase_instance.cxbase = OpenLibrary("commodities.library",37);
51 MUIMasterBase_instance.keymapbase = OpenLibrary("keymap.library",37);
52 __zune_prefs_init(&__zprefs);
54 return 1;
57 void closemuimaster(void)
61 #else
63 int openmuimaster(void)
65 if ((MUIMasterBase = OpenLibrary("muimaster.library", 0))) return 1;
66 return 0;
69 void closemuimaster(void)
71 if (MUIMasterBase) CloseLibrary(MUIMasterBase);
74 #endif
76 Object *SimpleChainedButton (STRPTR label)
78 Object *obj;
80 obj = MUI_MakeObject(MUIO_Button,label);
81 set(obj, MUIA_CycleChain, TRUE);
82 return obj;
85 Object *ChainedCheckmark (STRPTR label)
87 Object *obj;
89 obj = MUI_MakeObject(MUIO_Checkmark, _U(label));
90 set(obj, MUIA_CycleChain, TRUE);
91 return obj;
94 int main (int argc, char **argv)
96 Object *app;
97 Object *mainWin;
98 Object *radio1;
99 Object *radio2;
100 int result = 0;
102 if (!(openmuimaster())) return 20;
104 app = ApplicationObject,
105 SubWindow, mainWin = WindowObject,
106 MUIA_Window_Title, (IPTR)"Input modes",
107 WindowContents, VGroup,
108 Child, MUI_MakeObject(MUIO_BarTitle, (IPTR)_U("MUIV_InputMode_RelVerify")),
109 Child, SimpleChainedButton("Hello world, \33u\33iyo\n"
110 "\33l\33iHello \33bworld\33n, yo\n"
111 "\33iHello world, yo\n"
112 "_Hello \33uwo\0331r\33bl\33n\33ud\33n, \33iyo\n"
113 "\33cI \33ilove MUI\n"
114 "HelloH \33b\33ihello\33nH"),
115 Child, MUI_MakeObject(MUIO_BarTitle, (IPTR)_U("MUIV_InputMode_Toggle")),
116 Child, VSpace(0),
117 Child, HGroup,
118 MUIA_Frame, MUIV_Frame_Group,
119 MUIA_FrameTitle, (IPTR)"The quick brown fox jumps over the lazy dog",
120 MUIA_Background, MUII_GroupBack,
121 Child, ChainedCheckmark("My first checkmark"),
122 End,
123 Child, MUI_MakeObject(MUIO_BarTitle, (IPTR)_U("MUIV_InputMode_Immediate")),
124 Child, HGroup,
125 MUIA_Frame, MUIV_Frame_Group,
126 MUIA_FrameTitle, (IPTR)"Radio",
127 MUIA_FixHeight, 30,
128 Child, radio1 = RectangleObject,
129 MUIA_CycleChain, TRUE,
130 MUIA_ControlChar, 'i',
131 MUIA_InputMode, MUIV_InputMode_Immediate,
132 MUIA_Background, MUII_ButtonBack,
133 MUIA_Frame, MUIV_Frame_Button,
134 End,
135 Child, radio2 = RectangleObject,
136 MUIA_CycleChain, TRUE,
137 MUIA_ControlChar, 'o',
138 MUIA_InputMode, MUIV_InputMode_Immediate,
139 MUIA_Background, MUII_ButtonBack,
140 MUIA_Frame, MUIV_Frame_Button,
141 End,
142 End,
143 End,
144 End,
145 End;
147 if (!app)
149 kprintf("can't create application object.\n");
150 result = 20;
151 goto error;
154 kprintf("*** MUIM_Notify on MUIA_Window_CloseRequest...\n");
155 DoMethod(mainWin, MUIM_Notify, MUIA_Window_CloseRequest, TRUE,
156 _U(app), 2, MUIM_Application_ReturnID, MUIV_Application_ReturnID_Quit);
158 kprintf("*** set up radio1...\n");
159 set(radio1, MUIA_Selected, TRUE);
160 DoMethod(radio1, MUIM_Notify, MUIA_Selected, TRUE,
161 _U(radio2), 3, MUIM_Set, MUIA_Selected, FALSE);
162 DoMethod(radio2, MUIM_Notify, MUIA_Selected, TRUE,
163 _U(radio1), 3, MUIM_Set, MUIA_Selected, FALSE);
166 * Open window and ALWAYS check.
168 kprintf("*** open window...\n");
169 set(mainWin, MUIA_Window_Open, TRUE);
170 if (!XGET(mainWin, MUIA_Window_Open))
172 MUI_DisposeObject(app);
173 kprintf("%s : can't open main window.\n", argv[0]);
174 result = 5;
175 goto error;
179 ULONG sigs = 0;
181 kprintf("*** main loop...\n");
182 while (DoMethod(app, MUIM_Application_NewInput, _U(&sigs))
183 != MUIV_Application_ReturnID_Quit)
185 if (sigs)
187 sigs = Wait(sigs | SIGBREAKF_CTRL_C);
188 if (sigs & SIGBREAKF_CTRL_C) break;
193 kprintf("*** close window...\n");
194 set(mainWin, MUIA_Window_Open, FALSE);
195 kprintf("*** dispose app...\n");
196 MUI_DisposeObject(app);
198 error:
200 closemuimaster();
201 return result;