kdeui Library API Documentation

ktoolbar.h

00001 /* This file is part of the KDE libraries
00002     Copyright (C) 2000 Reginald Stadlbauer (reggie@kde.org)
00003     (C) 1997, 1998 Stephan Kulow (coolo@kde.org)
00004     (C) 1997, 1998 Sven Radej (radej@kde.org)
00005     (C) 1997, 1998 Mark Donohoe (donohoe@kde.org)
00006     (C) 1997, 1998 Matthias Ettrich (ettrich@kde.org)
00007     (C) 1999, 2000 Kurt Granroth (granroth@kde.org)
00008 
00009     This library is free software; you can redistribute it and/or
00010     modify it under the terms of the GNU Library General Public
00011     License version 2 as published by the Free Software Foundation.
00012 
00013     This library is distributed in the hope that it will be useful,
00014     but WITHOUT ANY WARRANTY; without even the implied warranty of
00015     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00016     Library General Public License for more details.
00017 
00018     You should have received a copy of the GNU Library General Public License
00019     along with this library; see the file COPYING.LIB.  If not, write to
00020     the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00021     Boston, MA 02111-1307, USA.
00022     */
00023 
00024 #ifndef KTOOLBAR_H
00025 #define KTOOLBAR_H
00026 
00027 #include <qtoolbar.h>
00028 #include <qmainwindow.h>
00029 #include <qcombobox.h>
00030 #include <qmap.h>
00031 #include <qptrlist.h>
00032 #include <kglobal.h>
00033 #include <qguardedptr.h>
00034 #include <qframe.h>
00035 #include <qiconset.h>
00036 
00037 class QDomElement;
00038 class QSize;
00039 class QPixmap;
00040 class QPopupMenu;
00041 class QStringList;
00042 class QDomDocument;
00043 class QTimer;
00044 
00045 class KLineEdit;
00046 class KToolBar;
00047 class KToolBarButton;
00048 class KToolBoxManager;
00049 class KAnimWidget;
00050 class KPopupMenu;
00051 class KInstance;
00052 class KComboBox;
00053 class KXMLGUIClient;
00054 
00055 class KToolBarPrivate;
00056 
00057 class KToolBarSeparator : public QFrame
00058 {
00059     Q_OBJECT
00060 public:
00061     KToolBarSeparator( Orientation, bool l, QToolBar *parent, const char* name=0 );
00062 
00063     QSize sizeHint() const;
00064     Orientation orientation() const { return orient; }
00065     QSizePolicy sizePolicy() const;
00066     bool showLine() const { return line; }
00067 public slots:
00068    void setOrientation( Orientation );
00069 protected:
00070     void styleChange( QStyle& );
00071 private:
00072     Orientation orient;
00073     bool line;
00074 };
00075 
00076 
00101 class KToolBar : public QToolBar
00102 {
00103     Q_OBJECT
00104     Q_ENUMS( IconText BarPosition )
00105     Q_PROPERTY( IconText iconText READ iconText WRITE setIconText )
00106     Q_PROPERTY( BarPosition barPos READ barPos WRITE setBarPos )
00107     Q_PROPERTY( bool fullSize READ fullSize WRITE setFullSize )
00108     Q_PROPERTY( int iconSize READ iconSize WRITE setIconSize )
00109     Q_PROPERTY( QString text READ text WRITE setText )
00110 
00111 public:
00112     enum IconText{IconOnly = 0, IconTextRight, TextOnly, IconTextBottom};
00117     enum BarStatus{Toggle, Show, Hide};
00121     enum BarPosition{ Unmanaged, Floating, Top, Bottom, Right, Left, Flat};
00122 
00140     KToolBar( QWidget *parent, const char *name = 0, bool honor_style = FALSE, bool readConfig = TRUE );
00141 
00157     KToolBar( QMainWindow *parentWindow, QMainWindow::ToolBarDock dock /*= QMainWindow::Top*/, bool newLine = false,
00158               const char *name = 0, bool honor_style = FALSE, bool readConfig = TRUE );
00159 
00175     KToolBar( QMainWindow *parentWindow, QWidget *dock, bool newLine = false,
00176               const char *name = 0, bool honor_style = FALSE, bool readConfig = TRUE );
00177 
00178     virtual ~KToolBar();
00179 
00200     int insertButton(const QString& icon, int id, bool enabled = true,
00201              const QString& text = QString::null, int index=-1,
00202              KInstance *_instance = KGlobal::instance());
00203 
00220     int insertButton(const QString& icon, int id, const char *signal,
00221              const QObject *receiver, const char *slot,
00222              bool enabled = true, const QString& text = QString::null,
00223              int index=-1, KInstance *_instance = KGlobal::instance() );
00224 
00249     int insertButton(const QPixmap& pixmap, int id, bool enabled = true,
00250              const QString& text = QString::null, int index=-1 );
00251 
00268     int insertButton(const QPixmap& pixmap, int id, const char *signal,
00269              const QObject *receiver, const char *slot,
00270              bool enabled = true, const QString& text = QString::null,
00271              int index=-1 );
00272 
00285     int insertButton(const QString& icon, int id, QPopupMenu *popup,
00286              bool enabled, const QString&_text, int index=-1);
00287 
00300     int insertButton(const QPixmap& pixmap, int id, QPopupMenu *popup,
00301              bool enabled, const QString&_text, int index=-1);
00302 
00315     int insertLined (const QString& text, int id,
00316              const char *signal,
00317              const QObject *receiver, const char *slot,
00318              bool enabled = true,
00319              const QString& toolTipText = QString::null,
00320              int size = 70, int index =-1);
00321 
00336     int insertCombo (const QStringList &list, int id, bool writable,
00337              const char *signal, const QObject *receiver,
00338              const char *slot, bool enabled=true,
00339              const QString& tooltiptext=QString::null,
00340              int size=70, int index=-1,
00341              QComboBox::Policy policy = QComboBox::AtBottom);
00342 
00352     int insertCombo (const QString& text, int id, bool writable,
00353              const char *signal, QObject *recevier,
00354              const char *slot, bool enabled=true,
00355              const QString& tooltiptext=QString::null,
00356              int size=70, int index=-1,
00357              QComboBox::Policy policy = QComboBox::AtBottom);
00358 
00363     int insertSeparator( int index = -1, int id = -1 );
00364 
00369     int insertLineSeparator( int index = -1, int id = -1 );
00370 
00381     int insertWidget(int id, int width, QWidget *_widget, int index=-1);
00382 
00399     int insertAnimatedWidget(int id, QObject *receiver, const char *slot,
00400                  const QString& icons, int index = -1);
00401 
00412     KAnimWidget *animatedWidget( int id );
00413 
00420     void addConnection (int id, const char *signal,
00421                         const QObject *receiver, const char *slot);
00425     void setItemEnabled( int id, bool enabled );
00426 
00432     void setButtonIcon( int id, const QString& _icon );
00433 
00439     void setButtonPixmap( int id, const QPixmap& _pixmap );
00440 
00446     void setButtonIconSet( int id, const QIconSet& iconset );
00447 
00472     void setDelayedPopup (int id , QPopupMenu *_popup, bool toggle = false);
00473 
00487     void setAutoRepeat (int id, bool flag=true);
00488 
00489 
00493     void setToggle (int id, bool flag = true);
00494 
00504     void toggleButton (int id);
00505 
00515     void setButton (int id, bool flag);
00516 
00522     bool isButtonOn (int id) const;
00523 
00529     void setLinedText (int id, const QString& text);
00530 
00534     QString getLinedText (int id) const;
00535 
00539     void insertComboItem (int id, const QString& text, int index);
00540 
00544     void insertComboList (int id, const QStringList &list, int index);
00545 
00549     void removeComboItem (int id, int index);
00550 
00554     void setCurrentComboItem (int id, int index);
00555 
00561     void changeComboItem  (int id, const QString& text, int index=-1);
00562 
00568     void clearCombo (int id);
00569 
00576     QString getComboItem (int id, int index=-1) const;
00577 
00588     KComboBox * getCombo(int id);
00589 
00601     KLineEdit * getLined (int id);
00602 
00615     KToolBarButton * getButton (int id);
00616 
00623     void alignItemRight (int id, bool right = true);
00624 
00635     QWidget *getWidget (int id);
00636 
00650     void setItemAutoSized (int id, bool yes = true);
00651 
00657     void clear ();
00658 
00664     void removeItem (int id);
00665 
00669     void hideItem (int id);
00670 
00674     void showItem (int id);
00675 
00688     void setFullSize(bool flag = true);
00689 
00694     bool fullSize() const;
00695 
00700     void enableMoving(bool flag = true);
00701 
00706     void setBarPos (BarPosition bpos);
00707 
00711     BarPosition barPos() const;
00712 
00721     bool enable(BarStatus stat);
00722 
00727     void setMaxHeight (int h);  // Set max height for vertical toolbars
00728 
00734     int maxHeight();
00735 
00741     void setMaxWidth (int dw);
00742 
00748     int maxWidth();
00749 
00756     void setTitle (const QString& _title);
00757 
00762     void enableFloating (bool arrrrrrgh);
00763 
00775     void setIconText(IconText it);
00776    // Note: don't merge with the next one, it breaks Qt properties
00777 
00784     void setIconText(IconText it, bool update);
00785 
00789     IconText iconText() const;
00790 
00801     void setIconSize(int size);
00802     // Note: don't merge with the next one, it breaks Qt properties
00803 
00812     void setIconSize(int size, bool update);
00813 
00817     int iconSize() const;
00818 
00824     void setEnableContextMenu(bool enable = true);
00825 
00831     bool contextMenuEnabled() const;
00832 
00841     void setItemNoStyle(int id, bool no_style = true);
00842 
00843     void setFlat (bool flag);
00844 
00848     int count() const;
00849 
00855     void saveState();
00856 
00860     void saveSettings(KConfig *config, const QString &configGroup);
00861 
00866     void applySettings(KConfig *config, const QString &configGroup);
00867 
00878   //  void setXML(const QString& xmlfile, const QDomDocument& xml);
00879   /* @internal */
00880     void setXMLGUIClient( KXMLGUIClient *client );
00881 
00886     void setText( const QString & txt );
00887 
00891     QString text() const;
00892 
00893     void setStretchableWidget( QWidget *w );
00894     QSizePolicy sizePolicy() const;
00895     bool highlight() const;
00896     QSize sizeHint() const;
00897     QSize minimumSizeHint() const;
00898     QSize minimumSize() const;
00899 
00900     void hide();
00901     void show();
00902 
00903     void updateRects( bool = FALSE ) {}
00904 
00905     void loadState( const QDomElement &e );
00906     void saveState( QDomElement &e );
00907 
00911     void positionYourself( bool force = false);
00912 
00913 signals:
00917     void clicked(int id);
00918 
00932     void doubleClicked (int id);
00933 
00937     void pressed(int);
00938 
00942     void released(int);
00943 
00953     void toggled(int);
00954 
00965     void highlighted(int id, bool isHighlighted);
00966 
00975     void highlighted(int id );
00976 
00986     void moved( BarPosition );
00987 
00995     void modechange ();
00996 
01004     void toolbarDestroyed();
01005 
01006 public:
01010     static bool highlightSetting();
01011 
01015     static bool transparentSetting();
01016 
01020     static IconText iconTextSetting();
01021 
01022 public slots:
01023     virtual void setIconText( const QString &txt )
01024     { QToolBar::setIconText( txt ); }
01025 
01026 protected:
01027     void mousePressEvent( QMouseEvent * );
01028     void childEvent( QChildEvent *e );
01029     void showEvent( QShowEvent *e );
01030     void resizeEvent( QResizeEvent *e );
01031     bool event( QEvent *e );
01032     void applyAppearanceSettings(KConfig *config, const QString &_configGroup, bool forceGlobal = false);
01033     QString settingsGroup() const;
01034 
01035 private slots:
01036     void rebuildLayout();
01037     void slotReadConfig ();
01038     void slotAppearanceChanged();
01039     void slotIconChanged(int);
01040     void slotRepaint();
01041     void toolBarPosChanged( QToolBar *tb );
01042     void slotContextAboutToShow();
01043     void widgetDestroyed();
01044 
01045 private:
01046     void init( bool readConfig = true, bool honorStyle = false );
01047     void doConnections( KToolBarButton *button );
01048     void insertWidgetInternal( QWidget *w, int &index, int id );
01049     void removeWidgetInternal( QWidget *w );
01050     void getAttributes( QString &position, QString &icontext, QString &index, QString &offset, QString &newLine );
01051     KPopupMenu *contextMenu();
01052 
01053     QMap<QWidget*, int > widget2id;
01054     typedef QMap<int, QWidget* > Id2WidgetMap;
01055     Id2WidgetMap id2widget;
01056     KPopupMenu *context;
01057     QPtrList<QWidget> widgets;
01058     QTimer *layoutTimer;
01059     QGuardedPtr<QWidget> stretchableWidget, rightAligned;
01060 protected:
01061     virtual void virtual_hook( int id, void* data );
01062 private:
01063     KToolBarPrivate *d;
01064 };
01065 
01066 #endif
KDE Logo
This file is part of the documentation for kdelibs Version 3.1.0.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Wed Oct 8 12:21:02 2003 by doxygen 1.2.18 written by Dimitri van Heesch, © 1997-2001