SGL
gscrollbar.h
1 /*
2  * File: qgscrollbar.h
3  * -------------------
4  *
5  * @author Marty Stepp
6  * @version 2021/04/09
7  * - added sgl namespace
8  * @version 2018/09/08
9  * - added doc comments for new documentation generation
10  * @version 2018/08/23
11  * - renamed to gscrollbar.h to replace Java version
12  * @version 2018/07/16
13  * - initial version
14  */
15 
16 
17 #ifndef _gscrollbar_h
18 #define _gscrollbar_h
19 
20 #include <string>
21 #include <QScrollBar>
22 
23 #include "ginteractor.h"
24 
25 namespace sgl {
26 
27 class _Internal_QScrollBar;
28 
39 class GScrollBar : public GInteractor {
40 public:
44  enum Orientation {
47  };
48 
53  GScrollBar(Orientation orientation = VERTICAL, int value = 0, int extent = 10, int min = 0, int max = 100, QWidget* parent = nullptr);
54 
58  ~GScrollBar() override;
59 
64  virtual int getExtent() const;
65 
66  /* @inherit */
67  _Internal_QWidget* getInternalWidget() const override;
68 
72  virtual int getMax() const;
73 
77  virtual int getMin() const;
78 
82  virtual Orientation getOrientation() const;
83 
84  /* @inherit */
85  string getType() const override;
86 
90  virtual int getValue() const;
91 
92  /* @inherit */
93  QWidget* getWidget() const override;
94 
99  virtual void setExtent(int extent);
100 
105  virtual void setMax(int max);
106 
111  virtual void setMin(int min);
112 
117  virtual void setState(int value, int extent, int min, int max);
118 
123  virtual void setValue(int value);
124 
125 protected:
129  string getActionEventType() const override;
130 
131 private:
132  Q_DISABLE_COPY(GScrollBar)
133 
134  _Internal_QScrollBar* _iqscrollbar;
135 
136  friend class _Internal_QScrollBar;
137 
138  void updateSize();
139 };
140 
145 class _Internal_QScrollBar : public QScrollBar, public _Internal_QWidget {
146  Q_OBJECT
147 
148 public:
149  _Internal_QScrollBar(GScrollBar* qgscrollbar, Qt::Orientation orientation, QWidget* parent = nullptr);
150  void detach() override;
151  QSize sizeHint() const override;
152 
153 public slots:
154  void handleValueChange(int value);
155 
156 private:
157  GScrollBar* _gscrollbar;
158 
159  friend class GScrollBar;
160 };
161 
162 } // namespace sgl
163 
164 #endif // _gscrollbar_h
virtual void setValue(int value)
Sets the current value of the scroll bar.
Definition: gscrollbar.cpp:121
Definition: gscrollbar.h:46
Definition: gscrollbar.h:45
virtual void setMin(int min)
Sets the minimum allowed value of the scroll bar.
Definition: gscrollbar.cpp:95
Orientation
The two valid orientations of scrollbars.
Definition: gscrollbar.h:44
_Internal_QWidget* getInternalWidget() const override
Returns a direct pointer to the internal Qt widget being wrapped by this interactor.
Definition: gscrollbar.cpp:50
Definition: console.h:45
This abstract class is the superclass for all graphical interactors.
Definition: ginteractor.h:52
virtual int getExtent() const
Returns the scroll bar&#39;s extent, meaning the amount of its range that is currently in view...
Definition: gscrollbar.cpp:46
virtual int getValue() const
Returns the current value of the scroll bar.
Definition: gscrollbar.cpp:70
virtual void setState(int value, int extent, int min, int max)
Sets all of the relevant state of the scroll bar.
Definition: gscrollbar.cpp:106
QWidget* getWidget() const override
Returns a direct pointer to the internal Qt widget being wrapped by this interactor.
Definition: gscrollbar.cpp:74
virtual Orientation getOrientation() const
Returns the orientation of the scroll bar, either HORIZONTAL or VERTICAL.
Definition: gscrollbar.cpp:62
~GScrollBar() override
Frees memory allocated internally by the scroll bar.
Definition: gscrollbar.cpp:36
GScrollBar(Orientation orientation=VERTICAL, int value=0, int extent=10, int min=0, int max=100, QWidget* parent=nullptr)
Creates a new scroll bar with the given orientation and value range.
Definition: gscrollbar.cpp:23
virtual int getMin() const
Returns the minimum allowed value of the scroll bar.
Definition: gscrollbar.cpp:58
virtual int getMax() const
Returns the maximum allowed value of the scroll bar.
Definition: gscrollbar.cpp:54
string getType() const override
Returns a string representing the class name of this interactor, such as "GButton" or "GCheckBox"...
Definition: gscrollbar.cpp:66
A GScrollBar represents a horizontal or vertical scroll bar that can be dragged by the user...
Definition: gscrollbar.h:39
virtual void setMax(int max)
Sets the maximum allowed value of the scroll bar.
Definition: gscrollbar.cpp:84
virtual void setExtent(int extent)
Sets the scroll bar&#39;s extent, meaning the amount of its range that is currently in view...
Definition: gscrollbar.cpp:78