Eneboo - Documentación para desarrolladores
src/qt/include/qbutton.h
Ir a la documentación de este archivo.
00001 /****************************************************************************
00002 ** $Id: qt/qbutton.h   3.3.8   edited Jan 11 14:38 $
00003 **
00004 ** Definition of QButton widget class
00005 **
00006 ** Created : 940206
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 QBUTTON_H
00039 #define QBUTTON_H
00040 
00041 #ifndef QT_H
00042 #include "qwidget.h"
00043 #include "qkeysequence.h"
00044 #endif // QT_H
00045 
00046 #ifndef QT_NO_BUTTON
00047 
00048 
00049 class QButtonGroup;
00050 class QToolBar;
00051 class QButtonData;
00052 
00053 class Q_EXPORT QButton : public QWidget
00054 {
00055     Q_OBJECT
00056     Q_ENUMS( ToggleType ToggleState )
00057     Q_PROPERTY( QString text READ text WRITE setText )
00058     Q_PROPERTY( QPixmap pixmap READ pixmap WRITE setPixmap )
00059     Q_PROPERTY( QKeySequence accel READ accel WRITE setAccel )
00060     Q_PROPERTY( bool toggleButton READ isToggleButton )
00061     Q_PROPERTY( ToggleType toggleType READ toggleType )
00062     Q_PROPERTY( bool down READ isDown WRITE setDown DESIGNABLE false  )
00063     Q_PROPERTY( bool on READ isOn )
00064     Q_PROPERTY( ToggleState toggleState READ state )
00065     Q_PROPERTY( bool autoResize READ autoResize WRITE setAutoResize DESIGNABLE false )
00066     Q_PROPERTY( bool autoRepeat READ autoRepeat WRITE setAutoRepeat )
00067     Q_PROPERTY( bool exclusiveToggle READ isExclusiveToggle )
00068 
00069 public:
00070     QButton( QWidget* parent=0, const char* name=0, WFlags f=0 );
00071     ~QButton();
00072 
00073     QString text() const;
00074     virtual void setText( const QString &);
00075     const QPixmap *pixmap() const;
00076     virtual void setPixmap( const QPixmap & );
00077 
00078 #ifndef QT_NO_ACCEL
00079     QKeySequence                accel() const;
00080     virtual void        setAccel( const QKeySequence& );
00081 #endif
00082 
00083     bool        isToggleButton() const;
00084 
00085     enum ToggleType { SingleShot, Toggle, Tristate };
00086     ToggleType  toggleType() const;
00087 
00088     virtual void setDown( bool );
00089     bool        isDown() const;
00090 
00091     bool        isOn() const;
00092 
00093     enum ToggleState { Off, NoChange, On };
00094     ToggleState state() const;
00095 
00096 #ifndef QT_NO_COMPAT
00097     bool        autoResize() const;
00098     void        setAutoResize( bool );
00099 #endif
00100 
00101     bool        autoRepeat() const;
00102     virtual void setAutoRepeat( bool );
00103     bool        isExclusiveToggle() const;
00104 
00105     QButtonGroup *group() const;
00106 
00107 public slots:
00108     void        animateClick();
00109     void        toggle();
00110 
00111 signals:
00112     void        pressed();
00113     void        released();
00114     void        clicked();
00115     void        toggled( bool );
00116     void        stateChanged( int );
00117 
00118 protected:
00119     void        setToggleButton( bool );
00120     virtual void        setToggleType( ToggleType );
00121     void        setOn( bool );
00122     virtual void        setState( ToggleState );
00123 
00124     virtual bool hitButton( const QPoint &pos ) const;
00125     virtual void drawButton( QPainter * );
00126     virtual void drawButtonLabel( QPainter * );
00127 
00128     void        keyPressEvent( QKeyEvent *);
00129     void        keyReleaseEvent( QKeyEvent *);
00130     void        mousePressEvent( QMouseEvent * );
00131     void        mouseReleaseEvent( QMouseEvent * );
00132     void        mouseMoveEvent( QMouseEvent * );
00133     void        paintEvent( QPaintEvent * );
00134     void        focusInEvent( QFocusEvent * );
00135     void        focusOutEvent( QFocusEvent * );
00136 
00137     void        enabledChange( bool );
00138 
00139 private slots:
00140     void        animateTimeout();
00141     void        autoRepeatTimeout();
00142     void        emulateClick();
00143 
00144 private:
00145     QString     btext;
00146     QPixmap    *bpixmap;
00147     uint        toggleTyp       : 2;
00148     uint        buttonDown      : 1;
00149     uint        stat            : 2;
00150     uint        mlbDown         : 1;
00151     uint        autoresize      : 1;
00152     uint        animation       : 1;
00153     uint        repeat          : 1;
00154     QButtonData *d;
00155 
00156     friend class QButtonGroup;
00157     friend class QToolBar;
00158     void          ensureData();
00159     virtual void setGroup( QButtonGroup* );
00160     QTimer       *timer();
00161     void        nextState();
00162 
00163 private:        // Disabled copy constructor and operator=
00164 #if defined(Q_DISABLE_COPY)
00165     QButton( const QButton & );
00166     QButton &operator=( const QButton & );
00167 #endif
00168 };
00169 
00170 
00171 inline QString QButton::text() const
00172 {
00173     return btext;
00174 }
00175 
00176 inline const QPixmap *QButton::pixmap() const
00177 {
00178     return bpixmap;
00179 }
00180 
00181 inline bool QButton::isToggleButton() const
00182 {
00183     return toggleTyp != SingleShot;
00184 }
00185 
00186 inline  bool QButton::isDown() const
00187 {
00188     return buttonDown;
00189 }
00190 
00191 inline bool QButton::isOn() const
00192 {
00193     return stat != Off;
00194 }
00195 
00196 #ifndef QT_NO_COMPAT
00197 inline bool QButton::autoResize() const
00198 {
00199     return autoresize;
00200 }
00201 #endif
00202 
00203 inline bool QButton::autoRepeat() const
00204 {
00205     return repeat;
00206 }
00207 
00208 inline QButton::ToggleState QButton::state() const
00209 {
00210     return ToggleState(stat);
00211 }
00212 
00213 inline void QButton::setToggleButton( bool b )
00214 {
00215     setToggleType( b ? Toggle : SingleShot );
00216 }
00217 
00218 inline void QButton::setOn( bool y )
00219 {
00220     setState( y ? On : Off );
00221 }
00222 
00223 inline QButton::ToggleType QButton::toggleType() const
00224 {
00225     return ToggleType(toggleTyp);
00226 }
00227 
00228 
00229 #endif // QT_NO_BUTTON
00230 
00231 #endif // QBUTTON_H
 Todo Clases Namespaces Archivos Funciones Variables 'typedefs' Enumeraciones Valores de enumeraciones Propiedades Amigas 'defines'