spinbox.h
00001 /* 00002 * spinbox.h - spin box with shift-click step value and read-only option 00003 * Program: kalarm 00004 * Copyright © 2002-2006,2008 by David Jarvie <djarvie@kde.org> 00005 * 00006 * This program is free software; you can redistribute it and/or modify 00007 * it under the terms of the GNU General Public License as published by 00008 * the Free Software Foundation; either version 2 of the License, or 00009 * (at your option) any later version. 00010 * 00011 * This program is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU General Public License along 00017 * with this program; if not, write to the Free Software Foundation, Inc., 00018 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00019 */ 00020 00021 #ifndef SPINBOX_H 00022 #define SPINBOX_H 00023 00024 #include <tqspinbox.h> 00025 00026 00042 class SpinBox : public TQSpinBox 00043 { 00044 Q_OBJECT 00045 TQ_OBJECT 00046 public: 00051 explicit SpinBox(TQWidget* parent = 0, const char* name = 0); 00059 SpinBox(int minValue, int maxValue, int step = 1, TQWidget* parent = 0, const char* name = 0); 00061 bool isReadOnly() const { return mReadOnly; } 00065 virtual void setReadOnly(bool readOnly); 00067 bool selectOnStep() const { return mSelectOnStep; } 00069 void setSelectOnStep(bool sel) { mSelectOnStep = sel; } 00071 void addValue(int change) { addValue(change, false); } 00073 int minValue() const { return mMinValue; } 00075 int maxValue() const { return mMaxValue; } 00077 void setMinValue(int val); 00079 void setMaxValue(int val); 00081 void setRange(int minValue, int maxValue) { setMinValue(minValue); setMaxValue(maxValue); } 00083 int bound(int val) const; 00087 int lineStep() const { return mLineStep; } 00091 void setLineStep(int step); 00095 int lineShiftStep() const { return mLineShiftStep; } 00099 void setLineShiftStep(int step); 00100 public slots: 00102 virtual void stepUp(); 00104 virtual void stepDown(); 00105 signals: 00110 void stepped(int step); 00111 00112 protected: 00114 virtual void valueChange(); 00125 virtual int shiftStepAdjustment(int oldValue, int shiftStep); 00127 virtual bool eventFilter(TQObject*, TQEvent*); 00131 virtual void updateDisplay(); 00132 00133 private slots: 00134 void textEdited(); 00135 private: 00136 void init(); 00137 void addValue(int change, bool current); 00138 int whichButton(const TQPoint&); 00139 bool setShiftStepping(bool, int currentButton); 00140 00141 enum { NO_BUTTON, UP, DOWN }; 00142 00143 int mMinValue; 00144 int mMaxValue; 00145 int mLineStep; // step when spin arrows are pressed 00146 int mLineShiftStep; // step when spin arrows are pressed with shift key 00147 int mCurrentButton; // current spin widget button 00148 bool mShiftMouse; // true while left button is being held down with shift key 00149 bool mShiftMinBound; // true if a temporary minimum bound has been set during shift stepping 00150 bool mShiftMaxBound; // true if a temporary maximum bound has been set during shift stepping 00151 bool mSelectOnStep; // select the editor text whenever spin buttons are clicked (default) 00152 bool mReadOnly; // value cannot be changed 00153 bool mSuppressSignals; 00154 bool mEdited; // text field has been edited 00155 }; 00156 00157 #endif // SPINBOX_H