SGL
gscrollbar.h
1 /*
2  * File: qgscrollbar.h
3  * -------------------
4  *
5  * @author Marty Stepp
6  * @version 2018/09/08
7  * - added doc comments for new documentation generation
8  * @version 2018/08/23
9  * - renamed to gscrollbar.h to replace Java version
10  * @version 2018/07/16
11  * - initial version
12  */
13 
14 
15 #ifndef _gscrollbar_h
16 #define _gscrollbar_h
17 
18 #include <string>
19 #include <QScrollBar>
20 
21 #include "ginteractor.h"
22 
23 class _Internal_QScrollBar;
24 
35 class GScrollBar : public GInteractor {
36 public:
40  enum Orientation {
43  };
44 
49  GScrollBar(Orientation orientation = VERTICAL, int value = 0, int extent = 10, int min = 0, int max = 100, QWidget* parent = nullptr);
50 
54  ~GScrollBar() override;
55 
60  virtual int getExtent() const;
61 
62  /* @inherit */
63  _Internal_QWidget* getInternalWidget() const override;
64 
68  virtual int getMax() const;
69 
73  virtual int getMin() const;
74 
78  virtual Orientation getOrientation() const;
79 
80  /* @inherit */
81  string getType() const override;
82 
86  virtual int getValue() const;
87 
88  /* @inherit */
89  QWidget* getWidget() const override;
90 
95  virtual void setExtent(int extent);
96 
101  virtual void setMax(int max);
102 
107  virtual void setMin(int min);
108 
113  virtual void setState(int value, int extent, int min, int max);
114 
119  virtual void setValue(int value);
120 
121 protected:
125  string getActionEventType() const override;
126 
127 private:
128  Q_DISABLE_COPY(GScrollBar)
129 
130  _Internal_QScrollBar* _iqscrollbar;
131 
132  friend class _Internal_QScrollBar;
133 
134  void updateSize();
135 };
136 
141 class _Internal_QScrollBar : public QScrollBar, public _Internal_QWidget {
142  Q_OBJECT
143 
144 public:
145  _Internal_QScrollBar(GScrollBar* qgscrollbar, Qt::Orientation orientation, QWidget* parent = nullptr);
146  void detach() override;
147  QSize sizeHint() const override;
148 
149 public slots:
150  void handleValueChange(int value);
151 
152 private:
153  GScrollBar* _gscrollbar;
154 
155  friend class GScrollBar;
156 };
157 
158 #endif // _gscrollbar_h
virtual void setMin(int min)
Sets the minimum allowed value of the scroll bar.
Definition: gscrollbar.cpp:91
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:42
Orientation
The two valid orientations of scrollbars.
Definition: gscrollbar.h:40
QWidget* getWidget() const override
Returns a direct pointer to the internal Qt widget being wrapped by this interactor.
Definition: gscrollbar.cpp:70
virtual int getMax() const
Returns the maximum allowed value of the scroll bar.
Definition: gscrollbar.cpp:50
A GScrollBar represents a horizontal or vertical scroll bar that can be dragged by the user...
Definition: gscrollbar.h:35
~GScrollBar() override
Frees memory allocated internally by the scroll bar.
Definition: gscrollbar.cpp:32
virtual void setValue(int value)
Sets the current value of the scroll bar.
Definition: gscrollbar.cpp:117
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:74
virtual void setState(int value, int extent, int min, int max)
Sets all of the relevant state of the scroll bar.
Definition: gscrollbar.cpp:102
Definition: gscrollbar.h:41
string getType() const override
Returns a string representing the class name of this interactor, such as "GButton" or "GCheckBox"...
Definition: gscrollbar.cpp:62
This abstract class is the superclass for all graphical interactors.
Definition: ginteractor.h:48
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:19
virtual void setMax(int max)
Sets the maximum allowed value of the scroll bar.
Definition: gscrollbar.cpp:80
_Internal_QWidget* getInternalWidget() const override
Returns a direct pointer to the internal Qt widget being wrapped by this interactor.
Definition: gscrollbar.cpp:46
virtual int getValue() const
Returns the current value of the scroll bar.
Definition: gscrollbar.cpp:66
virtual Orientation getOrientation() const
Returns the orientation of the scroll bar, either HORIZONTAL or VERTICAL.
Definition: gscrollbar.cpp:58
Definition: gscrollbar.h:42
virtual int getMin() const
Returns the minimum allowed value of the scroll bar.
Definition: gscrollbar.cpp:54