1 /***************************************************************************
3 codesets.library - Amiga shared library for handling different codesets
4 Copyright (C) 2001-2005 by Alfonso [alfie] Ranieri <alforan@tin.it>.
5 Copyright (C) 2005-2007 by codesets.library 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 codesets.library project: http://sourceforge.net/projects/codesetslib/
19 Most of the code included in this file was relicensed from GPL to LGPL
20 from the source code of SimpleMail (http://www.sf.net/projects/simplemail)
21 with full permissions by its authors.
25 ***************************************************************************/
27 #include <clib/alib_protos.h>
29 #include <proto/exec.h>
30 #include <proto/dos.h>
31 #include <proto/utility.h>
32 #include <proto/muimaster.h>
33 #include <proto/intuition.h>
34 #include <libraries/asl.h>
35 #include <libraries/gadtools.h>
36 #include <libraries/mui.h>
37 #include <mui/Textinput_mcc.h>
38 #include <mui/TextEditor_mcc.h>
40 #define USE_INLINE_STDARG
42 // tempoarly disable the INLINE STDARG define here
43 #if defined(NO_INLINE_STDARG)
44 #undef NO_INLINE_STDARG
45 #include <proto/codesets.h>
46 #define NO_INLINE_STDARG
47 #elif defined(NO_PPCINLINE_STDARG)
48 #undef NO_PPCINLINE_STDARG
49 #include <proto/codesets.h>
50 #define NO_PPCINLINE_STDARG
52 #include <proto/codesets.h>
58 #include "SDI_compiler.h"
60 #include "SDI_stdarg.h"
62 /***********************************************************************/
68 #define MAKE_ID(a,b,c,d) ((ULONG) (a)<<24 | (ULONG) (b)<<16 | (ULONG) (c)<<8 | (ULONG) (d))
71 #if defined(__amigaos4__)
72 #define GETINTERFACE(iface, base) (iface = (APTR)GetInterface((struct Library *)(base), "main", 1L, NULL))
73 #define DROPINTERFACE(iface) (DropInterface((struct Interface *)iface), iface = NULL)
75 #define GETINTERFACE(iface, base) TRUE
76 #define DROPINTERFACE(iface)
79 /***********************************************************************/
84 char __ver
[] = "\0$VER: CodesetsDemo1 1.0 (10.11.2004)";
87 struct Library
*MUIMasterBase
= NULL
;
88 struct Library
*CodesetsBase
= NULL
;
89 struct Library
*UtilityBase
= NULL
;
91 #if defined(__amigaos4__)
92 struct MUIMasterIFace
*IMUIMaster
= NULL
;
93 struct CodesetsIFace
*ICodesets
= NULL
;
94 struct IntuitionIFace
*IIntuition
= NULL
;
95 struct UtilityIFace
*IUtility
= NULL
;
96 struct Library
*IntuitionBase
= NULL
;
98 struct IntuitionBase
*IntuitionBase
= NULL
;
102 struct MUI_CustomClass
*appClass
, *popupCodesetsClass
, *editorClass
;
104 /***********************************************************************/
110 #define MUIA_App_Win (TAG_USER+1)
113 #define MUIM_App_DisposeWin (TAG_USER+2)
114 #define MUIM_App_About (TAG_USER+3)
115 #define MUIM_App_AboutMUI (TAG_USER+4)
117 struct MUIP_App_DisposeWin
123 /* Editor attributes */
124 #define MUIA_Editor_CodesetsObj (TAG_USER+5)
127 #define MUIM_Editor_Load (TAG_USER+6)
128 #define MUIM_Editor_Save (TAG_USER+7)
130 struct MUIP_Editor_Load
136 /* Classes object creation macros */
137 #define appObject NewObject(appClass->mcc_Class,NULL
138 #define editorObject NewObject(editorClass->mcc_Class,NULL
139 #define popupCodesetObject NewObject(popupCodesetsClass->mcc_Class,NULL
141 /***********************************************************************/
143 ** Usual DoSuperNew funct
147 // Calls parent NEW method within a subclass
148 #if !defined(__MORPHOS__)
149 Object
* STDARGS VARARGS68K
DoSuperNew(struct IClass
*cl
, Object
*obj
, ...)
155 rc
= (Object
*)DoSuperMethod(cl
, obj
, OM_NEW
, VA_ARG(args
, ULONG
), NULL
);
163 /***********************************************************************/
165 ** Codesets popup open window hook funct
168 HOOKPROTONH(popupWindowFun
, void, Object
*pop
, Object
*win
)
170 set(win
,MUIA_Window_DefaultObject
,pop
);
172 MakeStaticHook(popupWindowHook
, popupWindowFun
);
174 /***********************************************************************/
176 ** Codesets popup open hook funct
177 ** Sets the active entry in the list
180 HOOKPROTONH(popupOpenFun
, ULONG
, Object
*list
, Object
*str
)
185 get(str
, MUIA_Textinput_Contents
, (ULONG
)&s
);
189 DoMethod(list
,MUIM_List_GetEntry
,i
,&x
);
192 set(list
,MUIA_List_Active
,MUIV_List_Active_Off
);
198 set(list
,MUIA_List_Active
,i
);
205 MakeStaticHook(popupOpenHook
, popupOpenFun
);
207 /***********************************************************************/
209 ** Codesets popup close hook funct
210 ** Set the string contents
213 HOOKPROTONH(popupCloseFun
, void, Object
*list
, Object
*str
)
217 DoMethod(list
,MUIM_List_GetEntry
,MUIV_List_GetEntry_Active
,&e
);
218 set(str
,MUIA_Textinput_Contents
,e
);
220 MakeStaticHook(popupCloseHook
, popupCloseFun
);
222 /***********************************************************************/
224 ** Codesets popup new method
228 mpopupNew(struct IClass
*cl
,Object
*obj
,struct opSet
*msg
)
230 Object
*str
, *bt
, *lv
, *l
;
232 if((obj
= (Object
*)DoSuperNew(cl
,obj
,
234 MUIA_Popstring_String
, str
= TextinputObject
,
235 MUIA_ControlChar
, (ULONG
)'h',
236 MUIA_CycleChain
, TRUE
,
238 MUIA_Textinput_AdvanceOnCR
, TRUE
,
239 MUIA_Textinput_MaxLen
, 256,
242 MUIA_Popstring_Button
, bt
= MUI_MakeObject(MUIO_PopButton
,MUII_PopUp
),
244 MUIA_Popobject_Object
, lv
= ListviewObject
,
245 MUIA_Listview_List
, l
= ListObject
,
246 MUIA_Frame
, MUIV_Frame_InputList
,
247 MUIA_Background
, MUII_ListBack
,
248 MUIA_List_AutoVisible
, TRUE
,
249 MUIA_List_ConstructHook
, MUIV_List_ConstructHook_String
,
250 MUIA_List_DestructHook
, MUIV_List_DestructHook_String
,
253 MUIA_Popobject_WindowHook
, &popupWindowHook
,
254 MUIA_Popobject_StrObjHook
, &popupOpenHook
,
255 MUIA_Popobject_ObjStrHook
, &popupCloseHook
,
257 TAG_MORE
,msg
->ops_AttrList
)))
259 struct codeset
*codeset
;
262 set(bt
,MUIA_CycleChain
,TRUE
);
263 DoMethod(lv
,MUIM_Notify
,MUIA_Listview_DoubleClick
,TRUE
,obj
,2,MUIM_Popstring_Close
,TRUE
);
265 /* Build list of available codesets */
266 if((array
= CodesetsSupportedA(NULL
)))
268 DoMethod(l
,MUIM_List_Insert
,array
,-1,MUIV_List_Insert_Sorted
);
269 CodesetsFreeA(array
,NULL
);
271 else SetSuperAttrs(cl
,obj
,MUIA_Disabled
,TRUE
,TAG_DONE
);
273 /* Use the default codeset */
274 codeset
= CodesetsFindA(NULL
,NULL
);
275 set(str
,MUIA_Textinput_Contents
,codeset
->name
);
281 /***********************************************************************/
283 ** Codesets popup dispatcher
286 DISPATCHERPROTO(popupDispatcher
)
288 switch (msg
->MethodID
)
290 case OM_NEW
: return mpopupNew(cl
,obj
,(APTR
)msg
);
291 default: return DoSuperMethodA(cl
,obj
,msg
);
295 /***********************************************************************/
303 struct FileRequester
*req
;
306 /***********************************************************************/
312 meditorNew(struct IClass
*cl
,Object
*obj
,struct opSet
*msg
)
314 struct FileRequester
*req
;
316 if ((req
= MUI_AllocAslRequest(ASL_FileRequest
,NULL
)) &&
317 (obj
= (Object
*)DoSuperNew(cl
,obj
,
318 TAG_MORE
,msg
->ops_AttrList
)))
320 struct editorData
*data
= INST_DATA(cl
,obj
);
322 data
->codesetsObj
= (Object
*)GetTagData(MUIA_Editor_CodesetsObj
, 0, msg
->ops_AttrList
);
328 if (req
) MUI_FreeAslRequest(req
);
334 /***********************************************************************/
336 ** Editor dispose method
340 meditorDispose(struct IClass
*cl
,Object
*obj
,Msg msg
)
342 struct editorData
*data
= INST_DATA(cl
,obj
);
344 if (data
->req
) MUI_FreeAslRequest(data
->req
);
346 return DoSuperMethodA(cl
,obj
,msg
);
349 /***********************************************************************/
351 ** Editor load method
355 meditorLoad(struct IClass
*cl
,Object
*obj
,struct MUIP_Editor_Load
*msg
)
357 struct editorData
*data
= INST_DATA(cl
,obj
);
359 set(_app(obj
),MUIA_Application_Sleep
,TRUE
);
360 SetSuperAttrs(cl
,obj
,MUIA_TextEditor_Quiet
,FALSE
,TAG_DONE
);
362 /* Request file name */
363 if (MUI_AslRequestTags(data
->req
,ASLFR_TitleText
,msg
->plain
?
364 "Select a file to load" : "Select a file to load as UTF8",TAG_DONE
))
369 strcpy(fname
,data
->req
->fr_Drawer
);
370 AddPart(fname
,data
->req
->fr_File
,sizeof(fname
));
373 if((lock
= Lock(fname
,SHARED_LOCK
)))
375 struct FileInfoBlock
*fib
;
376 ULONG go
= FALSE
, size
= 0;
378 if((fib
= AllocDosObject(DOS_FIB
,NULL
)))
380 if (Examine(lock
,fib
))
382 size
= fib
->fib_Size
;
386 FreeDosObject(DOS_FIB
,fib
);
393 DoSuperMethod(cl
,obj
,MUIM_TextEditor_ClearText
);
399 /* Alloc whole file buf */
400 if((buf
= AllocMem(size
+1,MEMF_ANY
)))
404 if((file
= Open(fname
,MODE_OLDFILE
)))
408 r
= Read(file
,buf
,size
);
415 /* If plain just set it */
416 set(obj
,MUIA_TextEditor_Contents
,buf
);
420 struct codeset
*codeset
;
424 /* Get used codeset */
425 get(data
->codesetsObj
, MUIA_Textinput_Contents
, (ULONG
)&cname
);
426 codeset
= CodesetsFindA(cname
,NULL
);
429 str
= CodesetsUTF8ToStr(CSA_Source
, buf
,
430 CSA_SourceCodeset
, codeset
,
434 SetSuperAttrs(cl
,obj
,MUIA_TextEditor_Contents
,str
,TAG_DONE
);
435 CodesetsFreeA(str
,NULL
);
447 SetSuperAttrs(cl
,obj
,MUIA_TextEditor_CursorX
, 0,
448 MUIA_TextEditor_CursorY
, 0,
454 SetSuperAttrs(cl
,obj
,MUIA_TextEditor_Quiet
,FALSE
,TAG_DONE
);
455 set(_app(obj
),MUIA_Application_Sleep
,FALSE
);
460 /***********************************************************************/
462 ** Editor save method
466 meditorSave(struct IClass
*cl
, Object
*obj
, Msg msg
)
468 struct editorData
*data
= INST_DATA(cl
,obj
);
471 set(_app(obj
),MUIA_Application_Sleep
,TRUE
);
473 /* Get editor text */
474 if((text
= (STRPTR
)DoSuperMethod(cl
,obj
,MUIM_TextEditor_ExportText
)))
476 struct codeset
*codeset
;
481 /* Get current user codeset */
482 get(data
->codesetsObj
, MUIA_Textinput_Contents
, (ULONG
)&cname
);
483 codeset
= CodesetsFindA(cname
,NULL
);
485 /* Convert text as utf8 */
486 if((utf8
= CodesetsUTF8Create(CSA_Source
, text
,
487 CSA_SourceCodeset
, codeset
,
488 CSA_DestLenPtr
, &dlen
,
491 /* Save converted text to a file */
493 if (MUI_AslRequestTags(data
->req
,ASLFR_DoSaveMode
,TRUE
,ASLFR_TitleText
,"Select a file to save as UTF8",TAG_DONE
))
498 strcpy(fname
,data
->req
->fr_Drawer
);
499 AddPart(fname
,data
->req
->fr_File
,sizeof(fname
));
501 if((file
= Open(fname
,MODE_NEWFILE
)))
503 Write(file
,utf8
,dlen
);
508 /* Free converted string */
509 CodesetsFreeA(utf8
,NULL
);
515 set(_app(obj
),MUIA_Application_Sleep
,FALSE
);
520 /***********************************************************************/
525 DISPATCHERPROTO(editorDispatcher
)
527 switch (msg
->MethodID
)
529 case OM_NEW
: return meditorNew(cl
,obj
,(APTR
)msg
);
530 case OM_DISPOSE
: return meditorDispose(cl
,obj
,(APTR
)msg
);
531 case MUIM_Editor_Save
: return meditorSave(cl
,obj
,(APTR
)msg
);
532 case MUIM_Editor_Load
: return meditorLoad(cl
,obj
,(APTR
)msg
);
533 default: return DoSuperMethodA(cl
,obj
,msg
);
537 /***********************************************************************/
550 /***********************************************************************/
556 #define MTITLE(t) {NM_TITLE,(STRPTR)(t),0,0,0,0}
557 #define MITEM(t,d) {NM_ITEM,(STRPTR)(t),0,0,0,(APTR)(d)}
558 #define MBAR {NM_ITEM,(STRPTR)NM_BARLABEL,0,0,0,NULL}
559 #define MEND {NM_END,NULL,0,0,0,NULL}
569 static struct NewMenu appMenu
[] =
572 MITEM("?\0About...",MABOUT
),
573 MITEM("M\0About MUI...",MABOUTMUI
),
575 MITEM("Q\0Quit",MQUIT
),
578 MITEM("M\0MUI Settings...",MMUI
),
584 mappNew(struct IClass
*cl
,Object
*obj
,struct opSet
*msg
)
586 Object
*strip
, *win
, *codesets
= NULL
, *editor
, *sb
, *loadPlain
, *loadUTF8
, *save
, *cancel
;
588 if((obj
= (Object
*)DoSuperNew(cl
,obj
,
589 MUIA_Application_Title
, "Codesets Demo1",
590 MUIA_Application_Version
, "$VER: CodesetsDemo1 1.0 (10.11.2004)",
591 MUIA_Application_Copyright
, "Copyright 2004 by Alfonso Ranieri",
592 MUIA_Application_Author
, "Alfonso Ranieri <alforan@tin.it>",
593 MUIA_Application_Description
, "Codesets example",
594 MUIA_Application_Base
, "CODESETSEXAMPLE",
595 MUIA_Application_Menustrip
, strip
= MUI_MakeObject(MUIO_MenustripNM
,appMenu
,MUIO_MenustripNM_CommandKeyCheck
),
597 SubWindow
, win
= WindowObject
,
598 MUIA_Window_ID
, MAKE_ID('M','A','I','N'),
599 MUIA_Window_Title
, "Codesets Demo1",
600 WindowContents
, VGroup
,
603 Child
, Label2("C_harset"),
604 Child
, codesets
= popupCodesetObject
, End
,
608 MUIA_Group_Horiz
, TRUE
,
609 MUIA_Group_Spacing
, 0,
610 Child
, editor
= editorObject
,
611 MUIA_Editor_CodesetsObj
, codesets
,
613 Child
, sb
= ScrollbarObject
, End
,
617 Child
, loadPlain
= MUI_MakeObject(MUIO_Button
,"Load _plain"),
618 Child
, RectangleObject
, MUIA_Weight
, 50, End
,
619 Child
, loadUTF8
= MUI_MakeObject(MUIO_Button
,"_Load utf8"),
620 Child
, RectangleObject
, MUIA_Weight
, 50, End
,
621 Child
, save
= MUI_MakeObject(MUIO_Button
,"_Save utf8"),
622 Child
, RectangleObject
, MUIA_Weight
, 50, End
,
623 Child
, cancel
= MUI_MakeObject(MUIO_Button
,"_Cancel"),
628 TAG_MORE
,msg
->ops_AttrList
)))
630 struct appData
*data
= INST_DATA(cl
,obj
);
634 set(editor
,MUIA_TextEditor_Slider
,sb
);
636 set(loadPlain
,MUIA_CycleChain
,TRUE
);
637 set(loadUTF8
,MUIA_CycleChain
,TRUE
);
638 set(save
,MUIA_CycleChain
,TRUE
);
639 set(cancel
,MUIA_CycleChain
,TRUE
);
641 DoMethod(win
,MUIM_Notify
,MUIA_Window_CloseRequest
,TRUE
,MUIV_Notify_Application
,2,
642 MUIM_Application_ReturnID
,MUIV_Application_ReturnID_Quit
);
644 DoMethod(loadPlain
,MUIM_Notify
,MUIA_Pressed
,FALSE
,editor
,2,MUIM_Editor_Load
,TRUE
);
645 DoMethod(loadUTF8
,MUIM_Notify
,MUIA_Pressed
,FALSE
,editor
,2,MUIM_Editor_Load
,FALSE
);
646 DoMethod(save
,MUIM_Notify
,MUIA_Pressed
,FALSE
,editor
,1,MUIM_Editor_Save
);
647 DoMethod(cancel
,MUIM_Notify
,MUIA_Pressed
,FALSE
,MUIV_Notify_Application
,2,
648 MUIM_Application_ReturnID
,MUIV_Application_ReturnID_Quit
);
650 DoMethod((Object
*)DoMethod(strip
,MUIM_FindUData
,MABOUT
),MUIM_Notify
,
651 MUIA_Menuitem_Trigger
,MUIV_EveryTime
,obj
,1,MUIM_App_About
);
653 DoMethod((Object
*)DoMethod(strip
,MUIM_FindUData
,MABOUTMUI
),MUIM_Notify
,
654 MUIA_Menuitem_Trigger
,MUIV_EveryTime
,obj
,1,MUIM_App_AboutMUI
);
656 DoMethod((Object
*)DoMethod(strip
,MUIM_FindUData
,MQUIT
),MUIM_Notify
,
657 MUIA_Menuitem_Trigger
,MUIV_EveryTime
,obj
,2,MUIM_Application_ReturnID
,
658 MUIV_Application_ReturnID_Quit
);
660 DoMethod((Object
*)DoMethod(strip
,MUIM_FindUData
,MMUI
),MUIM_Notify
,
661 MUIA_Menuitem_Trigger
,MUIV_EveryTime
,obj
,2,MUIM_Application_OpenConfigWindow
,0);
663 set(win
,MUIA_Window_Open
,TRUE
);
669 /***********************************************************************/
671 ** App dispose win method
675 mappDisposeWin(struct IClass
*cl
,Object
*obj
,struct MUIP_App_DisposeWin
*msg
)
677 struct appData
*data
= INST_DATA(cl
,obj
);
678 Object
*win
= msg
->win
;
680 set(win
,MUIA_Window_Open
,FALSE
);
681 DoSuperMethod(cl
,obj
,OM_REMMEMBER
,win
);
682 MUI_DisposeObject(win
);
684 if (win
==data
->about
) data
->about
= NULL
;
685 else if (win
==data
->aboutMUI
) data
->aboutMUI
= NULL
;
690 /***********************************************************************/
696 mappAbout(struct IClass
*cl
,Object
*obj
,Msg msg
)
698 struct appData
*data
= INST_DATA(cl
,obj
);
700 SetSuperAttrs(cl
,obj
,MUIA_Application_Sleep
,TRUE
,TAG_DONE
);
706 if((data
->about
= WindowObject
,
707 MUIA_Window_RefWindow
, data
->win
,
708 MUIA_Window_Title
, "About Codesets Demo1",
709 WindowContents
, VGroup
,
711 MUIA_Text_Contents
, "\n"
713 "Copyright 2004 by Alfonso Ranieri <alforan@tin.it>\n",
714 MUIA_Text_PreParse
, MUIX_C
,
716 Child
, RectangleObject
, MUIA_Weight
, 0, MUIA_Rectangle_HBar
, TRUE
, End
,
718 Child
, RectangleObject
, MUIA_Weight
, 200, End
,
719 Child
, ok
= MUI_MakeObject(MUIO_Button
,"_OK"),
720 Child
, RectangleObject
, MUIA_Weight
, 200, End
,
725 DoSuperMethod(cl
,obj
,OM_ADDMEMBER
,data
->about
);
727 set(data
->about
,MUIA_Window_ActiveObject
,ok
);
729 DoMethod(data
->about
,MUIM_Notify
,MUIA_Window_CloseRequest
,TRUE
,obj
,5,
730 MUIM_Application_PushMethod
,obj
,2,MUIM_App_DisposeWin
,data
->about
);
732 DoMethod(ok
,MUIM_Notify
,MUIA_Pressed
,FALSE
,obj
,5,
733 MUIM_Application_PushMethod
,obj
,2,MUIM_App_DisposeWin
,data
->about
);
737 set(data
->about
,MUIA_Window_Open
,TRUE
);
739 SetSuperAttrs(cl
,obj
,MUIA_Application_Sleep
,FALSE
,TAG_DONE
);
744 /***********************************************************************/
746 ** App about mui method
750 mappAboutMUI(struct IClass
*cl
,Object
*obj
,Msg msg
)
752 struct appData
*data
= INST_DATA(cl
,obj
);
754 SetSuperAttrs(cl
,obj
,MUIA_Application_Sleep
,TRUE
,TAG_DONE
);
758 if((data
->aboutMUI
= AboutmuiObject
,
759 MUIA_Aboutmui_Application
, obj
,
760 MUIA_Window_RefWindow
, data
->win
,
763 DoMethod(data
->aboutMUI
,MUIM_Notify
,MUIA_Window_CloseRequest
,TRUE
,obj
,5,
764 MUIM_Application_PushMethod
,obj
,2,MUIM_App_DisposeWin
,data
->aboutMUI
);
768 set(data
->aboutMUI
,MUIA_Window_Open
,TRUE
);
770 SetSuperAttrs(cl
,obj
,MUIA_Application_Sleep
,FALSE
,TAG_DONE
);
775 /***********************************************************************/
777 ** App MUI settings method
781 mappOpenMUIConfigWindow(struct IClass
*cl
,Object
*obj
,Msg msg
)
785 SetSuperAttrs(cl
,obj
,MUIA_Application_Sleep
,TRUE
,TAG_DONE
);
786 res
= DoSuperMethodA(cl
,obj
,msg
);
787 SetSuperAttrs(cl
,obj
,MUIA_Application_Sleep
,FALSE
,TAG_DONE
);
792 /***********************************************************************/
797 DISPATCHERPROTO(appDispatcher
)
799 switch (msg
->MethodID
)
801 case OM_NEW
: return mappNew(cl
,obj
,(APTR
)msg
);
802 case MUIM_App_DisposeWin
: return mappDisposeWin(cl
,obj
,(APTR
)msg
);
803 case MUIM_App_About
: return mappAbout(cl
,obj
,(APTR
)msg
);
804 case MUIM_App_AboutMUI
: return mappAboutMUI(cl
,obj
,(APTR
)msg
);
805 case MUIM_Application_OpenConfigWindow
: return mappOpenMUIConfigWindow(cl
,obj
,(APTR
)msg
);
806 default: return DoSuperMethodA(cl
,obj
,msg
);
810 /***********************************************************************/
816 main(int argc
,char **argv
)
818 int res
= RETURN_FAIL
;
820 if((IntuitionBase
= (APTR
)OpenLibrary("intuition.library", 39)) && // open intuition.library
821 GETINTERFACE(IIntuition
, IntuitionBase
))
823 if((UtilityBase
= OpenLibrary("utility.library", 39)) && // open utility.library
824 GETINTERFACE(IUtility
, UtilityBase
))
826 if((CodesetsBase
= OpenLibrary(CODESETSNAME
, CODESETSVER
)) && // open codesets.library
827 GETINTERFACE(ICodesets
, CodesetsBase
))
829 /* Open muimaster.library */
830 if((MUIMasterBase
= OpenLibrary("muimaster.library",19)) &&
831 GETINTERFACE(IMUIMaster
, MUIMasterBase
))
834 if ((appClass
= MUI_CreateCustomClass(NULL
,MUIC_Application
,NULL
,sizeof(struct appData
),appDispatcher
)) &&
835 (popupCodesetsClass
= MUI_CreateCustomClass(NULL
,MUIC_Popobject
,NULL
,0,popupDispatcher
)) &&
836 (editorClass
= MUI_CreateCustomClass(NULL
,MUIC_TextEditor
,NULL
,sizeof(struct editorData
),editorDispatcher
)))
840 /* Create application */
841 if((app
= appObject
, End
))
846 while (DoMethod(app
,MUIM_Application_NewInput
,&sigs
) != (ULONG
)MUIV_Application_ReturnID_Quit
)
850 sigs
= Wait(sigs
| SIGBREAKF_CTRL_C
);
851 if (sigs
& SIGBREAKF_CTRL_C
) break;
855 MUI_DisposeObject(app
);
861 printf("%s: can't create application\n",argv
[0]);
864 MUI_DeleteCustomClass(popupCodesetsClass
);
865 MUI_DeleteCustomClass(editorClass
);
866 MUI_DeleteCustomClass(appClass
);
872 if (popupCodesetsClass
) MUI_DeleteCustomClass(popupCodesetsClass
);
873 MUI_DeleteCustomClass(appClass
);
876 printf("%s: can't create custom classes\n",argv
[0]);
879 DROPINTERFACE(IMUIMaster
);
880 CloseLibrary(MUIMasterBase
);
884 printf("%s: Can't open muimaster.library ver 19 or higher\n",argv
[0]);
888 DROPINTERFACE(ICodesets
);
889 CloseLibrary(CodesetsBase
);
893 printf("%s: Can't open codesets.library ver %d or higher.\n", argv
[0], CODESETSVER
);
897 DROPINTERFACE(IUtility
);
898 CloseLibrary(UtilityBase
);
901 DROPINTERFACE(IIntuition
);
902 CloseLibrary((struct Library
*)IntuitionBase
);
908 /***********************************************************************/