ui/qt/container.cpp

Sat, 13 Dec 2025 15:58:58 +0100

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Sat, 13 Dec 2025 15:58:58 +0100
changeset 115
e57ca2747782
parent 112
c3f2f16fa4b8
permissions
-rw-r--r--

fix build with newest toolkit version

0
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1 /*
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
3 *
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
4 * Copyright 2014 Olaf Wintermann. All rights reserved.
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
5 *
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
6 * Redistribution and use in source and binary forms, with or without
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
7 * modification, are permitted provided that the following conditions are met:
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
8 *
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
9 * 1. Redistributions of source code must retain the above copyright
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
10 * notice, this list of conditions and the following disclaimer.
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
11 *
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
12 * 2. Redistributions in binary form must reproduce the above copyright
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
13 * notice, this list of conditions and the following disclaimer in the
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
14 * documentation and/or other materials provided with the distribution.
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
15 *
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
26 * POSSIBILITY OF SUCH DAMAGE.
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
27 */
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
28
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
29 #include <stdio.h>
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
30 #include "container.h"
103
6606616eca9f update uwproj, toolkit, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
31 #include "../common/object.h"
112
c3f2f16fa4b8 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 109
diff changeset
32 #include "../common/container.h"
103
6606616eca9f update uwproj, toolkit, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
33
6606616eca9f update uwproj, toolkit, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
34 #include <cx/mempool.h>
0
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
35
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
36 #include <QSpacerItem>
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
37 #include <QStackedWidget>
103
6606616eca9f update uwproj, toolkit, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
38 #include <QLabel>
109
c3dfcb8f0be7 update toolkit, remove getvalue func from model to table/listview args
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 108
diff changeset
39 #include <QDockWidget>
0
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
40
103
6606616eca9f update uwproj, toolkit, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
41 static void delete_container(UiContainerPrivate *ct) {
6606616eca9f update uwproj, toolkit, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
42 delete ct;
6606616eca9f update uwproj, toolkit, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
43 }
6606616eca9f update uwproj, toolkit, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
44
112
c3f2f16fa4b8 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 109
diff changeset
45 void ui_obj_add_container(UiObject *obj, UiContainerPrivate *ct) {
103
6606616eca9f update uwproj, toolkit, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
46 UiContainerX *container = (UiContainerX*)ui_malloc(obj->ctx, sizeof(UiContainerX));
6606616eca9f update uwproj, toolkit, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
47 container->close = 0;
6606616eca9f update uwproj, toolkit, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
48 container->container = ct;
6606616eca9f update uwproj, toolkit, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
49 container->prev = NULL;
6606616eca9f update uwproj, toolkit, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
50 container->next = NULL;
112
c3f2f16fa4b8 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 109
diff changeset
51 ct->container = container;
103
6606616eca9f update uwproj, toolkit, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
52 cxMempoolRegister(obj->ctx->mp, ct, (cx_destructor_func)delete_container);
6606616eca9f update uwproj, toolkit, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
53 uic_object_push_container(obj, container);
6606616eca9f update uwproj, toolkit, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
54 }
0
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
55
112
c3f2f16fa4b8 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 109
diff changeset
56 /* ------------------------ margin helper ------------------------ */
c3f2f16fa4b8 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 109
diff changeset
57
c3f2f16fa4b8 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 109
diff changeset
58 QWidget* ui_widget_set_margin(QWidget *w, int left, int right, int top, int bottom) {
c3f2f16fa4b8 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 109
diff changeset
59 if((left | right | top | bottom) == 0) {
c3f2f16fa4b8 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 109
diff changeset
60 return w;
c3f2f16fa4b8 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 109
diff changeset
61 }
c3f2f16fa4b8 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 109
diff changeset
62 QWidget* wrapper = new QWidget;
c3f2f16fa4b8 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 109
diff changeset
63 QVBoxLayout* inner = new QVBoxLayout(wrapper);
c3f2f16fa4b8 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 109
diff changeset
64 inner->setContentsMargins(left, top, right, bottom);
c3f2f16fa4b8 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 109
diff changeset
65 inner->addWidget(w);
c3f2f16fa4b8 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 109
diff changeset
66
c3f2f16fa4b8 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 109
diff changeset
67 // TODO: handle widget visibility changes
c3f2f16fa4b8 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 109
diff changeset
68
c3f2f16fa4b8 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 109
diff changeset
69 return wrapper;
c3f2f16fa4b8 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 109
diff changeset
70 }
c3f2f16fa4b8 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 109
diff changeset
71
0
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
72 /* -------------------- UiBoxContainer -------------------- */
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
73
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
74 UiBoxContainer::UiBoxContainer(QBoxLayout* box) {
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
75 this->box = box;
112
c3f2f16fa4b8 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 109
diff changeset
76 this->direction = box->direction();
0
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
77 box->setContentsMargins(QMargins(0,0,0,0));
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
78 box->setSpacing(0);
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
79 }
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
80
112
c3f2f16fa4b8 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 109
diff changeset
81 void UiBoxContainer::add(QWidget* widget, UiLayout& layout) {
108
77254bd6dccb update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 103
diff changeset
82 bool fill = layout.fill;
0
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
83 if(hasStretchedWidget && fill) {
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
84 fill = false;
115
e57ca2747782 fix build with newest toolkit version
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 112
diff changeset
85 fprintf(stderr, "UiError: container has 2 filled widgets\n");
e57ca2747782 fix build with newest toolkit version
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 112
diff changeset
86 }
e57ca2747782 fix build with newest toolkit version
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 112
diff changeset
87
e57ca2747782 fix build with newest toolkit version
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 112
diff changeset
88 if(singleChild) {
e57ca2747782 fix build with newest toolkit version
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 112
diff changeset
89 fill = true;
e57ca2747782 fix build with newest toolkit version
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 112
diff changeset
90 if(hasChild) {
e57ca2747782 fix build with newest toolkit version
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 112
diff changeset
91 fprintf(stderr, "UiError: single child container already has a child\n");
e57ca2747782 fix build with newest toolkit version
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 112
diff changeset
92 }
0
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
93 }
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
94
112
c3f2f16fa4b8 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 109
diff changeset
95 uic_layout_setup_margin(&layout);
c3f2f16fa4b8 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 109
diff changeset
96 widget = ui_widget_set_margin(widget, layout.margin_left, layout.margin_right, layout.margin_top, layout.margin_bottom);
108
77254bd6dccb update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 103
diff changeset
97 box->addWidget(widget);
112
c3f2f16fa4b8 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 109
diff changeset
98 if(direction == Qt::LeftToRight) {
c3f2f16fa4b8 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 109
diff changeset
99 box->setAlignment(widget, Qt::AlignTop);
c3f2f16fa4b8 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 109
diff changeset
100 }
0
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
101
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
102 if(!hasStretchedWidget) {
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
103 QSpacerItem *newspace = new QSpacerItem(0, 0, QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
104 box->removeItem(space);
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
105 box->addSpacerItem(newspace);
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
106 space = newspace;
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
107 }
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
108
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
109 if(fill) {
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
110 hasStretchedWidget = true;
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
111 }
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
112 current = widget;
115
e57ca2747782 fix build with newest toolkit version
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 112
diff changeset
113 hasChild = true;
0
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
114 }
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
115
108
77254bd6dccb update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 103
diff changeset
116 UIWIDGET ui_box(UiObject *obj, UiContainerArgs *args, QBoxLayout::Direction dir) {
103
6606616eca9f update uwproj, toolkit, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
117 UiContainerPrivate *ctn = (UiContainerPrivate*)ui_obj_container(obj);
112
c3f2f16fa4b8 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 109
diff changeset
118 UiLayout layout = UI_ARGS2LAYOUT(args);
103
6606616eca9f update uwproj, toolkit, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
119
0
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
120 QWidget *widget = new QWidget();
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
121 QBoxLayout *box = new QBoxLayout(dir);
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
122 widget->setLayout(box);
112
c3f2f16fa4b8 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 109
diff changeset
123 ctn->add(widget, layout);
0
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
124
112
c3f2f16fa4b8 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 109
diff changeset
125 ui_obj_add_container(obj, new UiBoxContainer(box));
0
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
126
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
127 return widget;
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
128 }
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
129
108
77254bd6dccb update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 103
diff changeset
130 UIWIDGET ui_vbox_create(UiObject *obj, UiContainerArgs *args) {
103
6606616eca9f update uwproj, toolkit, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
131 return ui_box(obj, args, QBoxLayout::TopToBottom);
0
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
132 }
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
133
108
77254bd6dccb update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 103
diff changeset
134 UIWIDGET ui_hbox_create(UiObject *obj, UiContainerArgs *args) {
103
6606616eca9f update uwproj, toolkit, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
135 return ui_box(obj, args, QBoxLayout::LeftToRight);
0
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
136 }
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
137
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
138
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
139 /* -------------------- UiGridContainer -------------------- */
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
140
103
6606616eca9f update uwproj, toolkit, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
141 UiGridContainer::UiGridContainer(
6606616eca9f update uwproj, toolkit, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
142 QGridLayout *grid,
6606616eca9f update uwproj, toolkit, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
143 int margin,
6606616eca9f update uwproj, toolkit, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
144 int columnspacing,
6606616eca9f update uwproj, toolkit, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
145 int rowspacing,
6606616eca9f update uwproj, toolkit, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
146 bool def_hexpand,
6606616eca9f update uwproj, toolkit, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
147 bool def_vexpand,
6606616eca9f update uwproj, toolkit, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
148 bool def_hfill,
6606616eca9f update uwproj, toolkit, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
149 bool def_vfill)
6606616eca9f update uwproj, toolkit, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
150 {
0
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
151 this->current = NULL;
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
152 this->grid = grid;
103
6606616eca9f update uwproj, toolkit, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
153 this->def_hexpand = def_hexpand;
6606616eca9f update uwproj, toolkit, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
154 this->def_vexpand = def_vexpand;
6606616eca9f update uwproj, toolkit, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
155 this->def_hfill = def_hfill;
6606616eca9f update uwproj, toolkit, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
156 this->def_vfill = def_vfill;
0
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
157 grid->setContentsMargins(QMargins(margin, margin, margin, margin));
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
158 grid->setHorizontalSpacing(columnspacing);
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
159 grid->setVerticalSpacing(rowspacing);
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
160 }
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
161
112
c3f2f16fa4b8 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 109
diff changeset
162 void UiGridContainer::add(QWidget* widget, UiLayout& layout) {
c3f2f16fa4b8 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 109
diff changeset
163 if(container->newline) {
0
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
164 x = 0;
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
165 y++;
112
c3f2f16fa4b8 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 109
diff changeset
166 container->newline = false;
0
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
167 }
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
168
112
c3f2f16fa4b8 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 109
diff changeset
169 uic_layout_setup_expand_fill(&layout, def_hexpand, def_vexpand, def_hfill, def_vfill);
c3f2f16fa4b8 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 109
diff changeset
170 uic_layout_setup_margin(&layout);
c3f2f16fa4b8 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 109
diff changeset
171
c3f2f16fa4b8 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 109
diff changeset
172 if(layout.hexpand) {
c3f2f16fa4b8 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 109
diff changeset
173 col_expanding = true;
c3f2f16fa4b8 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 109
diff changeset
174 }
c3f2f16fa4b8 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 109
diff changeset
175 if(layout.vexpand) {
c3f2f16fa4b8 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 109
diff changeset
176 row_expanding = true;
0
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
177 }
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
178
103
6606616eca9f update uwproj, toolkit, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
179 if(layout.hexpand) {
112
c3f2f16fa4b8 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 109
diff changeset
180 grid->setColumnStretch(x, 1);
103
6606616eca9f update uwproj, toolkit, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
181 }
6606616eca9f update uwproj, toolkit, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
182 if(layout.vexpand) {
6606616eca9f update uwproj, toolkit, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
183 grid->setRowStretch(y, 1);
6606616eca9f update uwproj, toolkit, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
184 }
6606616eca9f update uwproj, toolkit, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
185
6606616eca9f update uwproj, toolkit, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
186 Qt::Alignment alignment = 0;
112
c3f2f16fa4b8 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 109
diff changeset
187 if(!layout.hfill) {
103
6606616eca9f update uwproj, toolkit, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
188 alignment = Qt::AlignLeft;
6606616eca9f update uwproj, toolkit, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
189 }
112
c3f2f16fa4b8 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 109
diff changeset
190 if(!layout.vfill) {
103
6606616eca9f update uwproj, toolkit, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
191 alignment = Qt::AlignTop;
6606616eca9f update uwproj, toolkit, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
192 }
6606616eca9f update uwproj, toolkit, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
193
6606616eca9f update uwproj, toolkit, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
194 int colspan = layout.colspan > 0 ? layout.colspan : 1;
6606616eca9f update uwproj, toolkit, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
195 int rowspan = layout.rowspan > 0 ? layout.rowspan : 1;
6606616eca9f update uwproj, toolkit, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
196
112
c3f2f16fa4b8 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 109
diff changeset
197 widget = ui_widget_set_margin(widget, layout.margin_left, layout.margin_right, layout.margin_top, layout.margin_bottom);
103
6606616eca9f update uwproj, toolkit, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
198 grid->addWidget(widget, y, x, rowspan, colspan, alignment);
6606616eca9f update uwproj, toolkit, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
199
6606616eca9f update uwproj, toolkit, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
200 if(x > max_x) {
6606616eca9f update uwproj, toolkit, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
201 max_x = x;
6606616eca9f update uwproj, toolkit, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
202 }
6606616eca9f update uwproj, toolkit, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
203 if(y > max_y) {
6606616eca9f update uwproj, toolkit, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
204 max_y = y;
6606616eca9f update uwproj, toolkit, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
205 }
6606616eca9f update uwproj, toolkit, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
206
6606616eca9f update uwproj, toolkit, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
207 x += colspan;
0
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
208
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
209 current = widget;
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
210 }
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
211
103
6606616eca9f update uwproj, toolkit, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
212 void UiGridContainer::end() {
6606616eca9f update uwproj, toolkit, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
213 if(!col_expanding) {
6606616eca9f update uwproj, toolkit, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
214 QSpacerItem *filler = new QSpacerItem(0, 0);
6606616eca9f update uwproj, toolkit, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
215 x = max_x + 1;
6606616eca9f update uwproj, toolkit, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
216 grid->setColumnStretch(x, 1);
6606616eca9f update uwproj, toolkit, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
217 grid->addItem(filler, 0, x, 1, 1, 0);
6606616eca9f update uwproj, toolkit, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
218 }
6606616eca9f update uwproj, toolkit, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
219 if(!row_expanding) {
6606616eca9f update uwproj, toolkit, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
220 QSpacerItem *filler = new QSpacerItem(0, 0);
6606616eca9f update uwproj, toolkit, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
221 y++;
6606616eca9f update uwproj, toolkit, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
222 grid->setRowStretch(y, 1);
6606616eca9f update uwproj, toolkit, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
223 grid->addItem(filler, y, 0, 1, 1, 0);
6606616eca9f update uwproj, toolkit, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
224 }
0
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
225 }
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
226
109
c3dfcb8f0be7 update toolkit, remove getvalue func from model to table/listview args
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 108
diff changeset
227 UIWIDGET ui_grid_create(UiObject *obj, UiContainerArgs *args) {
103
6606616eca9f update uwproj, toolkit, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
228 UiContainerPrivate *ctn = (UiContainerPrivate*)ui_obj_container(obj);
112
c3f2f16fa4b8 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 109
diff changeset
229 UiLayout layout = UI_ARGS2LAYOUT(args);
103
6606616eca9f update uwproj, toolkit, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
230
0
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
231 QWidget *widget = new QWidget();
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
232 QGridLayout *grid = new QGridLayout();
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
233 widget->setLayout(grid);
112
c3f2f16fa4b8 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 109
diff changeset
234 ctn->add(widget, layout);
0
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
235
112
c3f2f16fa4b8 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 109
diff changeset
236 ui_obj_add_container(obj, new UiGridContainer(
103
6606616eca9f update uwproj, toolkit, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
237 grid,
108
77254bd6dccb update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 103
diff changeset
238 args->margin,
77254bd6dccb update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 103
diff changeset
239 args->columnspacing,
77254bd6dccb update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 103
diff changeset
240 args->rowspacing,
77254bd6dccb update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 103
diff changeset
241 args->def_hexpand,
77254bd6dccb update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 103
diff changeset
242 args->def_vexpand,
77254bd6dccb update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 103
diff changeset
243 args->def_hfill,
77254bd6dccb update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 103
diff changeset
244 args->def_vfill));
0
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
245
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
246 return widget;
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
247 }
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
248
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
249
115
e57ca2747782 fix build with newest toolkit version
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 112
diff changeset
250 /* ------------------------------ Frame ------------------------------ */
e57ca2747782 fix build with newest toolkit version
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 112
diff changeset
251
e57ca2747782 fix build with newest toolkit version
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 112
diff changeset
252 UIWIDGET ui_frame_create(UiObject *obj, UiFrameArgs *args) {
e57ca2747782 fix build with newest toolkit version
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 112
diff changeset
253 UiContainerPrivate *ctn = (UiContainerPrivate*)ui_obj_container(obj);
e57ca2747782 fix build with newest toolkit version
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 112
diff changeset
254 UiLayout layout = UI_ARGS2LAYOUT(args);
e57ca2747782 fix build with newest toolkit version
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 112
diff changeset
255
e57ca2747782 fix build with newest toolkit version
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 112
diff changeset
256 bool createBox = true;
e57ca2747782 fix build with newest toolkit version
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 112
diff changeset
257 bool singleChild = false;
e57ca2747782 fix build with newest toolkit version
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 112
diff changeset
258 QBoxLayout::Direction dir = QBoxLayout::TopToBottom;
e57ca2747782 fix build with newest toolkit version
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 112
diff changeset
259 QGroupBox *widget = new QGroupBox();
e57ca2747782 fix build with newest toolkit version
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 112
diff changeset
260 if(args->label) {
e57ca2747782 fix build with newest toolkit version
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 112
diff changeset
261 widget->setTitle(args->label);
e57ca2747782 fix build with newest toolkit version
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 112
diff changeset
262 }
e57ca2747782 fix build with newest toolkit version
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 112
diff changeset
263
e57ca2747782 fix build with newest toolkit version
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 112
diff changeset
264 switch(args->subcontainer) {
e57ca2747782 fix build with newest toolkit version
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 112
diff changeset
265 default: break;
e57ca2747782 fix build with newest toolkit version
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 112
diff changeset
266 case UI_CONTAINER_HBOX: {
e57ca2747782 fix build with newest toolkit version
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 112
diff changeset
267 dir = QBoxLayout::LeftToRight;
e57ca2747782 fix build with newest toolkit version
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 112
diff changeset
268 break;
e57ca2747782 fix build with newest toolkit version
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 112
diff changeset
269 }
e57ca2747782 fix build with newest toolkit version
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 112
diff changeset
270 case UI_CONTAINER_GRID: {
e57ca2747782 fix build with newest toolkit version
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 112
diff changeset
271 createBox = false;
e57ca2747782 fix build with newest toolkit version
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 112
diff changeset
272 break;
e57ca2747782 fix build with newest toolkit version
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 112
diff changeset
273 }
e57ca2747782 fix build with newest toolkit version
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 112
diff changeset
274 case UI_CONTAINER_NO_SUB: {
e57ca2747782 fix build with newest toolkit version
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 112
diff changeset
275 singleChild = true;
e57ca2747782 fix build with newest toolkit version
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 112
diff changeset
276 }
e57ca2747782 fix build with newest toolkit version
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 112
diff changeset
277 }
e57ca2747782 fix build with newest toolkit version
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 112
diff changeset
278
e57ca2747782 fix build with newest toolkit version
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 112
diff changeset
279 if(createBox) {
e57ca2747782 fix build with newest toolkit version
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 112
diff changeset
280 QBoxLayout *box = new QBoxLayout(dir);
e57ca2747782 fix build with newest toolkit version
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 112
diff changeset
281 widget->setLayout(box);
e57ca2747782 fix build with newest toolkit version
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 112
diff changeset
282
e57ca2747782 fix build with newest toolkit version
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 112
diff changeset
283 UiBoxContainer *container = new UiBoxContainer(box);
e57ca2747782 fix build with newest toolkit version
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 112
diff changeset
284 ui_obj_add_container(obj, container);
e57ca2747782 fix build with newest toolkit version
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 112
diff changeset
285
e57ca2747782 fix build with newest toolkit version
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 112
diff changeset
286 container->singleChild = singleChild;
e57ca2747782 fix build with newest toolkit version
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 112
diff changeset
287 } else {
e57ca2747782 fix build with newest toolkit version
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 112
diff changeset
288 QGridLayout *grid = new QGridLayout();
e57ca2747782 fix build with newest toolkit version
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 112
diff changeset
289 widget->setLayout(grid);
e57ca2747782 fix build with newest toolkit version
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 112
diff changeset
290
e57ca2747782 fix build with newest toolkit version
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 112
diff changeset
291 ui_obj_add_container(obj, new UiGridContainer(
e57ca2747782 fix build with newest toolkit version
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 112
diff changeset
292 grid,
e57ca2747782 fix build with newest toolkit version
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 112
diff changeset
293 args->padding,
e57ca2747782 fix build with newest toolkit version
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 112
diff changeset
294 args->columnspacing,
e57ca2747782 fix build with newest toolkit version
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 112
diff changeset
295 args->rowspacing,
e57ca2747782 fix build with newest toolkit version
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 112
diff changeset
296 false,
e57ca2747782 fix build with newest toolkit version
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 112
diff changeset
297 false,
e57ca2747782 fix build with newest toolkit version
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 112
diff changeset
298 false,
e57ca2747782 fix build with newest toolkit version
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 112
diff changeset
299 false));
e57ca2747782 fix build with newest toolkit version
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 112
diff changeset
300 }
e57ca2747782 fix build with newest toolkit version
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 112
diff changeset
301
e57ca2747782 fix build with newest toolkit version
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 112
diff changeset
302
e57ca2747782 fix build with newest toolkit version
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 112
diff changeset
303 ctn->add(widget, layout);
e57ca2747782 fix build with newest toolkit version
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 112
diff changeset
304
e57ca2747782 fix build with newest toolkit version
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 112
diff changeset
305 return widget;
e57ca2747782 fix build with newest toolkit version
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 112
diff changeset
306 }
e57ca2747782 fix build with newest toolkit version
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 112
diff changeset
307
109
c3dfcb8f0be7 update toolkit, remove getvalue func from model to table/listview args
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 108
diff changeset
308 /* ---------------------------- UiSidebar ---------------------------- */
c3dfcb8f0be7 update toolkit, remove getvalue func from model to table/listview args
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 108
diff changeset
309
c3dfcb8f0be7 update toolkit, remove getvalue func from model to table/listview args
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 108
diff changeset
310 UIWIDGET ui_sidebar_create(UiObject *obj, UiSidebarArgs *args) {
c3dfcb8f0be7 update toolkit, remove getvalue func from model to table/listview args
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 108
diff changeset
311 QVariant v = obj->widget->property("ui_sidebar");
c3dfcb8f0be7 update toolkit, remove getvalue func from model to table/listview args
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 108
diff changeset
312 QDockWidget *dock = (QDockWidget*)v.value<void*>();
c3dfcb8f0be7 update toolkit, remove getvalue func from model to table/listview args
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 108
diff changeset
313 if(!dock) {
c3dfcb8f0be7 update toolkit, remove getvalue func from model to table/listview args
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 108
diff changeset
314 fprintf(stderr, "Error: window is not configured for sidebar\n");
c3dfcb8f0be7 update toolkit, remove getvalue func from model to table/listview args
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 108
diff changeset
315 return nullptr;
c3dfcb8f0be7 update toolkit, remove getvalue func from model to table/listview args
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 108
diff changeset
316 }
c3dfcb8f0be7 update toolkit, remove getvalue func from model to table/listview args
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 108
diff changeset
317
c3dfcb8f0be7 update toolkit, remove getvalue func from model to table/listview args
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 108
diff changeset
318 QWidget *widget = new QWidget();
c3dfcb8f0be7 update toolkit, remove getvalue func from model to table/listview args
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 108
diff changeset
319 QBoxLayout *box = new QBoxLayout(QBoxLayout::TopToBottom);
c3dfcb8f0be7 update toolkit, remove getvalue func from model to table/listview args
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 108
diff changeset
320 widget->setLayout(box);
c3dfcb8f0be7 update toolkit, remove getvalue func from model to table/listview args
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 108
diff changeset
321 dock->setWidget(widget);
c3dfcb8f0be7 update toolkit, remove getvalue func from model to table/listview args
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 108
diff changeset
322
112
c3f2f16fa4b8 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 109
diff changeset
323 ui_obj_add_container(obj, new UiBoxContainer(box));
109
c3dfcb8f0be7 update toolkit, remove getvalue func from model to table/listview args
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 108
diff changeset
324
c3dfcb8f0be7 update toolkit, remove getvalue func from model to table/listview args
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 108
diff changeset
325 return dock;
c3dfcb8f0be7 update toolkit, remove getvalue func from model to table/listview args
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 108
diff changeset
326 }
0
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
327
103
6606616eca9f update uwproj, toolkit, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
328 /* -------------------- Container Helper Functions -------------------- */
0
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
329
103
6606616eca9f update uwproj, toolkit, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
330 void ui_container_begin_close(UiObject *obj) {
6606616eca9f update uwproj, toolkit, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
331 obj->container_end->close = true;
0
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
332 }
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
333
103
6606616eca9f update uwproj, toolkit, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
334 int ui_container_finish(UiObject *obj) {
6606616eca9f update uwproj, toolkit, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
335 if(obj->container_end->close) {
6606616eca9f update uwproj, toolkit, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
336 UiContainerPrivate *ctn = (UiContainerPrivate*)obj->container_end->container;
6606616eca9f update uwproj, toolkit, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
337 ctn->end();
6606616eca9f update uwproj, toolkit, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
338 ui_end_new(obj);
6606616eca9f update uwproj, toolkit, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
339 return 0;
6606616eca9f update uwproj, toolkit, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
340 }
6606616eca9f update uwproj, toolkit, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
341 return 1;
0
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
342 }
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
343

mercurial