KUtils
kmultitabbar.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef _KMultitabbar_h_
00026 #define _KMultitabbar_h_
00027
00028 #include <qscrollview.h>
00029 #include <qvbox.h>
00030 #include <qhbox.h>
00031 #include <qlayout.h>
00032 #include <qstring.h>
00033 #include <qptrlist.h>
00034 #include <qpushbutton.h>
00035
00036 #include <kdelibs_export.h>
00037
00038 class QPixmap;
00039 class QPainter;
00040 class QFrame;
00041
00042 class KMultiTabBarPrivate;
00043 class KMultiTabBarTabPrivate;
00044 class KMultiTabBarButtonPrivate;
00045 class KMultiTabBarInternal;
00046
00056 class KUTILS_EXPORT KMultiTabBar: public QWidget
00057 {
00058 Q_OBJECT
00059 public:
00063 enum KMultiTabBarMode {
00064 Horizontal,
00065 Vertical
00066 };
00067
00071 enum KMultiTabBarPosition {
00072 Left,
00073 Right,
00074 Top,
00075 Bottom
00076 };
00077
00081 enum KMultiTabBarStyle {
00082 VSNET=0,
00083 KDEV3=1,
00084 KONQSBC=2,
00085 KDEV3ICON=3,
00086 STYLELAST=0xffff
00087 };
00088
00095 KMultiTabBar(KMultiTabBarMode bm,QWidget *parent=0,const char *name=0);
00096
00100 virtual ~KMultiTabBar();
00101
00111 int appendButton(const QPixmap &pic,int id=-1,QPopupMenu* popup=0,const QString& not_used_yet=QString::null);
00115 void removeButton(int id);
00123 int appendTab(const QPixmap &pic,int id=-1,const QString& text=QString::null);
00128 void removeTab(int id);
00134 void setTab(int id ,bool state);
00139 bool isTabRaised(int id) const;
00144 class KMultiTabBarButton *button(int id) const;
00145
00149 class KMultiTabBarTab *tab(int id) const;
00154 void setPosition(KMultiTabBarPosition pos);
00159 KMultiTabBarPosition position() const;
00164 void setStyle(KMultiTabBarStyle style);
00169 KMultiTabBarStyle tabStyle() const;
00175 QPtrList<KMultiTabBarTab>* tabs();
00181 QPtrList<KMultiTabBarButton>* buttons();
00182
00186 void showActiveTabTexts(bool show=true);
00187 protected:
00188 friend class KMultiTabBarButton;
00189 virtual void fontChange( const QFont& );
00190 void updateSeparator();
00191 private:
00192 class KMultiTabBarInternal *m_internal;
00193 QBoxLayout *m_l;
00194 QFrame *m_btnTabSep;
00195 QPtrList<KMultiTabBarButton> m_buttons;
00196 KMultiTabBarPosition m_position;
00197 KMultiTabBarPrivate *d;
00198 };
00199
00205 class KUTILS_EXPORT KMultiTabBarButton: public QPushButton
00206 {
00207 Q_OBJECT
00208 public:
00210 KMultiTabBarButton(const QPixmap& pic,const QString&, QPopupMenu *popup,
00211 int id,QWidget *parent, KMultiTabBar::KMultiTabBarPosition pos, KMultiTabBar::KMultiTabBarStyle style);
00213 KMultiTabBarButton(const QString&, QPopupMenu *popup,
00214 int id,QWidget *parent, KMultiTabBar::KMultiTabBarPosition pos, KMultiTabBar::KMultiTabBarStyle style);
00218 virtual ~KMultiTabBarButton();
00223 int id() const;
00224
00225 public slots:
00230 void setPosition(KMultiTabBar::KMultiTabBarPosition);
00235 void setStyle(KMultiTabBar::KMultiTabBarStyle);
00236
00240 void setText(const QString &);
00241
00242 QSize sizeHint() const;
00243
00244 protected:
00245 KMultiTabBar::KMultiTabBarPosition m_position;
00246 KMultiTabBar::KMultiTabBarStyle m_style;
00247 QString m_text;
00248 virtual void hideEvent( class QHideEvent*);
00249 virtual void showEvent( class QShowEvent*);
00250 private:
00251 int m_id;
00252 KMultiTabBarButtonPrivate *d;
00253 signals:
00258 void clicked(int id);
00259 protected slots:
00260 virtual void slotClicked();
00261 };
00262
00268 class KUTILS_EXPORT KMultiTabBarTab: public KMultiTabBarButton
00269 {
00270 Q_OBJECT
00271 public:
00273 KMultiTabBarTab(const QPixmap& pic,const QString&,int id,QWidget *parent,
00274 KMultiTabBar::KMultiTabBarPosition pos,KMultiTabBar::KMultiTabBarStyle style);
00278 virtual ~KMultiTabBarTab();
00283 void setState(bool state);
00289 void showActiveTabText(bool show);
00293 void resize(){ setSize( neededSize() ); }
00294 private:
00295 bool m_showActiveTabText;
00296 int m_expandedSize;
00297 KMultiTabBarTabPrivate *d;
00298 protected:
00299 friend class KMultiTabBarInternal;
00300 void setSize(int);
00301 int neededSize();
00302 void updateState();
00303 virtual void drawButton(QPainter *);
00304 virtual void drawButtonLabel(QPainter *);
00305 void drawButtonStyled(QPainter *);
00306 void drawButtonClassic(QPainter *);
00307 protected slots:
00308 virtual void slotClicked();
00309 void setTabsPosition(KMultiTabBar::KMultiTabBarPosition);
00310
00311 public slots:
00312 virtual void setIcon(const QString&);
00313 virtual void setIcon(const QPixmap&);
00314 };
00315
00316 #endif