kalarm/lib
spinbox2.h00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef SPINBOX2_H
00022 #define SPINBOX2_H
00023
00024 #include <tqglobal.h>
00025 #include <tqlineedit.h>
00026
00027 class SpinMirror;
00028 class ExtraSpinBox;
00029 #include "spinbox.h"
00030
00031
00056 class SpinBox2 : public TQFrame
00057 {
00058 Q_OBJECT
00059 TQ_OBJECT
00060 public:
00065 explicit SpinBox2(TQWidget* parent = 0, const char* name = 0);
00074 SpinBox2(int minValue, int maxValue, int step = 1, int step2 = 1,
00075 TQWidget* parent = 0, const char* name = 0);
00079 virtual void setReadOnly(bool readOnly);
00081 bool isReadOnly() const { return mSpinbox->isReadOnly(); }
00083 void setSelectOnStep(bool sel) { mSpinbox->setSelectOnStep(sel); }
00087 void setReverseWithLayout(bool reverse);
00089 bool reverseButtons() const { return mReverseLayout && !mReverseWithLayout; }
00090
00092 TQString text() const { return mSpinbox->text(); }
00094 virtual TQString prefix() const { return mSpinbox->prefix(); }
00096 virtual TQString suffix() const { return mSpinbox->suffix(); }
00098 virtual TQString cleanText() const { return mSpinbox->cleanText(); }
00099
00103 virtual void setSpecialValueText(const TQString& text) { mSpinbox->setSpecialValueText(text); }
00107 TQString specialValueText() const { return mSpinbox->specialValueText(); }
00108
00112 virtual void setWrapping(bool on);
00116 bool wrapping() const { return mSpinbox->wrapping(); }
00117
00119 void setAlignment(int a) { mSpinbox->setAlignment(a); }
00121 virtual void setButtonSymbols(TQSpinBox::ButtonSymbols);
00123 TQSpinBox::ButtonSymbols buttonSymbols() const { return mSpinbox->buttonSymbols(); }
00124
00128 virtual void setValidator(const TQValidator* v) { mSpinbox->setValidator(v); }
00132 const TQValidator* validator() const { return mSpinbox->validator(); }
00133
00134 virtual TQSize sizeHint() const;
00135 virtual TQSize minimumSizeHint() const;
00136
00138 int minValue() const { return mMinValue; }
00140 int maxValue() const { return mMaxValue; }
00142 virtual void setMinValue(int val);
00144 virtual void setMaxValue(int val);
00146 void setRange(int minValue, int maxValue) { setMinValue(minValue); setMaxValue(maxValue); }
00148 int value() const { return mSpinbox->value(); }
00150 int bound(int val) const;
00151
00153 TQRect upRect() const { return mSpinbox->upRect(); }
00155 TQRect downRect() const { return mSpinbox->downRect(); }
00157 TQRect up2Rect() const;
00159 TQRect down2Rect() const;
00160
00165 int lineStep() const { return mLineStep; }
00170 int lineShiftStep() const { return mLineShiftStep; }
00175 int pageStep() const { return mPageStep; }
00180 int pageShiftStep() const { return mPageShiftStep; }
00185 void setLineStep(int step);
00192 void setSteps(int line, int page);
00199 void setShiftSteps(int line, int page);
00200
00204 void addPage() { addValue(mPageStep); }
00208 void subtractPage() { addValue(-mPageStep); }
00212 void addLine() { addValue(mLineStep); }
00216 void subtractLine() { addValue(-mLineStep); }
00218 void addValue(int change) { mSpinbox->addValue(change); }
00219
00220 public slots:
00222 virtual void setValue(int val) { mSpinbox->setValue(val); }
00224 virtual void setPrefix(const TQString& text) { mSpinbox->setPrefix(text); }
00226 virtual void setSuffix(const TQString& text) { mSpinbox->setSuffix(text); }
00230 virtual void stepUp() { addValue(mLineStep); }
00234 virtual void stepDown() { addValue(-mLineStep); }
00238 virtual void pageUp() { addValue(mPageStep); }
00242 virtual void pageDown() { addValue(-mPageStep); }
00244 virtual void selectAll() { mSpinbox->selectAll(); }
00246 virtual void setEnabled(bool enabled);
00247
00248 signals:
00250 void valueChanged(int value);
00252 void valueChanged(const TQString& valueText);
00253
00254 protected:
00255 virtual TQString mapValueToText(int v) { return mSpinbox->mapValToText(v); }
00256 virtual int mapTextToValue(bool* ok) { return mSpinbox->mapTextToVal(ok); }
00257 virtual void resizeEvent(TQResizeEvent*) { arrange(); }
00258 virtual void showEvent(TQShowEvent*);
00259 virtual void styleChange(TQStyle&);
00260 virtual void getMetrics() const;
00261
00262 mutable int wUpdown2;
00263 mutable int xUpdown2;
00264 mutable int xSpinbox;
00265 mutable int wGap;
00266
00267 protected slots:
00268 virtual void valueChange();
00269 virtual void stepPage(int);
00270
00271 private slots:
00272 void updateMirror();
00273
00274 private:
00275 void init();
00276 void arrange();
00277 int whichButton(TQObject* spinWidget, const TQPoint&);
00278 void setShiftStepping(bool on);
00279
00280
00281
00282 class MainSpinBox : public SpinBox
00283 {
00284 public:
00285 MainSpinBox(SpinBox2* sb2, TQWidget* parent, const char* name = 0)
00286 : SpinBox(parent, name), owner(sb2) { }
00287 MainSpinBox(int minValue, int maxValue, int step, SpinBox2* sb2, TQWidget* parent, const char* name = 0)
00288 : SpinBox(minValue, maxValue, step, parent, name), owner(sb2) { }
00289 void setAlignment(int a) { editor()->setAlignment(a); }
00290 virtual TQString mapValueToText(int v) { return owner->mapValueToText(v); }
00291 virtual int mapTextToValue(bool* ok) { return owner->mapTextToValue(ok); }
00292 TQString mapValToText(int v) { return SpinBox::mapValueToText(v); }
00293 int mapTextToVal(bool* ok) { return SpinBox::mapTextToValue(ok); }
00294 virtual int shiftStepAdjustment(int oldValue, int shiftStep);
00295 private:
00296 SpinBox2* owner;
00297 };
00298
00299 enum { NO_BUTTON = -1, UP, DOWN, UP2, DOWN2 };
00300
00301 static int mReverseLayout;
00302 TQFrame* mUpdown2Frame;
00303 TQFrame* mSpinboxFrame;
00304 ExtraSpinBox* mUpdown2;
00305 MainSpinBox* mSpinbox;
00306 SpinMirror* mSpinMirror;
00307 int mMinValue;
00308 int mMaxValue;
00309 int mLineStep;
00310 int mLineShiftStep;
00311 int mPageStep;
00312 int mPageShiftStep;
00313 bool mReverseWithLayout;
00314
00315 friend class MainSpinBox;
00316 };
00317
00318 #endif // SPINBOX2_H
|