ui/gtk/container.c

Sun, 22 Sep 2024 16:39:10 +0200

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Sun, 22 Sep 2024 16:39:10 +0200
branch
newapi
changeset 302
b00cbbfeec7a
parent 298
c5e207d01ff2
child 303
dc8b504604f4
permissions
-rw-r--r--

add libadwaita toolkit option

4
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1 /*
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
3 *
140
c03c338a7dcf refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 121
diff changeset
4 * Copyright 2017 Olaf Wintermann. All rights reserved.
4
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
5 *
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
6 * Redistribution and use in source and binary forms, with or without
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
7 * modification, are permitted provided that the following conditions are met:
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
8 *
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
9 * 1. Redistributions of source code must retain the above copyright
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
10 * notice, this list of conditions and the following disclaimer.
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
11 *
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
12 * 2. Redistributions in binary form must reproduce the above copyright
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
13 * notice, this list of conditions and the following disclaimer in the
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
14 * documentation and/or other materials provided with the distribution.
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
15 *
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
39b9b86ec452 added simple container
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
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
26 * POSSIBILITY OF SUCH DAMAGE.
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
27 */
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
28
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
29 #include <stdio.h>
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
30 #include <stdlib.h>
165
3f32db79a76e add splitpane (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 163
diff changeset
31 #include <limits.h>
4
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
32
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
33 #include "container.h"
165
3f32db79a76e add splitpane (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 163
diff changeset
34 #include "toolkit.h"
3f32db79a76e add splitpane (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 163
diff changeset
35
4
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
36 #include "../common/context.h"
33
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
37 #include "../common/object.h"
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
38
166
6e48030cf2db add container macros (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 165
diff changeset
39
6e48030cf2db add container macros (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 165
diff changeset
40 void ui_container_begin_close(UiObject *obj) {
6e48030cf2db add container macros (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 165
diff changeset
41 UiContainer *ct = uic_get_current_container(obj);
6e48030cf2db add container macros (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 165
diff changeset
42 ct->close = 1;
6e48030cf2db add container macros (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 165
diff changeset
43 }
6e48030cf2db add container macros (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 165
diff changeset
44
6e48030cf2db add container macros (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 165
diff changeset
45 int ui_container_finish(UiObject *obj) {
6e48030cf2db add container macros (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 165
diff changeset
46 UiContainer *ct = uic_get_current_container(obj);
6e48030cf2db add container macros (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 165
diff changeset
47 if(ct->close) {
6e48030cf2db add container macros (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 165
diff changeset
48 ui_end(obj);
6e48030cf2db add container macros (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 165
diff changeset
49 return 0;
6e48030cf2db add container macros (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 165
diff changeset
50 }
6e48030cf2db add container macros (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 165
diff changeset
51 return 1;
6e48030cf2db add container macros (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 165
diff changeset
52 }
6e48030cf2db add container macros (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 165
diff changeset
53
107
9aff1dc3990d improved box container and added radio button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 100
diff changeset
54 GtkWidget* ui_gtk_vbox_new(int spacing) {
297
a73c60adf188 port container to gtk4
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 273
diff changeset
55 #if GTK_MAJOR_VERSION >= 3
107
9aff1dc3990d improved box container and added radio button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 100
diff changeset
56 return gtk_box_new(GTK_ORIENTATION_VERTICAL, spacing);
59
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
57 #else
107
9aff1dc3990d improved box container and added radio button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 100
diff changeset
58 return gtk_vbox_new(FALSE, spacing);
59
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
59 #endif
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
60 }
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
61
107
9aff1dc3990d improved box container and added radio button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 100
diff changeset
62 GtkWidget* ui_gtk_hbox_new(int spacing) {
297
a73c60adf188 port container to gtk4
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 273
diff changeset
63 #if GTK_MAJOR_VERSION >= 3
107
9aff1dc3990d improved box container and added radio button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 100
diff changeset
64 return gtk_box_new(GTK_ORIENTATION_HORIZONTAL, spacing);
59
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
65 #else
107
9aff1dc3990d improved box container and added radio button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 100
diff changeset
66 return gtk_hbox_new(FALSE, spacing);
59
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
67 #endif
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
68 }
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
69
33
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
70
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
71
59
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
72 /* -------------------- Box Container -------------------- */
297
a73c60adf188 port container to gtk4
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 273
diff changeset
73 UiContainer* ui_box_container(UiObject *obj, GtkWidget *box, UiSubContainerType type) {
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 166
diff changeset
74 UiBoxContainer *ct = cxCalloc(
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 166
diff changeset
75 obj->ctx->allocator,
59
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
76 1,
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
77 sizeof(UiBoxContainer));
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
78 ct->container.widget = box;
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
79 ct->container.add = ui_box_container_add;
297
a73c60adf188 port container to gtk4
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 273
diff changeset
80 ct->type = type;
59
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
81 return (UiContainer*)ct;
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
82 }
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
83
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
84 void ui_box_container_add(UiContainer *ct, GtkWidget *widget, UiBool fill) {
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
85 UiBoxContainer *bc = (UiBoxContainer*)ct;
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
86 if(ct->layout.fill != UI_LAYOUT_UNDEFINED) {
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
87 fill = ui_lb2bool(ct->layout.fill);
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
88 }
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
89
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
90 if(bc->has_fill && fill) {
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
91 fprintf(stderr, "UiError: container has 2 filled widgets");
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
92 fill = FALSE;
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
93 }
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
94 if(fill) {
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
95 bc->has_fill = TRUE;
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
96 }
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
97
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
98 UiBool expand = fill;
297
a73c60adf188 port container to gtk4
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 273
diff changeset
99 #if GTK_MAJOR_VERSION >= 4
a73c60adf188 port container to gtk4
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 273
diff changeset
100 gtk_box_append(GTK_BOX(ct->widget), widget);
a73c60adf188 port container to gtk4
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 273
diff changeset
101 GtkAlign align = expand ? GTK_ALIGN_FILL : GTK_ALIGN_START;
a73c60adf188 port container to gtk4
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 273
diff changeset
102 if(bc->type == UI_CONTAINER_VBOX) {
a73c60adf188 port container to gtk4
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 273
diff changeset
103 gtk_widget_set_valign(widget, align);
a73c60adf188 port container to gtk4
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 273
diff changeset
104 gtk_widget_set_vexpand(widget, expand);
a73c60adf188 port container to gtk4
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 273
diff changeset
105 gtk_widget_set_hexpand(widget, TRUE);
a73c60adf188 port container to gtk4
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 273
diff changeset
106 } else if(bc->type == UI_CONTAINER_HBOX) {
a73c60adf188 port container to gtk4
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 273
diff changeset
107 gtk_widget_set_halign(widget, align);
a73c60adf188 port container to gtk4
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 273
diff changeset
108 gtk_widget_set_hexpand(widget, expand);
a73c60adf188 port container to gtk4
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 273
diff changeset
109 gtk_widget_set_vexpand(widget, TRUE);
a73c60adf188 port container to gtk4
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 273
diff changeset
110 }
a73c60adf188 port container to gtk4
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 273
diff changeset
111
a73c60adf188 port container to gtk4
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 273
diff changeset
112 #else
59
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
113 gtk_box_pack_start(GTK_BOX(ct->widget), widget, expand, fill, 0);
297
a73c60adf188 port container to gtk4
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 273
diff changeset
114 #endif
59
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
115
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
116 ui_reset_layout(ct->layout);
75
efe2f65bea17 added context menus (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 74
diff changeset
117 ct->current = widget;
59
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
118 }
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
119
65
4697592e24ba added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 62
diff changeset
120 UiContainer* ui_grid_container(UiObject *obj, GtkWidget *grid) {
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 166
diff changeset
121 UiGridContainer *ct = cxCalloc(
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 166
diff changeset
122 obj->ctx->allocator,
65
4697592e24ba added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 62
diff changeset
123 1,
4697592e24ba added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 62
diff changeset
124 sizeof(UiGridContainer));
4697592e24ba added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 62
diff changeset
125 ct->container.widget = grid;
4697592e24ba added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 62
diff changeset
126 ct->container.add = ui_grid_container_add;
74
55718d4ed227 fixed grid container when using gtk2
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 66
diff changeset
127 #ifdef UI_GTK2
55718d4ed227 fixed grid container when using gtk2
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 66
diff changeset
128 ct->width = 0;
55718d4ed227 fixed grid container when using gtk2
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 66
diff changeset
129 ct->height = 1;
55718d4ed227 fixed grid container when using gtk2
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 66
diff changeset
130 #endif
65
4697592e24ba added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 62
diff changeset
131 return (UiContainer*)ct;
4697592e24ba added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 62
diff changeset
132 }
4697592e24ba added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 62
diff changeset
133
297
a73c60adf188 port container to gtk4
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 273
diff changeset
134 #if GTK_MAJOR_VERSION >= 3
65
4697592e24ba added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 62
diff changeset
135 void ui_grid_container_add(UiContainer *ct, GtkWidget *widget, UiBool fill) {
4697592e24ba added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 62
diff changeset
136 UiGridContainer *grid = (UiGridContainer*)ct;
4697592e24ba added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 62
diff changeset
137
4697592e24ba added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 62
diff changeset
138 if(ct->layout.newline) {
4697592e24ba added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 62
diff changeset
139 grid->x = 0;
4697592e24ba added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 62
diff changeset
140 grid->y++;
4697592e24ba added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 62
diff changeset
141 ct->layout.newline = FALSE;
4697592e24ba added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 62
diff changeset
142 }
4697592e24ba added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 62
diff changeset
143
99
ea1a2d5de765 improved grid container (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 94
diff changeset
144 int hexpand = FALSE;
ea1a2d5de765 improved grid container (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 94
diff changeset
145 int vexpand = FALSE;
ea1a2d5de765 improved grid container (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 94
diff changeset
146 if(ct->layout.hexpand != UI_LAYOUT_UNDEFINED) {
ea1a2d5de765 improved grid container (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 94
diff changeset
147 hexpand = ct->layout.hexpand;
94
d51e334c1439 added checkbox and labels with alignment (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 75
diff changeset
148 }
99
ea1a2d5de765 improved grid container (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 94
diff changeset
149 if(ct->layout.vexpand != UI_LAYOUT_UNDEFINED) {
ea1a2d5de765 improved grid container (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 94
diff changeset
150 vexpand = ct->layout.vexpand;
ea1a2d5de765 improved grid container (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 94
diff changeset
151 }
ea1a2d5de765 improved grid container (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 94
diff changeset
152
ea1a2d5de765 improved grid container (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 94
diff changeset
153 if(hexpand) {
94
d51e334c1439 added checkbox and labels with alignment (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 75
diff changeset
154 gtk_widget_set_hexpand(widget, TRUE);
d51e334c1439 added checkbox and labels with alignment (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 75
diff changeset
155 }
99
ea1a2d5de765 improved grid container (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 94
diff changeset
156 if(vexpand) {
ea1a2d5de765 improved grid container (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 94
diff changeset
157 gtk_widget_set_vexpand(widget, TRUE);
ea1a2d5de765 improved grid container (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 94
diff changeset
158 }
94
d51e334c1439 added checkbox and labels with alignment (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 75
diff changeset
159
260
eebb0626d020 implement grid colspan/rowspan (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 253
diff changeset
160 int colspan = ct->layout.colspan > 0 ? ct->layout.colspan : 1;
eebb0626d020 implement grid colspan/rowspan (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 253
diff changeset
161 int rowspan = ct->layout.rowspan > 0 ? ct->layout.rowspan : 1;
109
b9808f916687 added gridwidth layout option (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
162
260
eebb0626d020 implement grid colspan/rowspan (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 253
diff changeset
163 gtk_grid_attach(GTK_GRID(ct->widget), widget, grid->x, grid->y, colspan, rowspan);
eebb0626d020 implement grid colspan/rowspan (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 253
diff changeset
164 grid->x += colspan;
65
4697592e24ba added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 62
diff changeset
165
4697592e24ba added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 62
diff changeset
166 ui_reset_layout(ct->layout);
75
efe2f65bea17 added context menus (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 74
diff changeset
167 ct->current = widget;
65
4697592e24ba added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 62
diff changeset
168 }
74
55718d4ed227 fixed grid container when using gtk2
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 66
diff changeset
169 #endif
55718d4ed227 fixed grid container when using gtk2
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 66
diff changeset
170 #ifdef UI_GTK2
55718d4ed227 fixed grid container when using gtk2
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 66
diff changeset
171 void ui_grid_container_add(UiContainer *ct, GtkWidget *widget, UiBool fill) {
55718d4ed227 fixed grid container when using gtk2
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 66
diff changeset
172 UiGridContainer *grid = (UiGridContainer*)ct;
55718d4ed227 fixed grid container when using gtk2
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 66
diff changeset
173
55718d4ed227 fixed grid container when using gtk2
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 66
diff changeset
174 if(ct->layout.newline) {
55718d4ed227 fixed grid container when using gtk2
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 66
diff changeset
175 grid->x = 0;
55718d4ed227 fixed grid container when using gtk2
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 66
diff changeset
176 grid->y++;
55718d4ed227 fixed grid container when using gtk2
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 66
diff changeset
177 ct->layout.newline = FALSE;
55718d4ed227 fixed grid container when using gtk2
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 66
diff changeset
178 }
55718d4ed227 fixed grid container when using gtk2
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 66
diff changeset
179
100
d276306d801f improved gtk2 implementation of grid container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 99
diff changeset
180 int hexpand = FALSE;
d276306d801f improved gtk2 implementation of grid container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 99
diff changeset
181 int vexpand = FALSE;
d276306d801f improved gtk2 implementation of grid container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 99
diff changeset
182 if(ct->layout.hexpand != UI_LAYOUT_UNDEFINED) {
d276306d801f improved gtk2 implementation of grid container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 99
diff changeset
183 hexpand = ct->layout.hexpand;
d276306d801f improved gtk2 implementation of grid container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 99
diff changeset
184 }
d276306d801f improved gtk2 implementation of grid container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 99
diff changeset
185 if(ct->layout.vexpand != UI_LAYOUT_UNDEFINED) {
d276306d801f improved gtk2 implementation of grid container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 99
diff changeset
186 vexpand = ct->layout.vexpand;
d276306d801f improved gtk2 implementation of grid container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 99
diff changeset
187 }
d276306d801f improved gtk2 implementation of grid container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 99
diff changeset
188 GtkAttachOptions xoptions = hexpand ? GTK_FILL | GTK_EXPAND : GTK_FILL;
d276306d801f improved gtk2 implementation of grid container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 99
diff changeset
189 GtkAttachOptions yoptions = vexpand ? GTK_FILL | GTK_EXPAND : GTK_FILL;
d276306d801f improved gtk2 implementation of grid container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 99
diff changeset
190
260
eebb0626d020 implement grid colspan/rowspan (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 253
diff changeset
191 int colspan = ct->layout.colspan > 0 ? ct->layout.colspan : 1;
eebb0626d020 implement grid colspan/rowspan (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 253
diff changeset
192 int rowspan = ct->layout.rowspan > 0 ? ct->layout.rowspan : 1;
eebb0626d020 implement grid colspan/rowspan (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 253
diff changeset
193 // TODO: use colspan/rowspan
eebb0626d020 implement grid colspan/rowspan (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 253
diff changeset
194
100
d276306d801f improved gtk2 implementation of grid container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 99
diff changeset
195 gtk_table_attach(GTK_TABLE(ct->widget), widget, grid->x, grid->x+1, grid->y, grid->y+1, xoptions, yoptions, 0, 0);
74
55718d4ed227 fixed grid container when using gtk2
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 66
diff changeset
196 grid->x++;
55718d4ed227 fixed grid container when using gtk2
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 66
diff changeset
197 int nw = grid->x > grid->width ? grid->x : grid->width;
55718d4ed227 fixed grid container when using gtk2
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 66
diff changeset
198 if(grid->x > grid->width || grid->y > grid->height) {
55718d4ed227 fixed grid container when using gtk2
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 66
diff changeset
199 grid->width = nw;
55718d4ed227 fixed grid container when using gtk2
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 66
diff changeset
200 grid->height = grid->y + 1;
55718d4ed227 fixed grid container when using gtk2
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 66
diff changeset
201 gtk_table_resize(GTK_TABLE(ct->widget), grid->width, grid->height);
55718d4ed227 fixed grid container when using gtk2
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 66
diff changeset
202 }
75
efe2f65bea17 added context menus (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 74
diff changeset
203
efe2f65bea17 added context menus (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 74
diff changeset
204 ui_reset_layout(ct->layout);
efe2f65bea17 added context menus (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 74
diff changeset
205 ct->current = widget;
74
55718d4ed227 fixed grid container when using gtk2
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 66
diff changeset
206 }
55718d4ed227 fixed grid container when using gtk2
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 66
diff changeset
207 #endif
65
4697592e24ba added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 62
diff changeset
208
120
49bc645df8b7 added scrolledwindow (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
209 UiContainer* ui_scrolledwindow_container(UiObject *obj, GtkWidget *scrolledwindow) {
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 166
diff changeset
210 UiContainer *ct = cxCalloc(
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 166
diff changeset
211 obj->ctx->allocator,
120
49bc645df8b7 added scrolledwindow (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
212 1,
49bc645df8b7 added scrolledwindow (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
213 sizeof(UiContainer));
49bc645df8b7 added scrolledwindow (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
214 ct->widget = scrolledwindow;
49bc645df8b7 added scrolledwindow (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
215 ct->add = ui_scrolledwindow_container_add;
49bc645df8b7 added scrolledwindow (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
216 return ct;
49bc645df8b7 added scrolledwindow (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
217 }
49bc645df8b7 added scrolledwindow (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
218
49bc645df8b7 added scrolledwindow (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
219 void ui_scrolledwindow_container_add(UiContainer *ct, GtkWidget *widget, UiBool fill) {
121
1cc365c34125 added some special textfields (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 120
diff changeset
220 // TODO: check if the widget implements GtkScrollable
297
a73c60adf188 port container to gtk4
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 273
diff changeset
221 #ifdef UI_GTK4
a73c60adf188 port container to gtk4
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 273
diff changeset
222 gtk_scrolled_window_set_child(GTK_SCROLLED_WINDOW(ct->widget), widget);
a73c60adf188 port container to gtk4
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 273
diff changeset
223 #elif defined(UI_GTK3)
120
49bc645df8b7 added scrolledwindow (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
224 gtk_container_add(GTK_CONTAINER(ct->widget), widget);
121
1cc365c34125 added some special textfields (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 120
diff changeset
225 #else
1cc365c34125 added some special textfields (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 120
diff changeset
226 gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(ct->widget), widget);
1cc365c34125 added some special textfields (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 120
diff changeset
227 #endif
120
49bc645df8b7 added scrolledwindow (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
228 ui_reset_layout(ct->layout);
49bc645df8b7 added scrolledwindow (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
229 ct->current = widget;
49bc645df8b7 added scrolledwindow (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
230 }
49bc645df8b7 added scrolledwindow (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
231
65
4697592e24ba added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 62
diff changeset
232 UiContainer* ui_tabview_container(UiObject *obj, GtkWidget *tabview) {
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 166
diff changeset
233 UiTabViewContainer *ct = cxCalloc(
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 166
diff changeset
234 obj->ctx->allocator,
65
4697592e24ba added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 62
diff changeset
235 1,
4697592e24ba added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 62
diff changeset
236 sizeof(UiTabViewContainer));
4697592e24ba added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 62
diff changeset
237 ct->container.widget = tabview;
4697592e24ba added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 62
diff changeset
238 ct->container.add = ui_tabview_container_add;
4697592e24ba added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 62
diff changeset
239 return (UiContainer*)ct;
4697592e24ba added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 62
diff changeset
240 }
4697592e24ba added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 62
diff changeset
241
4697592e24ba added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 62
diff changeset
242 void ui_tabview_container_add(UiContainer *ct, GtkWidget *widget, UiBool fill) {
4697592e24ba added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 62
diff changeset
243 gtk_notebook_append_page(
4697592e24ba added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 62
diff changeset
244 GTK_NOTEBOOK(ct->widget),
4697592e24ba added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 62
diff changeset
245 widget,
4697592e24ba added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 62
diff changeset
246 gtk_label_new(ct->layout.label));
75
efe2f65bea17 added context menus (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 74
diff changeset
247
efe2f65bea17 added context menus (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 74
diff changeset
248 ui_reset_layout(ct->layout);
efe2f65bea17 added context menus (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 74
diff changeset
249 ct->current = widget;
65
4697592e24ba added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 62
diff changeset
250 }
4697592e24ba added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 62
diff changeset
251
4697592e24ba added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 62
diff changeset
252
107
9aff1dc3990d improved box container and added radio button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 100
diff changeset
253
9aff1dc3990d improved box container and added radio button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 100
diff changeset
254 static GtkWidget* box_set_margin(GtkWidget *box, int margin) {
9aff1dc3990d improved box container and added radio button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 100
diff changeset
255 GtkWidget *ret = box;
9aff1dc3990d improved box container and added radio button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 100
diff changeset
256 #ifdef UI_GTK3
9aff1dc3990d improved box container and added radio button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 100
diff changeset
257 #if GTK_MAJOR_VERSION == 3 && GTK_MINOR_VERSION >= 12
9aff1dc3990d improved box container and added radio button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 100
diff changeset
258 gtk_widget_set_margin_start(box, margin);
9aff1dc3990d improved box container and added radio button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 100
diff changeset
259 gtk_widget_set_margin_end(box, margin);
9aff1dc3990d improved box container and added radio button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 100
diff changeset
260 #else
9aff1dc3990d improved box container and added radio button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 100
diff changeset
261 gtk_widget_set_margin_left(box, margin);
9aff1dc3990d improved box container and added radio button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 100
diff changeset
262 gtk_widget_set_margin_right(box, margin);
9aff1dc3990d improved box container and added radio button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 100
diff changeset
263 #endif
9aff1dc3990d improved box container and added radio button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 100
diff changeset
264 gtk_widget_set_margin_top(box, margin);
9aff1dc3990d improved box container and added radio button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 100
diff changeset
265 gtk_widget_set_margin_bottom(box, margin);
9aff1dc3990d improved box container and added radio button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 100
diff changeset
266 #elif defined(UI_GTK2)
9aff1dc3990d improved box container and added radio button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 100
diff changeset
267 GtkWidget *a = gtk_alignment_new(0.5, 0.5, 1, 1);
9aff1dc3990d improved box container and added radio button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 100
diff changeset
268 gtk_alignment_set_padding(GTK_ALIGNMENT(a), margin, margin, margin, margin);
9aff1dc3990d improved box container and added radio button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 100
diff changeset
269 gtk_container_add(GTK_CONTAINER(a), box);
9aff1dc3990d improved box container and added radio button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 100
diff changeset
270 ret = a;
9aff1dc3990d improved box container and added radio button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 100
diff changeset
271 #endif
9aff1dc3990d improved box container and added radio button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 100
diff changeset
272 return ret;
9aff1dc3990d improved box container and added radio button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 100
diff changeset
273 }
9aff1dc3990d improved box container and added radio button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 100
diff changeset
274
253
087cc9216f28 initial newapi GTK port
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 174
diff changeset
275 UIWIDGET ui_box_create(UiObject *obj, UiContainerArgs args, UiSubContainerType type) {
087cc9216f28 initial newapi GTK port
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 174
diff changeset
276 UiObject *current = uic_current_obj(obj);
087cc9216f28 initial newapi GTK port
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 174
diff changeset
277 UiContainer *ct = current->container;
087cc9216f28 initial newapi GTK port
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 174
diff changeset
278 UI_APPLY_LAYOUT1(current, args);
62
70d2aee84432 added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 59
diff changeset
279
273
1dd2456c51d3 fix hbox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 271
diff changeset
280 GtkWidget *box = type == UI_CONTAINER_VBOX ? ui_gtk_vbox_new(args.spacing) : ui_gtk_hbox_new(args.spacing);
1dd2456c51d3 fix hbox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 271
diff changeset
281 GtkWidget *widget = args.margin > 0 ? box_set_margin(box, args.margin) : box;
107
9aff1dc3990d improved box container and added radio button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 100
diff changeset
282 ct->add(ct, widget, TRUE);
62
70d2aee84432 added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 59
diff changeset
283
273
1dd2456c51d3 fix hbox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 271
diff changeset
284 UiObject *newobj = uic_object_new(obj, box);
297
a73c60adf188 port container to gtk4
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 273
diff changeset
285 newobj->container = ui_box_container(obj, box, type);
62
70d2aee84432 added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 59
diff changeset
286 uic_obj_add(obj, newobj);
70d2aee84432 added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 59
diff changeset
287
107
9aff1dc3990d improved box container and added radio button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 100
diff changeset
288 return widget;
62
70d2aee84432 added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 59
diff changeset
289 }
70d2aee84432 added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 59
diff changeset
290
253
087cc9216f28 initial newapi GTK port
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 174
diff changeset
291 UIEXPORT UIWIDGET ui_vbox_create(UiObject *obj, UiContainerArgs args) {
087cc9216f28 initial newapi GTK port
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 174
diff changeset
292 return ui_box_create(obj, args, UI_CONTAINER_VBOX);
62
70d2aee84432 added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 59
diff changeset
293 }
70d2aee84432 added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 59
diff changeset
294
253
087cc9216f28 initial newapi GTK port
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 174
diff changeset
295 UIEXPORT UIWIDGET ui_hbox_create(UiObject *obj, UiContainerArgs args) {
087cc9216f28 initial newapi GTK port
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 174
diff changeset
296 return ui_box_create(obj, args, UI_CONTAINER_HBOX);
94
d51e334c1439 added checkbox and labels with alignment (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 75
diff changeset
297 }
d51e334c1439 added checkbox and labels with alignment (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 75
diff changeset
298
253
087cc9216f28 initial newapi GTK port
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 174
diff changeset
299
087cc9216f28 initial newapi GTK port
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 174
diff changeset
300
087cc9216f28 initial newapi GTK port
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 174
diff changeset
301 UIWIDGET ui_grid_create(UiObject *obj, UiContainerArgs args) {
271
94d44bdcad3e add new scrolledwindow (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 267
diff changeset
302 UiObject* current = uic_current_obj(obj);
94d44bdcad3e add new scrolledwindow (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 267
diff changeset
303 UI_APPLY_LAYOUT1(current, args);
100
d276306d801f improved gtk2 implementation of grid container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 99
diff changeset
304 GtkWidget *widget;
65
4697592e24ba added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 62
diff changeset
305
297
a73c60adf188 port container to gtk4
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 273
diff changeset
306 #if GTK_MAJOR_VERSION >= 3
65
4697592e24ba added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 62
diff changeset
307 GtkWidget *grid = gtk_grid_new();
253
087cc9216f28 initial newapi GTK port
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 174
diff changeset
308 gtk_grid_set_column_spacing(GTK_GRID(grid), args.columnspacing);
087cc9216f28 initial newapi GTK port
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 174
diff changeset
309 gtk_grid_set_row_spacing(GTK_GRID(grid), args.rowspacing);
297
a73c60adf188 port container to gtk4
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 273
diff changeset
310 #if GTK_MAJOR_VERSION >= 3 && GTK_MINOR_VERSION >= 12
253
087cc9216f28 initial newapi GTK port
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 174
diff changeset
311 gtk_widget_set_margin_start(grid, args.margin);
087cc9216f28 initial newapi GTK port
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 174
diff changeset
312 gtk_widget_set_margin_end(grid, args.margin);
99
ea1a2d5de765 improved grid container (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 94
diff changeset
313 #else
267
79dd183dd4cb port textfield to new API (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 260
diff changeset
314 gtk_widget_set_margin_left(grid, args.margin);
79dd183dd4cb port textfield to new API (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 260
diff changeset
315 gtk_widget_set_margin_right(grid, args.margin);
99
ea1a2d5de765 improved grid container (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 94
diff changeset
316 #endif
253
087cc9216f28 initial newapi GTK port
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 174
diff changeset
317 gtk_widget_set_margin_top(grid, args.margin);
087cc9216f28 initial newapi GTK port
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 174
diff changeset
318 gtk_widget_set_margin_bottom(grid, args.margin);
94
d51e334c1439 added checkbox and labels with alignment (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 75
diff changeset
319
100
d276306d801f improved gtk2 implementation of grid container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 99
diff changeset
320 widget = grid;
74
55718d4ed227 fixed grid container when using gtk2
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 66
diff changeset
321 #elif defined(UI_GTK2)
55718d4ed227 fixed grid container when using gtk2
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 66
diff changeset
322 GtkWidget *grid = gtk_table_new(1, 1, FALSE);
100
d276306d801f improved gtk2 implementation of grid container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 99
diff changeset
323
d276306d801f improved gtk2 implementation of grid container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 99
diff changeset
324 gtk_table_set_col_spacings(GTK_TABLE(grid), columnspacing);
d276306d801f improved gtk2 implementation of grid container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 99
diff changeset
325 gtk_table_set_row_spacings(GTK_TABLE(grid), rowspacing);
d276306d801f improved gtk2 implementation of grid container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 99
diff changeset
326
d276306d801f improved gtk2 implementation of grid container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 99
diff changeset
327 if(margin > 0) {
d276306d801f improved gtk2 implementation of grid container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 99
diff changeset
328 GtkWidget *a = gtk_alignment_new(0.5, 0.5, 1, 1);
d276306d801f improved gtk2 implementation of grid container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 99
diff changeset
329 gtk_alignment_set_padding(GTK_ALIGNMENT(a), margin, margin, margin, margin);
d276306d801f improved gtk2 implementation of grid container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 99
diff changeset
330 gtk_container_add(GTK_CONTAINER(a), grid);
d276306d801f improved gtk2 implementation of grid container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 99
diff changeset
331 widget = a;
d276306d801f improved gtk2 implementation of grid container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 99
diff changeset
332 } else {
d276306d801f improved gtk2 implementation of grid container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 99
diff changeset
333 widget = grid;
d276306d801f improved gtk2 implementation of grid container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 99
diff changeset
334 }
74
55718d4ed227 fixed grid container when using gtk2
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 66
diff changeset
335 #endif
271
94d44bdcad3e add new scrolledwindow (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 267
diff changeset
336 current->container->add(current->container, widget, TRUE);
65
4697592e24ba added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 62
diff changeset
337
4697592e24ba added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 62
diff changeset
338 UiObject *newobj = uic_object_new(obj, grid);
4697592e24ba added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 62
diff changeset
339 newobj->container = ui_grid_container(obj, grid);
4697592e24ba added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 62
diff changeset
340 uic_obj_add(obj, newobj);
4697592e24ba added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 62
diff changeset
341
100
d276306d801f improved gtk2 implementation of grid container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 99
diff changeset
342 return widget;
65
4697592e24ba added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 62
diff changeset
343 }
4697592e24ba added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 62
diff changeset
344
4697592e24ba added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 62
diff changeset
345
271
94d44bdcad3e add new scrolledwindow (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 267
diff changeset
346 UIWIDGET ui_scrolledwindow_create(UiObject* obj, UiFrameArgs args) {
94d44bdcad3e add new scrolledwindow (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 267
diff changeset
347 UiObject* current = uic_current_obj(obj);
94d44bdcad3e add new scrolledwindow (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 267
diff changeset
348 UI_APPLY_LAYOUT1(current, args);
94d44bdcad3e add new scrolledwindow (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 267
diff changeset
349
297
a73c60adf188 port container to gtk4
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 273
diff changeset
350 GtkWidget *sw = SCROLLEDWINDOW_NEW();
271
94d44bdcad3e add new scrolledwindow (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 267
diff changeset
351 UiObject *newobj = uic_object_new(obj, sw);
94d44bdcad3e add new scrolledwindow (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 267
diff changeset
352 newobj->container = ui_scrolledwindow_container(obj, sw);
94d44bdcad3e add new scrolledwindow (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 267
diff changeset
353 uic_obj_add(obj, newobj);
94d44bdcad3e add new scrolledwindow (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 267
diff changeset
354
94d44bdcad3e add new scrolledwindow (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 267
diff changeset
355 return sw;
94d44bdcad3e add new scrolledwindow (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 267
diff changeset
356 }
94d44bdcad3e add new scrolledwindow (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 267
diff changeset
357
94d44bdcad3e add new scrolledwindow (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 267
diff changeset
358
65
4697592e24ba added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 62
diff changeset
359 void ui_select_tab(UIWIDGET tabview, int tab) {
4697592e24ba added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 62
diff changeset
360 gtk_notebook_set_current_page(GTK_NOTEBOOK(tabview), tab);
4697592e24ba added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 62
diff changeset
361 }
4697592e24ba added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 62
diff changeset
362
165
3f32db79a76e add splitpane (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 163
diff changeset
363 /* -------------------- Splitpane -------------------- */
59
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
364
165
3f32db79a76e add splitpane (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 163
diff changeset
365 static GtkWidget* create_paned(UiOrientation orientation) {
297
a73c60adf188 port container to gtk4
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 273
diff changeset
366 #if GTK_MAJOR_VERSION >= 3
165
3f32db79a76e add splitpane (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 163
diff changeset
367 switch(orientation) {
3f32db79a76e add splitpane (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 163
diff changeset
368 case UI_HORIZONTAL: return gtk_paned_new(GTK_ORIENTATION_HORIZONTAL);
3f32db79a76e add splitpane (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 163
diff changeset
369 case UI_VERTICAL: return gtk_paned_new(GTK_ORIENTATION_VERTICAL);
3f32db79a76e add splitpane (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 163
diff changeset
370 }
3f32db79a76e add splitpane (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 163
diff changeset
371 #else
3f32db79a76e add splitpane (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 163
diff changeset
372 switch(orientation) {
3f32db79a76e add splitpane (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 163
diff changeset
373 case UI_HORIZONTAL: return gtk_hpaned_new();
3f32db79a76e add splitpane (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 163
diff changeset
374 case UI_VERTICAL: return gtk_vpaned_new();
3f32db79a76e add splitpane (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 163
diff changeset
375 }
3f32db79a76e add splitpane (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 163
diff changeset
376 #endif
3f32db79a76e add splitpane (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 163
diff changeset
377 return NULL;
3f32db79a76e add splitpane (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 163
diff changeset
378 }
3f32db79a76e add splitpane (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 163
diff changeset
379
3f32db79a76e add splitpane (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 163
diff changeset
380
3f32db79a76e add splitpane (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 163
diff changeset
381
33
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
382
59
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
383
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
384
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
385 /*
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
386 * -------------------- Layout Functions --------------------
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
387 *
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
388 * functions for setting layout attributes for the current container
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
389 *
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
390 */
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
391
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
392 void ui_layout_fill(UiObject *obj, UiBool fill) {
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
393 UiContainer *ct = uic_get_current_container(obj);
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
394 ct->layout.fill = ui_bool2lb(fill);
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
395 }
65
4697592e24ba added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 62
diff changeset
396
99
ea1a2d5de765 improved grid container (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 94
diff changeset
397 void ui_layout_hexpand(UiObject *obj, UiBool expand) {
ea1a2d5de765 improved grid container (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 94
diff changeset
398 UiContainer *ct = uic_get_current_container(obj);
111
40dbf1a7526a added close handler to UiContext (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 110
diff changeset
399 ct->layout.hexpand = expand;
99
ea1a2d5de765 improved grid container (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 94
diff changeset
400 }
ea1a2d5de765 improved grid container (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 94
diff changeset
401
ea1a2d5de765 improved grid container (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 94
diff changeset
402 void ui_layout_vexpand(UiObject *obj, UiBool expand) {
ea1a2d5de765 improved grid container (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 94
diff changeset
403 UiContainer *ct = uic_get_current_container(obj);
111
40dbf1a7526a added close handler to UiContext (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 110
diff changeset
404 ct->layout.vexpand = expand;
99
ea1a2d5de765 improved grid container (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 94
diff changeset
405 }
ea1a2d5de765 improved grid container (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 94
diff changeset
406
253
087cc9216f28 initial newapi GTK port
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 174
diff changeset
407 void ui_layout_colspan(UiObject* obj, int cols) {
087cc9216f28 initial newapi GTK port
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 174
diff changeset
408 UiContainer* ct = uic_get_current_container(obj);
087cc9216f28 initial newapi GTK port
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 174
diff changeset
409 ct->layout.colspan = cols;
087cc9216f28 initial newapi GTK port
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 174
diff changeset
410 }
087cc9216f28 initial newapi GTK port
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 174
diff changeset
411
087cc9216f28 initial newapi GTK port
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 174
diff changeset
412 void ui_layout_rowspan(UiObject* obj, int rows) {
087cc9216f28 initial newapi GTK port
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 174
diff changeset
413 UiContainer* ct = uic_get_current_container(obj);
087cc9216f28 initial newapi GTK port
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 174
diff changeset
414 ct->layout.rowspan = rows;
087cc9216f28 initial newapi GTK port
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 174
diff changeset
415 }
087cc9216f28 initial newapi GTK port
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 174
diff changeset
416
65
4697592e24ba added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 62
diff changeset
417 void ui_newline(UiObject *obj) {
4697592e24ba added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 62
diff changeset
418 UiContainer *ct = uic_get_current_container(obj);
4697592e24ba added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 62
diff changeset
419 ct->layout.newline = TRUE;
4697592e24ba added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 62
diff changeset
420 }
99
ea1a2d5de765 improved grid container (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 94
diff changeset
421

mercurial