Squashed commit of 'x11-hostlib' branch
[tangerine.git] / workbench / demos / Zune / mui_pages.c
blob72169c13dc87508e39421e2ca9fb51277d8d74b1
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 <libraries/mui.h>
13 #include <proto/exec.h>
14 #include <proto/intuition.h>
15 #include <proto/muimaster.h>
16 #ifdef __AROS__
17 #include <libraries/mui.h>
18 #endif
19 #include <clib/alib_protos.h>
20 #include <stdio.h>
22 struct Library *MUIMasterBase;
24 #ifndef __AROS__
26 #include <mui.h>
27 #undef SysBase
29 /* On AmigaOS we build a fake library base, because it's not compiled as sharedlibrary yet */
30 #include "muimaster_intern.h"
32 int openmuimaster(void)
34 static struct MUIMasterBase_intern MUIMasterBase_instance;
35 MUIMasterBase = (struct Library*)&MUIMasterBase_instance;
37 MUIMasterBase_instance.sysbase = *((struct ExecBase **)4);
38 MUIMasterBase_instance.dosbase = OpenLibrary("dos.library",37);
39 MUIMasterBase_instance.utilitybase = OpenLibrary("utility.library",37);
40 MUIMasterBase_instance.aslbase = OpenLibrary("asl.library",37);
41 MUIMasterBase_instance.gfxbase = OpenLibrary("graphics.library",37);
42 MUIMasterBase_instance.layersbase = OpenLibrary("layers.library",37);
43 MUIMasterBase_instance.intuibase = OpenLibrary("intuition.library",37);
44 MUIMasterBase_instance.cxbase = OpenLibrary("commodities.library",37);
45 MUIMasterBase_instance.keymapbase = OpenLibrary("keymap.library",37);
46 __zune_prefs_init(&__zprefs);
48 return 1;
51 void closemuimaster(void)
55 #else
57 int openmuimaster(void)
59 if ((MUIMasterBase = OpenLibrary("muimaster.library", 0))) return 1;
60 return 0;
63 void closemuimaster(void)
65 if (MUIMasterBase) CloseLibrary(MUIMasterBase);
68 #endif
70 int main (int argc, char **argv)
72 Object *app;
73 Object *mainWin;
74 Object *pages;
75 Object *stepb[2];
76 Object *b[3];
77 int i;
79 if (!openmuimaster()) return 20;
81 app = ApplicationObject,
82 SubWindow, mainWin = WindowObject,
83 MUIA_Window_Title, "Pages",
84 WindowContents, VGroup,
85 Child, VGroup,
86 GroupFrame,
87 Child, HGroup,
88 Child, stepb[0] = RectangleObject,
89 MUIA_Rectangle_BarTitle, "prev",
90 MUIA_CycleChain, TRUE,
91 MUIA_InnerLeft, 20,
92 MUIA_FixHeight, 20,
93 MUIA_InputMode, MUIV_InputMode_RelVerify,
94 MUIA_Background, MUII_ButtonBack,
95 ButtonFrame,
96 End,
97 Child, stepb[1] = RectangleObject,
98 MUIA_Rectangle_BarTitle, "next",
99 MUIA_CycleChain, TRUE,
100 MUIA_InnerLeft, 20,
101 MUIA_InputMode, MUIV_InputMode_RelVerify,
102 MUIA_Background, MUII_ButtonBack,
103 ButtonFrame,
104 End,
105 End,
107 Child, MUI_MakeObject(MUIO_HBar, 4),
108 Child, HGroup,
109 Child, b[0] = RectangleObject,
110 MUIA_Rectangle_BarTitle, "1",
111 MUIA_CycleChain, TRUE,
112 MUIA_InputMode, MUIV_InputMode_RelVerify,
113 MUIA_FixHeight, 20,
114 MUIA_Background, MUII_ButtonBack,
115 ButtonFrame,
116 End,
117 Child, b[1] = RectangleObject,
118 MUIA_Rectangle_BarTitle, "2",
119 MUIA_CycleChain, TRUE,
120 MUIA_InputMode, MUIV_InputMode_RelVerify,
121 MUIA_FixHeight, 20,
122 MUIA_Background, MUII_ButtonBack,
123 ButtonFrame,
124 End,
125 Child, b[2] = RectangleObject,
126 MUIA_Rectangle_BarTitle, "3",
127 MUIA_CycleChain, TRUE,
128 MUIA_InputMode, MUIV_InputMode_RelVerify,
129 MUIA_FixHeight, 20,
130 MUIA_Background, MUII_ButtonBack,
131 ButtonFrame,
132 End,
133 End,
134 End,
135 Child, pages = HGroup,
136 MUIA_Group_PageMode, TRUE,
137 InputListFrame,
138 MUIA_Background, MUII_PageBack,
139 Child, RectangleObject,
140 MUIA_FixWidth, 50,
141 MUIA_Background, MUII_SHADOW,
142 MUIA_Rectangle_BarTitle, "Rect1",
143 End,
144 Child, RectangleObject,
145 MUIA_FixWidth, 30,
146 MUIA_FixHeight, 30,
147 MUIA_Background, MUII_SHINE,
148 MUIA_Rectangle_BarTitle, "Rect2",
149 End,
150 Child, RectangleObject,
151 MUIA_FixHeight, 50,
152 MUIA_Background, MUII_FILL,
153 MUIA_Rectangle_BarTitle, "Rect3",
154 End,
155 End,
156 End,
157 End,
158 End;
160 if (!app)
162 fprintf(stderr, "can't create application object.\n");
163 goto error;
166 DoMethod(mainWin, MUIM_Notify, MUIA_Window_CloseRequest, TRUE,
167 (IPTR)app, 2,
168 MUIM_Application_ReturnID, MUIV_Application_ReturnID_Quit);
170 DoMethod(stepb[0], MUIM_Notify, MUIA_Timer, MUIV_EveryTime,
171 (IPTR)pages, 3, MUIM_Set,
172 MUIA_Group_ActivePage, MUIV_Group_ActivePage_Prev);
174 DoMethod(stepb[1], MUIM_Notify, MUIA_Timer, MUIV_EveryTime,
175 (IPTR)pages, 3, MUIM_Set,
176 MUIA_Group_ActivePage, MUIV_Group_ActivePage_Next);
178 for (i = 0; i < 3; i++)
180 DoMethod(b[i], MUIM_Notify, MUIA_Pressed, FALSE,
181 (IPTR)pages, 3, MUIM_Set, MUIA_Group_ActivePage, i);
184 * Open window and ALWAYS check.
186 set(mainWin, MUIA_Window_Open, TRUE);
187 if (!XGET(mainWin, MUIA_Window_Open))
189 MUI_DisposeObject(app);
190 fprintf(stderr, "can't open main window.\n");
191 goto error;
195 ULONG sigs = 0;
197 while (DoMethod(app, MUIM_Application_NewInput, (IPTR)&sigs)
198 != MUIV_Application_ReturnID_Quit)
200 if (sigs)
202 sigs = Wait(sigs | SIGBREAKF_CTRL_C);
203 if (sigs & SIGBREAKF_CTRL_C) break;
208 set(mainWin, MUIA_Window_Open, FALSE);
209 MUI_DisposeObject(app);
211 error:
213 closemuimaster();
215 return 0;
218 /*** EOF ***/