tdetexteditor.cpp
00001 /* This file is part of the KDE project 00002 Copyright (C) 2001 Christoph Cullmann (cullmann@kde.org) 00003 00004 This library is free software; you can redistribute it and/or 00005 modify it under the terms of the GNU Library General Public 00006 License as published by the Free Software Foundation; either 00007 version 2 of the License, or (at your option) any later version. 00008 00009 This library is distributed in the hope that it will be useful, 00010 but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 Library General Public License for more details. 00013 00014 You should have received a copy of the GNU Library General Public License 00015 along with this library; see the file COPYING.LIB. If not, write to 00016 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00017 Boston, MA 02110-1301, USA. 00018 */ 00019 00020 #include <config.h> 00021 00022 #include "document.h" 00023 #include "view.h" 00024 #include "plugin.h" 00025 #include "editor.h" 00026 00027 #include <tdeaction.h> 00028 #include <tdeparts/factory.h> 00029 #include <tdeparts/componentfactory.h> 00030 00031 #include "document.moc" 00032 #include "view.moc" 00033 #include "plugin.moc" 00034 #include "editor.moc" 00035 00036 using namespace KTextEditor; 00037 00038 namespace KTextEditor 00039 { 00040 class PrivateDocument 00041 { 00042 public: 00043 PrivateDocument () 00044 { 00045 } 00046 00047 ~PrivateDocument() 00048 { 00049 } 00050 }; 00051 00052 class PrivateView 00053 { 00054 public: 00055 PrivateView () 00056 { 00057 } 00058 00059 ~PrivateView() 00060 { 00061 } 00062 }; 00063 00064 class PrivatePlugin 00065 { 00066 public: 00067 PrivatePlugin () 00068 { 00069 } 00070 00071 ~PrivatePlugin () 00072 { 00073 } 00074 00075 class Document *m_doc; 00076 }; 00077 00078 class PrivatePluginViewInterface 00079 { 00080 public: 00081 PrivatePluginViewInterface () 00082 { 00083 } 00084 00085 ~PrivatePluginViewInterface () 00086 { 00087 } 00088 }; 00089 00090 class PrivateEditor 00091 { 00092 public: 00093 PrivateEditor () 00094 { 00095 } 00096 00097 ~PrivateEditor() 00098 { 00099 } 00100 }; 00101 } 00102 00103 unsigned int Document::globalDocumentNumber = 0; 00104 unsigned int View::globalViewNumber = 0; 00105 unsigned int Plugin::globalPluginNumber = 0; 00106 unsigned int PluginViewInterface::globalPluginViewInterfaceNumber = 0; 00107 unsigned int Editor::globalEditorNumber = 0; 00108 00109 Document::Document( TQObject *parent, const char *name ) : KTextEditor::Editor (parent, name ) 00110 { 00111 globalDocumentNumber++; 00112 myDocumentNumber = globalDocumentNumber; 00113 myDocumentListPosition = -1; // Don't care 00114 } 00115 00116 Document::~Document() 00117 { 00118 } 00119 00120 unsigned int Document::documentNumber () const 00121 { 00122 return myDocumentNumber; 00123 } 00124 00125 long Document::documentListPosition () const 00126 { 00127 return myDocumentListPosition; 00128 } 00129 00130 void Document::setDocumentListPosition (long pos) 00131 { 00132 myDocumentListPosition = pos; 00133 } 00134 00135 TQCString Document::documentDCOPSuffix () const 00136 { 00137 TQCString num; 00138 num.setNum (documentNumber()); 00139 00140 return num; 00141 } 00142 00143 View::View( Document *, TQWidget *parent, const char *name ) : TQWidget( parent, name ) 00144 { 00145 globalViewNumber++; 00146 myViewNumber = globalViewNumber; 00147 } 00148 00149 View::~View() 00150 { 00151 } 00152 00153 unsigned int View::viewNumber () const 00154 { 00155 return myViewNumber; 00156 } 00157 00158 TQCString View::viewDCOPSuffix () const 00159 { 00160 TQCString num1, num2; 00161 num1.setNum (viewNumber()); 00162 num2.setNum (document()->documentNumber()); 00163 00164 return num2 + "-" + num1; 00165 } 00166 00167 Plugin::Plugin( Document *document, const char *name ) : TQObject (document, name ) 00168 { 00169 globalPluginNumber++; 00170 myPluginNumber = globalPluginNumber; 00171 d = new PrivatePlugin (); 00172 d->m_doc = document; 00173 } 00174 00175 Plugin::~Plugin() 00176 { 00177 delete d; 00178 } 00179 00180 unsigned int Plugin::pluginNumber () const 00181 { 00182 return myPluginNumber; 00183 } 00184 00185 Document *Plugin::document () const 00186 { 00187 return d->m_doc; 00188 } 00189 00190 PluginViewInterface::PluginViewInterface() 00191 { 00192 globalPluginViewInterfaceNumber++; 00193 myPluginViewInterfaceNumber = globalPluginViewInterfaceNumber; 00194 } 00195 00196 PluginViewInterface::~PluginViewInterface() 00197 { 00198 } 00199 00200 unsigned int PluginViewInterface::pluginViewInterfaceNumber () const 00201 { 00202 return myPluginViewInterfaceNumber; 00203 } 00204 00205 Editor::Editor( TQObject *parent, const char *name ) : KParts::ReadWritePart( parent, name ) 00206 { 00207 globalEditorNumber++; 00208 myEditorNumber = globalEditorNumber; 00209 } 00210 00211 Editor::~Editor() 00212 { 00213 } 00214 00215 unsigned int Editor::editorNumber () const 00216 { 00217 return myEditorNumber; 00218 } 00219 00220 Editor *KTextEditor::createEditor ( const char* libname, TQWidget *parentWidget, const char *widgetName, TQObject *parent, const char *name ) 00221 { 00222 return KParts::ComponentFactory::createPartInstanceFromLibrary<Editor>( libname, parentWidget, widgetName, parent, name ); 00223 } 00224 00225 Document *KTextEditor::createDocument ( const char* libname, TQObject *parent, const char *name ) 00226 { 00227 return KParts::ComponentFactory::createPartInstanceFromLibrary<Document>( libname, 0, 0, parent, name ); 00228 } 00229 00230 Plugin *KTextEditor::createPlugin ( const char* libname, Document *document, const char *name ) 00231 { 00232 return KParts::ComponentFactory::createInstanceFromLibrary<Plugin>( libname, document, name ); 00233 } 00234 00235 PluginViewInterface *KTextEditor::pluginViewInterface (Plugin *plugin) 00236 { 00237 if (!plugin) 00238 return 0; 00239 00240 return dynamic_cast<KTextEditor::PluginViewInterface*>(plugin); 00241 } 00242