Choreonoid  1.8
ScrollBar.h
Go to the documentation of this file.
1 
5 #ifndef CNOID_BASE_SCROLLBAR_H
6 #define CNOID_BASE_SCROLLBAR_H
7 
8 #include <cnoid/Signal>
9 #include <QScrollBar>
10 #include "exportdecl.h"
11 
12 namespace cnoid {
13 
14 class CNOID_EXPORT ScrollBar : public QScrollBar
15 {
16  Q_OBJECT
17 
18 public:
19  ScrollBar(QWidget* parent = 0);
20  ScrollBar(Qt::Orientation orientation, QWidget* parent = 0);
21 
23  return sigValueChanged_;
24  }
25 
26 private Q_SLOTS:
27  void onValueChanged(int value);
28 
29 private:
30  Signal<void(int)> sigValueChanged_;
31  void initialize();
32 };
33 
34 
35 class CNOID_EXPORT DoubleScrollBar : public QScrollBar
36 {
37  Q_OBJECT
38 
39 public:
40  DoubleScrollBar(QWidget* parent = 0);
41  DoubleScrollBar(Qt::Orientation orientation, QWidget* parent = 0);
42 
43  double getMaximum() const { return QScrollBar::maximum() / resolution; }
44  double getMinimum() const { return QScrollBar::minimum() / resolution; }
45  double getPageStep() const { return QScrollBar::pageStep() / resolution; }
46  double getSingleStep() const { return QScrollBar::singleStep() / resolution; }
47  double getValue() const { return value() / resolution; }
48 
49  void setRange(double min, double max) {
50  QScrollBar::setRange(min * resolution, max * resolution);
51  }
52 
53  void setPageStep(double step) {
54  QScrollBar::setPageStep(step * resolution);
55  }
56 
57  void setSingleStep(double step) {
58  QScrollBar::setSingleStep(step * resolution);
59  }
60 
61  void setValue(double value) {
62  QScrollBar::setValue(value * resolution);
63  }
64 
65  SignalProxy<void(double)> sigValueChanged() {
66  return sigValueChanged_;
67  }
68 
69 private Q_SLOTS:
70  void onValueChanged(int value);
71 
72 private:
73  Signal<void(double)> sigValueChanged_;
74  double resolution;
75 
76  void initialize();
77 
78  // Original int version functions are disabled
79  int maximum() const { return QScrollBar::maximum(); }
80  int minimum() const { return QScrollBar::minimum(); }
81  int pageStep() const { return QScrollBar::pageStep(); }
82  int singleStep() const { return QScrollBar::singleStep(); }
83  int value() const { return QScrollBar::value(); }
84  void setMaximum(int max) { QScrollBar::setMaximum(max); }
85  void setMinimum(int min) { QScrollBar::setMinimum(min); }
86  void setPageStep(int step) { QScrollBar::setPageStep(step); }
87  void setRange(int min, int max) { QScrollBar::setRange(min, max); }
88  void setSingleStep(int step) { QScrollBar::setSingleStep(step); }
89  void setValue(int value) { QScrollBar::setValue(value); }
90 };
91 
92 }
93 
94 #endif
cnoid::DoubleScrollBar::setRange
void setRange(double min, double max)
Definition: ScrollBar.h:49
cnoid::DoubleScrollBar::setSingleStep
void setSingleStep(double step)
Definition: ScrollBar.h:57
cnoid::DoubleScrollBar::getValue
double getValue() const
Definition: ScrollBar.h:47
cnoid::ScrollBar::sigValueChanged
SignalProxy< void(int)> sigValueChanged()
Definition: ScrollBar.h:22
cnoid::DoubleScrollBar::getMaximum
double getMaximum() const
Definition: ScrollBar.h:43
cnoid::DoubleScrollBar::getSingleStep
double getSingleStep() const
Definition: ScrollBar.h:46
cnoid::DoubleScrollBar::sigValueChanged
SignalProxy< void(double)> sigValueChanged()
Definition: ScrollBar.h:65
cnoid::DoubleScrollBar::getPageStep
double getPageStep() const
Definition: ScrollBar.h:45
cnoid::DoubleScrollBar::setPageStep
void setPageStep(double step)
Definition: ScrollBar.h:53
cnoid
Definition: AbstractSceneLoader.h:11
cnoid::DoubleScrollBar
Definition: ScrollBar.h:35
cnoid::ScrollBar
Definition: ScrollBar.h:14
cnoid::DoubleScrollBar::getMinimum
double getMinimum() const
Definition: ScrollBar.h:44
cnoid::Signal
Definition: Signal.h:165
cnoid::SignalProxy
Definition: Signal.h:470
cnoid::DoubleScrollBar::setValue
void setValue(double value)
Definition: ScrollBar.h:61