spinbox2.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef SPINBOX2_H
00026 #define SPINBOX2_H
00027
00028 #include <qglobal.h>
00029 #if QT_VERSION >= 300
00030
00031 #include <qspinbox.h>
00032
00033 class SpinBox2;
00034
00035
00036 class SB2_SpinWidget : public QSpinBox
00037 {
00038 Q_OBJECT
00039 public:
00040 SB2_SpinWidget(QWidget* parent, const char* name = 0L) : QSpinBox(parent, name) { }
00041 SB2_SpinWidget(int minValue, int maxValue, int step, QWidget* parent, const char* name = 0L)
00042 : QSpinBox(minValue, maxValue, step, parent, name) { }
00043 public slots:
00044 virtual void stepUp() { QSpinBox::stepUp(); emit stepped(1); }
00045 virtual void stepDown() { QSpinBox::stepDown(); emit stepped(-1); }
00046 signals:
00047 void stepped(int);
00048 protected:
00049 virtual void valueChange();
00050 };
00051
00052
00053
00054
00055
00056
00057 class SpinBox2 : public QFrame
00058 {
00059 Q_OBJECT
00060 public:
00061 SpinBox2(QWidget* parent = 0L, const char* name = 0L);
00062 SpinBox2(int minValue, int maxValue, int step = 1, int step2 = 1,
00063 QWidget* parent = 0L, const char* name = 0L);
00064
00065 void setSelectOnStep(bool yes) { selectOnStep = yes; }
00066
00067 QString text() const { return spinbox->text(); }
00068 virtual QString prefix() const { return spinbox->prefix(); }
00069 virtual QString suffix() const { return spinbox->suffix(); }
00070 virtual QString cleanText() const { return spinbox->cleanText(); }
00071
00072 virtual void setSpecialValueText(const QString &text) { spinbox->setSpecialValueText(text); }
00073 QString specialValueText() const { return spinbox->specialValueText(); }
00074
00075 virtual void setWrapping(bool on) { spinbox->setWrapping(on); updown2->setWrapping(on); }
00076 bool wrapping() const { return spinbox->wrapping(); }
00077
00078 virtual void setButtonSymbols(QSpinBox::ButtonSymbols);
00079 QSpinBox::ButtonSymbols buttonSymbols() const { return spinbox->buttonSymbols(); }
00080
00081 virtual void setValidator(const QValidator* v) { spinbox->setValidator(v); }
00082 const QValidator* validator() const { return spinbox->validator(); }
00083
00084 virtual QSize sizeHint() const;
00085 virtual QSize minimumSizeHint() const;
00086
00087 int minValue() const { return spinbox->minValue(); }
00088 int maxValue() const { return spinbox->maxValue(); }
00089 void setMinValue(int val) { spinbox->setMinValue(val); updown2->setMinValue(val); }
00090 void setMaxValue(int val) { spinbox->setMaxValue(val); updown2->setMaxValue(val); }
00091 int lineStep() const { return spinbox->lineStep(); }
00092 void setLineStep(int step) { spinbox->setLineStep(step); }
00093 int value() const { return spinbox->value(); }
00094
00095 QRect upRect() const { return spinbox->upRect(); }
00096 QRect downRect() const { return spinbox->downRect(); }
00097 QRect upRect2() const { return updown2->upRect(); }
00098 QRect downRect2() const { return updown2->downRect(); }
00099
00100
00101 void addPage() { spinbox->addPage(); }
00102 void subtractPage() { spinbox->subtractPage(); }
00103 void addLine() { spinbox->addLine(); }
00104 void subtractLine() { spinbox->subtractLine(); }
00105
00106 void setRange(int minValue, int maxValue) { spinbox->setRange(minValue, maxValue); updown2->setRange(minValue, maxValue); }
00107
00108 int pageStep() const { return spinbox->pageStep(); }
00109 void setSteps(int line, int page){ spinbox->setSteps(line, page); updown2->setLineStep(page); }
00110 void setShiftSteps(int, int) { }
00111
00112 int bound(int b) const { return spinbox->bound(b); }
00113
00114 public slots:
00115 virtual void setValue(int val) { spinbox->setValue(val); }
00116 virtual void setPrefix(const QString& text) { spinbox->setPrefix(text); }
00117 virtual void setSuffix(const QString& text) { spinbox->setSuffix(text); }
00118 virtual void stepUp() { addVal(spinbox->lineStep()); }
00119 virtual void stepDown() { addVal(-spinbox->lineStep()); }
00120 virtual void pageUp() { addVal(spinbox->pageStep()); }
00121 virtual void pageDown() { addVal(-spinbox->pageStep()); }
00122 virtual void selectAll() { spinbox->selectAll(); }
00123
00124 signals:
00125 void valueChanged(int value);
00126 void valueChanged(const QString& valueText);
00127
00128 protected:
00129 virtual QString mapValueToText(int v) { return spinbox->mapValueToText(v); }
00130 virtual int mapTextToValue(bool* ok) { return spinbox->mapTextToValue(ok); }
00131 virtual void resizeEvent(QResizeEvent*) { arrange(); }
00132 virtual void showEvent(QShowEvent*);
00133 virtual void styleChange(QStyle&) { arrange(); }
00134
00135 protected slots:
00136 virtual void valueChange();
00137 virtual void stepped2(int);
00138
00139 private:
00140 void initSpinBox2();
00141 void addVal(int change);
00142 void arrange();
00143 void getMetrics() const;
00144
00145 class SB2_SpinBox : public QSpinBox
00146 {
00147 public:
00148 SB2_SpinBox(SpinBox2* sb2, QWidget* parent, const char* name = 0L) : QSpinBox(parent, name), spinBox2(sb2) { }
00149 SB2_SpinBox(int minValue, int maxValue, int step, SpinBox2* sb2, QWidget* parent, const char* name = 0L)
00150 : QSpinBox(minValue, maxValue, step, parent, name), spinBox2(sb2) { }
00151 virtual QString mapValueToText(int v) { return spinBox2->mapValueToText(v); }
00152 virtual int mapTextToValue(bool* ok) { return spinBox2->mapTextToValue(ok); }
00153 virtual void valueChange();
00154 private:
00155 SpinBox2* spinBox2;
00156 };
00157
00158 QFrame* updown2Frame;
00159 QFrame* spinboxFrame;
00160 SB2_SpinWidget* updown2;
00161 SB2_SpinBox* spinbox;
00162 mutable int wUpdown2;
00163 mutable int xUpdown2;
00164 mutable int xSpinbox;
00165 mutable int wGap;
00166 bool selectOnStep;
00167
00168 friend class SB2_SpinBox;
00169 friend class SB2_SpinWidget;
00170 };
00171
00172 #endif // QT_VERSION >= 300
00173 #endif // SPINBOX2_H
This file is part of the documentation for kdelibs Version 3.1.4.