SGL
gslider.h
1 /*
2  * File: gslider.h
3  * ---------------
4  *
5  * @author Marty Stepp
6  * @version 2019/04/23
7  * - added key events
8  * @version 2018/09/08
9  * - added doc comments for new documentation generation
10  * @version 2018/08/23
11  * - renamed to gslider.h to replace Java version
12  * @version 2018/06/29
13  * - initial version
14  */
15 
16 
17 #ifndef _gslider_h
18 #define _gslider_h
19 
20 #include <string>
21 #include <QSlider>
22 
23 #include "ginteractor.h"
24 
25 class _Internal_QSlider;
26 
31 class GSlider : public GInteractor {
32 public:
36  enum Orientation {
39  };
40 
44  static const int DEFAULT_MIN_VALUE;
45 
49  static const int DEFAULT_MAX_VALUE;
50 
54  static const int DEFAULT_INITIAL_VALUE;
55 
60  GSlider(int min = 0, int max = 100, int value = 50, QWidget* parent = nullptr);
61 
66  GSlider(Orientation orientation, int min = 0, int max = 100, int value = 50, QWidget* parent = nullptr);
67 
71  ~GSlider() override;
72 
73  /* @inherit */
74  _Internal_QWidget* getInternalWidget() const override;
75 
80  virtual int getMajorTickSpacing() const;
81 
85  virtual int getMax() const;
86 
90  virtual int getMin() const;
91 
96  virtual int getMinorTickSpacing() const;
97 
101  virtual Orientation getOrientation() const;
102 
108  virtual bool getPaintLabels() const;
109 
114  virtual bool getPaintTicks() const;
115 
121  virtual bool getSnapToTicks() const;
122 
123  /* @inherit */
124  string getType() const override;
125 
129  virtual int getValue() const;
130 
131  /* @inherit */
132  QWidget* getWidget() const override;
133 
138  virtual void setMajorTickSpacing(int value);
139 
144  virtual void setMax(int max);
145 
150  virtual void setMin(int min);
151 
156  virtual void setMinorTickSpacing(int value);
157 
163  virtual void setPaintLabels(bool value);
164 
169  virtual void setPaintTicks(bool value);
170 
175  virtual void setRange(int min, int max);
176 
182  virtual void setSnapToTicks(bool value);
183 
188  virtual void setState(int min, int max, int value);
189 
194  virtual void setValue(int value);
195 
196 protected:
200  string getActionEventType() const override;
201 
202 private:
203  Q_DISABLE_COPY(GSlider)
204 
205  _Internal_QSlider* _iqslider;
206 
207  friend class _Internal_QSlider;
208 };
209 
214 class _Internal_QSlider : public QSlider, public _Internal_QWidget {
215  Q_OBJECT
216 
217 public:
218  _Internal_QSlider(GSlider* qgslider, Qt::Orientation orientation = Qt::Horizontal, QWidget* parent = nullptr);
219  void detach() override;
220  void keyPressEvent(QKeyEvent* event) override;
221  void keyReleaseEvent(QKeyEvent* event) override;
222  QSize sizeHint() const override;
223 
224 public slots:
225  void handleChange(int value);
226 
227 private:
228  GSlider* _gslider;
229 
230  friend class GSlider;
231 };
232 
233 #endif // _gslider_h
This interactor subclass represents an onscreen slider.
Definition: gslider.h:31
_Internal_QWidget* getInternalWidget() const override
Returns a direct pointer to the internal Qt widget being wrapped by this interactor.
Definition: gslider.cpp:71
static const int DEFAULT_MAX_VALUE
Default maximum value for a slider (100).
Definition: gslider.h:49
virtual void setMax(int max)
Sets the maximum allowed value of the slider.
Definition: gslider.cpp:128
virtual int getMax() const
Returns the maximum allowed value of the slider.
Definition: gslider.cpp:79
string getType() const override
Returns a string representing the class name of this interactor, such as "GButton" or "GCheckBox"...
Definition: gslider.cpp:110
virtual void setRange(int min, int max)
Sets the min-max range of the slider.
Definition: gslider.cpp:164
virtual Orientation getOrientation() const
Returns the orientation of the slider, either HORIZONTAL or VERTICAL.
Definition: gslider.cpp:91
virtual int getValue() const
Returns the slider&#39;s current value.
Definition: gslider.cpp:114
static const int DEFAULT_MIN_VALUE
Default minimum value for a slider (0).
Definition: gslider.h:44
This abstract class is the superclass for all graphical interactors.
Definition: ginteractor.h:48
Definition: gslider.h:38
virtual void setMin(int min)
Sets the minimum allowed value of the slider.
Definition: gslider.cpp:138
Definition: gslider.h:37
~GSlider() override
Frees memory allocated internally by the slider.
Definition: gslider.cpp:61
static const int DEFAULT_INITIAL_VALUE
Default initial value for a slider (50).
Definition: gslider.h:54
GSlider(int min=0, int max=100, int value=50, QWidget* parent=nullptr)
Creates a new horizontal slider with the given value range.
Definition: gslider.cpp:27
virtual void setState(int min, int max, int value)
Sets all of the relevant state of the slider.
Definition: gslider.cpp:177
virtual void setValue(int value)
Sets the current value of the slider.
Definition: gslider.cpp:190
QWidget* getWidget() const override
Returns a direct pointer to the internal Qt widget being wrapped by this interactor.
Definition: gslider.cpp:118
Orientation
The two valid orientations of sliders.
Definition: gslider.h:36
virtual int getMin() const
Returns the minimum allowed value of the slider.
Definition: gslider.cpp:83