• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdepim API Reference
  • KDE Home
  • Contact Us
 

kalarm/lib

  • sources
  • kde-4.12
  • kdepim
  • kalarm
  • lib
spinbox2.h
Go to the documentation of this file.
1 /*
2  * spinbox2.h - spin box with extra pair of spin buttons
3  * Program: kalarm
4  * Copyright © 2001-2008 by David Jarvie <djarvie@kde.org>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License along
17  * with this program; if not, write to the Free Software Foundation, Inc.,
18  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19  */
20 
21 #ifndef SPINBOX2_H
22 #define SPINBOX2_H
23 
24 #include "spinbox.h"
25 
26 #include <QFrame>
27 class QShowEvent;
28 class QResizeEvent;
29 class SpinMirror;
30 class ExtraSpinBox;
31 
32 
57 class SpinBox2 : public QFrame
58 {
59  Q_OBJECT
60  public:
64  explicit SpinBox2(QWidget* parent = 0);
71  SpinBox2(int minValue, int maxValue, int pageStep = 1, QWidget* parent = 0);
75  virtual void setReadOnly(bool readOnly);
77  bool isReadOnly() const { return mSpinbox->isReadOnly(); }
79  void setSelectOnStep(bool sel) { mSpinbox->setSelectOnStep(sel); }
83  void setReverseWithLayout(bool reverse);
85  bool reverseButtons() const { return mRightToLeft && !mReverseWithLayout; }
86 
88  QString text() const { return mSpinbox->text(); }
90  QString prefix() const { return mSpinbox->prefix(); }
92  QString suffix() const { return mSpinbox->suffix(); }
94  void setPrefix(const QString& text) { mSpinbox->setPrefix(text); }
96  void setSuffix(const QString& text) { mSpinbox->setSuffix(text); }
98  QString cleanText() const { return mSpinbox->cleanText(); }
99 
103  void setSpecialValueText(const QString& text) { mSpinbox->setSpecialValueText(text); }
107  QString specialValueText() const { return mSpinbox->specialValueText(); }
108 
112  void setWrapping(bool on);
116  bool wrapping() const { return mSpinbox->wrapping(); }
117 
119  void setAlignment(Qt::Alignment a) { mSpinbox->setAlignment(a); }
121  void setButtonSymbols(QSpinBox::ButtonSymbols);
123  QSpinBox::ButtonSymbols buttonSymbols() const { return mSpinbox->buttonSymbols(); }
124 
126  virtual QValidator::State validate(QString&, int& /*pos*/) const { return QValidator::Acceptable; }
127 
128  virtual QSize sizeHint() const;
129  virtual QSize minimumSizeHint() const;
130 
132  int minimum() const { return mMinValue; }
134  int maximum() const { return mMaxValue; }
136  virtual void setMinimum(int val);
138  virtual void setMaximum(int val);
140  void setRange(int minValue, int maxValue) { setMinimum(minValue); setMaximum(maxValue); }
142  int value() const { return mSpinbox->value(); }
144  int bound(int val) const;
145 
147  QRect upRect() const { return mSpinbox->upRect(); }
149  QRect downRect() const { return mSpinbox->downRect(); }
151  QRect up2Rect() const;
153  QRect down2Rect() const;
154 
159  int singleStep() const { return mSingleStep; }
164  int singleShiftStep() const { return mSingleShiftStep; }
169  int pageStep() const { return mPageStep; }
174  int pageShiftStep() const { return mPageShiftStep; }
179  void setSingleStep(int step);
186  void setSteps(int line, int page);
193  void setShiftSteps(int line, int page);
194 
198  void addPage() { addValue(mPageStep); }
202  void subtractPage() { addValue(-mPageStep); }
206  void addSingle() { addValue(mSingleStep); }
210  void subtractSingle() { addValue(-mSingleStep); }
212  void addValue(int change) { mSpinbox->addValue(change); }
216  virtual void stepBy(int increment) { addValue(increment); }
217 
218  public slots:
220  void setValue(int val) { mSpinbox->setValue(val); }
224  virtual void pageUp() { addValue(mPageStep); }
228  virtual void pageDown() { addValue(-mPageStep); }
230  void selectAll() { mSpinbox->selectAll(); }
232  virtual void setEnabled(bool enabled);
233 
234  signals:
236  void valueChanged(int value);
238  void valueChanged(const QString& valueText);
239 
240  protected:
241  virtual QString textFromValue(int v) const { return mSpinbox->textFromVal(v); }
242  virtual int valueFromText(const QString& t) const { return mSpinbox->valFromText(t); }
243  virtual void paintEvent(QPaintEvent*);
244  virtual void showEvent(QShowEvent*);
245  virtual void styleChange(QStyle&);
246  virtual void getMetrics() const;
247 
248  mutable int wUpdown2; // width of second spin widget
249  mutable int wSpinboxHide; // width at left of 'mSpinbox' hidden by second spin widget
250  mutable QPoint mButtonPos; // position of buttons inside mirror widget
251 
252  protected slots:
253  virtual void valueChange();
254  virtual void stepPage(int);
255 
256  private slots:
257  void updateMirrorButtons();
258  void updateMirrorFrame();
259  void paintTimer();
260 
261  private:
262  void init();
263  void arrange();
264  void updateMirror();
265  bool eventFilter(QObject*, QEvent*);
266  void spinboxResized(QResizeEvent*);
267  void setUpdown2Size();
268  int whichButton(QObject* spinWidget, const QPoint&);
269  void setShiftStepping(bool on);
270 
271  // Visible spin box class.
272  // Declared here to allow use of mSpinBox in inline methods.
273  class MainSpinBox : public SpinBox
274  {
275  public:
276  MainSpinBox(SpinBox2* sb2, QWidget* parent)
277  : SpinBox(parent), owner(sb2) { }
278  MainSpinBox(int minValue, int maxValue, SpinBox2* sb2, QWidget* parent)
279  : SpinBox(minValue, maxValue, parent), owner(sb2) { }
280  virtual QString textFromValue(int v) const { return owner->textFromValue(v); }
281  virtual int valueFromText(const QString& t) const
282  { return owner->valueFromText(t); }
283  QString textFromVal(int v) const { return SpinBox::textFromValue(v); }
284  int valFromText(const QString& t) const
285  { return SpinBox::valueFromText(t); }
286  virtual int shiftStepAdjustment(int oldValue, int shiftStep);
287  virtual QValidator::State validate(QString& text, int& pos) const
288  { return owner->validate(text, pos); }
289  protected:
290  virtual void resizeEvent(QResizeEvent* e) { owner->spinboxResized(e); SpinBox::resizeEvent(e); }
291  private:
292  SpinBox2* owner; // owner SpinBox2
293  };
294 
295  enum { NO_BUTTON = -1, UP, DOWN, UP2, DOWN2 };
296 
297  static int mRightToLeft; // widgets are mirrored right to left
298  QFrame* mSpinboxFrame; // contains the main spin box
299  ExtraSpinBox* mUpdown2; // the extra pair of spin buttons
300  MainSpinBox* mSpinbox; // the visible spin box
301  SpinMirror* mSpinMirror; // image of the extra pair of spin buttons
302  int mMinValue;
303  int mMaxValue;
304  int mSingleStep; // right button increment
305  int mSingleShiftStep; // right button increment with shift pressed
306  int mPageStep; // left button increment
307  int mPageShiftStep; // left button increment with shift pressed
308  bool mReverseWithLayout; // reverse button positions if reverse layout (default = true)
309 
310  friend class MainSpinBox;
311 };
312 
313 #endif // SPINBOX2_H
314 
315 // vim: et sw=4:
SpinBox2::setValue
void setValue(int val)
Sets the current value to val.
Definition: spinbox2.h:220
SpinBox2::setEnabled
virtual void setEnabled(bool enabled)
Sets whether the widget is enabled.
Definition: spinbox2.cpp:129
SpinBox2::setSpecialValueText
void setSpecialValueText(const QString &text)
Sets the special-value text which, if non-null, is displayed instead of a numeric value when the curr...
Definition: spinbox2.h:103
SpinBox2::text
QString text() const
Returns the spin box's text, including any prefix() and suffix().
Definition: spinbox2.h:88
SpinBox2::addSingle
void addSingle()
Increments the current value by adding the unshifted step increment for the right-hand spin buttons...
Definition: spinbox2.h:206
SpinBox2::stepPage
virtual void stepPage(int)
Definition: spinbox2.cpp:449
SpinMirror
Definition: spinbox2_p.h:68
SpinBox2::down2Rect
QRect down2Rect() const
Returns the geometry of the left-hand "down" button.
Definition: spinbox2.cpp:148
SpinBox2::setSuffix
void setSuffix(const QString &text)
Sets the suffix which is prepended to the start of the displayed text.
Definition: spinbox2.h:96
SpinBox2::up2Rect
QRect up2Rect() const
Returns the geometry of the left-hand "up" button.
Definition: spinbox2.cpp:143
SpinBox2::setAlignment
void setAlignment(Qt::Alignment a)
Set the text alignment of the widget.
Definition: spinbox2.h:119
SpinBox2::wSpinboxHide
int wSpinboxHide
Definition: spinbox2.h:249
SpinBox2::getMetrics
virtual void getMetrics() const
Definition: spinbox2.cpp:399
QWidget
SpinBox2::SpinBox2
SpinBox2(QWidget *parent=0)
Constructor.
Definition: spinbox2.cpp:63
SpinBox2::pageStep
int pageStep() const
Returns the unshifted step increment for the left-hand spin buttons, i.e.
Definition: spinbox2.h:169
SpinBox2::cleanText
QString cleanText() const
Returns the spin box's text with no prefix(), suffix() or leading or trailing whitespace.
Definition: spinbox2.h:98
SpinBox2::suffix
QString suffix() const
Returns the suffix for the spin box's text.
Definition: spinbox2.h:92
SpinBox2::setSteps
void setSteps(int line, int page)
Sets the unshifted step increments for the two pairs of spin buttons, i.e.
Definition: spinbox2.cpp:162
QObject
SpinBox2::singleShiftStep
int singleShiftStep() const
Returns the shifted step increment for the right-hand spin buttons, i.e.
Definition: spinbox2.h:164
SpinBox2::subtractPage
void subtractPage()
Decrements the current value by subtracting the unshifted step increment for the left-hand spin butto...
Definition: spinbox2.h:202
SpinBox2::prefix
QString prefix() const
Returns the prefix for the spin box's text.
Definition: spinbox2.h:90
SpinBox2::setWrapping
void setWrapping(bool on)
Sets whether it is possible to step the value from the highest value to the lowest value and vice ver...
Definition: spinbox2.cpp:137
SpinBox2::textFromValue
virtual QString textFromValue(int v) const
Definition: spinbox2.h:241
SpinBox2::setReverseWithLayout
void setReverseWithLayout(bool reverse)
Sets whether the spin button pairs should be reversed for a right-to-left language.
Definition: spinbox2.cpp:119
SpinBox2::reverseButtons
bool reverseButtons() const
Returns whether the spin button pairs will be reversed for a right-to-left language.
Definition: spinbox2.h:85
SpinBox2::valueFromText
virtual int valueFromText(const QString &t) const
Definition: spinbox2.h:242
SpinBox2::setShiftSteps
void setShiftSteps(int line, int page)
Sets the shifted step increments for the two pairs of spin buttons, i.e.
Definition: spinbox2.cpp:178
SpinBox2::upRect
QRect upRect() const
Returns the geometry of the right-hand "up" button.
Definition: spinbox2.h:147
SpinBox2::subtractSingle
void subtractSingle()
Decrements the current value by subtracting the unshifted step increment for the right-hand spin butt...
Definition: spinbox2.h:210
SpinBox2::setButtonSymbols
void setButtonSymbols(QSpinBox::ButtonSymbols)
Sets the button symbols to use (arrows or plus/minus).
Definition: spinbox2.cpp:194
SpinBox2::pageDown
virtual void pageDown()
Decrements the current value by subtracting the unshifted step increment for the left-hand spin butto...
Definition: spinbox2.h:228
SpinBox2::valueChange
virtual void valueChange()
Definition: spinbox2.cpp:221
SpinBox2::valueChanged
void valueChanged(int value)
Signal which is emitted whenever the value of the spin box changes.
SpinBox2::setReadOnly
virtual void setReadOnly(bool readOnly)
Sets whether the spin box can be changed by the user.
Definition: spinbox2.cpp:109
SpinBox2::addPage
void addPage()
Increments the current value by adding the unshifted step increment for the left-hand spin buttons...
Definition: spinbox2.h:198
SpinBox2::stepBy
virtual void stepBy(int increment)
Increments the current value by adding the unshifted increment for the right-hand spin buttons...
Definition: spinbox2.h:216
SpinBox2::selectAll
void selectAll()
Selects all the text in the spin box's editor.
Definition: spinbox2.h:230
SpinBox2::addValue
void addValue(int change)
Adjusts the current value by adding change.
Definition: spinbox2.h:212
SpinBox2::minimumSizeHint
virtual QSize minimumSizeHint() const
Definition: spinbox2.cpp:250
SpinBox2::buttonSymbols
QSpinBox::ButtonSymbols buttonSymbols() const
Returns the button symbols currently in use (arrows or plus/minus).
Definition: spinbox2.h:123
SpinBox2::pageUp
virtual void pageUp()
Increments the current value by adding the unshifted step increment for the left-hand spin buttons...
Definition: spinbox2.h:224
SpinBox2::wrapping
bool wrapping() const
Returns whether it is possible to step the value from the highest value to the lowest value and vice ...
Definition: spinbox2.h:116
SpinBox2::singleStep
int singleStep() const
Returns the unshifted step increment for the right-hand spin buttons, i.e.
Definition: spinbox2.h:159
SpinBox2::value
int value() const
Returns the current value of the spin box.
Definition: spinbox2.h:142
SpinBox2
Spin box with a pair of spin buttons on either side.
Definition: spinbox2.h:57
SpinBox
Spin box with accelerated shift key stepping and read-only option.
Definition: spinbox.h:44
SpinBox2::setMinimum
virtual void setMinimum(int val)
Sets the minimum value of the spin box.
Definition: spinbox2.cpp:207
SpinBox2::setRange
void setRange(int minValue, int maxValue)
Sets the minimum and maximum values of the spin box.
Definition: spinbox2.h:140
SpinBox2::bound
int bound(int val) const
Returns the specified value clamped to the range of the spin box.
Definition: spinbox2.cpp:202
SpinBox2::setSelectOnStep
void setSelectOnStep(bool sel)
Sets whether the spin box value text should be selected when its value is stepped.
Definition: spinbox2.h:79
SpinBox2::pageShiftStep
int pageShiftStep() const
Returns the shifted step increment for the left-hand spin buttons, i.e.
Definition: spinbox2.h:174
SpinBox2::downRect
QRect downRect() const
Returns the geometry of the right-hand "down" button.
Definition: spinbox2.h:149
SpinBox2::styleChange
virtual void styleChange(QStyle &)
Definition: spinbox2.cpp:258
SpinBox2::MainSpinBox
friend class MainSpinBox
Definition: spinbox2.h:310
SpinBox2::showEvent
virtual void showEvent(QShowEvent *)
Definition: spinbox2.cpp:235
SpinBox2::setPrefix
void setPrefix(const QString &text)
Sets the prefix which is prepended to the start of the displayed text.
Definition: spinbox2.h:94
SpinBox2::paintEvent
virtual void paintEvent(QPaintEvent *)
Definition: spinbox2.cpp:265
SpinBox2::maximum
int maximum() const
Returns the maximum value of the spin box.
Definition: spinbox2.h:134
SpinBox2::sizeHint
virtual QSize sizeHint() const
Definition: spinbox2.cpp:242
SpinBox2::setSingleStep
void setSingleStep(int step)
Sets the unshifted step increment for the right-hand spin buttons, i.e.
Definition: spinbox2.cpp:153
SpinBox2::specialValueText
QString specialValueText() const
Returns the special-value text which, if non-null, is displayed instead of a numeric value when the c...
Definition: spinbox2.h:107
SpinBox2::validate
virtual QValidator::State validate(QString &, int &) const
Determine whether the current input is valid.
Definition: spinbox2.h:126
SpinBox2::isReadOnly
bool isReadOnly() const
Returns true if the widget is read only.
Definition: spinbox2.h:77
SpinBox2::setMaximum
virtual void setMaximum(int val)
Sets the maximum value of the spin box.
Definition: spinbox2.cpp:214
SpinBox2::mButtonPos
QPoint mButtonPos
Definition: spinbox2.h:250
QFrame
ExtraSpinBox
Definition: spinbox2_p.h:39
spinbox.h
SpinBox2::minimum
int minimum() const
Returns the minimum value of the spin box.
Definition: spinbox2.h:132
SpinBox2::wUpdown2
int wUpdown2
Definition: spinbox2.h:248
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:59:20 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kalarm/lib

Skip menu "kalarm/lib"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members

kdepim API Reference

Skip menu "kdepim API Reference"
  • akonadi_next
  • akregator
  • blogilo
  • calendarsupport
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt2
  • kjots
  • kleopatra
  • kmail
  • knode
  • knotes
  • kontact
  • korgac
  • korganizer
  • ktimetracker
  • libkdepim
  • libkleo
  • libkpgp
  • mailcommon
  • messagelist
  • messageviewer

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal