Fri, 11 Dec 2020 18:32:54 +0100
add sqlite dependency
0
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
1 | /* |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
3 | * |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
4 | * Copyright 2014 Olaf Wintermann. All rights reserved. |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
5 | * |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
6 | * Redistribution and use in source and binary forms, with or without |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
7 | * modification, are permitted provided that the following conditions are met: |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
8 | * |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
9 | * 1. Redistributions of source code must retain the above copyright |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
10 | * notice, this list of conditions and the following disclaimer. |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
11 | * |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
12 | * 2. Redistributions in binary form must reproduce the above copyright |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
13 | * notice, this list of conditions and the following disclaimer in the |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
14 | * documentation and/or other materials provided with the distribution. |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
15 | * |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
804d8803eade
add existing toolkit source
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 |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
26 | * POSSIBILITY OF SUCH DAMAGE. |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
27 | */ |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
28 | |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
29 | #include <stdio.h> |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
30 | #include "container.h" |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
31 | |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
32 | #include <QSpacerItem> |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
33 | #include <QStackedWidget> |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
34 | |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
35 | |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
36 | /* -------------------- UiBoxContainer -------------------- */ |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
37 | |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
38 | UiBoxContainer::UiBoxContainer(QBoxLayout* box) { |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
39 | this->current = NULL; |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
40 | this->menu = NULL; |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
41 | this->box = box; |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
42 | box->setContentsMargins(QMargins(0,0,0,0)); |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
43 | box->setSpacing(0); |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
44 | |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
45 | ui_reset_layout(layout); |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
46 | } |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
47 | |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
48 | void UiBoxContainer::add(QWidget* widget, bool fill) { |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
49 | if(layout.fill != UI_LAYOUT_UNDEFINED) { |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
50 | fill = ui_lb2bool(layout.fill); |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
51 | } |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
52 | |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
53 | if(hasStretchedWidget && fill) { |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
54 | fill = false; |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
55 | fprintf(stderr, "UiError: container has 2 filled widgets"); |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
56 | } |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
57 | |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
58 | box->addWidget(widget, fill); |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
59 | |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
60 | if(!hasStretchedWidget) { |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
61 | QSpacerItem *newspace = new QSpacerItem(0, 0, QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding); |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
62 | box->removeItem(space); |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
63 | box->addSpacerItem(newspace); |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
64 | space = newspace; |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
65 | } |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
66 | |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
67 | if(fill) { |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
68 | hasStretchedWidget = true; |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
69 | } |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
70 | ui_reset_layout(layout); |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
71 | current = widget; |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
72 | } |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
73 | |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
74 | UIWIDGET ui_box(UiObject *obj, QBoxLayout::Direction dir) { |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
75 | UiContainer *ct = uic_get_current_container(obj); |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
76 | QWidget *widget = new QWidget(); |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
77 | QBoxLayout *box = new QBoxLayout(dir); |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
78 | widget->setLayout(box); |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
79 | ct->add(widget, true); |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
80 | |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
81 | UiObject *newobj = uic_object_new(obj, widget); |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
82 | newobj->container = new UiBoxContainer(box); |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
83 | uic_obj_add(obj, newobj); |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
84 | |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
85 | return widget; |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
86 | } |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
87 | |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
88 | UIWIDGET ui_vbox(UiObject *obj) { |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
89 | return ui_box(obj, QBoxLayout::TopToBottom); |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
90 | } |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
91 | |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
92 | UIWIDGET ui_hbox(UiObject *obj) { |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
93 | return ui_box(obj, QBoxLayout::LeftToRight); |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
94 | } |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
95 | |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
96 | |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
97 | |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
98 | /* -------------------- UiGridContainer -------------------- */ |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
99 | |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
100 | UiGridContainer::UiGridContainer(QGridLayout* grid, int margin, int columnspacing, int rowspacing) { |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
101 | this->current = NULL; |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
102 | this->menu = NULL; |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
103 | this->grid = grid; |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
104 | grid->setContentsMargins(QMargins(margin, margin, margin, margin)); |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
105 | grid->setHorizontalSpacing(columnspacing); |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
106 | grid->setVerticalSpacing(rowspacing); |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
107 | ui_reset_layout(layout); |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
108 | } |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
109 | |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
110 | void UiGridContainer::add(QWidget* widget, bool fill) { |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
111 | if(layout.newline) { |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
112 | x = 0; |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
113 | y++; |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
114 | } |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
115 | |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
116 | Qt::Alignment alignment = Qt::AlignTop; |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
117 | grid->setColumnStretch(x, layout.hexpand ? 1 : 0); |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
118 | if(layout.vexpand) { |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
119 | grid->setRowStretch(y, 1); |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
120 | alignment = 0; |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
121 | } else { |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
122 | grid->setRowStretch(y, 0); |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
123 | } |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
124 | |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
125 | int gwidth = layout.gridwidth > 0 ? layout.gridwidth : 1; |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
126 | |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
127 | grid->addWidget(widget, y, x, 1, gwidth, alignment); |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
128 | x += gwidth; |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
129 | |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
130 | ui_reset_layout(layout); |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
131 | current = widget; |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
132 | } |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
133 | |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
134 | UIWIDGET ui_grid(UiObject *obj) { |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
135 | return ui_grid_sp(obj, 0, 0, 0); |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
136 | } |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
137 | |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
138 | UIWIDGET ui_grid_sp(UiObject *obj, int margin, int columnspacing, int rowspacing) { |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
139 | UiContainer *ct = uic_get_current_container(obj); |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
140 | QWidget *widget = new QWidget(); |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
141 | QGridLayout *grid = new QGridLayout(); |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
142 | widget->setLayout(grid); |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
143 | ct->add(widget, true); |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
144 | |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
145 | UiObject *newobj = uic_object_new(obj, widget); |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
146 | newobj->container = new UiGridContainer(grid, margin, columnspacing, rowspacing); |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
147 | uic_obj_add(obj, newobj); |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
148 | |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
149 | return widget; |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
150 | } |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
151 | |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
152 | |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
153 | /* -------------------- UiTabViewContainer -------------------- */ |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
154 | |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
155 | UiTabViewContainer::UiTabViewContainer(QTabWidget* tabwidget) { |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
156 | this->current = NULL; |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
157 | this->menu = NULL; |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
158 | this->tabwidget = tabwidget; |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
159 | } |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
160 | |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
161 | void UiTabViewContainer::add(QWidget* widget, bool fill) { |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
162 | QString str = QString::fromUtf8(layout.label); |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
163 | tabwidget->addTab(widget, str); |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
164 | } |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
165 | |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
166 | |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
167 | /* -------------------- UiStackContainer -------------------- */ |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
168 | |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
169 | UiStackContainer::UiStackContainer(QStackedWidget *stack) { |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
170 | this->stack = stack; |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
171 | } |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
172 | |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
173 | void UiStackContainer::add(QWidget* widget, bool fill) { |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
174 | stack->addWidget(widget); |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
175 | current = widget; |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
176 | } |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
177 | |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
178 | UIWIDGET ui_tabview(UiObject *obj) { |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
179 | QStackedWidget *tabwidget = new QStackedWidget(); |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
180 | |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
181 | UiContainer *ct = uic_get_current_container(obj); |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
182 | ct->add(tabwidget, true); |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
183 | |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
184 | UiObject *tabviewobj = uic_object_new(obj, tabwidget); |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
185 | tabviewobj->container = new UiStackContainer(tabwidget); |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
186 | uic_obj_add(obj, tabviewobj); |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
187 | |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
188 | return tabwidget; |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
189 | } |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
190 | |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
191 | void ui_tab(UiObject *obj, char *title) { |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
192 | UiContainer *ct = uic_get_current_container(obj); |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
193 | ct->layout.label = title; |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
194 | ui_vbox(obj); |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
195 | } |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
196 | |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
197 | void ui_select_tab(UIWIDGET tabview, int tab) { |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
198 | QStackedWidget *w = (QStackedWidget*)tabview; |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
199 | w->setCurrentIndex(tab); |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
200 | } |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
201 | |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
202 | |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
203 | /* -------------------- UiSidebarContainer -------------------- */ |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
204 | |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
205 | UiSidebarContainer::UiSidebarContainer(QSplitter *splitter) { |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
206 | this->splitter = splitter; |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
207 | } |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
208 | |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
209 | UIWIDGET ui_sidebar(UiObject *obj) { |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
210 | QSplitter *splitter = new QSplitter(Qt::Horizontal); |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
211 | UiContainer *ct = uic_get_current_container(obj); |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
212 | ct->add(splitter, true); |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
213 | |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
214 | UiObject *left = uic_object_new(obj, splitter); |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
215 | left->container = new UiSidebarContainer(splitter); |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
216 | |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
217 | UiObject *right = uic_object_new(obj, splitter); |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
218 | right->container = new UiSidebarContainer(splitter); |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
219 | |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
220 | uic_obj_add(obj, right); |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
221 | uic_obj_add(obj, left); |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
222 | |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
223 | return splitter; |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
224 | } |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
225 | |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
226 | void UiSidebarContainer::add(QWidget *widget, bool fill) { |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
227 | splitter->addWidget(widget); |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
228 | } |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
229 | |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
230 | |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
231 | /* -------------------- layout functions -------------------- */ |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
232 | |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
233 | void ui_layout_fill(UiObject *obj, UiBool fill) { |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
234 | UiContainer *ct = uic_get_current_container(obj); |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
235 | ct->layout.fill = ui_bool2lb(fill); |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
236 | } |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
237 | |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
238 | void ui_layout_hexpand(UiObject *obj, UiBool expand) { |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
239 | UiContainer *ct = uic_get_current_container(obj); |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
240 | ct->layout.hexpand = expand; |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
241 | } |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
242 | |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
243 | void ui_layout_vexpand(UiObject *obj, UiBool expand) { |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
244 | UiContainer *ct = uic_get_current_container(obj); |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
245 | ct->layout.vexpand = expand; |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
246 | } |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
247 | |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
248 | void ui_layout_gridwidth(UiObject *obj, int width) { |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
249 | UiContainer *ct = uic_get_current_container(obj); |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
250 | ct->layout.gridwidth = width; |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
251 | } |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
252 | |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
253 | void ui_newline(UiObject *obj) { |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
254 | UiContainer *ct = uic_get_current_container(obj); |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
255 | ct->layout.newline = TRUE; |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
256 | } |