#include <q3rangecontrol.h>
Inheritance diagram for Q3SpinWidget:


Definition at line 111 of file q3rangecontrol.h.
Public Types | |
| enum | ButtonSymbols |
Public Slots | |
| void | stepUp () |
| void | stepDown () |
Signals | |
| void | stepUpPressed () |
| void | stepDownPressed () |
Public Member Functions | |
| Q3SpinWidget (QWidget *parent=0, const char *name=0) | |
| ~Q3SpinWidget () | |
| void | setEditWidget (QWidget *widget) |
| QWidget * | editWidget () |
| QRect | upRect () const |
| QRect | downRect () const |
| void | setUpEnabled (bool on) |
| void | setDownEnabled (bool on) |
| bool | isUpEnabled () const |
| bool | isDownEnabled () const |
| virtual void | setButtonSymbols (ButtonSymbols bs) |
| ButtonSymbols | buttonSymbols () const |
| void | arrange () |
Protected Member Functions | |
| void | mousePressEvent (QMouseEvent *e) |
| void | resizeEvent (QResizeEvent *ev) |
| void | mouseReleaseEvent (QMouseEvent *e) |
| void | mouseMoveEvent (QMouseEvent *e) |
| void | wheelEvent (QWheelEvent *) |
| void | changeEvent (QEvent *) |
| void | paintEvent (QPaintEvent *) |
Private Slots | |
| void | timerDone () |
| void | timerDoneEx () |
Private Member Functions | |
| void | updateDisplay () |
Private Attributes | |
| Q3SpinWidgetPrivate * | d |
| Q3SpinWidget::Q3SpinWidget | ( | QWidget * | parent = 0, |
|
| const char * | name = 0 | |||
| ) |
Definition at line 73 of file q3spinwidget.cpp.
References arrange(), Q3SpinWidgetPrivate::auRepTimer, QObject::connect(), d, QWidget::setFocusPolicy(), SIGNAL, SLOT, Qt::StrongFocus, timerDone(), and updateDisplay().
00074 : QWidget(parent, name) 00075 { 00076 d = new Q3SpinWidgetPrivate(); 00077 connect(&d->auRepTimer, SIGNAL(timeout()), this, SLOT(timerDone())); 00078 setFocusPolicy(Qt::StrongFocus); 00079 00080 arrange(); 00081 updateDisplay(); 00082 }
Here is the call graph for this function:

| Q3SpinWidget::~Q3SpinWidget | ( | ) |
Destroys the object and frees any allocated resources.
Definition at line 89 of file q3spinwidget.cpp.
References d.
00090 { 00091 delete d; 00092 }
| void Q3SpinWidget::setEditWidget | ( | QWidget * | w | ) |
Sets the editing widget to w.
Definition at line 103 of file q3spinwidget.cpp.
References arrange(), d, Q3SpinWidgetPrivate::ed, QWidget::setFocusProxy(), updateDisplay(), and w.
Referenced by Q3DateEdit::init(), and Q3TimeEdit::init().
00104 { 00105 if (w) { 00106 if (w->parentWidget() != this) 00107 w->setParent(this); 00108 setFocusProxy(w); 00109 } 00110 d->ed = w; 00111 arrange(); 00112 updateDisplay(); 00113 }
Here is the call graph for this function:

| QWidget * Q3SpinWidget::editWidget | ( | ) |
| QRect Q3SpinWidget::upRect | ( | ) | const |
Definition at line 360 of file q3spinwidget.cpp.
References d, and Q3SpinWidgetPrivate::up.
Referenced by Q3TimeEdit::sizeHint(), and Q3DateEdit::sizeHint().
| QRect Q3SpinWidget::downRect | ( | ) | const |
| void Q3SpinWidget::setUpEnabled | ( | bool | on | ) |
Sets up-enabled to on.
Definition at line 398 of file q3spinwidget.cpp.
References d, updateDisplay(), and Q3SpinWidgetPrivate::upEnabled.
Referenced by Q3DateEdit::updateButtons(), and Q3TimeEdit::updateButtons().
00399 { 00400 if ((bool)d->upEnabled != on) { 00401 d->upEnabled = on; 00402 updateDisplay(); 00403 } 00404 }
Here is the call graph for this function:

