28 |
28 |
29 #ifndef CONTAINER_H |
29 #ifndef CONTAINER_H |
30 #define CONTAINER_H |
30 #define CONTAINER_H |
31 |
31 |
32 #include "toolkit.h" |
32 #include "toolkit.h" |
|
33 #include "../ui/container.h" |
33 #include "window.h" |
34 #include "window.h" |
34 |
35 |
35 #include <string.h> |
36 #include <string.h> |
36 #include <QBoxLayout> |
37 #include <QBoxLayout> |
37 #include <QGridLayout> |
38 #include <QGridLayout> |
38 #include <QTabWidget> |
39 #include <QTabWidget> |
39 #include <QStackedWidget> |
40 #include <QStackedWidget> |
40 #include <QSplitter> |
41 #include <QSplitter> |
41 |
42 |
|
43 #define UI_APPLY_LAYOUT(layout, args) \ |
|
44 layout.fill = args.fill; \ |
|
45 layout.hexpand = args.hexpand; \ |
|
46 layout.vexpand = args.vexpand; \ |
|
47 layout.hfill = args.hfill; \ |
|
48 layout.vfill = args.vfill; \ |
|
49 layout.override_defaults = args.override_defaults; \ |
|
50 layout.colspan = args.colspan; \ |
|
51 layout.rowspan = args.rowspan |
42 |
52 |
|
53 #define ui_reset_layout(layout) memset(&(layout), 0, sizeof(UiLayout)) |
|
54 #define ui_lb2bool(b) ((b) == UI_LAYOUT_TRUE ? TRUE : FALSE) |
|
55 #define ui_bool2lb(b) ((b) ? UI_LAYOUT_TRUE : UI_LAYOUT_FALSE) |
|
56 |
|
57 #define ui_obj_container(obj) (UiContainerPrivate*)obj->container_end |
|
58 |
|
59 typedef enum UiLayoutBool { |
|
60 UI_LAYOUT_UNDEFINED = 0, |
|
61 UI_LAYOUT_TRUE, |
|
62 UI_LAYOUT_FALSE, |
|
63 } UiLayoutBool; |
|
64 |
|
65 typedef struct UiLayout UiLayout; |
|
66 struct UiLayout { |
|
67 UiTri fill; |
|
68 UiBool newline; |
|
69 char *label; |
|
70 UiBool hexpand; |
|
71 UiBool vexpand; |
|
72 UiBool hfill; |
|
73 UiBool vfill; |
|
74 UiBool override_defaults; |
|
75 int width; |
|
76 int colspan; |
|
77 int rowspan; |
|
78 }; |
|
79 |
|
80 struct UiContainerPrivate { |
|
81 UiLayout layout; |
|
82 UIWIDGET current; |
|
83 |
|
84 virtual void add(QWidget *widget, bool fill) = 0; |
|
85 }; |
|
86 |
|
87 class UiBoxContainer : public UiContainerPrivate { |
|
88 public: |
|
89 QBoxLayout *box; |
|
90 bool hasStretchedWidget = false; |
|
91 QSpacerItem *space; |
|
92 |
|
93 UiBoxContainer(QBoxLayout *box); |
|
94 |
|
95 virtual void add(QWidget *widget, bool fill); |
|
96 }; |
|
97 |
|
98 class UiGridContainer : public UiContainerPrivate { |
|
99 public: |
|
100 QGridLayout *grid; |
|
101 int x = 0; |
|
102 int y = 0; |
|
103 |
|
104 UiGridContainer(QGridLayout *grid, int margin, int columnspacing, int rowspacing); |
|
105 |
|
106 virtual void add(QWidget *widget, bool fill); |
|
107 }; |
43 |
108 |
44 |
109 |
45 #endif /* CONTAINER_H */ |
110 #endif /* CONTAINER_H */ |
46 |
111 |