[Jahshaka-cvs] jah/jahwidgets/src/qt3/widgets pushbutton.cpp, 1.2, 1.3 pushbutton.h, 1.14, 1.15 wid
Status: Beta
Brought to you by:
jahshaka
From: tim <tim...@us...> - 2007-03-04 21:40:48
|
Update of /cvsroot/jahshaka/jah/jahwidgets/src/qt3/widgets In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv9521 Modified Files: pushbutton.h widgets.pri widgets_vc71.vcproj Added Files: pushbutton.cpp Log Message: jahwidgets - tidy up of pushbutton Index: widgets.pri =================================================================== RCS file: /cvsroot/jahshaka/jah/jahwidgets/src/qt3/widgets/widgets.pri,v retrieving revision 1.31 retrieving revision 1.32 diff -u -d -r1.31 -r1.32 --- widgets.pri 16 Jan 2007 10:51:30 -0000 1.31 +++ widgets.pri 4 Mar 2007 21:40:42 -0000 1.32 @@ -5,6 +5,7 @@ timelineSlider.cpp \ valueFormatters.cpp \ player.cpp \ + pushbutton.cpp \ mediaPtr.cpp \ scribbler.cpp \ slider.cpp \ @@ -38,7 +39,7 @@ pushbutton.h \ scribbler.h \ slider.h \ - spinbox.h \ + spinbox.h \ progress.h \ timecodeLabel.h \ combobox.h \ Index: widgets_vc71.vcproj =================================================================== RCS file: /cvsroot/jahshaka/jah/jahwidgets/src/qt3/widgets/widgets_vc71.vcproj,v retrieving revision 1.26 retrieving revision 1.27 diff -u -d -r1.26 -r1.27 --- widgets_vc71.vcproj 25 Jan 2007 21:28:32 -0000 1.26 +++ widgets_vc71.vcproj 4 Mar 2007 21:40:42 -0000 1.27 @@ -164,6 +164,9 @@ RelativePath=".\player.cpp"> </File> <File + RelativePath=".\pushbutton.cpp"> + </File> + <File RelativePath=".\rangeControl.cpp"> </File> <File Index: pushbutton.h =================================================================== RCS file: /cvsroot/jahshaka/jah/jahwidgets/src/qt3/widgets/pushbutton.h,v retrieving revision 1.14 retrieving revision 1.15 diff -u -d -r1.14 -r1.15 --- pushbutton.h 2 Mar 2007 14:23:05 -0000 1.14 +++ pushbutton.h 4 Mar 2007 21:40:42 -0000 1.15 @@ -1,3 +1,4 @@ +/* -*- tab-width: 4; indent-tabs-mode: t -*- */ // jahwidgets - A widget library representation. // Copyright (C) 2006 VM Inc. @@ -18,156 +19,68 @@ namespace jahwidgets { namespace qt3 { +/// thin wrapper around QPushButton allowing icon sets to be directly set from +/// within designer class WIDGETS_DECLSPEC Pushbutton : public QPushButton { - Q_OBJECT - Q_PROPERTY( bool clicked READ clicked ) - Q_PROPERTY( bool on READ wrapped_isOn WRITE wrapped_setOn ) - Q_PROPERTY( bool pressed READ pressed ) - Q_PROPERTY( QPixmap activeOnIcon READ activeOnIcon WRITE setActiveOnIcon RESET resetActiveOnIcon ) - Q_PROPERTY( QPixmap normalOnIcon READ normalOnIcon WRITE setNormalOnIcon RESET resetNormalOnIcon ) - Q_PROPERTY( QPixmap disabledOnIcon READ disabledOnIcon WRITE setDisabledOnIcon RESET resetDisabledOnIcon ) - Q_PROPERTY( QPixmap activeOffIcon READ activeOffIcon WRITE setActiveOffIcon RESET resetActiveOffIcon ) - Q_PROPERTY( QPixmap normalOffIcon READ normalOffIcon WRITE setNormalOffIcon RESET resetNormalOffIcon ) - Q_PROPERTY( QPixmap disabledOffIcon READ disabledOffIcon WRITE setDisabledOffIcon RESET resetDisabledOffIcon ) + Q_OBJECT + Q_PROPERTY( bool clicked READ clicked ) + Q_PROPERTY( bool pressed READ pressed ) + Q_PROPERTY( QPixmap activeOnIcon READ activeOnIcon WRITE setActiveOnIcon RESET resetActiveOnIcon ) + Q_PROPERTY( QPixmap normalOnIcon READ normalOnIcon WRITE setNormalOnIcon RESET resetNormalOnIcon ) + Q_PROPERTY( QPixmap disabledOnIcon READ disabledOnIcon WRITE setDisabledOnIcon RESET resetDisabledOnIcon ) + Q_PROPERTY( QPixmap activeOffIcon READ activeOffIcon WRITE setActiveOffIcon RESET resetActiveOffIcon ) + Q_PROPERTY( QPixmap normalOffIcon READ normalOffIcon WRITE setNormalOffIcon RESET resetNormalOffIcon ) + Q_PROPERTY( QPixmap disabledOffIcon READ disabledOffIcon WRITE setDisabledOffIcon RESET resetDisabledOffIcon ) public: - Pushbutton( QWidget* parent, const char* name = 0 ) - : QPushButton( parent, name ), - m_pressed( false ), - m_hover( false ) - { - connect( this, SIGNAL( clicked() ), this, SIGNAL( clicked_changed() ) ); - connect( this, SIGNAL( toggled( bool ) ), this, SIGNAL( on_changed() ) ); - connect( this, SIGNAL( pressed() ), this, SLOT( onPressed() ) ); - connect( this, SIGNAL( released() ), this, SLOT( onReleased() ) ); - } - - bool clicked() const { return true; } - - void wrapped_setOn( bool b ) - { - setOn( b ); - } - - bool wrapped_isOn() const - { - return isOn(); - } - - bool pressed() const { return m_pressed; } - - QPixmap activeOnIcon() const { return m_iconSet.pixmap( QIconSet::Small, QIconSet::Active, QIconSet::On ); } - QPixmap normalOnIcon() const { return m_iconSet.pixmap( QIconSet::Small, QIconSet::Normal, QIconSet::On ); } - QPixmap disabledOnIcon() const { return m_iconSet.pixmap( QIconSet::Small, QIconSet::Disabled, QIconSet::On ); } - void resetActiveOnIcon() { setActiveOnIcon( QPixmap() ); } - void resetNormalOnIcon() { setNormalOnIcon( QPixmap() ); } - void resetDisabledOnIcon() { setDisabledOnIcon( QPixmap() ); } + Pushbutton( QWidget* parent, const char* name = 0 ); - void setActiveOnIcon( const QPixmap& p ) - { - m_iconSet.setPixmap( p, QIconSet::Small, QIconSet::Active, QIconSet::On ); - updatePixmap(); - } - void setNormalOnIcon( const QPixmap& p ) - { - m_iconSet.setPixmap( p, QIconSet::Small, QIconSet::Normal, QIconSet::On ); - updatePixmap(); - } - void setDisabledOnIcon( const QPixmap& p ) - { - m_iconSet.setPixmap( p, QIconSet::Small, QIconSet::Disabled, QIconSet::On ); - updatePixmap(); - } + bool clicked() const; + bool pressed() const; - QPixmap activeOffIcon() const { return m_iconSet.pixmap( QIconSet::Small, QIconSet::Active, QIconSet::Off ); } - QPixmap normalOffIcon() const { return m_iconSet.pixmap( QIconSet::Small, QIconSet::Normal, QIconSet::Off ); } - QPixmap disabledOffIcon() const { return m_iconSet.pixmap( QIconSet::Small, QIconSet::Disabled, QIconSet::Off ); } - void resetActiveOffIcon() { setActiveOffIcon( QPixmap() ); } - void resetNormalOffIcon() { setNormalOffIcon( QPixmap() ); } - void resetDisabledOffIcon() { setDisabledOffIcon( QPixmap() ); } + QPixmap activeOnIcon() const; + QPixmap normalOnIcon() const; + QPixmap disabledOnIcon() const; + void resetActiveOnIcon(); + void resetNormalOnIcon(); + void resetDisabledOnIcon(); + void setActiveOnIcon( const QPixmap& p ); + void setNormalOnIcon( const QPixmap& p ); + void setDisabledOnIcon( const QPixmap& p ); - void setActiveOffIcon( const QPixmap& p ) - { - m_iconSet.setPixmap( p, QIconSet::Small, QIconSet::Active, QIconSet::Off ); - updatePixmap(); - } - void setNormalOffIcon( const QPixmap& p ) - { - m_iconSet.setPixmap( p, QIconSet::Small, QIconSet::Normal, QIconSet::Off ); - updatePixmap(); - } - void setDisabledOffIcon( const QPixmap& p ) - { - m_iconSet.setPixmap( p, QIconSet::Small, QIconSet::Disabled, QIconSet::Off ); - updatePixmap(); - } + QPixmap activeOffIcon() const; + QPixmap normalOffIcon() const; + QPixmap disabledOffIcon() const; + void resetActiveOffIcon(); + void resetNormalOffIcon(); + void resetDisabledOffIcon(); + void setActiveOffIcon( const QPixmap& p ); + void setNormalOffIcon( const QPixmap& p ); + void setDisabledOffIcon( const QPixmap& p ); protected: - void mousePressEvent( QMouseEvent * e ) { - QPushButton::mousePressEvent( e ); - updatePixmap(); - } - - void mouseReleaseEvent( QMouseEvent * e ) { - QPushButton::mouseReleaseEvent( e ); - updatePixmap(); - } - - void mouseMoveEvent( QMouseEvent * e ) { - QPushButton::mouseMoveEvent( e ); - m_hover = rect().contains( e->pos() ); - setDown( m_hover ); - updatePixmap(); - } - - void enterEvent( QEvent* e ) { - m_hover = true; - QPushButton::enterEvent( e ); - updatePixmap(); - } - - void leaveEvent( QEvent* e ) { - m_hover = false; - QPushButton::leaveEvent( e ); - updatePixmap(); - } + void mousePressEvent( QMouseEvent * e ); + void mouseReleaseEvent( QMouseEvent * e ); + void mouseMoveEvent( QMouseEvent * e ); + void enterEvent( QEvent* e ); + void leaveEvent( QEvent* e ); signals: - void clicked_changed(); - void on_changed(); - void pressed_changed(); + void clicked_changed(); + void on_changed(); + void pressed_changed(); private slots: - void onPressed() - { - m_pressed = true; - emit pressed_changed(); - } - - void onReleased() - { - m_pressed = false; - emit pressed_changed(); - } + void onPressed(); + void onReleased(); private: - void updatePixmap() - { - if ( !m_iconSet.isNull() ) - { - if ( m_hover ) { - setPixmap( (isOn() || isDown()) ? activeOnIcon() : activeOffIcon() ); - } - else { - setPixmap( isOn() ? normalOnIcon() : normalOffIcon() ); - } - } - } + void updatePixmap(); - bool m_pressed; - bool m_hover; - QIconSet m_iconSet; + bool m_pressed; + bool m_hover; + QIconSet m_iconSet; }; } } --- NEW FILE: pushbutton.cpp --- /* -*- tab-width: 4; indent-tabs-mode: t -*- */ // jahwidgets - A widget library representation. // Copyright (C) 2006 VM Inc. // Released under the GPL. // For more information, see http://www.jahshaka.org. #include "pushbutton.h" // qt #include <qbitmap.h> namespace jahwidgets { namespace qt3 { Pushbutton::Pushbutton( QWidget* parent, const char* name ) : QPushButton( parent, name ), m_pressed( false ), m_hover( false ) { connect( this, SIGNAL( clicked() ), this, SIGNAL( clicked_changed() ) ); connect( this, SIGNAL( toggled( bool ) ), this, SIGNAL( on_changed() ) ); connect( this, SIGNAL( pressed() ), this, SLOT( onPressed() ) ); connect( this, SIGNAL( released() ), this, SLOT( onReleased() ) ); } bool Pushbutton::clicked() const { return true; } bool Pushbutton::pressed() const { return m_pressed; } QPixmap Pushbutton::activeOnIcon() const { return m_iconSet.pixmap( QIconSet::Small, QIconSet::Active, QIconSet::On ); } QPixmap Pushbutton::normalOnIcon() const { return m_iconSet.pixmap( QIconSet::Small, QIconSet::Normal, QIconSet::On ); } QPixmap Pushbutton::disabledOnIcon() const { return m_iconSet.pixmap( QIconSet::Small, QIconSet::Disabled, QIconSet::On ); } void Pushbutton::resetActiveOnIcon() { setActiveOnIcon( QPixmap() ); } void Pushbutton::resetNormalOnIcon() { setNormalOnIcon( QPixmap() ); } void Pushbutton::resetDisabledOnIcon() { setDisabledOnIcon( QPixmap() ); } void Pushbutton::setActiveOnIcon( const QPixmap& p ) { m_iconSet.setPixmap( p, QIconSet::Small, QIconSet::Active, QIconSet::On ); updatePixmap(); } void Pushbutton::setNormalOnIcon( const QPixmap& p ) { m_iconSet.setPixmap( p, QIconSet::Small, QIconSet::Normal, QIconSet::On ); updatePixmap(); } void Pushbutton::setDisabledOnIcon( const QPixmap& p ) { m_iconSet.setPixmap( p, QIconSet::Small, QIconSet::Disabled, QIconSet::On ); updatePixmap(); } QPixmap Pushbutton::activeOffIcon() const { return m_iconSet.pixmap( QIconSet::Small, QIconSet::Active, QIconSet::Off ); } QPixmap Pushbutton::normalOffIcon() const { return m_iconSet.pixmap( QIconSet::Small, QIconSet::Normal, QIconSet::Off ); } QPixmap Pushbutton::disabledOffIcon() const { return m_iconSet.pixmap( QIconSet::Small, QIconSet::Disabled, QIconSet::Off ); } void Pushbutton::resetActiveOffIcon() { setActiveOffIcon( QPixmap() ); } void Pushbutton::resetNormalOffIcon() { setNormalOffIcon( QPixmap() ); } void Pushbutton::resetDisabledOffIcon() { setDisabledOffIcon( QPixmap() ); } void Pushbutton::setActiveOffIcon( const QPixmap& p ) { m_iconSet.setPixmap( p, QIconSet::Small, QIconSet::Active, QIconSet::Off ); updatePixmap(); } void Pushbutton::setNormalOffIcon( const QPixmap& p ) { m_iconSet.setPixmap( p, QIconSet::Small, QIconSet::Normal, QIconSet::Off ); updatePixmap(); } void Pushbutton::setDisabledOffIcon( const QPixmap& p ) { m_iconSet.setPixmap( p, QIconSet::Small, QIconSet::Disabled, QIconSet::Off ); updatePixmap(); } void Pushbutton::mousePressEvent( QMouseEvent * e ) { QPushButton::mousePressEvent( e ); updatePixmap(); } void Pushbutton::mouseReleaseEvent( QMouseEvent * e ) { QPushButton::mouseReleaseEvent( e ); updatePixmap(); } void Pushbutton::mouseMoveEvent( QMouseEvent * e ) { QPushButton::mouseMoveEvent( e ); m_hover = rect().contains( e->pos() ); setDown( m_hover ); updatePixmap(); } void Pushbutton::enterEvent( QEvent* e ) { m_hover = true; QPushButton::enterEvent( e ); updatePixmap(); } void Pushbutton::leaveEvent( QEvent* e ) { m_hover = false; QPushButton::leaveEvent( e ); updatePixmap(); } void Pushbutton::onPressed() { m_pressed = true; emit pressed_changed(); } void Pushbutton::onReleased() { m_pressed = false; emit pressed_changed(); } void Pushbutton::updatePixmap() { if ( !m_iconSet.isNull() ) { if ( m_hover ) { setPixmap( (isOn() || isDown()) ? activeOnIcon() : activeOffIcon() ); } else { setPixmap( isOn() ? normalOnIcon() : normalOffIcon() ); } } } } } |