grub2: bring back build of aros-side grub2 tools
[AROS.git] / workbench / classes / zune / betterstring / mcc / BetterString-Test.c
blob988ab2e148ba461d03fd8bc4082848012594567c
1 /***************************************************************************
3 BetterString.mcc - A better String gadget MUI Custom Class
4 Copyright (C) 1997-2000 Allan Odgaard
5 Copyright (C) 2005-2013 by BetterString.mcc Open Source Team
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either
10 version 2.1 of the License, or (at your option) any later version.
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
17 BetterString class Support Site: http://www.sf.net/projects/bstring-mcc/
19 $Id$
21 ***************************************************************************/
23 #include <libraries/asl.h>
24 #include <libraries/mui.h>
25 #include <libraries/iffparse.h>
26 #include <clib/alib_protos.h>
27 #include <proto/intuition.h>
28 #include <proto/muimaster.h>
29 #include <proto/exec.h>
30 #include <proto/utility.h>
32 #include "private.h"
34 #if defined(__amigaos4__)
35 struct Library *DiskfontBase = NULL;
36 struct Library *GfxBase = NULL;
37 struct Library *IntuitionBase = NULL;
38 struct Library *MUIMasterBase = NULL;
39 struct Library *LayersBase = NULL;
40 struct Library *LocaleBase = NULL;
41 struct Library *UtilityBase = NULL;
42 struct Library *KeymapBase = NULL;
43 #elif defined(__MORPHOS__)
44 struct Library *DiskfontBase = NULL;
45 struct Library *GfxBase = NULL;
46 struct IntuitionBase *IntuitionBase = NULL;
47 struct Library *MUIMasterBase = NULL;
48 struct Library *LayersBase = NULL;
49 struct Library *LocaleBase = NULL;
50 struct Library *UtilityBase = NULL;
51 struct Library *KeymapBase = NULL;
52 #else
53 struct Library *DiskfontBase = NULL;
54 struct Library *GfxBase = NULL;
55 struct IntuitionBase *IntuitionBase = NULL;
56 struct Library *MUIMasterBase = NULL;
57 struct Library *LayersBase = NULL;
58 struct Library *LocaleBase = NULL;
59 #if defined(__AROS__)
60 struct UtilityBase *UtilityBase = NULL;
61 #else
62 struct Library *UtilityBase = NULL;
63 #endif
64 struct Library *KeymapBase = NULL;
65 #endif
67 #if defined(__amigaos4__)
68 struct DiskfontIFace *IDiskfont = NULL;
69 struct GraphicsIFace *IGraphics = NULL;
70 struct MUIMasterIFace *IMUIMaster = NULL;
71 struct IntuitionIFace *IIntuition = NULL;
72 struct LayersIFace *ILayers = NULL;
73 struct LocaleIFace *ILocale = NULL;
74 struct UtilityIFace *IUtility = NULL;
75 struct KeymapIFace *IKeymap = NULL;
76 #endif
78 DISPATCHERPROTO(_Dispatcher);
80 int main(void)
82 if((DiskfontBase = OpenLibrary("diskfont.library", 38)) &&
83 GETINTERFACE(IDiskfont, DiskfontBase))
84 if((GfxBase = OpenLibrary("graphics.library", 38)) &&
85 GETINTERFACE(IGraphics, GfxBase))
86 if((IntuitionBase = (APTR)OpenLibrary("intuition.library", 38)) &&
87 GETINTERFACE(IIntuition, IntuitionBase))
88 if((KeymapBase = OpenLibrary("keymap.library", 37)) &&
89 GETINTERFACE(IKeymap, KeymapBase))
90 if((LocaleBase = OpenLibrary("locale.library", 38)) &&
91 GETINTERFACE(ILocale, LocaleBase))
92 if((LayersBase = OpenLibrary("layers.library", 38)) &&
93 GETINTERFACE(ILayers, LayersBase))
94 if((UtilityBase = (APTR)OpenLibrary("utility.library", 38)) &&
95 GETINTERFACE(IUtility, UtilityBase))
96 if((MUIMasterBase = OpenLibrary("muimaster.library", MUIMASTER_VMIN)) &&
97 GETINTERFACE(IMUIMaster, MUIMasterBase))
98 if(StartClipboardServer() == TRUE)
99 if(CreateSharedPool() == TRUE)
101 struct MUI_CustomClass *mcc;
102 Object *a1, *a2, *app, *window, *bstring, *bstring2, *bpos, *ssize, *button, *numbutton;
103 const char *classes[] = {"BetterString.mcp", NULL};
105 #if defined(DEBUG)
106 SetupDebug();
107 #endif
109 mcc = MUI_CreateCustomClass(NULL, "Area.mui", NULL, sizeof(struct InstData), ENTRY(_Dispatcher));
111 app = ApplicationObject,
112 MUIA_Application_Author, "BetterString.mcc Open Source Team",
113 MUIA_Application_Base, "BetterString-Test",
114 MUIA_Application_Copyright, "(C) 2005-2013 by BetterString.mcc Open Source Team",
115 MUIA_Application_Description, "BetterString.mcc demonstration program",
116 MUIA_Application_Title, "BetterString-Test",
117 MUIA_Application_Version, "$VER: BetterString-Demo V1.0 (18.05.2007)",
118 MUIA_Application_UsedClasses, classes,
120 MUIA_Application_Window, window = WindowObject,
121 MUIA_Window_Title, "BetterString-Test",
122 MUIA_Window_ID, MAKE_ID('M','A','I','N'),
123 MUIA_Window_RootObject, VGroup,
125 Child, PopaslObject,
126 MUIA_Popstring_String, NewObject(mcc->mcc_Class, NULL, StringFrame, MUIA_BetterString_NoInput, TRUE, MUIA_CycleChain, TRUE, End,
127 MUIA_Popstring_Button, MUI_MakeObject(MUIO_PopButton, MUII_PopUp),
128 MUIA_Popasl_Type, ASL_FontRequest,
129 End,
131 Child, ColGroup(2), StringFrame,
132 MUIA_Background, MUII_GroupBack,
133 Child, TextObject,
134 MUIA_Weight, 0,
135 MUIA_Text_Contents, "\33rName:",
136 End,
137 Child, a1 = (Object *)NewObject(mcc->mcc_Class, NULL,
138 MUIA_CycleChain, TRUE,
139 MUIA_Background, MUII_GroupBack,
140 MUIA_Frame, MUIV_Frame_None,
141 MUIA_String_AdvanceOnCR, TRUE,
142 MUIA_String_MaxLen, 10,
143 MUIA_ObjectID, MAKE_ID('N','A','M','E'),
144 End,
145 Child, TextObject,
146 MUIA_Weight, 0,
147 MUIA_Text_Contents, "\33rStreet:",
148 End,
149 Child, a2 = (Object *)NewObject(mcc->mcc_Class, NULL,
150 MUIA_CycleChain, TRUE,
151 MUIA_Background, MUII_GroupBack,
152 MUIA_Frame, MUIV_Frame_None,
153 MUIA_String_AdvanceOnCR, TRUE,
154 MUIA_ObjectID, MAKE_ID('S','T','R','T'),
155 End,
156 Child, TextObject,
157 MUIA_Weight, 0,
158 MUIA_Text_Contents, "\33rZip, City:",
159 End,
160 Child, NewObject(mcc->mcc_Class, NULL,
161 MUIA_CycleChain, TRUE,
162 MUIA_Background, MUII_GroupBack,
163 MUIA_Frame, MUIV_Frame_None,
164 MUIA_String_AdvanceOnCR, TRUE,
165 MUIA_ObjectID, MAKE_ID('C','I','T','Y'),
166 End,
167 End,
169 Child, TextObject,
170 MUIA_Font, MUIV_Font_Tiny,
171 MUIA_Text_Contents, "\33cBetterString.mcc",
172 End,
173 Child, NewObject(mcc->mcc_Class, NULL,
174 StringFrame,
175 MUIA_CycleChain, TRUE,
176 MUIA_String_Secret, TRUE,
177 // MUIA_String_MaxLen, 20,
178 MUIA_String_AdvanceOnCR, TRUE,
179 MUIA_BetterString_StayActive, TRUE,
180 // MUIA_String_Accept, "0123456789",
181 MUIA_String_Contents, "This is a wonderful example string!",
182 End,
183 Child, NewObject(mcc->mcc_Class, NULL,
184 StringFrame,
185 MUIA_CycleChain, TRUE,
186 MUIA_BetterString_InactiveContents, "This is a wonderful example string!",
187 End,
188 Child, NewObject(mcc->mcc_Class, NULL,
189 StringFrame,
190 MUIA_CycleChain, TRUE,
191 MUIA_String_Secret, TRUE,
192 MUIA_BetterString_InactiveContents, "This is a wonderful example string!",
193 End,
194 Child, TextObject,
195 MUIA_Font, MUIV_Font_Tiny,
196 MUIA_Text_Contents, "\33cCentered",
197 End,
198 Child, bstring = (Object *)NewObject(mcc->mcc_Class, NULL,
199 ButtonFrame,
200 MUIA_Font, MUIV_Font_Big,
201 // StringFrame,
202 MUIA_String_AdvanceOnCR, TRUE,
203 MUIA_String_Format, MUIV_String_Format_Center,
204 MUIA_String_Contents, "This is a wonderful example string!",
205 MUIA_CycleChain, TRUE,
206 End,
207 Child, TextObject,
208 MUIA_Font, MUIV_Font_Tiny,
209 MUIA_Text_Contents, "\33cRight-Aligned",
210 End,
211 Child, bstring2 = NewObject(mcc->mcc_Class, NULL,
212 MUIA_CycleChain, TRUE,
213 // StringFrame,
214 MUIA_String_AdvanceOnCR, TRUE,
215 MUIA_String_Contents, "This is a wonderful example string!",
216 MUIA_String_Format, MUIV_String_Format_Right,
217 End,
218 Child, TextObject,
219 MUIA_Font, MUIV_Font_Tiny,
220 MUIA_Text_Contents, "\33cStringObject",
221 End,
222 Child, StringObject,
223 StringFrame,
224 MUIA_String_AdvanceOnCR, TRUE,
225 MUIA_String_Contents, "This is a standard StringObject",
226 MUIA_String_Format, MUIV_String_Format_Right,
227 MUIA_String_MaxLen, 1024,
228 MUIA_CycleChain, TRUE,
229 End,
230 Child, (Object *)NewObject(mcc->mcc_Class, NULL,
231 StringFrame,
232 MUIA_String_AdvanceOnCR, TRUE,
233 MUIA_String_Contents, "Select on activate",
234 MUIA_String_MaxLen, 1024,
235 MUIA_CycleChain, TRUE,
236 MUIA_BetterString_SelectOnActive, TRUE,
237 End,
238 Child, HGroup,
239 Child, button = SimpleButton("Insert"),
240 Child, bpos = SliderObject,
241 MUIA_Slider_Horiz, TRUE,
242 MUIA_Numeric_Max, 60,
243 End,
244 Child, ssize = SliderObject,
245 MUIA_Slider_Horiz, TRUE,
246 MUIA_Numeric_Min, -30,
247 MUIA_Numeric_Max, 30,
248 MUIA_Numeric_Value, 0,
249 End,
250 Child, numbutton = NumericbuttonObject,
251 MUIA_Numeric_Min, -30,
252 MUIA_Numeric_Max, 30,
253 MUIA_Numeric_Value, 0,
254 MUIA_Disabled, TRUE,
255 End,
256 End,
257 End,
258 End,
259 End;
261 if(app)
263 ULONG sigs;
265 DoMethod(app, MUIM_Application_Load, MUIV_Application_Load_ENV);
267 DoMethod(a1, MUIM_Notify, MUIA_String_Contents, MUIV_EveryTime, a2, 3, MUIM_Set, MUIA_String_Contents, MUIV_TriggerValue);
268 DoMethod(a2, MUIM_Notify, MUIA_String_Contents, MUIV_EveryTime, a1, 3, MUIM_Set, MUIA_String_Contents, MUIV_TriggerValue);
270 DoMethod(ssize, MUIM_Notify, MUIA_Numeric_Value, MUIV_EveryTime, numbutton, 3, MUIM_Set, MUIA_Numeric_Value, MUIV_TriggerValue);
271 DoMethod(bpos, MUIM_Notify, MUIA_Numeric_Value, MUIV_EveryTime, bstring, 3, MUIM_Set, MUIA_String_BufferPos, MUIV_TriggerValue);
272 DoMethod(ssize, MUIM_Notify, MUIA_Numeric_Value, MUIV_EveryTime, bstring, 3, MUIM_Set, MUIA_BetterString_SelectSize, MUIV_TriggerValue);
273 DoMethod(button, MUIM_Notify, MUIA_Pressed, FALSE, bstring, 3, MUIM_BetterString_Insert, "*Test*", MUIV_BetterString_Insert_BufferPos);
274 DoMethod(window, MUIM_Notify, MUIA_Window_CloseRequest, TRUE, MUIV_Notify_Application, 2, MUIM_Application_ReturnID, MUIV_Application_ReturnID_Quit);
276 set(bstring, MUIA_BetterString_KeyDownFocus, bstring2);
277 set(bstring2, MUIA_BetterString_KeyUpFocus, bstring);
279 set(window, MUIA_Window_ActiveObject, bstring);
280 set(window, MUIA_Window_DefaultObject, bstring);
281 set(window, MUIA_Window_Open, TRUE);
283 while((LONG)DoMethod(app, MUIM_Application_NewInput, &sigs) != MUIV_Application_ReturnID_Quit)
285 if(sigs)
287 sigs = Wait(sigs | SIGBREAKF_CTRL_C);
288 if(sigs & SIGBREAKF_CTRL_C)
289 break;
292 DoMethod(app, MUIM_Application_Save, MUIV_Application_Save_ENV);
294 MUI_DisposeObject(app);
295 if(mcc)
296 MUI_DeleteCustomClass(mcc);
299 DROPINTERFACE(IMUIMaster);
300 CloseLibrary(MUIMasterBase);
301 MUIMasterBase = NULL;
304 DeleteSharedPool();
305 ShutdownClipboardServer();
307 if(UtilityBase)
309 DROPINTERFACE(IUtility);
310 CloseLibrary((struct Library *)UtilityBase);
313 if(LayersBase)
315 DROPINTERFACE(ILayers);
316 CloseLibrary(LayersBase);
319 if(LocaleBase)
321 DROPINTERFACE(ILocale);
322 CloseLibrary(LocaleBase);
325 if(KeymapBase)
327 DROPINTERFACE(IKeymap);
328 CloseLibrary(KeymapBase);
331 if(IntuitionBase)
333 DROPINTERFACE(IIntuition);
334 CloseLibrary((struct Library *)IntuitionBase);
337 if(GfxBase)
339 DROPINTERFACE(IGraphics);
340 CloseLibrary(GfxBase);
343 if(DiskfontBase)
345 DROPINTERFACE(IDiskfont);
346 CloseLibrary(DiskfontBase);
349 return 0;