grub2: bring back build of aros-side grub2 tools
[AROS.git] / workbench / classes / zune / betterstring / mcc / hotkeystring / HotkeyString-Test.c
blobc64faa665db66e9b417aa714776e78523f6ff11d
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/mui.h>
24 #include <libraries/iffparse.h>
25 #include <clib/alib_protos.h>
26 #include <proto/intuition.h>
27 #include <proto/muimaster.h>
28 #include <proto/exec.h>
29 #include <proto/utility.h>
31 #include "private.h"
33 #if defined(__amigaos4__)
34 struct Library *IntuitionBase = NULL;
35 struct Library *MUIMasterBase = NULL;
36 struct Library *UtilityBase = NULL;
37 struct Library *KeymapBase = NULL;
38 #elif defined(__MORPHOS__)
39 struct IntuitionBase *IntuitionBase = NULL;
40 struct Library *MUIMasterBase = NULL;
41 struct Library *UtilityBase = NULL;
42 struct Library *KeymapBase = NULL;
43 #else
44 struct IntuitionBase *IntuitionBase = NULL;
45 struct Library *MUIMasterBase = NULL;
46 #if defined(__AROS__)
47 struct UtilityBase *UtilityBase = NULL;
48 #else
49 struct Library *UtilityBase = NULL;
50 #endif
51 struct Library *KeymapBase = NULL;
52 #endif
54 #if defined(__amigaos4__)
55 struct MUIMasterIFace *IMUIMaster = NULL;
56 struct IntuitionIFace *IIntuition = NULL;
57 struct UtilityIFace *IUtility = NULL;
58 struct KeymapIFace *IKeymap = NULL;
59 #endif
61 DISPATCHERPROTO(_Dispatcher);
63 int main(void)
65 if((IntuitionBase = (APTR)OpenLibrary("intuition.library", 38)) &&
66 GETINTERFACE(IIntuition, IntuitionBase))
67 if((KeymapBase = OpenLibrary("keymap.library", 37)) &&
68 GETINTERFACE(IKeymap, KeymapBase))
69 if((UtilityBase = (APTR)OpenLibrary("utility.library", 38)) &&
70 GETINTERFACE(IUtility, UtilityBase))
71 if((MUIMasterBase = OpenLibrary("muimaster.library", MUIMASTER_VMIN)) &&
72 GETINTERFACE(IMUIMaster, MUIMasterBase))
74 struct MUI_CustomClass *mcc;
75 Object *app, *window, *bstring, *button;
76 const char *classes[] = {"BetterString.mcc", NULL};
78 mcc = MUI_CreateCustomClass(NULL, "BetterString.mcc", NULL, sizeof(struct InstData), ENTRY(_Dispatcher));
79 app = ApplicationObject,
80 MUIA_Application_Author, "Allan Odgaard",
81 MUIA_Application_Base, "HotkeyString-Demo",
82 MUIA_Application_Copyright, "®1997 Allan Odgaard",
83 MUIA_Application_Description, "HotkeyString.mcc demonstration program",
84 MUIA_Application_Title, "HotkeyString-Demo",
85 MUIA_Application_Version, "$VER: HotkeyString-Demo V1.0 (3-Sep-97)",
86 MUIA_Application_UsedClasses, classes,
88 MUIA_Application_Window, window = WindowObject,
89 MUIA_Window_Title, "HotkeyString-Demo",
90 MUIA_Window_ID, MAKE_ID('M','A','I','N'),
91 MUIA_Window_RootObject, VGroup,
92 Child, TextObject,
93 MUIA_Font, MUIV_Font_Tiny,
94 MUIA_Text_Contents, "\33cHotkeyString.mcc",
95 End,
97 Child, HGroup,
98 Child, bstring = ((Object *)NewObject(mcc->mcc_Class, NULL,
99 StringFrame,
100 MUIA_CycleChain, TRUE,
101 MUIA_String_AdvanceOnCR, TRUE,
102 MUIA_HotkeyString_Snoop, FALSE,
103 End),
104 Child, button = TextObject, ButtonFrame,
105 MUIA_CycleChain, TRUE,
106 MUIA_Background, MUII_ButtonBack,
107 MUIA_Text_Contents, "Sample",
108 MUIA_Text_SetMax, TRUE,
109 MUIA_InputMode, MUIV_InputMode_Toggle,
110 End,
111 End,
113 Child, TextObject,
114 MUIA_Font, MUIV_Font_Tiny,
115 MUIA_Text_Contents, "\33cConstant snoop",
116 End,
117 Child, NewObject(mcc->mcc_Class, NULL,
118 StringFrame,
119 MUIA_CycleChain, TRUE,
120 End,
122 End,
123 End,
124 End;
126 if(app)
128 ULONG sigs;
130 DoMethod(window, MUIM_Notify, MUIA_Window_CloseRequest, TRUE, MUIV_Notify_Application, 3, MUIM_Application_ReturnID, MUIV_Application_ReturnID_Quit);
131 DoMethod(button, MUIM_Notify, MUIA_Selected, TRUE, MUIV_Notify_Window, 3, MUIM_Set, MUIA_Window_ActiveObject, bstring);
132 DoMethod(button, MUIM_Notify, MUIA_Selected, MUIV_EveryTime, bstring, 3, MUIM_Set, MUIA_HotkeyString_Snoop, MUIV_TriggerValue);
133 DoMethod(bstring, MUIM_Notify, MUIA_String_Contents, MUIV_EveryTime, button, 3, MUIM_Set, MUIA_Selected, FALSE);
135 set(window, MUIA_Window_ActiveObject, bstring);
136 set(window, MUIA_Window_Open, TRUE);
138 while((LONG)DoMethod(app, MUIM_Application_NewInput, &sigs) != (LONG)MUIV_Application_ReturnID_Quit)
140 if(sigs)
142 sigs = Wait(sigs | SIGBREAKF_CTRL_C);
143 if(sigs & SIGBREAKF_CTRL_C)
144 break;
148 MUI_DisposeObject(app);
149 if(mcc)
150 MUI_DeleteCustomClass(mcc);
153 DROPINTERFACE(IMUIMaster);
154 CloseLibrary(MUIMasterBase);
157 if(UtilityBase)
159 DROPINTERFACE(IUtility);
160 CloseLibrary((struct Library *)UtilityBase);
163 if(KeymapBase)
165 DROPINTERFACE(IKeymap);
166 CloseLibrary(KeymapBase);
169 if(IntuitionBase)
171 DROPINTERFACE(IIntuition);
172 CloseLibrary((struct Library *)IntuitionBase);
175 return 0;