katemdi.h
00001 /* This file is part of the KDE libraries 00002 Copyright (C) 2005 Christoph Cullmann <cullmann@kde.org> 00003 Copyright (C) 2002, 2003 Joseph Wenninger <jowenn@kde.org> 00004 00005 This library is free software; you can redistribute it and/or 00006 modify it under the terms of the GNU Library General Public 00007 License as published by the Free Software Foundation; either 00008 version 2 of the License, or (at your option) any later version. 00009 00010 This library is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 Library General Public License for more details. 00014 00015 You should have received a copy of the GNU Library General Public License 00016 along with this library; see the file COPYING.LIB. If not, write to 00017 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00018 Boston, MA 02110-1301, USA. 00019 */ 00020 00021 #ifndef __KATE_MDI_H__ 00022 #define __KATE_MDI_H__ 00023 00024 #include <tdeparts/mainwindow.h> 00025 00026 #include <tdemultitabbar.h> 00027 #include <kxmlguiclient.h> 00028 #include <tdeaction.h> 00029 00030 #include <tqdict.h> 00031 #include <tqintdict.h> 00032 #include <tqmap.h> 00033 #include <tqsplitter.h> 00034 #include <tqpixmap.h> 00035 #include <tqptrlist.h> 00036 00037 namespace KateMDI { 00038 00039 00041 class Splitter : public TQSplitter 00042 { 00043 Q_OBJECT 00044 00045 00046 public: 00047 Splitter(Orientation o, TQWidget* parent=0, const char* name=0); 00048 ~Splitter(); 00049 00056 bool isLastChild(TQWidget* w) const; 00057 00058 int idAfter ( TQWidget * w ) const; 00059 }; 00060 00061 class ToggleToolViewAction : public TDEToggleAction 00062 { 00063 Q_OBJECT 00064 00065 00066 public: 00067 ToggleToolViewAction ( const TQString& text, const TDEShortcut& cut, 00068 class ToolView *tv, TQObject* parent = 0, const char* name = 0 ); 00069 00070 virtual ~ToggleToolViewAction(); 00071 00072 protected slots: 00073 void slotToggled(bool); 00074 void visibleChanged(bool); 00075 00076 private: 00077 ToolView *m_tv; 00078 }; 00079 00080 class GUIClient : public TQObject, public KXMLGUIClient 00081 { 00082 Q_OBJECT 00083 00084 00085 public: 00086 GUIClient ( class MainWindow *mw ); 00087 virtual ~GUIClient(); 00088 00089 void registerToolView (ToolView *tv); 00090 void unregisterToolView (ToolView *tv); 00091 void updateSidebarsVisibleAction(); 00092 00093 private slots: 00094 void clientAdded( KXMLGUIClient *client ); 00095 void updateActions(); 00096 00097 private: 00098 MainWindow *m_mw; 00099 TDEToggleAction *m_showSidebarsAction; 00100 TQPtrList<TDEAction> m_toolViewActions; 00101 TQMap<ToolView*, TDEAction*> m_toolToAction; 00102 TDEActionMenu *m_toolMenu; 00103 }; 00104 00105 class ToolView : public TQVBox 00106 { 00107 Q_OBJECT 00108 00109 00110 friend class Sidebar; 00111 friend class MainWindow; 00112 friend class GUIClient; 00113 friend class ToggleToolViewAction; 00114 00115 protected: 00125 ToolView (class MainWindow *mainwin, class Sidebar *sidebar, TQWidget *parent); 00126 00127 public: 00132 virtual ~ToolView (); 00133 00134 signals: 00139 void visibleChanged (bool visible); 00140 00144 protected: 00145 MainWindow *mainWindow () { return m_mainWin; } 00146 00147 Sidebar *sidebar () { return m_sidebar; } 00148 00149 void setVisible (bool vis); 00150 00151 public: 00152 bool visible () const; 00153 00154 protected: 00155 void childEvent ( TQChildEvent *ev ); 00156 00157 private: 00158 MainWindow *m_mainWin; 00159 Sidebar *m_sidebar; 00160 00164 TQString id; 00165 00169 bool m_visible; 00170 00174 bool persistent; 00175 00176 TQPixmap icon; 00177 TQString text; 00178 }; 00179 00180 class Sidebar : public KMultiTabBar 00181 { 00182 Q_OBJECT 00183 00184 00185 public: 00186 Sidebar (KMultiTabBar::KMultiTabBarPosition pos, class MainWindow *mainwin, TQWidget *parent); 00187 virtual ~Sidebar (); 00188 00189 void setSplitter (Splitter *sp); 00190 00191 public: 00192 ToolView *addWidget (const TQPixmap &icon, const TQString &text, ToolView *widget); 00193 bool removeWidget (ToolView *widget); 00194 00195 bool showWidget (ToolView *widget); 00196 bool hideWidget (ToolView *widget); 00197 00198 void setLastSize (int s) { m_lastSize = s; } 00199 int lastSize () const { return m_lastSize; } 00200 void updateLastSize (); 00201 00202 bool splitterVisible () const { return m_ownSplit->isVisible(); } 00203 00204 void restoreSession (); 00205 00210 void restoreSession (TDEConfig *config); 00211 00216 void saveSession (TDEConfig *config); 00217 00218 public slots: 00219 // reimplemented, to block a show() call if we have no children or if 00220 // all sidebars are forced hidden. 00221 virtual void show(); 00222 00223 private slots: 00224 void tabClicked(int); 00225 00226 protected: 00227 bool eventFilter(TQObject *obj, TQEvent *ev); 00228 00229 private slots: 00230 void buttonPopupActivate (int id); 00231 00232 private: 00233 MainWindow *m_mainWin; 00234 00235 KMultiTabBar::KMultiTabBarPosition m_pos; 00236 Splitter *m_splitter; 00237 KMultiTabBar *m_tabBar; 00238 Splitter *m_ownSplit; 00239 00240 TQIntDict<ToolView> m_idToWidget; 00241 TQMap<ToolView*, int> m_widgetToId; 00242 00246 TQValueList<ToolView*> m_toolviews; 00247 00248 int m_lastSize; 00249 00250 int m_popupButton; 00251 }; 00252 00253 class MainWindow : public KParts::MainWindow 00254 { 00255 Q_OBJECT 00256 00257 00258 friend class ToolView; 00259 00260 // 00261 // Constructor area 00262 // 00263 public: 00267 MainWindow (TQWidget* parentWidget = 0, const char* name = 0); 00268 00272 virtual ~MainWindow (); 00273 00274 // 00275 // public interfaces 00276 // 00277 public: 00284 TQWidget *centralWidget () const; 00285 00294 ToolView *createToolView (const TQString &identifier, KMultiTabBar::KMultiTabBarPosition pos, const TQPixmap &icon, const TQString &text); 00295 00301 ToolView *toolView (const TQString &identifier) const; 00302 00307 void setToolViewStyle (KMultiTabBar::KMultiTabBarStyle style); 00308 00314 KMultiTabBar::KMultiTabBarStyle toolViewStyle () const; 00315 00320 bool sidebarsVisible() const; 00321 00322 public slots: 00329 void setSidebarsVisible( bool visible ); 00330 00331 protected: 00336 void toolViewDeleted (ToolView *widget); 00337 00341 public: 00348 bool moveToolView (ToolView *widget, KMultiTabBar::KMultiTabBarPosition pos); 00349 00355 bool showToolView (ToolView *widget); 00356 00362 bool hideToolView (ToolView *widget); 00363 00367 public: 00373 void startRestore (TDEConfig *config, const TQString &group); 00374 00378 void finishRestore (); 00379 00385 void saveSession (TDEConfig *config, const TQString &group); 00386 00390 private: 00394 TQDict<ToolView> m_idToWidget; 00395 00399 TQValueList<ToolView*> m_toolviews; 00400 00405 TQWidget *m_centralWidget; 00406 00410 Splitter *m_hSplitter; 00411 00415 Splitter *m_vSplitter; 00416 00420 Sidebar *m_sidebars[4]; 00421 00425 bool m_sidebarsVisible; 00426 00431 TDEConfig *m_restoreConfig; 00432 00436 TQString m_restoreGroup; 00437 00441 GUIClient *m_guiClient; 00442 }; 00443 00444 } 00445 00446 #endif 00447 00448 // kate: space-indent on; indent-width 2;