2 Copyright © 1999, David Le Corfec.
3 Copyright © 2002, The AROS Development Team.
9 #include <exec/types.h>
12 #include <proto/exec.h>
13 #include <proto/intuition.h>
14 #include <proto/muimaster.h>
16 #include <libraries/mui.h>
18 #include <clib/alib_protos.h>
21 struct Library
*MUIMasterBase
;
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
);
50 void closemuimaster(void)
56 int openmuimaster(void)
58 if ((MUIMasterBase
= OpenLibrary("muimaster.library", 0))) return 1;
62 void closemuimaster(void)
64 if (MUIMasterBase
) CloseLibrary(MUIMasterBase
);
69 int main (int argc
, char **argv
)
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
,
92 Child
, RectangleObject
,
93 MUIA_Background
, MUII_ButtonBack
,
94 MUIA_Frame
, MUIV_Frame_Button
,
100 /* MUIA_FixWidth, 30, */
102 Child
, RectangleObject
,
103 MUIA_Background
, MUII_FILL
,
104 MUIA_Frame
, MUIV_Frame_Button
,
107 Child
, RectangleObject
,
108 MUIA_Background
, MUII_FILLSHINE
,
109 MUIA_Frame
, MUIV_Frame_Button
,
114 Child
, RectangleObject
,
115 MUIA_Background
, MUII_SHADOWBACK
,
116 MUIA_Frame
, MUIV_Frame_Button
,
119 Child
, RectangleObject
,
120 MUIA_Background
, MUII_TextBack
,
121 MUIA_Frame
, MUIV_Frame_Button
,
126 Child
, RectangleObject
,
127 MUIA_Background
, MUII_FILLSHINE
,
128 MUIA_Frame
, MUIV_Frame_Button
,
129 /* MUIA_FixWidth, 30, */
131 Child
, RectangleObject
,
132 MUIA_Background
, MUII_FILLBACK
,
133 MUIA_Frame
, MUIV_Frame_Button
,
143 fprintf(stderr
, "ERROR: can't create application object.\n");
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");
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.
172 while (DoMethod(app
, MUIM_Application_NewInput
, (IPTR
)&sigs
)
173 != MUIV_Application_ReturnID_Quit
)
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
);
200 * Dynamic window adding
205 dynWin
= WindowObject
,
206 MUIA_Window_Title
, "A dynamic window",
207 WindowContents
, RectangleObject
,
208 MUIA_Background
, MUII_SHINE
, /* a MUI-fixed color */
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
);