| 1 | /****************************************************************************
|
|---|
| 2 | ** $Id: qpushbutton.h 2 2005-11-16 15:49:26Z dmik $
|
|---|
| 3 | **
|
|---|
| 4 | ** Definition of QPushButton class
|
|---|
| 5 | **
|
|---|
| 6 | ** Created : 940221
|
|---|
| 7 | **
|
|---|
| 8 | ** Copyright (C) 1992-2000 Trolltech AS. All rights reserved.
|
|---|
| 9 | **
|
|---|
| 10 | ** This file is part of the widgets module of the Qt GUI Toolkit.
|
|---|
| 11 | **
|
|---|
| 12 | ** This file may be distributed under the terms of the Q Public License
|
|---|
| 13 | ** as defined by Trolltech AS of Norway and appearing in the file
|
|---|
| 14 | ** LICENSE.QPL included in the packaging of this file.
|
|---|
| 15 | **
|
|---|
| 16 | ** This file may be distributed and/or modified under the terms of the
|
|---|
| 17 | ** GNU General Public License version 2 as published by the Free Software
|
|---|
| 18 | ** Foundation and appearing in the file LICENSE.GPL included in the
|
|---|
| 19 | ** packaging of this file.
|
|---|
| 20 | **
|
|---|
| 21 | ** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
|
|---|
| 22 | ** licenses may use this file in accordance with the Qt Commercial License
|
|---|
| 23 | ** Agreement provided with the Software.
|
|---|
| 24 | **
|
|---|
| 25 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
|---|
| 26 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
|---|
| 27 | **
|
|---|
| 28 | ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
|
|---|
| 29 | ** information about Qt Commercial License Agreements.
|
|---|
| 30 | ** See http://www.trolltech.com/qpl/ for QPL licensing information.
|
|---|
| 31 | ** See http://www.trolltech.com/gpl/ for GPL licensing information.
|
|---|
| 32 | **
|
|---|
| 33 | ** Contact info@trolltech.com if any conditions of this licensing are
|
|---|
| 34 | ** not clear to you.
|
|---|
| 35 | **
|
|---|
| 36 | **********************************************************************/
|
|---|
| 37 |
|
|---|
| 38 | #ifndef QPUSHBUTTON_H
|
|---|
| 39 | #define QPUSHBUTTON_H
|
|---|
| 40 |
|
|---|
| 41 | #ifndef QT_H
|
|---|
| 42 | #include "qbutton.h"
|
|---|
| 43 | #include "qiconset.h"
|
|---|
| 44 | #endif // QT_H
|
|---|
| 45 |
|
|---|
| 46 | #ifndef QT_NO_PUSHBUTTON
|
|---|
| 47 | class QPushButtonPrivate;
|
|---|
| 48 | class QPopupMenu;
|
|---|
| 49 |
|
|---|
| 50 | class Q_EXPORT QPushButton : public QButton
|
|---|
| 51 | {
|
|---|
| 52 | Q_OBJECT
|
|---|
| 53 |
|
|---|
| 54 | Q_PROPERTY( bool autoDefault READ autoDefault WRITE setAutoDefault )
|
|---|
| 55 | Q_PROPERTY( bool default READ isDefault WRITE setDefault )
|
|---|
| 56 | Q_PROPERTY( bool menuButton READ isMenuButton DESIGNABLE false )
|
|---|
| 57 | Q_PROPERTY( QIconSet iconSet READ iconSet WRITE setIconSet )
|
|---|
| 58 | Q_OVERRIDE( bool toggleButton WRITE setToggleButton )
|
|---|
| 59 | Q_OVERRIDE( bool on WRITE setOn )
|
|---|
| 60 | Q_PROPERTY( bool flat READ isFlat WRITE setFlat )
|
|---|
| 61 | Q_OVERRIDE( bool autoMask DESIGNABLE true SCRIPTABLE true )
|
|---|
| 62 |
|
|---|
| 63 | public:
|
|---|
| 64 | QPushButton( QWidget *parent, const char* name=0 );
|
|---|
| 65 | QPushButton( const QString &text, QWidget *parent, const char* name=0 );
|
|---|
| 66 | #ifndef QT_NO_ICONSET
|
|---|
| 67 | QPushButton( const QIconSet& icon, const QString &text, QWidget *parent, const char* name=0 );
|
|---|
| 68 | #endif
|
|---|
| 69 | ~QPushButton();
|
|---|
| 70 |
|
|---|
| 71 | QSize sizeHint() const;
|
|---|
| 72 |
|
|---|
| 73 | void move( int x, int y );
|
|---|
| 74 | void move( const QPoint &p );
|
|---|
| 75 | void resize( int w, int h );
|
|---|
| 76 | void resize( const QSize & );
|
|---|
| 77 | void setGeometry( int x, int y, int w, int h );
|
|---|
| 78 |
|
|---|
| 79 | void setGeometry( const QRect & );
|
|---|
| 80 |
|
|---|
| 81 | void setToggleButton( bool );
|
|---|
| 82 |
|
|---|
| 83 | bool autoDefault() const { return autoDefButton; }
|
|---|
| 84 | virtual void setAutoDefault( bool autoDef );
|
|---|
| 85 | bool isDefault() const { return defButton; }
|
|---|
| 86 | virtual void setDefault( bool def );
|
|---|
| 87 |
|
|---|
| 88 | virtual void setIsMenuButton( bool enable ) { // obsolete functions
|
|---|
| 89 | if ( (bool)hasMenuArrow == enable )
|
|---|
| 90 | return;
|
|---|
| 91 | hasMenuArrow = enable ? 1 : 0;
|
|---|
| 92 | update();
|
|---|
| 93 | updateGeometry();
|
|---|
| 94 | }
|
|---|
| 95 | bool isMenuButton() const { return hasMenuArrow; }
|
|---|
| 96 |
|
|---|
| 97 | #ifndef QT_NO_POPUPMENU
|
|---|
| 98 | void setPopup( QPopupMenu* popup );
|
|---|
| 99 | QPopupMenu* popup() const;
|
|---|
| 100 | #endif
|
|---|
| 101 | #ifndef QT_NO_ICONSET
|
|---|
| 102 | void setIconSet( const QIconSet& );
|
|---|
| 103 | QIconSet* iconSet() const;
|
|---|
| 104 | #endif
|
|---|
| 105 | void setFlat( bool );
|
|---|
| 106 | bool isFlat() const;
|
|---|
| 107 |
|
|---|
| 108 | public slots:
|
|---|
| 109 | virtual void setOn( bool );
|
|---|
| 110 |
|
|---|
| 111 | protected:
|
|---|
| 112 | void drawButton( QPainter * );
|
|---|
| 113 | void drawButtonLabel( QPainter * );
|
|---|
| 114 | void focusInEvent( QFocusEvent * );
|
|---|
| 115 | void focusOutEvent( QFocusEvent * );
|
|---|
| 116 | void resizeEvent( QResizeEvent * );
|
|---|
| 117 | void updateMask();
|
|---|
| 118 | private slots:
|
|---|
| 119 | #ifndef QT_NO_POPUPMENU
|
|---|
| 120 | void popupPressed();
|
|---|
| 121 | #endif
|
|---|
| 122 | private:
|
|---|
| 123 | void init();
|
|---|
| 124 |
|
|---|
| 125 | uint autoDefButton : 1;
|
|---|
| 126 | uint defButton : 1;
|
|---|
| 127 | uint flt : 1;
|
|---|
| 128 | uint reserved : 1; // UNUSED
|
|---|
| 129 | uint lastEnabled : 1; // UNUSED
|
|---|
| 130 | uint hasMenuArrow : 1;
|
|---|
| 131 |
|
|---|
| 132 | QPushButtonPrivate* d;
|
|---|
| 133 |
|
|---|
| 134 | friend class QDialog;
|
|---|
| 135 |
|
|---|
| 136 | private: // Disabled copy constructor and operator=
|
|---|
| 137 | #if defined(Q_DISABLE_COPY)
|
|---|
| 138 | QPushButton( const QPushButton & );
|
|---|
| 139 | QPushButton &operator=( const QPushButton & );
|
|---|
| 140 | #endif
|
|---|
| 141 | };
|
|---|
| 142 |
|
|---|
| 143 |
|
|---|
| 144 | #endif // QT_NO_PUSHBUTTON
|
|---|
| 145 |
|
|---|
| 146 | #endif // QPUSHBUTTON_H
|
|---|