| void Q3SpinWidget::setDownEnabled | ( | bool | on | ) |
Sets down-enabled to on.
Definition at line 418 of file q3spinwidget.cpp.
References d, Q3SpinWidgetPrivate::downEnabled, and updateDisplay().
Referenced by Q3DateEdit::updateButtons(), and Q3TimeEdit::updateButtons().
00419 { 00420 if ((bool)d->downEnabled != on) { 00421 d->downEnabled = on; 00422 updateDisplay(); 00423 } 00424 }
Here is the call graph for this function:

| bool Q3SpinWidget::isUpEnabled | ( | ) | const |
Definition at line 409 of file q3spinwidget.cpp.
References d, and Q3SpinWidgetPrivate::upEnabled.
Referenced by getStyleOption().
| bool Q3SpinWidget::isDownEnabled | ( | ) | const |
Definition at line 429 of file q3spinwidget.cpp.
References d, and Q3SpinWidgetPrivate::downEnabled.
Referenced by getStyleOption().
00430 { 00431 return d->downEnabled; 00432 }
| void Q3SpinWidget::setButtonSymbols | ( | ButtonSymbols | bs | ) | [virtual] |
Sets the button symbol to bs.
Definition at line 438 of file q3spinwidget.cpp.
References Q3SpinWidgetPrivate::bsyms, and d.
| Q3SpinWidget::ButtonSymbols Q3SpinWidget::buttonSymbols | ( | ) | const |
Definition at line 446 of file q3spinwidget.cpp.
References Q3SpinWidgetPrivate::bsyms, and d.
Referenced by getStyleOption().
| void Q3SpinWidget::arrange | ( | ) |
Definition at line 178 of file q3spinwidget.cpp.
References QStyle::CC_SpinBox, d, Q3SpinWidgetPrivate::down, Q3SpinWidgetPrivate::ed, getStyleOption(), QStyle::SC_SpinBoxDown, QStyle::SC_SpinBoxEditField, QStyle::SC_SpinBoxUp, QWidget::setGeometry(), QWidget::style(), QStyle::subControlRect(), and Q3SpinWidgetPrivate::up.
Referenced by changeEvent(), Q3SpinWidget(), resizeEvent(), and setEditWidget().
00179 { 00180 QStyleOptionSpinBox opt = getStyleOption(this); 00181 d->up = style()->subControlRect(QStyle::CC_SpinBox, &opt, QStyle::SC_SpinBoxUp, this); 00182 d->down = style()->subControlRect(QStyle::CC_SpinBox, &opt, QStyle::SC_SpinBoxDown, this); 00183 if (d->ed) { 00184 QRect r = style()->subControlRect(QStyle::CC_SpinBox, &opt, 00185 QStyle::SC_SpinBoxEditField, this); 00186 d->ed->setGeometry(r); 00187 } 00188 }
Here is the call graph for this function:

