revert between 56095 -> 55830 in arch
[AROS.git] / workbench / classes / zune / texteditor / mcc / library.c
blobd3da1530c79bba906813fac9f8b7a65a4a375394
1 /***************************************************************************
3 TextEditor.mcc - Textediting MUI Custom Class
4 Copyright (C) 1997-2000 Allan Odgaard
5 Copyright (C) 2005-2014 TextEditor.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 TextEditor class Support Site: http://www.sf.net/projects/texteditor-mcc
19 $Id$
21 ***************************************************************************/
23 #include <proto/exec.h>
24 #include <proto/intuition.h>
26 /******************************************************************************/
27 /* */
28 /* MCC/MCP name and version */
29 /* */
30 /* ATTENTION: The FIRST LETTER of NAME MUST be UPPERCASE */
31 /* */
32 /******************************************************************************/
34 #include "private.h"
36 #define DEBUG_USE_MALLOC_REDEFINE 1
37 #include "Debug.h"
38 #include "version.h"
40 /******************************************************************************/
41 /* include the minimal startup code to be able to start the class from a */
42 /* shell without crashing the system */
43 /******************************************************************************/
44 #include "shellstart.c"
46 #define VERSION LIB_VERSION
47 #define REVISION LIB_REVISION
49 #define CLASS MUIC_TextEditor
50 #define SUPERCLASS MUIC_Area
52 #define INSTDATA InstData
54 #define USERLIBID CLASS " " LIB_REV_STRING " [" SYSTEMSHORT "/" CPU "] (" LIB_DATE ") " LIB_COPYRIGHT
55 #define MASTERVERSION 19
57 #define CLASSINIT
58 #define CLASSEXPUNGE
60 #define USEDCLASSESP used_mcps
61 static const char *used_mcps[] = { "TextEditor.mcp", NULL };
63 #define MIN_STACKSIZE 8192
65 struct Library *DiskfontBase = NULL;
66 struct Library *KeymapBase = NULL;
67 struct Library *LayersBase = NULL;
68 struct Library *LocaleBase = NULL;
69 struct Library *RexxSysBase = NULL;
70 struct Library *WorkbenchBase = NULL;
72 #if defined(__amigaos4__)
73 struct DiskfontIFace *IDiskfont = NULL;
74 struct KeymapIFace *IKeymap = NULL;
75 struct LayersIFace *ILayers = NULL;
76 struct LocaleIFace *ILocale = NULL;
77 struct RexxSysIFace *IRexxSys = NULL;
78 struct Interface *IWorkbench = NULL;
79 #endif
81 /******************************************************************************/
82 /* define the functions used by the startup code ahead of including mccinit.c */
83 /******************************************************************************/
84 static BOOL ClassInit(UNUSED struct Library *base);
85 static VOID ClassExpunge(UNUSED struct Library *base);
87 /******************************************************************************/
88 /* include the lib startup code for the mcc/mcp (and muimaster inlines) */
89 /******************************************************************************/
90 #include "mccinit.c"
92 /******************************************************************************/
93 /* define all implementations of our user functions */
94 /******************************************************************************/
95 static BOOL ClassInit(UNUSED struct Library *base)
97 ENTER();
99 if((LocaleBase = OpenLibrary("locale.library", 38)) &&
100 GETINTERFACE(ILocale, struct LocaleIFace *, LocaleBase))
102 if((LayersBase = OpenLibrary("layers.library", 36)) &&
103 GETINTERFACE(ILayers, struct LayersIFace *, LayersBase))
105 if((KeymapBase = OpenLibrary("keymap.library", 36)) &&
106 GETINTERFACE(IKeymap, struct KeymapIFace *, KeymapBase))
108 if((RexxSysBase = OpenLibrary("rexxsyslib.library", 36)) &&
109 GETINTERFACE(IRexxSys, struct RexxSysIFace *, RexxSysBase))
111 if((DiskfontBase = OpenLibrary("diskfont.library", 36)) &&
112 GETINTERFACE(IDiskfont, struct DiskfontIFace *, DiskfontBase))
114 if(StartClipboardServer() == TRUE)
116 /* workbench.library is optional */
117 if ((WorkbenchBase = OpenLibrary("workbench.library", 44)))
119 if (!(GETINTERFACE(IWorkbench, struct Interface *, WorkbenchBase)))
121 CloseLibrary(WorkbenchBase);
122 WorkbenchBase = NULL;
126 RETURN(TRUE);
127 return(TRUE);
130 DROPINTERFACE(IDiskfont);
131 CloseLibrary(DiskfontBase);
132 DiskfontBase = NULL;
135 DROPINTERFACE(IRexxSys);
136 CloseLibrary(RexxSysBase);
137 RexxSysBase = NULL;
140 DROPINTERFACE(IKeymap);
141 CloseLibrary(KeymapBase);
142 KeymapBase = NULL;
145 DROPINTERFACE(ILayers);
146 CloseLibrary(LayersBase);
147 LayersBase = NULL;
150 DROPINTERFACE(ILocale);
151 CloseLibrary(LocaleBase);
152 LocaleBase = NULL;
155 RETURN(FALSE);
156 return(FALSE);
160 static VOID ClassExpunge(UNUSED struct Library *base)
162 ENTER();
164 ShutdownClipboardServer();
166 if(WorkbenchBase)
168 DROPINTERFACE(IWorkbench);
169 CloseLibrary(WorkbenchBase);
170 WorkbenchBase = NULL;
173 if(DiskfontBase)
175 DROPINTERFACE(IDiskfont);
176 CloseLibrary(DiskfontBase);
177 DiskfontBase = NULL;
180 if(RexxSysBase)
182 DROPINTERFACE(IRexxSys);
183 CloseLibrary(RexxSysBase);
184 RexxSysBase = NULL;
187 if(KeymapBase)
189 DROPINTERFACE(IKeymap);
190 CloseLibrary(KeymapBase);
191 KeymapBase = NULL;
194 if(LayersBase)
196 DROPINTERFACE(ILayers);
197 CloseLibrary(LayersBase);
198 LayersBase = NULL;
201 if(LocaleBase)
203 DROPINTERFACE(ILocale);
204 CloseLibrary(LocaleBase);
205 LocaleBase = NULL;
208 LEAVE();