lib

KoToolBox.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 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 #ifndef _KO_TOOLBOX_H_
00020 #define _KO_TOOLBOX_H_
00021 
00022 #include <qtoolbutton.h>
00023 #include <qptrvector.h>
00024 #include <qtoolbar.h>
00025 #include <koffice_export.h>
00026 #include <ktoolbar.h>
00027 
00028 class QWidget;
00029 class KAction;
00030 class KMainWindow;
00031 class KDualColorButton;
00032 class QGridLayout;
00033 class ToolArea;
00034 
00035 
00045 class KOFFICEUI_EXPORT KoToolBox : public KToolBar {
00046 
00047     Q_OBJECT
00048 
00049 public:
00050 
00051     KoToolBox( KMainWindow *mainWin, const char* name, KInstance* instance, int numberOfTooltypes);
00052     virtual ~KoToolBox();
00053 
00054     // Called by the toolcontroller for each tool. For every category,
00055     // there is a separate list, and the tool is categorized correctly.
00056     // The tool is not yet added to the widgets; call setupTools()
00057     // to do that. We don't store the tool.
00058     void registerTool(KAction * tool, int toolType, Q_UINT32 priority);
00059 
00060     // Called when all tools have been added by the tool controller
00061     void setupTools();
00062 
00063 public slots:
00064 
00065     virtual void setOrientation ( Orientation o );
00066     void slotButtonPressed( int id );
00067     void slotPressButton( int id );
00068 
00069     // Enables or disables all buttons and the corresponding actions.
00070     void enableTools(bool enable);
00071 
00072     void slotSetTool(const QString & toolname);
00073 
00074 private:
00075 
00076     QToolButton * createButton(QWidget * parent, const char* iconName, QString tooltip);
00077 
00078 
00079 private:
00080     Q_UINT32 m_numberOfButtons;
00081 
00082     QButtonGroup * m_buttonGroup; // The invisible group of all toolbuttons, so only one can be active at a given time
00083 
00084     QPtrList<ToolArea> m_toolBoxes; // For every ToolArea
00085 
00086     typedef QMap< int, KAction*> ToolList; // The priority ordered list of tools for a certain tooltype
00087 
00088     QPtrList<ToolList> m_tools;
00089     QPtrList<KAction> m_idToActionMap; // Map the buttongroup id's to actions for easy activating.
00090     KInstance* m_instance;
00091 };
00092 
00093 
00094 class ToolArea : public QWidget {
00095 
00096 public:
00097     ToolArea(QWidget *parent);
00098     ~ToolArea();
00099 
00100     void  setOrientation ( Qt::Orientation o );
00101     void  add(QWidget *button);
00102 
00103     QWidget* getNextParent();
00104 
00105 private:
00106     QPtrList<QWidget>  m_children;
00107     QBoxLayout        *m_layout;
00108 
00109     QWidget           *m_leftRow;
00110     QBoxLayout        *m_leftLayout;
00111 
00112     QWidget           *m_rightRow;
00113     QBoxLayout        *m_rightLayout;
00114 
00115     bool               m_left;
00116 };
00117 
00118 
00119 #endif // _KO_TOOLBOX_H_
KDE Home | KDE Accessibility Home | Description of Access Keys