| void Q3SpinWidget::stepUpPressed | ( | ) | [signal] |
Referenced by stepUp().
| void Q3SpinWidget::stepDownPressed | ( | ) | [signal] |
Referenced by stepDown().
| void Q3SpinWidget::stepUp | ( | ) | [slot] |
Definition at line 194 of file q3spinwidget.cpp.
References emit, and stepUpPressed().
Referenced by mousePressEvent(), timerDoneEx(), and wheelEvent().
00195 { 00196 emit stepUpPressed(); 00197 }
| void Q3SpinWidget::stepDown | ( | ) | [slot] |
Definition at line 208 of file q3spinwidget.cpp.
References emit, and stepDownPressed().
Referenced by mousePressEvent(), timerDoneEx(), and wheelEvent().
00209 { 00210 emit stepDownPressed(); 00211 }
| void Q3SpinWidget::mousePressEvent | ( | QMouseEvent * | e | ) | [protected, virtual] |
Reimplemented from QWidget.
Definition at line 119 of file q3spinwidget.cpp.
References QMouseEvent::button(), Q3SpinWidgetPrivate::buttonDown, QRect::contains(), d, Q3SpinWidgetPrivate::down, Q3SpinWidgetPrivate::downEnabled, QEvent::ignore(), Qt::LeftButton, QMouseEvent::pos(), QWidget::repaint(), Q3SpinWidgetPrivate::startTimer(), stepDown(), stepUp(), Q3SpinWidgetPrivate::stopTimer(), Q3SpinWidgetPrivate::theButton, QRect::united(), Q3SpinWidgetPrivate::up, and Q3SpinWidgetPrivate::upEnabled.
00120 { 00121 if (e->button() != Qt::LeftButton) { 00122 d->stopTimer(); 00123 d->buttonDown = 0; 00124 d->theButton = 0; 00125 repaint(d->down.united(d->up)); 00126 return; 00127 } 00128 00129 uint oldButtonDown = d->buttonDown; 00130 00131 if (d->down.contains(e->pos()) && d->downEnabled) 00132 d->buttonDown = 1; 00133 else if (d->up.contains(e->pos()) && d->upEnabled) 00134 d->buttonDown = 2; 00135 else 00136 d->buttonDown = 0; 00137 00138 d->theButton = d->buttonDown; 00139 if (oldButtonDown != d->buttonDown) { 00140 if (!d->buttonDown) { 00141 repaint(d->down.united(d->up)); 00142 } else if (d->buttonDown & 1) { 00143 repaint(d->down); 00144 stepDown(); 00145 d->startTimer(false, 300); 00146 } else if (d->buttonDown & 2) { 00147 repaint(d->up); 00148 stepUp(); 00149 d->startTimer(true, 300); 00150 } 00151 } 00152 00153 if (!oldButtonDown && !d->buttonDown) 00154 e->ignore(); 00155 00156 }
Here is the call graph for this function:

| void Q3SpinWidget::resizeEvent | ( | QResizeEvent * | ev | ) | [protected, virtual] |
This event handler can be reimplemented in a subclass to receive widget resize events which are passed in the event parameter. When resizeEvent() is called, the widget already has its new geometry. The old size is accessible through QResizeEvent::oldSize().
The widget will be erased and receive a paint event immediately after processing the resize event. No drawing need be (or should be) done inside this handler.
Reimplemented from QWidget.
Definition at line 199 of file q3spinwidget.cpp.
References arrange().
00200 { 00201 arrange(); 00202 }
Here is the call graph for this function:

| void Q3SpinWidget::mouseReleaseEvent | ( | QMouseEvent * | e | ) | [protected, virtual] |
The event is passed in e.
Reimplemented from QWidget.
Definition at line 237 of file q3spinwidget.cpp.
References QMouseEvent::button(), Q3SpinWidgetPrivate::buttonDown, d, Q3SpinWidgetPrivate::down, QEvent::ignore(), Qt::LeftButton, QWidget::repaint(), Q3SpinWidgetPrivate::stopTimer(), Q3SpinWidgetPrivate::theButton, and Q3SpinWidgetPrivate::up.
00238 { 00239 if (e->button() != Qt::LeftButton) 00240 return; 00241 00242 uint oldButtonDown = d->theButton; 00243 d->theButton = 0; 00244 if (oldButtonDown != d->theButton) { 00245 if (oldButtonDown & 1) 00246 repaint(d->down); 00247 else if (oldButtonDown & 2) 00248 repaint(d->up); 00249 } 00250 d->stopTimer(); 00251 d->buttonDown = 0; 00252 00253 if (!oldButtonDown && !d->buttonDown) 00254 e->ignore(); 00255 }
Here is the call graph for this function:

| void Q3SpinWidget::mouseMoveEvent | ( | QMouseEvent * | e | ) | [protected, virtual] |
The event is passed in e.
Reimplemented from QWidget.
Definition at line 262 of file q3spinwidget.cpp.
References Q3SpinWidgetPrivate::buttonDown, QRect::contains(), d, Q3SpinWidgetPrivate::down, QEvent::ignore(), Qt::LeftButton, QMouseEvent::pos(), QWidget::repaint(), Q3SpinWidgetPrivate::startTimer(), Q3SpinWidgetPrivate::stopTimer(), Q3SpinWidgetPrivate::theButton, and Q3SpinWidgetPrivate::up.
00263 { 00264 if (!(e->state() & Qt::LeftButton)) 00265 return; 00266 00267 uint oldButtonDown = d->theButton; 00268 if (oldButtonDown & 1 && !d->down.contains(e->pos())) { 00269 d->stopTimer(); 00270 d->theButton = 0; 00271 repaint(d->down); 00272 } else if (oldButtonDown & 2 && !d->up.contains(e->pos())) { 00273 d->stopTimer(); 00274 d->theButton = 0; 00275 repaint(d->up); 00276 } else if (!oldButtonDown && d->up.contains(e->pos()) && d->buttonDown & 2) { 00277 d->startTimer(500); 00278 d->theButton = 2; 00279 repaint(d->up); 00280 } else if (!oldButtonDown && d->down.contains(e->pos()) && d->buttonDown & 1) { 00281 d->startTimer(500); 00282 d->theButton = 1; 00283 repaint(d->down); 00284 } 00285 00286 if (!oldButtonDown && !d->buttonDown) 00287 e->ignore(); 00288 }
Here is the call graph for this function:

