55 |
55 |
56 if(!hasStretchedWidget) { |
56 if(!hasStretchedWidget) { |
57 QSpacerItem *newspace = new QSpacerItem(0, 0, QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding); |
57 QSpacerItem *newspace = new QSpacerItem(0, 0, QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding); |
58 box->removeItem(space); |
58 box->removeItem(space); |
59 box->addSpacerItem(newspace); |
59 box->addSpacerItem(newspace); |
60 space = newspace; |
60 space = newspace; |
61 |
|
62 } |
61 } |
63 |
62 |
64 if(fill) { |
63 if(fill) { |
65 hasStretchedWidget = true; |
64 hasStretchedWidget = true; |
66 } |
65 } |
89 return ui_box(obj, QBoxLayout::LeftToRight); |
88 return ui_box(obj, QBoxLayout::LeftToRight); |
90 } |
89 } |
91 |
90 |
92 |
91 |
93 |
92 |
|
93 /* -------------------- UiGridContainer -------------------- */ |
|
94 |
|
95 UiGridContainer::UiGridContainer(QGridLayout* grid) { |
|
96 this->grid = grid; |
|
97 grid->setContentsMargins(QMargins(0,0,0,0)); |
|
98 grid->setSpacing(0); |
|
99 ui_reset_layout(layout); |
|
100 } |
|
101 |
|
102 void UiGridContainer::add(QWidget* widget, bool fill) { |
|
103 if(layout.newline) { |
|
104 QSpacerItem *s = new QSpacerItem(0, 0, QSizePolicy::MinimumExpanding, QSizePolicy::Minimum); |
|
105 grid->addItem(s, y, x); |
|
106 x = 0; |
|
107 y++; |
|
108 } |
|
109 if(x == 0) { |
|
110 if(space) { |
|
111 grid->removeItem(space); |
|
112 } |
|
113 QSpacerItem *s = new QSpacerItem(0, 0, QSizePolicy::Minimum, QSizePolicy::MinimumExpanding); |
|
114 grid->addItem(s, y+1, 0); |
|
115 space = s; |
|
116 } |
|
117 |
|
118 grid->addWidget(widget, y, x); |
|
119 x++; |
|
120 |
|
121 ui_reset_layout(layout); |
|
122 } |
|
123 |
|
124 UIWIDGET ui_grid(UiObject *obj) { |
|
125 UiContainer *ct = uic_get_current_container(obj); |
|
126 QWidget *widget = new QWidget(); |
|
127 QGridLayout *grid = new QGridLayout(); |
|
128 widget->setLayout(grid); |
|
129 ct->add(widget, true); |
|
130 |
|
131 UiObject *newobj = uic_object_new(obj, widget); |
|
132 newobj->container = new UiGridContainer(grid); |
|
133 uic_obj_add(obj, newobj); |
|
134 |
|
135 return widget; |
|
136 } |
|
137 |
94 |
138 |
95 /* -------------------- layout functions -------------------- */ |
139 /* -------------------- layout functions -------------------- */ |
96 |
140 |
97 void ui_layout_fill(UiObject *obj, UiBool fill) { |
141 void ui_layout_fill(UiObject *obj, UiBool fill) { |
98 UiContainer *ct = uic_get_current_container(obj); |
142 UiContainer *ct = uic_get_current_container(obj); |
99 ct->layout.fill = ui_bool2lb(fill); |
143 ct->layout.fill = ui_bool2lb(fill); |
100 } |
144 } |
|
145 |
|
146 void ui_newline(UiObject *obj) { |
|
147 UiContainer *ct = uic_get_current_container(obj); |
|
148 ct->layout.newline = TRUE; |
|
149 } |