Eneboo - Documentación para desarrolladores
src/qt/src/widgets/qtoolbutton.h
Ir a la documentación de este archivo.
00001 /****************************************************************************
00002 ** $Id: qt/qtoolbutton.h   3.3.8   edited Jan 11 14:39 $
00003 **
00004 ** Definition of QToolButton class
00005 **
00006 ** Created : 979899
00007 **
00008 ** Copyright (C) 1992-2007 Trolltech ASA.  All rights reserved.
00009 **
00010 ** This file is part of the widgets module of the Qt GUI Toolkit.
00011 **
00012 ** This file may be distributed under the terms of the Q Public License
00013 ** as defined by Trolltech ASA of Norway and appearing in the file
00014 ** LICENSE.QPL included in the packaging of this file.
00015 **
00016 ** This file may be distributed and/or modified under the terms of the
00017 ** GNU General Public License version 2 as published by the Free Software
00018 ** Foundation and appearing in the file LICENSE.GPL included in the
00019 ** packaging of this file.
00020 **
00021 ** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
00022 ** licenses may use this file in accordance with the Qt Commercial License
00023 ** Agreement provided with the Software.
00024 **
00025 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00026 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00027 **
00028 ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
00029 **   information about Qt Commercial License Agreements.
00030 ** See http://www.trolltech.com/qpl/ for QPL licensing information.
00031 ** See http://www.trolltech.com/gpl/ for GPL licensing information.
00032 **
00033 ** Contact info@trolltech.com if any conditions of this licensing are
00034 ** not clear to you.
00035 **
00036 **********************************************************************/
00037 
00038 #ifndef QTOOLBUTTON_H
00039 #define QTOOLBUTTON_H
00040 
00041 #ifndef QT_H
00042 #include "qbutton.h"
00043 #include "qstring.h"
00044 #include "qpixmap.h"
00045 #include "qiconset.h"
00046 #endif // QT_H
00047 
00048 #ifndef QT_NO_TOOLBUTTON
00049 
00050 class QToolButtonPrivate;
00051 class QToolBar;
00052 class QPopupMenu;
00053 
00054 class Q_EXPORT QToolButton : public QButton
00055 {
00056     Q_OBJECT
00057     Q_ENUMS( TextPosition )
00058 
00059     Q_PROPERTY( QIconSet iconSet READ iconSet WRITE setIconSet )
00060     Q_PROPERTY( QIconSet onIconSet READ onIconSet WRITE setOnIconSet DESIGNABLE false STORED false )
00061     Q_PROPERTY( QIconSet offIconSet READ offIconSet WRITE setOffIconSet DESIGNABLE false STORED false )
00062     Q_PROPERTY( bool usesBigPixmap READ usesBigPixmap WRITE setUsesBigPixmap )
00063     Q_PROPERTY( bool usesTextLabel READ usesTextLabel WRITE setUsesTextLabel )
00064     Q_PROPERTY( QString textLabel READ textLabel WRITE setTextLabel )
00065     Q_PROPERTY( int popupDelay READ popupDelay WRITE setPopupDelay )
00066     Q_PROPERTY( bool autoRaise READ autoRaise WRITE setAutoRaise )
00067     Q_PROPERTY( TextPosition textPosition READ textPosition WRITE setTextPosition )
00068 
00069     Q_OVERRIDE( bool toggleButton WRITE setToggleButton )
00070     Q_OVERRIDE( bool on WRITE setOn )
00071     Q_OVERRIDE( QPixmap pixmap DESIGNABLE false STORED false )
00072     Q_OVERRIDE( BackgroundMode backgroundMode DESIGNABLE true)
00073 
00074 public:
00075     enum TextPosition {
00076         BesideIcon,
00077         BelowIcon,
00078         Right = BesideIcon, // obsolete
00079         Under = BelowIcon // obsolete
00080     };
00081     QToolButton( QWidget * parent, const char* name=0 );
00082 #ifndef QT_NO_TOOLBAR
00083     QToolButton( const QIconSet& s, const QString &textLabel,
00084                  const QString& grouptext,
00085                  QObject * receiver, const char* slot,
00086                  QToolBar * parent, const char* name=0 );
00087 #endif
00088     QToolButton( ArrowType type, QWidget *parent, const char* name=0 );
00089     ~QToolButton();
00090 
00091     QSize sizeHint() const;
00092     QSize minimumSizeHint() const;
00093 
00094 #ifndef QT_NO_COMPAT
00095     void setOnIconSet( const QIconSet& );
00096     void setOffIconSet( const QIconSet& );
00097     void setIconSet( const QIconSet &, bool on );
00098     QIconSet onIconSet() const;
00099     QIconSet offIconSet( ) const;
00100     QIconSet iconSet( bool on ) const;
00101 #endif
00102     virtual void setIconSet( const QIconSet & );
00103     QIconSet iconSet() const;
00104 
00105     bool usesBigPixmap() const { return ubp; }
00106     bool usesTextLabel() const { return utl; }
00107     QString textLabel() const { return tl; }
00108 
00109 #ifndef QT_NO_POPUPMENU
00110     void setPopup( QPopupMenu* popup );
00111     QPopupMenu* popup() const;
00112 
00113     void setPopupDelay( int delay );
00114     int popupDelay() const;
00115 
00116     void openPopup();
00117 #endif
00118 
00119     void setAutoRaise( bool enable );
00120     bool autoRaise() const;
00121     TextPosition textPosition() const;
00122 
00123     void setText( const QString &txt );
00124 
00125 public slots:
00126     virtual void setUsesBigPixmap( bool enable );
00127     virtual void setUsesTextLabel( bool enable );
00128     virtual void setTextLabel( const QString &, bool );
00129 
00130     virtual void setToggleButton( bool enable );
00131 
00132     virtual void setOn( bool enable );
00133     void toggle();
00134     void setTextLabel( const QString & );
00135     void setTextPosition( TextPosition pos );
00136 
00137 protected:
00138     void mousePressEvent( QMouseEvent * );
00139     void drawButton( QPainter * );
00140     void drawButtonLabel(QPainter *);
00141 
00142     void enterEvent( QEvent * );
00143     void leaveEvent( QEvent * );
00144     void moveEvent( QMoveEvent * );
00145 
00146     // ### Make virtual in 4.0, maybe act like QPushButton with
00147     // regards to setFlat() instead?  Andy
00148     bool uses3D() const;
00149 #if (QT_VERSION >= 0x040000)
00150 #error "Some functions need to be changed to virtual for Qt 4.0"
00151 #endif
00152 
00153     bool eventFilter( QObject *o, QEvent *e );
00154 
00155 #ifndef QT_NO_PALETTE
00156     void paletteChange( const QPalette & );
00157 #endif
00158 
00159 private slots:
00160     void popupTimerDone();
00161     void popupPressed();
00162 
00163 private:
00164     void init();
00165 
00166     QPixmap bp;
00167     int bpID;
00168     QPixmap sp;
00169     int spID;
00170 
00171     QString tl;
00172 
00173     QToolButtonPrivate *d;
00174     QIconSet *s;
00175 
00176     uint utl : 1;
00177     uint ubp : 1;
00178     uint hasArrow : 1;
00179 
00180 private:        // Disabled copy constructor and operator=
00181 #if defined(Q_DISABLE_COPY)
00182     QToolButton( const QToolButton & );
00183     QToolButton& operator=( const QToolButton & );
00184 #endif
00185 };
00186 
00187 #endif // QT_NO_TOOLBUTTON
00188 
00189 #endif // QTOOLBUTTON_H
 Todo Clases Namespaces Archivos Funciones Variables 'typedefs' Enumeraciones Valores de enumeraciones Propiedades Amigas 'defines'