lib

kopalettemanager.h

00001 /*
00002  *  Copyright (c) 2005 Boudewijn Rempt <boud@valdyas.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 version 2, as published by the Free Software Foundation.
00007 
00008    This library is distributed in the hope that it will be useful,
00009    but WITHOUT ANY WARRANTY; without even the implied warranty of
00010    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011    Library General Public License for more details.
00012 
00013    You should have received a copy of the GNU Library General Public License
00014    along with this library; see the file COPYING.LIB.  If not, write to
00015    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00016  */
00017 
00018 #ifndef _KO_PALETTE_MANAGER_
00019 #define _KO_PALETTE_MANAGER_
00020 
00021 #include <qobject.h>
00022 #include <qdockwindow.h>
00023 #include <qstring.h>
00024 #include <qmap.h>
00025 #include <qdict.h>
00026 #include <qvaluestack.h>
00027 #include <qwidget.h>
00028 #include <qsignalmapper.h>
00029 #include <qstringlist.h>
00030 
00031 #include <koffice_export.h>
00032 
00033 #include <KoView.h>
00034 
00035 class KoPalette;
00036 class KActionMenu;
00037 class KAction;
00038 class KActionCollection;
00039 class KToggleAction;
00040 
00041 enum enumKoDockability {
00042     DOCK_ENABLED = 0, // It's possible to dock the dockers
00043     DOCK_DISABLED = 1, // The dockers cannot be docked
00044     DOCK_SMART = 2 // On small screens, don't dock, else dock, initially
00045 };
00046 
00047 enum enumKoPaletteStyle {
00048     PALETTE_DOCKER, // QDockWindow based docker with tabs
00049     PALETTE_TOOLBOX // QDockWindow based docker with a QToolBox
00050 };
00051 
00052 
00053 namespace {
00054     struct DockerRecord {
00055         int position;
00056         int x;
00057         int y;
00058         int w;
00059         int h;
00060     };
00061 }
00062 
00085 class KOPALETTE_EXPORT KoPaletteManager : public QObject {
00086 
00087     Q_OBJECT
00088 
00089 
00090 public:
00091 
00092     KoPaletteManager(KoView * view, KActionCollection * ac, const char * name);
00093     virtual ~KoPaletteManager();
00094 
00095 public:
00096     
00115     virtual void addWidget(QWidget * widget, const QString & name, const QString & paletteName, int position = -1, 
00116                enumKoPaletteStyle style = PALETTE_DOCKER, bool shown = true);
00117 
00118 
00122     virtual QWidget * widget(const QString & name);
00123 
00127     virtual void showWidget(const QString & name);
00128 
00132     virtual void hideWidget(const QString & name);
00133     
00140     virtual void removeWidget(const QString & name);
00141 
00142 
00147     virtual KoPalette * createPalette(const QString & name, const QString & caption, enumKoPaletteStyle style = PALETTE_DOCKER);
00148 
00154     virtual void placePalette(const QString & name, Dock location = DockRight);
00155 
00160      virtual void addPalette(KoPalette * palette, const QString & name, Dock location = DockRight);
00161 
00165      virtual void setFixedWidth(int w);
00166 
00167 public slots:
00168 
00169     void slotTogglePalette(int paletteIndex);
00170     void slotToggleAllPalettes();
00171     void showAllPalettes(bool shown);
00172 
00177     virtual void slotReset();
00178 
00182     virtual void slotResetFont();
00183      
00184 
00185 protected:
00186 
00187     bool eventFilter( QObject *o, QEvent *e );
00188 
00189 private:
00190 
00191 
00195     virtual void save();
00196 
00197 
00198 private:
00199 
00200     KoView                  * m_view;
00201     KActionCollection       * m_actionCollection;
00202     KActionMenu             * m_viewActionMenu;
00203     KToggleAction           * m_toggleShowHidePalettes;
00204     enumKoDockability         m_dockability;
00205     
00206     QStringList             * m_widgetNames;
00207 
00208     QDict<QWidget>          * m_widgets;
00209     QDict<KoPalette>        * m_palettes;
00210     QValueStack<QString>   m_hiddenWidgets; // names of widgets actively hidden by hide all
00211     QDict<KToggleAction>    * m_actions;
00212     QSignalMapper           * m_mapper;
00213 
00214     QMap<QString, QString>  * m_defaultMapping; // widget to docker
00215     QStringList               m_defaultPaletteOrder; // Order of palette creation
00216     QStringList               m_defaultWidgetOrder; // Order of widget addition
00217     QMap<QString, QString>  * m_currentMapping; // widget to docker
00218 
00219     bool m_setFixedWidth;
00220     int m_fixedWidth;
00221 };
00222 
00223 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys