ui/qt/container.h

changeset 802
cc73993a3ff9
parent 672
1b08ba076b65
child 822
54e43e4efac2
equal deleted inserted replaced
801:e096c441e874 802:cc73993a3ff9
38 #include <QGridLayout> 38 #include <QGridLayout>
39 #include <QTabWidget> 39 #include <QTabWidget>
40 #include <QStackedWidget> 40 #include <QStackedWidget>
41 #include <QSplitter> 41 #include <QSplitter>
42 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
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*)((UiContainerX*)obj->container_end)->container 43 #define ui_obj_container(obj) (UiContainerPrivate*)((UiContainerX*)obj->container_end)->container
58 44
59 typedef enum UiLayoutBool { 45 struct UiContainerPrivate {
60 UI_LAYOUT_UNDEFINED = 0, 46 UIWIDGET current;
61 UI_LAYOUT_TRUE, 47 UiContainerX *container;
62 UI_LAYOUT_FALSE,
63 } UiLayoutBool;
64 48
65 typedef struct UiLayout UiLayout; 49 virtual void add(QWidget *widget, UiLayout& layout) = 0;
66 struct UiLayout {
67 UiBool 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) = 0;
85 virtual void end() {} 50 virtual void end() {}
86 }; 51 };
87 52
88 class UiBoxContainer : public UiContainerPrivate { 53 class UiBoxContainer : public UiContainerPrivate {
89 public: 54 public:
91 bool hasStretchedWidget = false; 56 bool hasStretchedWidget = false;
92 QSpacerItem *space; 57 QSpacerItem *space;
93 58
94 UiBoxContainer(QBoxLayout *box); 59 UiBoxContainer(QBoxLayout *box);
95 60
96 virtual void add(QWidget *widget); 61 virtual void add(QWidget *widget, UiLayout& layout);
97 }; 62 };
98 63
99 class UiGridContainer : public UiContainerPrivate { 64 class UiGridContainer : public UiContainerPrivate {
100 public: 65 public:
101 QGridLayout *grid; 66 QGridLayout *grid;
118 bool def_hexpand, 83 bool def_hexpand,
119 bool def_vexpand, 84 bool def_vexpand,
120 bool def_hfill, 85 bool def_hfill,
121 bool def_vfill); 86 bool def_vfill);
122 87
123 virtual void add(QWidget *widget); 88 virtual void add(QWidget *widget, UiLayout& layout);
124 virtual void end(); 89 virtual void end();
125 }; 90 };
126 91
127 void ui_container_add(UiObject *obj, UiContainerPrivate *ct); 92 void ui_container_add(UiObject *obj, UiContainerPrivate *ct);
128 93

mercurial