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/
21 ***************************************************************************/
23 #include <proto/exec.h>
24 #include <proto/intuition.h>
25 #include <proto/iffparse.h>
26 #include <proto/muimaster.h>
27 #include <libraries/asl.h>
28 #include <libraries/mui.h>
30 #include "BetterString_mcc.h"
33 #if defined(__amigaos4__)
34 struct Library
*DiskfontBase
= NULL
;
35 struct Library
*GfxBase
= NULL
;
36 struct Library
*IntuitionBase
= NULL
;
37 struct Library
*MUIMasterBase
= NULL
;
38 struct Library
*LocaleBase
= NULL
;
39 struct Library
*UtilityBase
= NULL
;
40 struct Library
*KeymapBase
= NULL
;
41 #elif defined(__MORPHOS__)
42 struct Library
*DiskfontBase
= NULL
;
43 struct Library
*GfxBase
= NULL
;
44 struct IntuitionBase
*IntuitionBase
= NULL
;
45 struct Library
*MUIMasterBase
= NULL
;
46 struct Library
*LocaleBase
= NULL
;
47 struct Library
*UtilityBase
= NULL
;
48 struct Library
*KeymapBase
= NULL
;
50 struct Library
*DiskfontBase
= NULL
;
51 struct Library
*GfxBase
= NULL
;
52 struct IntuitionBase
*IntuitionBase
= NULL
;
53 struct Library
*MUIMasterBase
= NULL
;
54 struct Library
*LocaleBase
= NULL
;
55 struct Library
*UtilityBase
= NULL
;
56 struct Library
*KeymapBase
= NULL
;
59 #if defined(__amigaos4__)
60 struct DiskfontIFace
*IDiskfont
= NULL
;
61 struct GraphicsIFace
*IGraphics
= NULL
;
62 struct MUIMasterIFace
*IMUIMaster
= NULL
;
63 struct IntuitionIFace
*IIntuition
= NULL
;
64 struct LocaleIFace
*ILocale
= NULL
;
65 struct UtilityIFace
*IUtility
= NULL
;
66 struct KeymapIFace
*IKeymap
= NULL
;
69 extern SAVEDS ASM ULONG
_Dispatcher(REG(a0
, struct IClass
* cl
), REG(a2
, Object
* obj
), REG(a1
, Msg msg
));
72 DISPATCHERPROTO(_Dispatcher
);
77 if((DiskfontBase
= OpenLibrary("diskfont.library", 38)) &&
78 GETINTERFACE(IDiskfont
, DiskfontBase
))
79 if((GfxBase
= OpenLibrary("graphics.library", 38)) &&
80 GETINTERFACE(IGraphics
, GfxBase
))
81 if((IntuitionBase
= (APTR
)OpenLibrary("intuition.library", 38)) &&
82 GETINTERFACE(IIntuition
, IntuitionBase
))
83 if((KeymapBase
= OpenLibrary("keymap.library", 38)) &&
84 GETINTERFACE(IKeymap
, KeymapBase
))
85 if((LocaleBase
= OpenLibrary("locale.library", 38)) &&
86 GETINTERFACE(ILocale
, LocaleBase
))
87 if((UtilityBase
= OpenLibrary("utility.library", 38)) &&
88 GETINTERFACE(IUtility
, UtilityBase
))
89 if((MUIMasterBase
= OpenLibrary("muimaster.library", MUIMASTER_VMIN
)) &&
90 GETINTERFACE(IMUIMaster
, MUIMasterBase
))
92 struct MUI_CustomClass
*mcc
;
93 Object
*a1
, *a2
, *app
, *window
, *bstring
, *bpos
, *ssize
, *button
, *numbutton
;
94 STRPTR classes
[] = {"BetterString.mcc", NULL
};
96 mcc
= MUI_CreateCustomClass(NULL
, "Area.mui", NULL
, sizeof(struct InstData
), ENTRY(_Dispatcher
));
97 app
= ApplicationObject
,
98 MUIA_Application_Author
, "Allan Odgaard",
99 MUIA_Application_Base
, "BetterString-Demo",
100 MUIA_Application_Copyright
, "®1997 Allan Odgaard",
101 MUIA_Application_Description
, "BetterString.mcc demonstration program",
102 MUIA_Application_Title
, "BetterString-Demo",
103 MUIA_Application_Version
, "$VER: BetterString-Demo V1.0 (3-Sep-97)",
104 MUIA_Application_UsedClasses
, classes
,
106 MUIA_Application_Window
, window
= WindowObject
,
107 MUIA_Window_Title
, "BetterString-Demo",
108 MUIA_Window_ID
, MAKE_ID('M','A','I','N'),
109 MUIA_Window_RootObject
, VGroup
,
112 MUIA_Popstring_String
, NewObject(mcc
->mcc_Class
, NULL
, StringFrame
, MUIA_BetterString_NoInput
, TRUE
, MUIA_CycleChain
, TRUE
, End
,
113 MUIA_Popstring_Button
, MUI_MakeObject(MUIO_PopButton
, MUII_PopUp
),
114 MUIA_Popasl_Type
, ASL_FontRequest
,
117 Child
, ColGroup(2), StringFrame
,
118 MUIA_Background
, MUII_GroupBack
,
121 MUIA_Text_Contents
, "\33rName:",
123 Child
, a1
= (Object
*)NewObject(mcc
->mcc_Class
, NULL
,
124 MUIA_CycleChain
, TRUE
,
125 MUIA_Background
, MUII_GroupBack
,
126 MUIA_String_AdvanceOnCR
, TRUE
,
127 MUIA_String_MaxLen
, 10,
128 MUIA_ObjectID
, MAKE_ID('N','A','M','E'),
132 MUIA_Text_Contents
, "\33rStreet:",
134 Child
, a2
= (Object
*)NewObject(mcc
->mcc_Class
, NULL
,
135 MUIA_CycleChain
, TRUE
,
136 MUIA_Background
, MUII_GroupBack
,
137 MUIA_String_AdvanceOnCR
, TRUE
,
138 MUIA_ObjectID
, MAKE_ID('S','T','R','T'),
142 MUIA_Text_Contents
, "\33rZip, City:",
144 Child
, NewObject(mcc
->mcc_Class
, NULL
,
145 MUIA_CycleChain
, TRUE
,
146 MUIA_Background
, MUII_GroupBack
,
147 MUIA_String_AdvanceOnCR
, TRUE
,
148 MUIA_ObjectID
, MAKE_ID('C','I','T','Y'),
153 MUIA_Font
, MUIV_Font_Tiny
,
154 MUIA_Text_Contents
, "\33cBetterString.mcc",
156 Child
, bstring
= (Object
*)NewObject(mcc
->mcc_Class
, NULL
,
158 MUIA_CycleChain
, TRUE
,
159 MUIA_String_Secret
, TRUE
,
160 // MUIA_String_MaxLen, 20,
161 MUIA_String_AdvanceOnCR
, TRUE
,
162 MUIA_BetterString_StayActive
, TRUE
,
163 // MUIA_String_Accept, "0123456789",
164 MUIA_String_Contents
, "This is some crappy shit!",
167 MUIA_Font
, MUIV_Font_Tiny
,
168 MUIA_Text_Contents
, "\33cCentered",
170 Child
, NewObject(mcc
->mcc_Class
, NULL
,
172 MUIA_Font
, MUIV_Font_Big
,
174 MUIA_String_AdvanceOnCR
, TRUE
,
175 MUIA_String_Format
, MUIV_String_Format_Center
,
176 MUIA_String_Contents
, "This is some crappy shit!",
177 MUIA_CycleChain
, TRUE
,
180 MUIA_Font
, MUIV_Font_Tiny
,
181 MUIA_Text_Contents
, "\33cRight-Aligned",
183 Child
, NewObject(mcc
->mcc_Class
, NULL
,
185 MUIA_String_AdvanceOnCR
, TRUE
,
186 MUIA_String_Contents
, "This is some crappy shit!",
187 MUIA_String_Format
, MUIV_String_Format_Right
,
188 MUIA_CycleChain
, TRUE
,
191 MUIA_Font
, MUIV_Font_Tiny
,
192 MUIA_Text_Contents
, "\33cPlain",
196 MUIA_String_AdvanceOnCR
, TRUE
,
197 MUIA_String_Contents
, "This is some crappy shit!",
198 MUIA_String_Format
, MUIV_String_Format_Right
,
199 MUIA_CycleChain
, TRUE
,
202 Child
, button
= SimpleButton("Insert"),
203 Child
, bpos
= SliderObject
,
204 MUIA_Slider_Horiz
, TRUE
,
205 MUIA_Numeric_Max
, 60,
207 Child
, ssize
= SliderObject
,
208 MUIA_Slider_Horiz
, TRUE
,
209 MUIA_Numeric_Min
, -30,
210 MUIA_Numeric_Max
, 30,
211 MUIA_Numeric_Value
, 0,
213 Child
, numbutton
= NumericbuttonObject
,
214 MUIA_Numeric_Min
, -30,
215 MUIA_Numeric_Max
, 30,
216 MUIA_Numeric_Value
, 0,
228 DoMethod(app
, MUIM_Application_Load
, MUIV_Application_Load_ENV
);
230 DoMethod(a1
, MUIM_Notify
, MUIA_String_Contents
, MUIV_EveryTime
, a2
, 3, MUIM_Set
, MUIA_String_Contents
, MUIV_TriggerValue
);
231 DoMethod(a2
, MUIM_Notify
, MUIA_String_Contents
, MUIV_EveryTime
, a1
, 3, MUIM_Set
, MUIA_String_Contents
, MUIV_TriggerValue
);
233 DoMethod(ssize
, MUIM_Notify
, MUIA_Numeric_Value
, MUIV_EveryTime
, numbutton
, 3, MUIM_Set
, MUIA_Numeric_Value
, MUIV_TriggerValue
);
234 DoMethod(bpos
, MUIM_Notify
, MUIA_Numeric_Value
, MUIV_EveryTime
, bstring
, 3, MUIM_Set
, MUIA_String_BufferPos
, MUIV_TriggerValue
);
235 DoMethod(ssize
, MUIM_Notify
, MUIA_Numeric_Value
, MUIV_EveryTime
, bstring
, 3, MUIM_Set
, MUIA_BetterString_SelectSize
, MUIV_TriggerValue
);
236 DoMethod(button
, MUIM_Notify
, MUIA_Pressed
, FALSE
, bstring
, 3, MUIM_BetterString_Insert
, "*Test*", MUIV_BetterString_Insert_BufferPos
);
237 DoMethod(window
, MUIM_Notify
, MUIA_Window_CloseRequest
, TRUE
, MUIV_Notify_Application
, 2, MUIM_Application_ReturnID
, MUIV_Application_ReturnID_Quit
);
238 set(window
, MUIA_Window_ActiveObject
, bstring
);
239 set(window
, MUIA_Window_Open
, TRUE
);
241 while(DoMethod(app
, MUIM_Application_NewInput
, &sigs
) != MUIV_Application_ReturnID_Quit
)
245 sigs
= Wait(sigs
| SIGBREAKF_CTRL_C
);
246 if(sigs
& SIGBREAKF_CTRL_C
)
250 DoMethod(app
, MUIM_Application_Save
, MUIV_Application_Save_ENV
);
252 MUI_DisposeObject(app
);
254 MUI_DeleteCustomClass(mcc
);
257 DROPINTERFACE(IMUIMaster
);
258 CloseLibrary(MUIMasterBase
);
259 MUIMasterBase
= NULL
;
264 DROPINTERFACE(IUtility
);
265 CloseLibrary(UtilityBase
);
270 DROPINTERFACE(ILocale
);
271 CloseLibrary(LocaleBase
);
276 DROPINTERFACE(IKeymap
);
277 CloseLibrary(KeymapBase
);
282 DROPINTERFACE(IIntuition
);
283 CloseLibrary((struct Library
*)IntuitionBase
);
288 DROPINTERFACE(IGraphics
);
289 CloseLibrary(GfxBase
);
294 DROPINTERFACE(IDiskfont
);
295 CloseLibrary(DiskfontBase
);