SGL
glayout.h
1 /*
2  * File: glayout.h
3  * ---------------
4  *
5  * @author Marty Stepp
6  * @version 2018/09/07
7  * - added doc comments for new documentation generation
8  * @version 2018/08/23
9  * - renamed to glayout.h to replace Java version
10  * @version 2018/06/25
11  * - initial version
12  */
13 
14 
15 #ifndef _glayout_h
16 #define _glayout_h
17 
18 #include <QLayout>
19 #include <QRect>
20 #include <QWidget>
21 
22 #include "ginteractor.h"
23 
29 class GLayout {
30 public:
31 
32  enum Position { West, North, South, East, Center };
33 
34  static void clearLayout(QLayout* layout);
35  static bool contains(QLayout* layout, QWidget* widget);
36  static void forceUpdate(GInteractor* interactor);
37  static void forceUpdate(QWidget* widget);
38  static QSize getPreferredSize(QWidget* widget);
39  static QSize getProperSize(QLayout* layout);
40  static QSize getProperSize(QWidget* widget);
41  static void invalidateLayout(QLayout* layout);
42  static Position toPosition(const string& positionName);
43 
44 private:
45  GLayout(); // forbid construction
46 };
47 
58 class GBorderLayout : public QLayout {
59 public:
60  GBorderLayout(QWidget* parent, int margin = 0, int spacing = -1);
61  GBorderLayout(int spacing = -1);
62  ~GBorderLayout() override;
63 
64  void addItem(QLayoutItem* item) override;
65  void addWidget(QWidget* widget);
66  void addWidget(QWidget* widget, GLayout::Position position);
67  Qt::Orientations expandingDirections() const override;
68  bool hasHeightForWidth() const override;
69  int count() const override;
70  QLayoutItem* itemAt(int index) const override;
71  QSize minimumSize() const override;
72  void setGeometry(const QRect& rect) override;
73  QSize sizeHint() const override;
74  QLayoutItem* takeAt(int index) override;
75 
76  void add(QLayoutItem* item, GLayout::Position position);
77 
78 private:
79  Q_DISABLE_COPY(GBorderLayout)
80 
81  struct ItemWrapper {
82  ItemWrapper(QLayoutItem* i, GLayout::Position p) {
83  item = i;
84  position = p;
85  }
86 
87  QLayoutItem* item;
88  GLayout::Position position;
89  };
90 
91  enum SizeType { MinimumSize, SizeHint };
92 
93  QSize calculateSize(SizeType sizeType) const;
94 
95  QList<ItemWrapper*> list;
96 };
97 
98 #endif // _glayout_h
This abstract class is the superclass for all graphical interactors.
Definition: ginteractor.h:48