revert between 56095 -> 55830 in arch
[AROS.git] / workbench / demos / Zune / mui_layout1.c
blobbfb27d39add3d8f0eacaab43bae1cb7b878acc5d
1 /*
2 Copyright © 1999, David Le Corfec.
3 Copyright © 2002, The AROS Development Team.
4 All rights reserved.
6 $Id$
7 */
9 #include <exec/types.h>
10 #include <dos/dos.h>
12 #include <proto/exec.h>
13 #include <proto/intuition.h>
14 #include <proto/muimaster.h>
15 #ifdef __AROS__
16 #include <libraries/mui.h>
17 #endif
18 #include <clib/alib_protos.h>
19 #include <stdio.h>
21 struct Library *MUIMasterBase;
23 #ifndef __AROS__
25 #include <mui.h>
26 #undef SysBase
28 /* On AmigaOS we build a fake library base, because it's not compiled as sharedlibrary yet */
29 #include "muimaster_intern.h"
31 int openmuimaster(void)
33 static struct MUIMasterBase_intern MUIMasterBase_instance;
34 MUIMasterBase = (struct Library*)&MUIMasterBase_instance;
36 MUIMasterBase_instance.sysbase = *((struct ExecBase **)4);
37 MUIMasterBase_instance.dosbase = OpenLibrary("dos.library",37);
38 MUIMasterBase_instance.utilitybase = OpenLibrary("utility.library",37);
39 MUIMasterBase_instance.aslbase = OpenLibrary("asl.library",37);
40 MUIMasterBase_instance.gfxbase = OpenLibrary("graphics.library",37);
41 MUIMasterBase_instance.layersbase = OpenLibrary("layers.library",37);
42 MUIMasterBase_instance.intuibase = OpenLibrary("intuition.library",37);
43 MUIMasterBase_instance.cxbase = OpenLibrary("commodities.library",37);
44 MUIMasterBase_instance.keymapbase = OpenLibrary("keymap.library",37);
45 __zune_prefs_init(&__zprefs);
47 return 1;
50 void closemuimaster(void)
54 #else
56 int openmuimaster(void)
58 if ((MUIMasterBase = OpenLibrary("muimaster.library", 0))) return 1;
59 return 0;
62 void closemuimaster(void)
64 if (MUIMasterBase) CloseLibrary(MUIMasterBase);
67 #endif
69 int main (int argc, char **argv)
71 Object *app;
72 Object *mainWin;
74 if (!openmuimaster()) return 0;
77 * This big call uses macros from mui.h
78 * You may also create intermediate objects.
79 * Usually you will only create one window, which will be
80 * an instance of a custom Window subclass (remember to use
81 * subclasses as much as possible !)
83 app = ApplicationObject,
84 MUIA_Application_Author, "Reez",
85 MUIA_Application_Title, "Layout1",
86 MUIA_Application_Version, "$VER: Layout1 1.0 (01.08.99)",
87 MUIA_Application_Description, "A very simple test program",
88 SubWindow, mainWin = WindowObject,
89 MUIA_Window_Title, "My first MUI app !",
90 WindowContents, VGroup,
91 Child, HGroup,
92 Child, RectangleObject,
93 MUIA_Background, MUII_ButtonBack,
94 MUIA_Frame, MUIV_Frame_Button,
95 MUIA_Weight, 60,
96 MUIA_InnerLeft, 10,
97 MUIA_InnerRight, 10,
98 MUIA_InnerTop, 10,
99 MUIA_InnerBottom, 10,
100 /* MUIA_FixWidth, 30, */
101 End,
102 Child, RectangleObject,
103 MUIA_Background, MUII_FILL,
104 MUIA_Frame, MUIV_Frame_Button,
105 MUIA_FixWidth, 42,
106 End,
107 Child, RectangleObject,
108 MUIA_Background, MUII_FILLSHINE,
109 MUIA_Frame, MUIV_Frame_Button,
110 MUIA_Weight, 40,
111 End,
112 End,
113 Child, HGroup,
114 Child, RectangleObject,
115 MUIA_Background, MUII_SHADOWBACK,
116 MUIA_Frame, MUIV_Frame_Button,
117 MUIA_FixHeight, 30,
118 End,
119 Child, RectangleObject,
120 MUIA_Background, MUII_TextBack,
121 MUIA_Frame, MUIV_Frame_Button,
122 End,
123 End,
124 Child, HGroup,
125 MUIA_Weight, 50,
126 Child, RectangleObject,
127 MUIA_Background, MUII_FILLSHINE,
128 MUIA_Frame, MUIV_Frame_Button,
129 /* MUIA_FixWidth, 30, */
130 End,
131 Child, RectangleObject,
132 MUIA_Background, MUII_FILLBACK,
133 MUIA_Frame, MUIV_Frame_Button,
134 MUIA_Weight, 50,
135 End,
136 End,
137 End,
138 End,
139 End;
141 if (!app)
143 fprintf(stderr, "ERROR: can't create application object.\n");
144 goto error;
146 printf("created Application object %p\n", app);
148 DoMethod(mainWin, MUIM_Notify, MUIA_Window_CloseRequest, TRUE,
149 (IPTR)app, 2, MUIM_Application_ReturnID, MUIV_Application_ReturnID_Quit);
152 * Open window and ALWAYS check.
154 set(mainWin, MUIA_Window_Open, TRUE);
155 if (!XGET(mainWin, MUIA_Window_Open))
157 MUI_DisposeObject(app);
158 fprintf(stderr, "ERROR: can't open main window.\n");
159 goto error;
163 ** This is the ideal input loop for an object oriented MUI application.
164 ** Everything is encapsulated in classes, no return ids need to be used,
165 ** we just check if the program shall terminate.
166 ** Note that MUIM_Application_NewInput expects sigs to contain the result
167 ** from Wait() (or 0). This makes the input loop significantly faster.
170 ULONG sigs = 0;
172 while (DoMethod(app, MUIM_Application_NewInput, (IPTR)&sigs)
173 != MUIV_Application_ReturnID_Quit)
175 if (sigs)
177 sigs = Wait(sigs | SIGBREAKF_CTRL_C);
178 if (sigs & SIGBREAKF_CTRL_C) break;
183 set(mainWin, MUIA_Window_Open, FALSE);
184 MUI_DisposeObject(app);
186 error:
188 closemuimaster();
190 return 0;
195 #ifdef FOO
196 void
197 foo ()
200 * Dynamic window adding
203 Object *dynWin;
205 dynWin = WindowObject,
206 MUIA_Window_Title, "A dynamic window",
207 WindowContents, RectangleObject,
208 MUIA_Background, MUII_SHINE, /* a MUI-fixed color */
209 End,
210 End,
211 End;
213 if (!dynWin)
215 set(mainWin, MUIA_Window_Open, FALSE);
216 MUI_DisposeObject(appli);
217 g_error("can't create dynamic window\n");
220 DoMethod(app, OM_ADDMEMBER, dynWin);
221 /* Window added to Application window list.
222 * Then you should open it ...
225 set(dynWin, MUIA_Window_Open, TRUE);
226 if (!XGET(dynWin, MUIA_Window_Open))
228 MUI_DisposeObject(appli);
229 set(mainWin, MUIA_Window_Open, FALSE);
230 g_error("can't open dynamic window.\n");
233 set(dynWin, MUIA_Window_Open, FALSE);
236 * Remove window from application
238 DoMethod(app, OM_REMMEMBER, dynWin);
240 * If you intend to close a window from one of its methods
241 * (because you subclassed it), use MUIM_Application_PushMethod
242 * to ask another object to destroy you.
243 * Never EVER dispose yourself !!!
245 MUI_DisposeObject(dynWin);
248 #endif
250 /*** EOF ***/