• 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
spinbox.h
Go to the documentation of this file.
1 /*
2  * spinbox.h - spin box with shift-click step value and read-only option
3  * Program: kalarm
4  * Copyright © 2002-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 SPINBOX_H
22 #define SPINBOX_H
23 
24 #include <QSpinBox>
25 class QEvent;
26 class QStyleOptionSpinBox;
27 
28 
44 class SpinBox : public QSpinBox
45 {
46  Q_OBJECT
47  public:
51  explicit SpinBox(QWidget* parent = 0);
57  SpinBox(int minValue, int maxValue, QWidget* parent = 0);
59  bool isReadOnly() const { return mReadOnly; }
63  virtual void setReadOnly(bool readOnly);
65  bool selectOnStep() const { return mSelectOnStep; }
67  void setSelectOnStep(bool sel) { mSelectOnStep = sel; }
69  void addValue(int change) { addValue(change, false); }
71  int minimum() const { return mMinValue; }
73  int maximum() const { return mMaxValue; }
75  void setMinimum(int val);
77  void setMaximum(int val);
79  void setRange(int minValue, int maxValue) { setMinimum(minValue); setMaximum(maxValue); }
81  int bound(int val) const;
85  virtual void stepBy(int steps);
89  int singleStep() const { return mLineStep; }
93  void setSingleStep(int step);
97  int singleShiftStep() const { return mLineShiftStep; }
101  void setSingleShiftStep(int step);
103  QRect upRect() const;
105  QRect downRect() const;
107  QRect upDownRect() const;
109  void setUpDownOnly(bool only) { mUpDownOnly = only; }
111  void initStyleOption(QStyleOptionSpinBox&) const;
112 
113  signals:
118  void stepped(int step);
119 
120  protected:
131  virtual int shiftStepAdjustment(int oldValue, int shiftStep);
133  virtual bool eventFilter(QObject*, QEvent*);
134 
135  virtual void paintEvent(QPaintEvent*);
136  virtual void focusOutEvent(QFocusEvent*);
137  virtual void mousePressEvent(QMouseEvent*);
138  virtual void mouseDoubleClickEvent(QMouseEvent*);
139  virtual void mouseReleaseEvent(QMouseEvent*);
140  virtual void mouseMoveEvent(QMouseEvent*);
141  virtual void keyPressEvent(QKeyEvent*);
142  virtual void keyReleaseEvent(QKeyEvent*);
143  virtual void wheelEvent(QWheelEvent*);
144 
145  private slots:
146  void textEdited();
147  void valueChange();
148  private:
149  void init();
150  void addValue(int change, bool current);
151  int whichButton(const QPoint&);
152  bool setShiftStepping(bool, int currentButton);
153  bool clickEvent(QMouseEvent*);
154  bool keyEvent(QKeyEvent*);
155 
156  enum { NO_BUTTON, UP, DOWN };
157 
158  int mMinValue;
159  int mMaxValue;
160  int mLineStep; // step when spin arrows are pressed
161  int mLineShiftStep; // step when spin arrows are pressed with shift key
162  int mCurrentButton; // current spin widget button
163  bool mShiftMouse; // true while left button is being held down with shift key
164  bool mShiftMinBound; // true if a temporary minimum bound has been set during shift stepping
165  bool mShiftMaxBound; // true if a temporary maximum bound has been set during shift stepping
166  bool mSelectOnStep; // select the editor text whenever spin buttons are clicked (default)
167  bool mUpDownOnly; // true if edit field isn't displayed
168  bool mReadOnly; // value cannot be changed
169  bool mSuppressSignals;
170  bool mEdited; // text field has been edited
171 };
172 
173 #endif // SPINBOX_H
174 
175 // vim: et sw=4:
SpinBox::setUpDownOnly
void setUpDownOnly(bool only)
Sets whether the edit field is displayed.
Definition: spinbox.h:109
SpinBox::singleStep
int singleStep() const
Returns the unshifted step increment, i.e.
Definition: spinbox.h:89
SpinBox::upRect
QRect upRect() const
Returns the rectangle containing the up arrow.
Definition: spinbox.cpp:494
SpinBox::downRect
QRect downRect() const
Returns the rectangle containing the down arrow.
Definition: spinbox.cpp:501
SpinBox::initStyleOption
void initStyleOption(QStyleOptionSpinBox &) const
Initialise a QStyleOptionSpinBox with this instance's details.
Definition: spinbox.cpp:529
SpinBox::setSingleStep
void setSingleStep(int step)
Sets the unshifted step increment, i.e.
Definition: spinbox.cpp:106
QWidget
SpinBox::setSelectOnStep
void setSelectOnStep(bool sel)
Sets whether the spin box value text should be selected when its value is stepped.
Definition: spinbox.h:67
SpinBox::upDownRect
QRect upDownRect() const
Returns the rectangle containing the up and down arrows.
Definition: spinbox.cpp:508
SpinBox::paintEvent
virtual void paintEvent(QPaintEvent *)
Definition: spinbox.cpp:516
SpinBox::focusOutEvent
virtual void focusOutEvent(QFocusEvent *)
Definition: spinbox.cpp:239
SpinBox::keyPressEvent
virtual void keyPressEvent(QKeyEvent *)
Definition: spinbox.cpp:328
SpinBox::maximum
int maximum() const
Returns the maximum value of the spin box.
Definition: spinbox.h:73
QObject
SpinBox::setMinimum
void setMinimum(int val)
Sets the minimum value of the spin box.
Definition: spinbox.cpp:92
SpinBox::mousePressEvent
virtual void mousePressEvent(QMouseEvent *)
Definition: spinbox.cpp:249
SpinBox::mouseReleaseEvent
virtual void mouseReleaseEvent(QMouseEvent *)
Definition: spinbox.cpp:297
SpinBox::mouseDoubleClickEvent
virtual void mouseDoubleClickEvent(QMouseEvent *)
Definition: spinbox.cpp:255
SpinBox::eventFilter
virtual bool eventFilter(QObject *, QEvent *)
Receives events destined for the spin widget or for the edit field.
Definition: spinbox.cpp:189
SpinBox::setRange
void setRange(int minValue, int maxValue)
Sets the minimum and maximum values of the spin box.
Definition: spinbox.h:79
SpinBox::isReadOnly
bool isReadOnly() const
Returns true if the widget is read only.
Definition: spinbox.h:59
SpinBox::minimum
int minimum() const
Returns the minimum value of the spin box.
Definition: spinbox.h:71
SpinBox::SpinBox
SpinBox(QWidget *parent=0)
Constructor.
Definition: spinbox.cpp:36
SpinBox::keyReleaseEvent
virtual void keyReleaseEvent(QKeyEvent *)
Definition: spinbox.cpp:334
SpinBox::stepped
void stepped(int step)
Signal emitted when the spin box's value is stepped (by the shifted or unshifted increment).
SpinBox::shiftStepAdjustment
virtual int shiftStepAdjustment(int oldValue, int shiftStep)
Returns the initial adjustment to the value for a shift step up or down.
Definition: spinbox.cpp:459
SpinBox::addValue
void addValue(int change)
Adds a value to the current value of the spin box.
Definition: spinbox.h:69
SpinBox
Spin box with accelerated shift key stepping and read-only option.
Definition: spinbox.h:44
SpinBox::setMaximum
void setMaximum(int val)
Sets the maximum value of the spin box.
Definition: spinbox.cpp:99
SpinBox::stepBy
virtual void stepBy(int steps)
Called whenever the user triggers a step, to adjust the value of the spin box by the unshifted increm...
Definition: spinbox.cpp:120
SpinBox::wheelEvent
virtual void wheelEvent(QWheelEvent *)
Definition: spinbox.cpp:284
SpinBox::setSingleShiftStep
void setSingleShiftStep(int step)
Sets the shifted step increment, i.e.
Definition: spinbox.cpp:113
SpinBox::selectOnStep
bool selectOnStep() const
Returns whether the spin box value text is selected when its value is stepped.
Definition: spinbox.h:65
SpinBox::singleShiftStep
int singleShiftStep() const
Returns the shifted step increment, i.e.
Definition: spinbox.h:97
SpinBox::bound
int bound(int val) const
Returns the specified value clamped to the range of the spin box.
Definition: spinbox.cpp:87
SpinBox::mouseMoveEvent
virtual void mouseMoveEvent(QMouseEvent *)
Definition: spinbox.cpp:304
QSpinBox
SpinBox::setReadOnly
virtual void setReadOnly(bool readOnly)
Sets whether the spin box can be changed by the user.
Definition: spinbox.cpp:76
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