1 // File: QtxIntSpinBox.cxx
2 // Author: Sergey TELKOV
4 #include "QtxIntSpinBox.h"
7 #include <qapplication.h>
9 QtxIntSpinBox::QtxIntSpinBox( QWidget* parent, const char* name )
10 : QSpinBox( parent, name ),
14 connect( editor(), SIGNAL( textChanged( const QString& ) ), this, SLOT( onTextChanged( const QString& ) ) );
17 QtxIntSpinBox::QtxIntSpinBox( int min, int max, int step, QWidget* parent, const char* name )
18 : QSpinBox( min, max, step, parent, name ),
22 connect( editor(), SIGNAL( textChanged( const QString& ) ), this, SLOT( onTextChanged( const QString& ) ) );
25 QtxIntSpinBox::~QtxIntSpinBox()
29 bool QtxIntSpinBox::isCleared() const
34 void QtxIntSpinBox::setCleared( const bool on )
36 if ( myCleared == on )
43 void QtxIntSpinBox::setValue( int value )
47 QSpinBox::setValue( value );
50 bool QtxIntSpinBox::eventFilter( QObject* o, QEvent* e )
52 if ( !myCleared || o != editor() || !editor()->text().stripWhiteSpace().isEmpty() )
53 return QSpinBox::eventFilter( o, e );
55 if ( e->type() == QEvent::FocusOut || e->type() == QEvent::Leave || e->type() == QEvent::Hide )
58 if ( e->type() == QEvent::KeyPress &&
59 ( ((QKeyEvent*)e)->key() == Key_Tab || ((QKeyEvent*)e)->key() == Key_BackTab ) )
61 QApplication::sendEvent( this, e );
65 return QSpinBox::eventFilter( o, e );
68 void QtxIntSpinBox::interpretText()
72 QSpinBox::interpretText();
75 void QtxIntSpinBox::updateDisplay()
80 bool block = myBlocked;
83 QSpinBox::updateDisplay();
87 else if ( editor()->hasFocus() )
89 if ( editor()->text() == specialValueText() )
90 editor()->selectAll();
92 editor()->setSelection( prefix().length(), editor()->text().length() - prefix().length() - suffix().length() );
98 void QtxIntSpinBox::leaveEvent( QEvent* e )
101 QSpinBox::leaveEvent( e );
104 void QtxIntSpinBox::wheelEvent( QWheelEvent* e )
109 QSpinBox::wheelEvent( e );
113 void QtxIntSpinBox::onTextChanged( const QString& )