| void Q3SpinWidget::wheelEvent | ( | QWheelEvent * | e | ) | [protected, virtual] |
The event is passed in e.
Reimplemented from QWidget.
Definition at line 295 of file q3spinwidget.cpp.
References QEvent::accept(), QWheelEvent::delta(), i, int, stepDown(), and stepUp().
Referenced by QDateTimeSpinWidget::wheelEvent().
00296 { 00297 e->accept(); 00298 static float offset = 0; 00299 static Q3SpinWidget* offset_owner = 0; 00300 if (offset_owner != this) { 00301 offset_owner = this; 00302 offset = 0; 00303 } 00304 offset += -e->delta()/120; 00305 if (QABS(offset) < 1) 00306 return; 00307 int ioff = int(offset); 00308 int i; 00309 for(i=0; i < QABS(ioff); i++) 00310 offset > 0 ? stepDown() : stepUp(); 00311 offset -= ioff; 00312 }
Here is the call graph for this function:

| void Q3SpinWidget::changeEvent | ( | QEvent * | ev | ) | [protected, virtual] |
The previous style is passed in ev.
Reimplemented from QWidget.
Definition at line 339 of file q3spinwidget.cpp.
References QEvent::ActivationChange, arrange(), Q3SpinWidgetPrivate::buttonDown, QWidget::changeEvent(), d, Q3SpinWidgetPrivate::downEnabled, QEvent::EnabledChange, QWidget::isActiveWindow(), QWidget::isEnabled(), Q3SpinWidgetPrivate::stopTimer(), QEvent::StyleChange, Q3SpinWidgetPrivate::theButton, QEvent::type(), updateDisplay(), and Q3SpinWidgetPrivate::upEnabled.
00340 { 00341 if(ev->type() == QEvent::StyleChange) { 00342 arrange(); 00343 } else if(ev->type() == QEvent::ActivationChange) { 00344 if (!isActiveWindow() && d->buttonDown) { //was active, but lost focus 00345 d->stopTimer(); 00346 d->buttonDown = 0; 00347 d->theButton = 0; 00348 } 00349 } else if(ev->type() == QEvent::EnabledChange) { 00350 d->upEnabled = isEnabled(); 00351 d->downEnabled = isEnabled(); 00352 updateDisplay(); 00353 } 00354 QWidget::changeEvent(ev); 00355 }
Here is the call graph for this function:

| void Q3SpinWidget::paintEvent | ( | QPaintEvent * | ) | [protected, virtual] |
This event handler can be reimplemented in a subclass to receive paint events which are passed in the event parameter.
A paint event is a request to repaint all or part of the widget. It can happen as a result of repaint() or update(), or because the widget was obscured and has now been uncovered, or for many other reasons.
Many widgets can simply repaint their entire surface when asked to, but some slow widgets need to optimize by painting only the requested region: QPaintEvent::region(). This speed optimization does not change the result, as painting is clipped to that region during event processing. QListView and QTableView do this, for example.
Qt also tries to speed up painting by merging multiple paint events into one. When update() is called several times or the window system sends several paint events, Qt merges these events into one event with a larger region (see QRegion::united()). repaint() does not permit this optimization, so we suggest using update() whenever possible.
When the paint event occurs, the update region has normally been erased, so that you're painting on the widget's background.
The background can be set using setBackgroundRole() and setPalette().
From Qt 4.0, QWidget automatically double-buffers its painting, so there's no need to write double-buffering code in paintEvent() to avoid flicker.
Note: Under X11 it is possible to toggle the global double buffering by calling qt_x11_set_global_double_buffer(). Example usage:
...
extern void qt_x11_set_global_double_buffer(bool);
qt_x11_set_global_double_buffer(false);
...
Reimplemented from QWidget.
Definition at line 318 of file q3spinwidget.cpp.
References QStyleOptionComplex::activeSubControls, QStyle::CC_SpinBox, d, QStyle::drawComplexControl(), getStyleOption(), p, QStyleOption::rect, QStyle::SC_All, QStyle::SC_None, QStyle::SC_SpinBoxDown, QStyle::SC_SpinBoxFrame, QStyle::SC_SpinBoxUp, QWidget::style(), QStyle::subControlRect(), QStyleOptionComplex::subControls, and Q3SpinWidgetPrivate::theButton.
00319 { 00320 QPainter p(this); 00321 QStyleOptionSpinBox opt = getStyleOption(this); 00322 00323 if (d->theButton & 1) 00324 opt.activeSubControls = QStyle::SC_SpinBoxDown; 00325 else if (d->theButton & 2) 00326 opt.activeSubControls = QStyle::SC_SpinBoxUp; 00327 else 00328 opt.activeSubControls = QStyle::SC_None; 00329 opt.rect = style()->subControlRect(QStyle::CC_SpinBox, &opt, QStyle::SC_SpinBoxFrame, this); 00330 opt.subControls = QStyle::SC_All; 00331 style()->drawComplexControl(QStyle::CC_SpinBox, &opt, &p, this); 00332 }
Here is the call graph for this function:

| void Q3SpinWidget::timerDone | ( | ) | [private, slot] |
Definition at line 214 of file q3spinwidget.cpp.
References QTimer::singleShot(), SLOT, and timerDoneEx().
Referenced by Q3SpinWidget().
00215 { 00216 // we use a double timer to make it possible for users to do 00217 // something with 0-timer on valueChanged. 00218 QTimer::singleShot(1, this, SLOT(timerDoneEx())); 00219 }
| void Q3SpinWidget::timerDoneEx | ( | ) | [private, slot] |
Definition at line 221 of file q3spinwidget.cpp.
References Q3SpinWidgetPrivate::buttonDown, d, Q3SpinWidgetPrivate::startTimer(), stepDown(), stepUp(), and Q3SpinWidgetPrivate::timerUp.
Referenced by timerDone().
00222 { 00223 if (!d->buttonDown) 00224 return; 00225 if (d->timerUp) 00226 stepUp(); 00227 else 00228 stepDown(); 00229 d->startTimer(100); 00230 }
| void Q3SpinWidget::updateDisplay | ( | ) | [private] |
Definition at line 376 of file q3spinwidget.cpp.
References Q3SpinWidgetPrivate::buttonDown, d, Q3SpinWidgetPrivate::downEnabled, QWidget::isEnabled(), QWidget::repaint(), Q3SpinWidgetPrivate::theButton, and Q3SpinWidgetPrivate::upEnabled.
Referenced by changeEvent(), Q3SpinWidget(), setDownEnabled(), setEditWidget(), and setUpEnabled().
00377 { 00378 if (!isEnabled()) { 00379 d->upEnabled = false; 00380 d->downEnabled = false; 00381 } 00382 if (d->theButton & 1 && (d->downEnabled) == 0) { 00383 d->theButton &= ~1; 00384 d->buttonDown &= ~1; 00385 } 00386 00387 if (d->theButton & 2 && (d->upEnabled) == 0) { 00388 d->theButton &= ~2; 00389 d->buttonDown &= ~2; 00390 } 00391 repaint(); 00392 }
Here is the call graph for this function:

Q3SpinWidgetPrivate* Q3SpinWidget::d [private] |
Definition at line 160 of file q3rangecontrol.h.
Referenced by arrange(), buttonSymbols(), changeEvent(), downRect(), editWidget(), isDownEnabled(), isUpEnabled(), mouseMoveEvent(), mousePressEvent(), mouseReleaseEvent(), paintEvent(), Q3SpinWidget(), setButtonSymbols(), setDownEnabled(), setEditWidget(), setUpEnabled(), timerDoneEx(), updateDisplay(), upRect(), and ~Q3SpinWidget().
1.5.1