home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / qt3_emx.zip / include / qtabbar.h < prev    next >
C/C++ Source or Header  |  2001-10-11  |  5KB  |  181 lines

  1. /****************************************************************************
  2. ** $Id:  qt/qtabbar.h   3.0.0   edited Oct 1 12:11 $
  3. **
  4. ** Definition of QTab and QTabBar classes
  5. **
  6. ** Copyright (C) 1992-2000 Trolltech AS.  All rights reserved.
  7. **
  8. ** This file is part of the widgets module of the Qt GUI Toolkit.
  9. **
  10. ** This file may be distributed under the terms of the Q Public License
  11. ** as defined by Trolltech AS of Norway and appearing in the file
  12. ** LICENSE.QPL included in the packaging of this file.
  13. **
  14. ** This file may be distributed and/or modified under the terms of the
  15. ** GNU General Public License version 2 as published by the Free Software
  16. ** Foundation and appearing in the file LICENSE.GPL included in the
  17. ** packaging of this file.
  18. **
  19. ** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
  20. ** licenses may use this file in accordance with the Qt Commercial License
  21. ** Agreement provided with the Software.
  22. **
  23. ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
  24. ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  25. **
  26. ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
  27. **   information about Qt Commercial License Agreements.
  28. ** See http://www.trolltech.com/qpl/ for QPL licensing information.
  29. ** See http://www.trolltech.com/gpl/ for GPL licensing information.
  30. **
  31. ** Contact info@trolltech.com if any conditions of this licensing are
  32. ** not clear to you.
  33. **
  34. **********************************************************************/
  35.  
  36. #ifndef QTABBAR_H
  37. #define QTABBAR_H
  38.  
  39. #ifndef QT_H
  40. #include "qwidget.h"
  41. #include "qptrlist.h"
  42. #endif // QT_H
  43.  
  44. #ifndef QT_NO_TABBAR
  45.  
  46. class QTabBar;
  47. class QIconSet;
  48.  
  49. class Q_EXPORT QTab : public Qt
  50. {
  51.     friend class QTabBar;
  52.     friend class QTabWidget;
  53.  
  54. public:
  55.     QTab();
  56.     virtual ~QTab();
  57.     QTab( const QString& text );
  58.     QTab( const QIconSet& icon, const QString& text = QString::null );
  59.  
  60.     void setText( const QString& text);
  61.     QString text() const { return label; }
  62.     void setIconSet( const QIconSet& icon );
  63.     QIconSet* iconSet() const { return iconset; }
  64.     void setRect( const QRect& rect ) { r = rect; }
  65.     QRect rect() const { return r; }
  66.     void setEnabled( bool enable ) { enabled = enable; }
  67.     bool isEnabled() const { return enabled; }
  68.     void setIdentifier( int i ) { id = i; }
  69.     int identifier() const { return id; }
  70.  
  71. private:
  72.     void setTabBar( QTabBar *tb );
  73.     QString label;
  74.     QRect r; // the bounding rectangle of this (may overlap with others)
  75.     bool enabled;
  76.     int id;
  77.     QIconSet* iconset; // optional iconset
  78.     QTabBar *tb;
  79. };
  80.  
  81.  
  82. struct QTabPrivate;
  83. //class *QAccel;
  84.  
  85. class Q_EXPORT QTabBar: public QWidget
  86. {
  87.     Q_OBJECT
  88.     Q_ENUMS( Shape )
  89.     Q_PROPERTY( Shape shape READ shape WRITE setShape )
  90.     Q_PROPERTY( int currentTab READ currentTab WRITE setCurrentTab )
  91.     Q_PROPERTY( int count READ count )
  92.     Q_PROPERTY( int keyboardFocusTab READ keyboardFocusTab )
  93.  
  94. public:
  95.     QTabBar( QWidget* parent=0, const char* name=0 );
  96.     ~QTabBar();
  97.  
  98.     enum Shape { RoundedAbove, RoundedBelow,
  99.          TriangularAbove, TriangularBelow };
  100.  
  101.     Shape shape() const;
  102.     virtual void setShape( Shape );
  103.  
  104.     void show();
  105.  
  106.     virtual int addTab( QTab * );
  107.     virtual int insertTab( QTab *, int index = -1 );
  108.     virtual void removeTab( QTab * );
  109.  
  110.     virtual void setTabEnabled( int, bool );
  111.     bool isTabEnabled( int ) const;
  112.  
  113.  
  114.     QSize sizeHint() const;
  115.     QSize minimumSizeHint() const;
  116.  
  117.     int currentTab() const;
  118.     int keyboardFocusTab() const;
  119.  
  120.     QTab * tab( int ) const;
  121.     QTab * tabAt( int ) const;
  122.     int indexOf( int ) const;
  123.     int count() const;
  124.  
  125.     virtual void layoutTabs();
  126.     virtual QTab * selectTab( const QPoint & p ) const;
  127.  
  128.     void     removeToolTip( int index );
  129.     void         setToolTip( int index, const QString & tip );
  130.     QString     toolTip( int index ) const;
  131.  
  132. public slots:
  133.     virtual void setCurrentTab( int );
  134.     virtual void setCurrentTab( QTab * );
  135.  
  136. signals:
  137.     void  selected( int );
  138.  
  139. protected:
  140.     virtual void paint( QPainter *, QTab *, bool ) const; // ### not const
  141.     virtual void paintLabel( QPainter*, const QRect&, QTab*, bool ) const;
  142.  
  143.     void focusInEvent( QFocusEvent *e );
  144.     void focusOutEvent( QFocusEvent *e );
  145.  
  146.     void resizeEvent( QResizeEvent * );
  147.     void paintEvent( QPaintEvent * );
  148.     void mousePressEvent ( QMouseEvent * );
  149.     void mouseMoveEvent ( QMouseEvent * );
  150.     void mouseReleaseEvent ( QMouseEvent * );
  151.     void keyPressEvent( QKeyEvent * );
  152.     void styleChange( QStyle& );
  153.     void fontChange ( const QFont & );
  154.     
  155.     QPtrList<QTab> * tabList();
  156.  
  157. private slots:
  158.     void scrollTabs();
  159.  
  160. private:
  161.     QPtrList<QTab> * l;
  162.     QPtrList<QTab> * lstatic;
  163.     void makeVisible( QTab* t  );
  164.     void updateArrowButtons();
  165.     QTabPrivate * d;
  166.  
  167.     friend class QTabBarToolTip;
  168.     friend class QTab;
  169.  
  170. private:    // Disabled copy constructor and operator=
  171. #if defined(Q_DISABLE_COPY)
  172.     QTabBar( const QTabBar & );
  173.     QTabBar& operator=( const QTabBar & );
  174. #endif
  175. };
  176.  
  177.  
  178. #endif // QT_NO_TABBAR
  179.  
  180. #endif // QTABBAR_H
  181.