Fixed binary search: no more infinite loops when vendor is unknown.
[tangerine.git] / workbench / classes / zune / betterstring / mcp / Preference.c
blobde4facd0ae4675e1377bc30b2fe3ad2e96cbf496
1 /***************************************************************************
3 BetterString.mcc - A better String gadget MUI Custom Class
4 Copyright (C) 1997-2000 Allan Odgaard
5 Copyright (C) 2005 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 <stdio.h>
25 #include <exec/tasks.h>
26 #include <exec/memory.h>
27 #include <libraries/mui.h>
28 #include <proto/dos.h>
29 #include <proto/exec.h>
30 #include <proto/muimaster.h>
31 #include <proto/intuition.h>
32 #include <proto/iffparse.h>
34 #include "BetterString_mcp.h"
35 #include "locale.h"
36 #include "private.h"
38 #include "SDI_hook.h"
40 #if defined(__amigaos4__)
41 struct Library *IntuitionBase = NULL;
42 struct Library *MUIMasterBase = NULL;
43 struct Library *LocaleBase = NULL;
44 struct Library *UtilityBase = NULL;
45 #elif defined(__MORPHOS__)
46 struct IntuitionBase *IntuitionBase = NULL;
47 struct Library *MUIMasterBase = NULL;
48 struct Library *LocaleBase = NULL;
49 struct Library *UtilityBase = NULL;
50 #else
51 struct IntuitionBase *IntuitionBase = NULL;
52 struct Library *MUIMasterBase = NULL;
53 struct LocaleBase *LocaleBase = NULL;
54 struct Library *UtilityBase = NULL;
55 #endif
57 #if defined(__amigaos4__)
58 struct IntuitionIFace *IIntuition = NULL;
59 struct MUIMasterIFace *IMUIMaster = NULL;
60 struct LocaleIFace *ILocale = NULL;
61 struct UtilityIFace *IUtility = NULL;
62 #endif
64 extern DISPATCHERPROTO(_DispatcherP);
66 int main(void)
68 if((UtilityBase = OpenLibrary("utility.library", 38)) &&
69 GETINTERFACE(IUtility, UtilityBase))
70 if((IntuitionBase = OpenLibrary("intuition.library", 38)) &&
71 GETINTERFACE(IIntuition, IntuitionBase))
72 if((LocaleBase = OpenLibrary("locale.library", 38)) &&
73 GETINTERFACE(ILocale, LocaleBase))
74 if((MUIMasterBase = OpenLibrary("muimaster.library", MUIMASTER_VMIN)) &&
75 GETINTERFACE(IMUIMaster, MUIMasterBase))
77 Object *app = NULL, *window;
78 struct MUI_CustomClass *mcc;
80 OpenCat();
82 if((mcc = MUI_CreateCustomClass(NULL, "Group.mui", NULL, sizeof(struct InstData_MCP), ENTRY(_DispatcherP))))
84 app = MUI_NewObject("Application.mui",
85 MUIA_Application_Author, "Allan Odgaard",
86 MUIA_Application_Base, "BetterString-Prefs",
87 MUIA_Application_Copyright, "®1997 Allan Odgaard",
88 MUIA_Application_Description, "Preference for BetterString.mcc",
89 MUIA_Application_Title, "BetterString-Prefs",
90 MUIA_Application_Version, "$VER: BetterString-Prefs V1.0 (18-Feb-97)",
92 MUIA_Application_Window,
93 window = MUI_NewObject("Window.mui",
94 MUIA_Window_Title, "BetterString-Prefs",
95 MUIA_Window_ID, MAKE_ID('M','A','I','N'),
96 MUIA_Window_RootObject,
97 MUI_NewObject("Group.mui",
98 MUIA_Background, MUII_PageBack,
99 MUIA_Frame, MUIV_Frame_Text,
100 MUIA_InnerBottom, 11,
101 MUIA_InnerLeft, 6,
102 MUIA_InnerRight, 6,
103 MUIA_InnerTop, 11,
105 MUIA_Group_Child,
106 NewObject(mcc->mcc_Class, NULL, TAG_DONE),
108 TAG_DONE ),
109 TAG_DONE ),
110 TAG_DONE );
112 if(app)
114 unsigned long sigs;
116 DoMethod(window, MUIM_Notify,
117 MUIA_Window_CloseRequest, TRUE,
118 app, 2, MUIM_Application_ReturnID, MUIV_Application_ReturnID_Quit);
120 set(window, MUIA_Window_Open, TRUE);
121 while((LONG)DoMethod(app, MUIM_Application_NewInput, &sigs) != MUIV_Application_ReturnID_Quit)
122 if(sigs)
124 sigs = Wait(sigs | SIGBREAKF_CTRL_C);
125 if(sigs & SIGBREAKF_CTRL_C)
126 break;
129 MUI_DisposeObject(app);
131 MUI_DeleteCustomClass(mcc);
134 CloseCat();
136 DROPINTERFACE(IMUIMaster);
137 CloseLibrary(MUIMasterBase);
141 if(LocaleBase)
143 DROPINTERFACE(ILocale);
144 CloseLibrary(LocaleBase);
147 if(IntuitionBase)
149 DROPINTERFACE(IIntuition);
150 CloseLibrary(IntuitionBase);
153 if(UtilityBase)
155 DROPINTERFACE(IUtility);
156 CloseLibrary(UtilityBase);
159 return 0;