ui/gtk/container.c

Mon, 13 Jan 2025 22:36:57 +0100

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Mon, 13 Jan 2025 22:36:57 +0100
changeset 442
dc762a79e72d
parent 440
7c4b9cba09ca
permissions
-rw-r--r--

add ui_customwidget_create function (GTK)

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"
336
56c12f44c2d3 add custom headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 333
diff changeset
35 #include "headerbar.h"
165
3f32db79a76e add splitpane (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 163
diff changeset
36
4
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
37 #include "../common/context.h"
33
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
38 #include "../common/object.h"
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
39
166
6e48030cf2db add container macros (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 165
diff changeset
40
6e48030cf2db add container macros (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 165
diff changeset
41 void ui_container_begin_close(UiObject *obj) {
6e48030cf2db add container macros (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 165
diff changeset
42 UiContainer *ct = uic_get_current_container(obj);
6e48030cf2db add container macros (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 165
diff changeset
43 ct->close = 1;
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
6e48030cf2db add container macros (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 165
diff changeset
46 int ui_container_finish(UiObject *obj) {
6e48030cf2db add container macros (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 165
diff changeset
47 UiContainer *ct = uic_get_current_container(obj);
6e48030cf2db add container macros (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 165
diff changeset
48 if(ct->close) {
6e48030cf2db add container macros (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 165
diff changeset
49 ui_end(obj);
6e48030cf2db add container macros (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 165
diff changeset
50 return 0;
6e48030cf2db add container macros (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 165
diff changeset
51 }
6e48030cf2db add container macros (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 165
diff changeset
52 return 1;
6e48030cf2db add container macros (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 165
diff changeset
53 }
6e48030cf2db add container macros (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 165
diff changeset
54
442
dc762a79e72d add ui_customwidget_create function (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
55 UIEXPORT UIWIDGET ui_customwidget_create(UiObject *obj, ui_createwidget_func create_widget, void *userdata, UiWidgetArgs args) {
dc762a79e72d add ui_customwidget_create function (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
56 UiObject* current = uic_current_obj(obj);
dc762a79e72d add ui_customwidget_create function (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
57
dc762a79e72d add ui_customwidget_create function (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
58 UIWIDGET widget = create_widget(obj, args, userdata);
dc762a79e72d add ui_customwidget_create function (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
59
dc762a79e72d add ui_customwidget_create function (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
60 UI_APPLY_LAYOUT1(current, args);
dc762a79e72d add ui_customwidget_create function (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
61 current->container->add(current->container, widget, FALSE);
dc762a79e72d add ui_customwidget_create function (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
62
dc762a79e72d add ui_customwidget_create function (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
63 return widget;
dc762a79e72d add ui_customwidget_create function (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
64 }
dc762a79e72d add ui_customwidget_create function (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
65
107
9aff1dc3990d improved box container and added radio button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 100
diff changeset
66 GtkWidget* ui_gtk_vbox_new(int spacing) {
297
a73c60adf188 port container to gtk4
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 273
diff changeset
67 #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
68 return gtk_box_new(GTK_ORIENTATION_VERTICAL, spacing);
59
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
69 #else
107
9aff1dc3990d improved box container and added radio button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 100
diff changeset
70 return gtk_vbox_new(FALSE, spacing);
59
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
71 #endif
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
72 }
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
73
107
9aff1dc3990d improved box container and added radio button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 100
diff changeset
74 GtkWidget* ui_gtk_hbox_new(int spacing) {
297
a73c60adf188 port container to gtk4
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 273
diff changeset
75 #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
76 return gtk_box_new(GTK_ORIENTATION_HORIZONTAL, spacing);
59
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
77 #else
107
9aff1dc3990d improved box container and added radio button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 100
diff changeset
78 return gtk_hbox_new(FALSE, spacing);
59
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
79 #endif
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
80 }
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
81
353
ae999e3346a9 add frame container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 351
diff changeset
82 GtkWidget* ui_subcontainer_create(
ae999e3346a9 add frame container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 351
diff changeset
83 UiSubContainerType type,
ae999e3346a9 add frame container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 351
diff changeset
84 UiObject *newobj,
ae999e3346a9 add frame container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 351
diff changeset
85 int spacing,
ae999e3346a9 add frame container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 351
diff changeset
86 int columnspacing,
ae999e3346a9 add frame container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 351
diff changeset
87 int rowspacing,
ae999e3346a9 add frame container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 351
diff changeset
88 int margin)
ae999e3346a9 add frame container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 351
diff changeset
89 {
ae999e3346a9 add frame container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 351
diff changeset
90 GtkWidget *sub = NULL;
ae999e3346a9 add frame container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 351
diff changeset
91 GtkWidget *add = NULL;
ae999e3346a9 add frame container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 351
diff changeset
92 switch(type) {
ae999e3346a9 add frame container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 351
diff changeset
93 default: {
ae999e3346a9 add frame container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 351
diff changeset
94 sub = ui_gtk_vbox_new(spacing);
ae999e3346a9 add frame container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 351
diff changeset
95 add = ui_box_set_margin(sub, margin);
ae999e3346a9 add frame container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 351
diff changeset
96 newobj->container = ui_box_container(newobj, sub, type);
ae999e3346a9 add frame container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 351
diff changeset
97 newobj->widget = sub;
ae999e3346a9 add frame container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 351
diff changeset
98 break;
ae999e3346a9 add frame container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 351
diff changeset
99 }
ae999e3346a9 add frame container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 351
diff changeset
100 case UI_CONTAINER_HBOX: {
ae999e3346a9 add frame container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 351
diff changeset
101 sub = ui_gtk_hbox_new(spacing);
ae999e3346a9 add frame container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 351
diff changeset
102 add = ui_box_set_margin(sub, margin);
ae999e3346a9 add frame container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 351
diff changeset
103 newobj->container = ui_box_container(newobj, sub, type);
ae999e3346a9 add frame container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 351
diff changeset
104 newobj->widget = sub;
ae999e3346a9 add frame container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 351
diff changeset
105 break;
ae999e3346a9 add frame container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 351
diff changeset
106 }
ae999e3346a9 add frame container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 351
diff changeset
107 case UI_CONTAINER_GRID: {
ae999e3346a9 add frame container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 351
diff changeset
108 sub = ui_create_grid_widget(columnspacing, rowspacing);
ae999e3346a9 add frame container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 351
diff changeset
109 add = ui_box_set_margin(sub, margin);
ae999e3346a9 add frame container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 351
diff changeset
110 newobj->container = ui_grid_container(newobj, sub);
ae999e3346a9 add frame container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 351
diff changeset
111 newobj->widget = sub;
ae999e3346a9 add frame container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 351
diff changeset
112 break;
ae999e3346a9 add frame container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 351
diff changeset
113 }
ae999e3346a9 add frame container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 351
diff changeset
114 case UI_CONTAINER_NO_SUB: {
ae999e3346a9 add frame container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 351
diff changeset
115 break;
ae999e3346a9 add frame container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 351
diff changeset
116 }
ae999e3346a9 add frame container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 351
diff changeset
117 }
ae999e3346a9 add frame container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 351
diff changeset
118 return add;
ae999e3346a9 add frame container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 351
diff changeset
119 }
33
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
120
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
121
59
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
122 /* -------------------- Box Container -------------------- */
297
a73c60adf188 port container to gtk4
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 273
diff changeset
123 UiContainer* ui_box_container(UiObject *obj, GtkWidget *box, UiSubContainerType type) {
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 166
diff changeset
124 UiBoxContainer *ct = cxCalloc(
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 166
diff changeset
125 obj->ctx->allocator,
59
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
126 1,
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
127 sizeof(UiBoxContainer));
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
128 ct->container.widget = box;
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
129 ct->container.add = ui_box_container_add;
297
a73c60adf188 port container to gtk4
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 273
diff changeset
130 ct->type = type;
59
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
131 return (UiContainer*)ct;
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
132 }
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
133
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
134 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
135 UiBoxContainer *bc = (UiBoxContainer*)ct;
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
136 if(ct->layout.fill != UI_LAYOUT_UNDEFINED) {
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
137 fill = ui_lb2bool(ct->layout.fill);
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
138 }
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
139
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
140 if(bc->has_fill && fill) {
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
141 fprintf(stderr, "UiError: container has 2 filled widgets");
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
142 fill = FALSE;
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
143 }
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
144 if(fill) {
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
145 bc->has_fill = TRUE;
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
146 }
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
147
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
148 UiBool expand = fill;
297
a73c60adf188 port container to gtk4
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 273
diff changeset
149 #if GTK_MAJOR_VERSION >= 4
a73c60adf188 port container to gtk4
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 273
diff changeset
150 gtk_box_append(GTK_BOX(ct->widget), widget);
a73c60adf188 port container to gtk4
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 273
diff changeset
151 GtkAlign align = expand ? GTK_ALIGN_FILL : GTK_ALIGN_START;
a73c60adf188 port container to gtk4
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 273
diff changeset
152 if(bc->type == UI_CONTAINER_VBOX) {
a73c60adf188 port container to gtk4
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 273
diff changeset
153 gtk_widget_set_valign(widget, align);
a73c60adf188 port container to gtk4
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 273
diff changeset
154 gtk_widget_set_vexpand(widget, expand);
a73c60adf188 port container to gtk4
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 273
diff changeset
155 gtk_widget_set_hexpand(widget, TRUE);
a73c60adf188 port container to gtk4
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 273
diff changeset
156 } else if(bc->type == UI_CONTAINER_HBOX) {
a73c60adf188 port container to gtk4
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 273
diff changeset
157 gtk_widget_set_halign(widget, align);
a73c60adf188 port container to gtk4
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 273
diff changeset
158 gtk_widget_set_hexpand(widget, expand);
a73c60adf188 port container to gtk4
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 273
diff changeset
159 gtk_widget_set_vexpand(widget, TRUE);
a73c60adf188 port container to gtk4
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 273
diff changeset
160 }
a73c60adf188 port container to gtk4
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 273
diff changeset
161
a73c60adf188 port container to gtk4
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 273
diff changeset
162 #else
59
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
163 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
164 #endif
59
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
165
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
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;
59
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
168 }
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
169
65
4697592e24ba added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 62
diff changeset
170 UiContainer* ui_grid_container(UiObject *obj, GtkWidget *grid) {
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 166
diff changeset
171 UiGridContainer *ct = cxCalloc(
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 166
diff changeset
172 obj->ctx->allocator,
65
4697592e24ba added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 62
diff changeset
173 1,
4697592e24ba added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 62
diff changeset
174 sizeof(UiGridContainer));
4697592e24ba added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 62
diff changeset
175 ct->container.widget = grid;
4697592e24ba added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 62
diff changeset
176 ct->container.add = ui_grid_container_add;
305
98470af75dcf simplfy macro usage in container.c (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 304
diff changeset
177 UI_GTK_V2(ct->width = 0);
98470af75dcf simplfy macro usage in container.c (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 304
diff changeset
178 UI_GTK_V2(ct->height = 1);
65
4697592e24ba added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 62
diff changeset
179 return (UiContainer*)ct;
4697592e24ba added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 62
diff changeset
180 }
4697592e24ba added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 62
diff changeset
181
297
a73c60adf188 port container to gtk4
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 273
diff changeset
182 #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
183 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
184 UiGridContainer *grid = (UiGridContainer*)ct;
4697592e24ba added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 62
diff changeset
185
4697592e24ba added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 62
diff changeset
186 if(ct->layout.newline) {
4697592e24ba added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 62
diff changeset
187 grid->x = 0;
4697592e24ba added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 62
diff changeset
188 grid->y++;
4697592e24ba added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 62
diff changeset
189 ct->layout.newline = FALSE;
4697592e24ba added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 62
diff changeset
190 }
4697592e24ba added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 62
diff changeset
191
99
ea1a2d5de765 improved grid container (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 94
diff changeset
192 int hexpand = FALSE;
ea1a2d5de765 improved grid container (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 94
diff changeset
193 int vexpand = FALSE;
378
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 354
diff changeset
194 int hfill = FALSE;
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 354
diff changeset
195 int vfill = FALSE;
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 354
diff changeset
196 if(ct->layout.fill != UI_LAYOUT_UNDEFINED) {
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 354
diff changeset
197 fill = ui_lb2bool(ct->layout.fill);
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 354
diff changeset
198 }
99
ea1a2d5de765 improved grid container (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 94
diff changeset
199 if(ct->layout.hexpand != UI_LAYOUT_UNDEFINED) {
ea1a2d5de765 improved grid container (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 94
diff changeset
200 hexpand = ct->layout.hexpand;
378
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 354
diff changeset
201 hfill = TRUE;
94
d51e334c1439 added checkbox and labels with alignment (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 75
diff changeset
202 }
99
ea1a2d5de765 improved grid container (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 94
diff changeset
203 if(ct->layout.vexpand != UI_LAYOUT_UNDEFINED) {
ea1a2d5de765 improved grid container (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 94
diff changeset
204 vexpand = ct->layout.vexpand;
378
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 354
diff changeset
205 vfill = TRUE;
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 354
diff changeset
206 }
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 354
diff changeset
207 if(fill) {
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 354
diff changeset
208 hfill = TRUE;
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 354
diff changeset
209 vfill = TRUE;
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 354
diff changeset
210 }
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 354
diff changeset
211
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 354
diff changeset
212 if(!hfill) {
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 354
diff changeset
213 gtk_widget_set_halign(widget, GTK_ALIGN_START);
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 354
diff changeset
214 }
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 354
diff changeset
215 if(!vfill) {
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 354
diff changeset
216 gtk_widget_set_valign(widget, GTK_ALIGN_START);
99
ea1a2d5de765 improved grid container (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 94
diff changeset
217 }
ea1a2d5de765 improved grid container (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 94
diff changeset
218
303
dc8b504604f4 fix gtk3/4 grid hexpand/vexpand setting
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 298
diff changeset
219 gtk_widget_set_hexpand(widget, hexpand);
dc8b504604f4 fix gtk3/4 grid hexpand/vexpand setting
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 298
diff changeset
220 gtk_widget_set_vexpand(widget, vexpand);
94
d51e334c1439 added checkbox and labels with alignment (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 75
diff changeset
221
260
eebb0626d020 implement grid colspan/rowspan (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 253
diff changeset
222 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
223 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
224
260
eebb0626d020 implement grid colspan/rowspan (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 253
diff changeset
225 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
226 grid->x += colspan;
65
4697592e24ba added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 62
diff changeset
227
4697592e24ba added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 62
diff changeset
228 ui_reset_layout(ct->layout);
75
efe2f65bea17 added context menus (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 74
diff changeset
229 ct->current = widget;
65
4697592e24ba added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 62
diff changeset
230 }
74
55718d4ed227 fixed grid container when using gtk2
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 66
diff changeset
231 #endif
55718d4ed227 fixed grid container when using gtk2
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 66
diff changeset
232 #ifdef UI_GTK2
55718d4ed227 fixed grid container when using gtk2
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 66
diff changeset
233 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
234 UiGridContainer *grid = (UiGridContainer*)ct;
55718d4ed227 fixed grid container when using gtk2
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 66
diff changeset
235
55718d4ed227 fixed grid container when using gtk2
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 66
diff changeset
236 if(ct->layout.newline) {
55718d4ed227 fixed grid container when using gtk2
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 66
diff changeset
237 grid->x = 0;
55718d4ed227 fixed grid container when using gtk2
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 66
diff changeset
238 grid->y++;
55718d4ed227 fixed grid container when using gtk2
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 66
diff changeset
239 ct->layout.newline = FALSE;
55718d4ed227 fixed grid container when using gtk2
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 66
diff changeset
240 }
55718d4ed227 fixed grid container when using gtk2
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 66
diff changeset
241
100
d276306d801f improved gtk2 implementation of grid container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 99
diff changeset
242 int hexpand = FALSE;
d276306d801f improved gtk2 implementation of grid container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 99
diff changeset
243 int vexpand = FALSE;
d276306d801f improved gtk2 implementation of grid container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 99
diff changeset
244 if(ct->layout.hexpand != UI_LAYOUT_UNDEFINED) {
d276306d801f improved gtk2 implementation of grid container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 99
diff changeset
245 hexpand = ct->layout.hexpand;
d276306d801f improved gtk2 implementation of grid container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 99
diff changeset
246 }
d276306d801f improved gtk2 implementation of grid container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 99
diff changeset
247 if(ct->layout.vexpand != UI_LAYOUT_UNDEFINED) {
d276306d801f improved gtk2 implementation of grid container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 99
diff changeset
248 vexpand = ct->layout.vexpand;
d276306d801f improved gtk2 implementation of grid container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 99
diff changeset
249 }
d276306d801f improved gtk2 implementation of grid container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 99
diff changeset
250 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
251 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
252
260
eebb0626d020 implement grid colspan/rowspan (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 253
diff changeset
253 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
254 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
255 // TODO: use colspan/rowspan
eebb0626d020 implement grid colspan/rowspan (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 253
diff changeset
256
100
d276306d801f improved gtk2 implementation of grid container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 99
diff changeset
257 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
258 grid->x++;
55718d4ed227 fixed grid container when using gtk2
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 66
diff changeset
259 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
260 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
261 grid->width = nw;
55718d4ed227 fixed grid container when using gtk2
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 66
diff changeset
262 grid->height = grid->y + 1;
55718d4ed227 fixed grid container when using gtk2
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 66
diff changeset
263 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
264 }
75
efe2f65bea17 added context menus (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 74
diff changeset
265
efe2f65bea17 added context menus (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 74
diff changeset
266 ui_reset_layout(ct->layout);
efe2f65bea17 added context menus (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 74
diff changeset
267 ct->current = widget;
74
55718d4ed227 fixed grid container when using gtk2
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 66
diff changeset
268 }
55718d4ed227 fixed grid container when using gtk2
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 66
diff changeset
269 #endif
65
4697592e24ba added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 62
diff changeset
270
353
ae999e3346a9 add frame container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 351
diff changeset
271 UiContainer* ui_frame_container(UiObject *obj, GtkWidget *frame) {
ae999e3346a9 add frame container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 351
diff changeset
272 UiContainer *ct = cxCalloc(
ae999e3346a9 add frame container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 351
diff changeset
273 obj->ctx->allocator,
ae999e3346a9 add frame container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 351
diff changeset
274 1,
ae999e3346a9 add frame container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 351
diff changeset
275 sizeof(UiContainer));
ae999e3346a9 add frame container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 351
diff changeset
276 ct->widget = frame;
ae999e3346a9 add frame container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 351
diff changeset
277 ct->add = ui_frame_container_add;
ae999e3346a9 add frame container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 351
diff changeset
278 return ct;
ae999e3346a9 add frame container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 351
diff changeset
279 }
ae999e3346a9 add frame container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 351
diff changeset
280
ae999e3346a9 add frame container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 351
diff changeset
281 void ui_frame_container_add(UiContainer *ct, GtkWidget *widget, UiBool fill) {
ae999e3346a9 add frame container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 351
diff changeset
282 FRAME_SET_CHILD(ct->widget, widget);
ae999e3346a9 add frame container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 351
diff changeset
283 }
ae999e3346a9 add frame container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 351
diff changeset
284
354
baf9bcc98d87 add expander container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 353
diff changeset
285 UiContainer* ui_expander_container(UiObject *obj, GtkWidget *expander) {
baf9bcc98d87 add expander container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 353
diff changeset
286 UiContainer *ct = cxCalloc(
baf9bcc98d87 add expander container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 353
diff changeset
287 obj->ctx->allocator,
baf9bcc98d87 add expander container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 353
diff changeset
288 1,
baf9bcc98d87 add expander container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 353
diff changeset
289 sizeof(UiContainer));
baf9bcc98d87 add expander container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 353
diff changeset
290 ct->widget = expander;
baf9bcc98d87 add expander container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 353
diff changeset
291 ct->add = ui_expander_container_add;
baf9bcc98d87 add expander container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 353
diff changeset
292 return ct;
baf9bcc98d87 add expander container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 353
diff changeset
293 }
baf9bcc98d87 add expander container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 353
diff changeset
294
baf9bcc98d87 add expander container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 353
diff changeset
295 void ui_expander_container_add(UiContainer *ct, GtkWidget *widget, UiBool fill) {
baf9bcc98d87 add expander container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 353
diff changeset
296 EXPANDER_SET_CHILD(ct->widget, widget);
baf9bcc98d87 add expander container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 353
diff changeset
297 }
baf9bcc98d87 add expander container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 353
diff changeset
298
baf9bcc98d87 add expander container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 353
diff changeset
299 void ui_scrolledwindow_container_add(UiContainer *ct, GtkWidget *widget, UiBool fill) {
baf9bcc98d87 add expander container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 353
diff changeset
300 // TODO: check if the widget implements GtkScrollable
baf9bcc98d87 add expander container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 353
diff changeset
301 SCROLLEDWINDOW_SET_CHILD(ct->widget, widget);
baf9bcc98d87 add expander container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 353
diff changeset
302 ui_reset_layout(ct->layout);
baf9bcc98d87 add expander container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 353
diff changeset
303 ct->current = widget;
baf9bcc98d87 add expander container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 353
diff changeset
304 }
baf9bcc98d87 add expander container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 353
diff changeset
305
120
49bc645df8b7 added scrolledwindow (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
306 UiContainer* ui_scrolledwindow_container(UiObject *obj, GtkWidget *scrolledwindow) {
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 166
diff changeset
307 UiContainer *ct = cxCalloc(
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 166
diff changeset
308 obj->ctx->allocator,
120
49bc645df8b7 added scrolledwindow (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
309 1,
49bc645df8b7 added scrolledwindow (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
310 sizeof(UiContainer));
49bc645df8b7 added scrolledwindow (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
311 ct->widget = scrolledwindow;
49bc645df8b7 added scrolledwindow (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
312 ct->add = ui_scrolledwindow_container_add;
49bc645df8b7 added scrolledwindow (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
313 return ct;
49bc645df8b7 added scrolledwindow (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
314 }
49bc645df8b7 added scrolledwindow (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
315
65
4697592e24ba added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 62
diff changeset
316 UiContainer* ui_tabview_container(UiObject *obj, GtkWidget *tabview) {
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 166
diff changeset
317 UiTabViewContainer *ct = cxCalloc(
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 166
diff changeset
318 obj->ctx->allocator,
65
4697592e24ba added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 62
diff changeset
319 1,
4697592e24ba added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 62
diff changeset
320 sizeof(UiTabViewContainer));
4697592e24ba added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 62
diff changeset
321 ct->container.widget = tabview;
4697592e24ba added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 62
diff changeset
322 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
323 return (UiContainer*)ct;
4697592e24ba added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 62
diff changeset
324 }
4697592e24ba added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 62
diff changeset
325
4697592e24ba added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 62
diff changeset
326 void ui_tabview_container_add(UiContainer *ct, GtkWidget *widget, UiBool fill) {
328
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
327 UiGtkTabView *data = ui_widget_get_tabview_data(ct->widget);
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
328 if(!data) {
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
329 fprintf(stderr, "UI Error: widget is not a tabview");
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
330 return;
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
331 }
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
332 data->add_tab(ct->widget, -1, ct->layout.label, widget);
75
efe2f65bea17 added context menus (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 74
diff changeset
333
efe2f65bea17 added context menus (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 74
diff changeset
334 ui_reset_layout(ct->layout);
efe2f65bea17 added context menus (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 74
diff changeset
335 ct->current = widget;
65
4697592e24ba added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 62
diff changeset
336 }
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
107
9aff1dc3990d improved box container and added radio button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 100
diff changeset
339
344
870dd3d41d83 add dialog window (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 336
diff changeset
340 GtkWidget* ui_box_set_margin(GtkWidget *box, int margin) {
107
9aff1dc3990d improved box container and added radio button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 100
diff changeset
341 GtkWidget *ret = box;
304
d554b2a60105 fix gtk box margin
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
342 #if GTK_MAJOR_VERSION >= 3
d554b2a60105 fix gtk box margin
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 303
diff changeset
343 #if GTK_MAJOR_VERSION * 1000 + GTK_MINOR_VERSION >= 3012
107
9aff1dc3990d improved box container and added radio button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 100
diff changeset
344 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
345 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
346 #else
9aff1dc3990d improved box container and added radio button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 100
diff changeset
347 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
348 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
349 #endif
9aff1dc3990d improved box container and added radio button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 100
diff changeset
350 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
351 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
352 #elif defined(UI_GTK2)
9aff1dc3990d improved box container and added radio button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 100
diff changeset
353 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
354 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
355 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
356 ret = a;
9aff1dc3990d improved box container and added radio button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 100
diff changeset
357 #endif
9aff1dc3990d improved box container and added radio button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 100
diff changeset
358 return ret;
9aff1dc3990d improved box container and added radio button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 100
diff changeset
359 }
9aff1dc3990d improved box container and added radio button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 100
diff changeset
360
253
087cc9216f28 initial newapi GTK port
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 174
diff changeset
361 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
362 UiObject *current = uic_current_obj(obj);
087cc9216f28 initial newapi GTK port
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 174
diff changeset
363 UiContainer *ct = current->container;
087cc9216f28 initial newapi GTK port
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 174
diff changeset
364 UI_APPLY_LAYOUT1(current, args);
62
70d2aee84432 added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 59
diff changeset
365
273
1dd2456c51d3 fix hbox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 271
diff changeset
366 GtkWidget *box = type == UI_CONTAINER_VBOX ? ui_gtk_vbox_new(args.spacing) : ui_gtk_hbox_new(args.spacing);
313
b679cc6059ab add option to name widgets and add css classes (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 305
diff changeset
367 ui_set_name_and_style(box, args.name, args.style_class);
344
870dd3d41d83 add dialog window (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 336
diff changeset
368 GtkWidget *widget = args.margin > 0 ? ui_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
369 ct->add(ct, widget, TRUE);
62
70d2aee84432 added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 59
diff changeset
370
273
1dd2456c51d3 fix hbox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 271
diff changeset
371 UiObject *newobj = uic_object_new(obj, box);
297
a73c60adf188 port container to gtk4
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 273
diff changeset
372 newobj->container = ui_box_container(obj, box, type);
62
70d2aee84432 added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 59
diff changeset
373 uic_obj_add(obj, newobj);
70d2aee84432 added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 59
diff changeset
374
107
9aff1dc3990d improved box container and added radio button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 100
diff changeset
375 return widget;
62
70d2aee84432 added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 59
diff changeset
376 }
70d2aee84432 added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 59
diff changeset
377
253
087cc9216f28 initial newapi GTK port
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 174
diff changeset
378 UIEXPORT UIWIDGET ui_vbox_create(UiObject *obj, UiContainerArgs args) {
087cc9216f28 initial newapi GTK port
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 174
diff changeset
379 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
380 }
70d2aee84432 added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 59
diff changeset
381
253
087cc9216f28 initial newapi GTK port
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 174
diff changeset
382 UIEXPORT UIWIDGET ui_hbox_create(UiObject *obj, UiContainerArgs args) {
087cc9216f28 initial newapi GTK port
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 174
diff changeset
383 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
384 }
d51e334c1439 added checkbox and labels with alignment (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 75
diff changeset
385
344
870dd3d41d83 add dialog window (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 336
diff changeset
386 GtkWidget* ui_create_grid_widget(int colspacing, int rowspacing) {
305
98470af75dcf simplfy macro usage in container.c (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 304
diff changeset
387 #if GTK_MAJOR_VERSION >= 3
98470af75dcf simplfy macro usage in container.c (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 304
diff changeset
388 GtkWidget *grid = gtk_grid_new();
98470af75dcf simplfy macro usage in container.c (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 304
diff changeset
389 gtk_grid_set_column_spacing(GTK_GRID(grid), colspacing);
98470af75dcf simplfy macro usage in container.c (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 304
diff changeset
390 gtk_grid_set_row_spacing(GTK_GRID(grid), rowspacing);
98470af75dcf simplfy macro usage in container.c (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 304
diff changeset
391 #else
98470af75dcf simplfy macro usage in container.c (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 304
diff changeset
392 GtkWidget *grid = gtk_table_new(1, 1, FALSE);
98470af75dcf simplfy macro usage in container.c (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 304
diff changeset
393 gtk_table_set_col_spacings(GTK_TABLE(grid), colspacing);
98470af75dcf simplfy macro usage in container.c (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 304
diff changeset
394 gtk_table_set_row_spacings(GTK_TABLE(grid), rowspacing);
98470af75dcf simplfy macro usage in container.c (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 304
diff changeset
395 #endif
98470af75dcf simplfy macro usage in container.c (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 304
diff changeset
396 return grid;
98470af75dcf simplfy macro usage in container.c (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 304
diff changeset
397 }
253
087cc9216f28 initial newapi GTK port
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 174
diff changeset
398
087cc9216f28 initial newapi GTK port
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 174
diff changeset
399 UIWIDGET ui_grid_create(UiObject *obj, UiContainerArgs args) {
271
94d44bdcad3e add new scrolledwindow (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 267
diff changeset
400 UiObject* current = uic_current_obj(obj);
94d44bdcad3e add new scrolledwindow (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 267
diff changeset
401 UI_APPLY_LAYOUT1(current, args);
100
d276306d801f improved gtk2 implementation of grid container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 99
diff changeset
402 GtkWidget *widget;
65
4697592e24ba added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 62
diff changeset
403
344
870dd3d41d83 add dialog window (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 336
diff changeset
404 GtkWidget *grid = ui_create_grid_widget(args.columnspacing, args.rowspacing);
313
b679cc6059ab add option to name widgets and add css classes (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 305
diff changeset
405 ui_set_name_and_style(grid, args.name, args.style_class);
344
870dd3d41d83 add dialog window (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 336
diff changeset
406 widget = ui_box_set_margin(grid, args.margin);
271
94d44bdcad3e add new scrolledwindow (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 267
diff changeset
407 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
408
4697592e24ba added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 62
diff changeset
409 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
410 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
411 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
412
100
d276306d801f improved gtk2 implementation of grid container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 99
diff changeset
413 return widget;
65
4697592e24ba added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 62
diff changeset
414 }
4697592e24ba added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 62
diff changeset
415
353
ae999e3346a9 add frame container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 351
diff changeset
416 UIWIDGET ui_frame_create(UiObject *obj, UiFrameArgs args) {
ae999e3346a9 add frame container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 351
diff changeset
417 UiObject* current = uic_current_obj(obj);
ae999e3346a9 add frame container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 351
diff changeset
418 UI_APPLY_LAYOUT1(current, args);
ae999e3346a9 add frame container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 351
diff changeset
419
ae999e3346a9 add frame container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 351
diff changeset
420 GtkWidget *frame = gtk_frame_new(args.label);
ae999e3346a9 add frame container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 351
diff changeset
421 UiObject *newobj = uic_object_new(obj, frame);
ae999e3346a9 add frame container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 351
diff changeset
422 GtkWidget *sub = ui_subcontainer_create(args.subcontainer, newobj, args.spacing, args.columnspacing, args.rowspacing, args.margin);
ae999e3346a9 add frame container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 351
diff changeset
423 if(sub) {
ae999e3346a9 add frame container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 351
diff changeset
424 FRAME_SET_CHILD(frame, sub);
ae999e3346a9 add frame container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 351
diff changeset
425 } else {
ae999e3346a9 add frame container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 351
diff changeset
426 newobj->widget = frame;
ae999e3346a9 add frame container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 351
diff changeset
427 newobj->container = ui_frame_container(obj, frame);
ae999e3346a9 add frame container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 351
diff changeset
428 }
354
baf9bcc98d87 add expander container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 353
diff changeset
429 current->container->add(current->container, frame, FALSE);
baf9bcc98d87 add expander container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 353
diff changeset
430 uic_obj_add(obj, newobj);
353
ae999e3346a9 add frame container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 351
diff changeset
431
ae999e3346a9 add frame container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 351
diff changeset
432 return frame;
ae999e3346a9 add frame container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 351
diff changeset
433 }
ae999e3346a9 add frame container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 351
diff changeset
434
354
baf9bcc98d87 add expander container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 353
diff changeset
435 UIEXPORT UIWIDGET ui_expander_create(UiObject *obj, UiFrameArgs args) {
baf9bcc98d87 add expander container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 353
diff changeset
436 UiObject* current = uic_current_obj(obj);
baf9bcc98d87 add expander container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 353
diff changeset
437 UI_APPLY_LAYOUT1(current, args);
baf9bcc98d87 add expander container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 353
diff changeset
438
baf9bcc98d87 add expander container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 353
diff changeset
439 GtkWidget *expander = gtk_expander_new(args.label);
baf9bcc98d87 add expander container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 353
diff changeset
440 gtk_expander_set_expanded(GTK_EXPANDER(expander), args.isexpanded);
baf9bcc98d87 add expander container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 353
diff changeset
441 UiObject *newobj = uic_object_new(obj, expander);
baf9bcc98d87 add expander container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 353
diff changeset
442 GtkWidget *sub = ui_subcontainer_create(args.subcontainer, newobj, args.spacing, args.columnspacing, args.rowspacing, args.margin);
baf9bcc98d87 add expander container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 353
diff changeset
443 if(sub) {
baf9bcc98d87 add expander container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 353
diff changeset
444 EXPANDER_SET_CHILD(expander, sub);
baf9bcc98d87 add expander container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 353
diff changeset
445 } else {
baf9bcc98d87 add expander container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 353
diff changeset
446 newobj->widget = expander;
baf9bcc98d87 add expander container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 353
diff changeset
447 newobj->container = ui_expander_container(obj, expander);
baf9bcc98d87 add expander container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 353
diff changeset
448 }
baf9bcc98d87 add expander container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 353
diff changeset
449 current->container->add(current->container, expander, FALSE);
baf9bcc98d87 add expander container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 353
diff changeset
450 uic_obj_add(obj, newobj);
baf9bcc98d87 add expander container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 353
diff changeset
451
baf9bcc98d87 add expander container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 353
diff changeset
452 return expander;
baf9bcc98d87 add expander container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 353
diff changeset
453 }
baf9bcc98d87 add expander container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 353
diff changeset
454
65
4697592e24ba added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 62
diff changeset
455
271
94d44bdcad3e add new scrolledwindow (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 267
diff changeset
456 UIWIDGET ui_scrolledwindow_create(UiObject* obj, UiFrameArgs args) {
94d44bdcad3e add new scrolledwindow (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 267
diff changeset
457 UiObject* current = uic_current_obj(obj);
94d44bdcad3e add new scrolledwindow (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 267
diff changeset
458 UI_APPLY_LAYOUT1(current, args);
94d44bdcad3e add new scrolledwindow (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 267
diff changeset
459
297
a73c60adf188 port container to gtk4
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 273
diff changeset
460 GtkWidget *sw = SCROLLEDWINDOW_NEW();
313
b679cc6059ab add option to name widgets and add css classes (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 305
diff changeset
461 ui_set_name_and_style(sw, args.name, args.style_class);
350
70305d427f25 fix ui_scrolledwindow (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 344
diff changeset
462 GtkWidget *widget = ui_box_set_margin(sw, args.margin);
70305d427f25 fix ui_scrolledwindow (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 344
diff changeset
463 current->container->add(current->container, widget, TRUE);
70305d427f25 fix ui_scrolledwindow (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 344
diff changeset
464
271
94d44bdcad3e add new scrolledwindow (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 267
diff changeset
465 UiObject *newobj = uic_object_new(obj, sw);
353
ae999e3346a9 add frame container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 351
diff changeset
466 GtkWidget *sub = ui_subcontainer_create(args.subcontainer, newobj, args.spacing, args.columnspacing, args.rowspacing, args.margin);
ae999e3346a9 add frame container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 351
diff changeset
467 if(sub) {
ae999e3346a9 add frame container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 351
diff changeset
468 SCROLLEDWINDOW_SET_CHILD(sw, sub);
ae999e3346a9 add frame container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 351
diff changeset
469 } else {
ae999e3346a9 add frame container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 351
diff changeset
470 newobj->widget = sw;
ae999e3346a9 add frame container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 351
diff changeset
471 newobj->container = ui_scrolledwindow_container(obj, sw);
351
63db7e35e2e9 implement scrolledwindow sub container type (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 350
diff changeset
472 }
63db7e35e2e9 implement scrolledwindow sub container type (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 350
diff changeset
473
271
94d44bdcad3e add new scrolledwindow (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 267
diff changeset
474 uic_obj_add(obj, newobj);
94d44bdcad3e add new scrolledwindow (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 267
diff changeset
475
94d44bdcad3e add new scrolledwindow (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 267
diff changeset
476 return sw;
94d44bdcad3e add new scrolledwindow (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 267
diff changeset
477 }
94d44bdcad3e add new scrolledwindow (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 267
diff changeset
478
94d44bdcad3e add new scrolledwindow (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 267
diff changeset
479
328
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
480 void ui_notebook_tab_select(UIWIDGET tabview, int tab) {
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
481 gtk_notebook_set_current_page(GTK_NOTEBOOK(tabview), tab);
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
482 }
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
483
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
484 void ui_notebook_tab_remove(UIWIDGET tabview, int tab) {
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
485 gtk_notebook_remove_page(GTK_NOTEBOOK(tabview), tab);
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
486 }
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
487
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
488 void ui_notebook_tab_add(UIWIDGET widget, int index, const char *name, UIWIDGET child) {
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
489 gtk_notebook_insert_page(
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
490 GTK_NOTEBOOK(widget),
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
491 child,
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
492 gtk_label_new(name),
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
493 index);
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
494 }
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
495
330
d615aa36c98e add tabview value/varname parameter
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 328
diff changeset
496 int64_t ui_notebook_get(UiInteger *i) {
d615aa36c98e add tabview value/varname parameter
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 328
diff changeset
497 GtkNotebook *nb = i->obj;
d615aa36c98e add tabview value/varname parameter
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 328
diff changeset
498 i->value = gtk_notebook_get_current_page(nb);
d615aa36c98e add tabview value/varname parameter
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 328
diff changeset
499 return i->value;
d615aa36c98e add tabview value/varname parameter
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 328
diff changeset
500 }
d615aa36c98e add tabview value/varname parameter
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 328
diff changeset
501
d615aa36c98e add tabview value/varname parameter
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 328
diff changeset
502 void ui_notebook_set(UiInteger *i, int64_t value) {
d615aa36c98e add tabview value/varname parameter
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 328
diff changeset
503 GtkNotebook *nb = i->obj;
d615aa36c98e add tabview value/varname parameter
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 328
diff changeset
504 gtk_notebook_set_current_page(nb, value);
d615aa36c98e add tabview value/varname parameter
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 328
diff changeset
505 i->value = gtk_notebook_get_current_page(nb);
d615aa36c98e add tabview value/varname parameter
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 328
diff changeset
506 }
d615aa36c98e add tabview value/varname parameter
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 328
diff changeset
507
331
cdad8b7e83db implement side navigation tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 330
diff changeset
508
333
634e3ce80afe implement gtk3 stack tabview
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 332
diff changeset
509 #if GTK_MAJOR_VERSION >= 4
332
7e7c05af8f3a implement stack set/get/remove (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 331
diff changeset
510 static int stack_set_page(GtkWidget *stack, int index) {
7e7c05af8f3a implement stack set/get/remove (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 331
diff changeset
511 GtkSelectionModel *pages = gtk_stack_get_pages(GTK_STACK(stack));
7e7c05af8f3a implement stack set/get/remove (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 331
diff changeset
512 GListModel *list = G_LIST_MODEL(pages);
7e7c05af8f3a implement stack set/get/remove (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 331
diff changeset
513 GtkStackPage *page = g_list_model_get_item(list, index);
7e7c05af8f3a implement stack set/get/remove (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 331
diff changeset
514 if(page) {
7e7c05af8f3a implement stack set/get/remove (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 331
diff changeset
515 gtk_stack_set_visible_child(GTK_STACK(stack), gtk_stack_page_get_child(page));
7e7c05af8f3a implement stack set/get/remove (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 331
diff changeset
516 } else {
7e7c05af8f3a implement stack set/get/remove (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 331
diff changeset
517 fprintf(stderr, "UI Error: ui_stack_set value out of bounds\n");
7e7c05af8f3a implement stack set/get/remove (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 331
diff changeset
518 return -1;
7e7c05af8f3a implement stack set/get/remove (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 331
diff changeset
519 }
7e7c05af8f3a implement stack set/get/remove (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 331
diff changeset
520 return index;
7e7c05af8f3a implement stack set/get/remove (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 331
diff changeset
521 }
7e7c05af8f3a implement stack set/get/remove (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 331
diff changeset
522
331
cdad8b7e83db implement side navigation tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 330
diff changeset
523 void ui_stack_tab_select(UIWIDGET tabview, int tab) {
332
7e7c05af8f3a implement stack set/get/remove (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 331
diff changeset
524 stack_set_page(tabview, tab);
331
cdad8b7e83db implement side navigation tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 330
diff changeset
525 }
cdad8b7e83db implement side navigation tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 330
diff changeset
526
cdad8b7e83db implement side navigation tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 330
diff changeset
527 void ui_stack_tab_remove(UIWIDGET tabview, int tab) {
332
7e7c05af8f3a implement stack set/get/remove (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 331
diff changeset
528 GtkStack *stack = GTK_STACK(tabview);
7e7c05af8f3a implement stack set/get/remove (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 331
diff changeset
529 GtkWidget *current = gtk_stack_get_visible_child(stack);
7e7c05af8f3a implement stack set/get/remove (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 331
diff changeset
530 GtkSelectionModel *pages = gtk_stack_get_pages(stack);
7e7c05af8f3a implement stack set/get/remove (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 331
diff changeset
531 GListModel *list = G_LIST_MODEL(pages);
7e7c05af8f3a implement stack set/get/remove (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 331
diff changeset
532 GtkStackPage *page = g_list_model_get_item(list, tab);
7e7c05af8f3a implement stack set/get/remove (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 331
diff changeset
533 if(page) {
7e7c05af8f3a implement stack set/get/remove (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 331
diff changeset
534 gtk_stack_remove(stack, gtk_stack_page_get_child(page));
7e7c05af8f3a implement stack set/get/remove (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 331
diff changeset
535 }
331
cdad8b7e83db implement side navigation tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 330
diff changeset
536 }
cdad8b7e83db implement side navigation tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 330
diff changeset
537
cdad8b7e83db implement side navigation tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 330
diff changeset
538 void ui_stack_tab_add(UIWIDGET widget, int index, const char *name, UIWIDGET child) {
332
7e7c05af8f3a implement stack set/get/remove (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 331
diff changeset
539 (void)gtk_stack_add_titled(GTK_STACK(widget), child, name, name);
331
cdad8b7e83db implement side navigation tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 330
diff changeset
540 }
cdad8b7e83db implement side navigation tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 330
diff changeset
541
cdad8b7e83db implement side navigation tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 330
diff changeset
542 int64_t ui_stack_get(UiInteger *i) {
332
7e7c05af8f3a implement stack set/get/remove (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 331
diff changeset
543 GtkStack *stack = GTK_STACK(i->obj);
7e7c05af8f3a implement stack set/get/remove (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 331
diff changeset
544 GtkWidget *current = gtk_stack_get_visible_child(stack);
7e7c05af8f3a implement stack set/get/remove (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 331
diff changeset
545 GtkSelectionModel *pages = gtk_stack_get_pages(stack);
7e7c05af8f3a implement stack set/get/remove (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 331
diff changeset
546 GListModel *list = G_LIST_MODEL(pages);
7e7c05af8f3a implement stack set/get/remove (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 331
diff changeset
547 int nitems = g_list_model_get_n_items(list);
7e7c05af8f3a implement stack set/get/remove (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 331
diff changeset
548 for(int p=0;p<nitems;p++) {
7e7c05af8f3a implement stack set/get/remove (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 331
diff changeset
549 GtkStackPage *page = g_list_model_get_item(list, p);
7e7c05af8f3a implement stack set/get/remove (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 331
diff changeset
550 GtkWidget *child = gtk_stack_page_get_child(page);
7e7c05af8f3a implement stack set/get/remove (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 331
diff changeset
551 if(child == current) {
7e7c05af8f3a implement stack set/get/remove (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 331
diff changeset
552 i->value = p;
7e7c05af8f3a implement stack set/get/remove (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 331
diff changeset
553 break;
7e7c05af8f3a implement stack set/get/remove (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 331
diff changeset
554 }
7e7c05af8f3a implement stack set/get/remove (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 331
diff changeset
555 }
7e7c05af8f3a implement stack set/get/remove (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 331
diff changeset
556 return i->value;
331
cdad8b7e83db implement side navigation tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 330
diff changeset
557 }
cdad8b7e83db implement side navigation tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 330
diff changeset
558
cdad8b7e83db implement side navigation tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 330
diff changeset
559 void ui_stack_set(UiInteger *i, int64_t value) {
332
7e7c05af8f3a implement stack set/get/remove (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 331
diff changeset
560 GtkWidget *widget = i->obj;
7e7c05af8f3a implement stack set/get/remove (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 331
diff changeset
561 if(stack_set_page(widget, value) >= 0) {
7e7c05af8f3a implement stack set/get/remove (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 331
diff changeset
562 i->value = value;
7e7c05af8f3a implement stack set/get/remove (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 331
diff changeset
563 }
331
cdad8b7e83db implement side navigation tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 330
diff changeset
564 }
333
634e3ce80afe implement gtk3 stack tabview
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 332
diff changeset
565 #elif GTK_MAJOR_VERSION >= 3
634e3ce80afe implement gtk3 stack tabview
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 332
diff changeset
566 static GtkWidget* stack_get_child(GtkWidget *stack, int index) {
634e3ce80afe implement gtk3 stack tabview
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 332
diff changeset
567 GList *children = gtk_container_get_children(GTK_CONTAINER(stack));
634e3ce80afe implement gtk3 stack tabview
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 332
diff changeset
568 if(children) {
634e3ce80afe implement gtk3 stack tabview
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 332
diff changeset
569 return g_list_nth_data(children, index);
634e3ce80afe implement gtk3 stack tabview
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 332
diff changeset
570 }
634e3ce80afe implement gtk3 stack tabview
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 332
diff changeset
571 return NULL;
634e3ce80afe implement gtk3 stack tabview
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 332
diff changeset
572 }
634e3ce80afe implement gtk3 stack tabview
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 332
diff changeset
573
634e3ce80afe implement gtk3 stack tabview
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 332
diff changeset
574 void ui_stack_tab_select(UIWIDGET tabview, int tab) {
634e3ce80afe implement gtk3 stack tabview
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 332
diff changeset
575 GtkWidget *child = stack_get_child(tabview, tab);
634e3ce80afe implement gtk3 stack tabview
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 332
diff changeset
576 if(child) {
634e3ce80afe implement gtk3 stack tabview
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 332
diff changeset
577 gtk_stack_set_visible_child(GTK_STACK(tabview), child);
634e3ce80afe implement gtk3 stack tabview
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 332
diff changeset
578 }
634e3ce80afe implement gtk3 stack tabview
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 332
diff changeset
579 }
634e3ce80afe implement gtk3 stack tabview
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 332
diff changeset
580
634e3ce80afe implement gtk3 stack tabview
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 332
diff changeset
581 void ui_stack_tab_remove(UIWIDGET tabview, int tab) {
634e3ce80afe implement gtk3 stack tabview
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 332
diff changeset
582 GtkWidget *child = stack_get_child(tabview, tab);
634e3ce80afe implement gtk3 stack tabview
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 332
diff changeset
583 if(child) {
634e3ce80afe implement gtk3 stack tabview
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 332
diff changeset
584 gtk_container_remove(GTK_CONTAINER(tabview), child);
634e3ce80afe implement gtk3 stack tabview
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 332
diff changeset
585 }
634e3ce80afe implement gtk3 stack tabview
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 332
diff changeset
586 }
634e3ce80afe implement gtk3 stack tabview
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 332
diff changeset
587
634e3ce80afe implement gtk3 stack tabview
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 332
diff changeset
588 void ui_stack_tab_add(UIWIDGET widget, int index, const char *name, UIWIDGET child) {
634e3ce80afe implement gtk3 stack tabview
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 332
diff changeset
589 gtk_stack_add_titled(GTK_STACK(widget), child, name, name);
634e3ce80afe implement gtk3 stack tabview
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 332
diff changeset
590 }
634e3ce80afe implement gtk3 stack tabview
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 332
diff changeset
591
634e3ce80afe implement gtk3 stack tabview
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 332
diff changeset
592 int64_t ui_stack_get(UiInteger *i) {
634e3ce80afe implement gtk3 stack tabview
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 332
diff changeset
593 GtkWidget *visible = gtk_stack_get_visible_child(GTK_STACK(i->obj));
634e3ce80afe implement gtk3 stack tabview
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 332
diff changeset
594 GList *children = gtk_container_get_children(GTK_CONTAINER(i->obj));
634e3ce80afe implement gtk3 stack tabview
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 332
diff changeset
595 GList *elm = children;
634e3ce80afe implement gtk3 stack tabview
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 332
diff changeset
596 int n = 0;
634e3ce80afe implement gtk3 stack tabview
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 332
diff changeset
597 int64_t v = -1;
634e3ce80afe implement gtk3 stack tabview
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 332
diff changeset
598 while(elm) {
634e3ce80afe implement gtk3 stack tabview
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 332
diff changeset
599 GtkWidget *child = elm->data;
634e3ce80afe implement gtk3 stack tabview
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 332
diff changeset
600 if(child == visible) {
634e3ce80afe implement gtk3 stack tabview
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 332
diff changeset
601 v = n;
634e3ce80afe implement gtk3 stack tabview
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 332
diff changeset
602 break;
634e3ce80afe implement gtk3 stack tabview
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 332
diff changeset
603 }
634e3ce80afe implement gtk3 stack tabview
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 332
diff changeset
604
634e3ce80afe implement gtk3 stack tabview
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 332
diff changeset
605 elm = elm->next;
634e3ce80afe implement gtk3 stack tabview
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 332
diff changeset
606 n++;
634e3ce80afe implement gtk3 stack tabview
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 332
diff changeset
607 }
634e3ce80afe implement gtk3 stack tabview
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 332
diff changeset
608 g_list_free(children);
634e3ce80afe implement gtk3 stack tabview
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 332
diff changeset
609 i->value = v;
634e3ce80afe implement gtk3 stack tabview
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 332
diff changeset
610 return v;
634e3ce80afe implement gtk3 stack tabview
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 332
diff changeset
611 }
634e3ce80afe implement gtk3 stack tabview
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 332
diff changeset
612
634e3ce80afe implement gtk3 stack tabview
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 332
diff changeset
613 void ui_stack_set(UiInteger *i, int64_t value) {
634e3ce80afe implement gtk3 stack tabview
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 332
diff changeset
614 GtkWidget *child = stack_get_child(i->obj, value);
634e3ce80afe implement gtk3 stack tabview
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 332
diff changeset
615 if(child) {
634e3ce80afe implement gtk3 stack tabview
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 332
diff changeset
616 gtk_stack_set_visible_child(GTK_STACK(i->obj), child);
634e3ce80afe implement gtk3 stack tabview
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 332
diff changeset
617 i->value = value;
634e3ce80afe implement gtk3 stack tabview
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 332
diff changeset
618 }
634e3ce80afe implement gtk3 stack tabview
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 332
diff changeset
619 }
634e3ce80afe implement gtk3 stack tabview
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 332
diff changeset
620
634e3ce80afe implement gtk3 stack tabview
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 332
diff changeset
621 #endif
634e3ce80afe implement gtk3 stack tabview
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 332
diff changeset
622
634e3ce80afe implement gtk3 stack tabview
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 332
diff changeset
623
331
cdad8b7e83db implement side navigation tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 330
diff changeset
624
cdad8b7e83db implement side navigation tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 330
diff changeset
625
328
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
626 UiGtkTabView* ui_widget_get_tabview_data(UIWIDGET tabview) {
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
627 return g_object_get_data(G_OBJECT(tabview), "ui_tabview");
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
628 }
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
629
330
d615aa36c98e add tabview value/varname parameter
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 328
diff changeset
630 typedef int64_t(*ui_tabview_get_func)(UiInteger*);
d615aa36c98e add tabview value/varname parameter
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 328
diff changeset
631 typedef void (*ui_tabview_set_func)(UiInteger*, int64_t);
d615aa36c98e add tabview value/varname parameter
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 328
diff changeset
632
328
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
633 UIWIDGET ui_tabview_create(UiObject* obj, UiTabViewArgs args) {
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
634 UiGtkTabView *data = malloc(sizeof(UiGtkTabView));
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
635 data->margin = args.margin;
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
636 data->spacing = args.spacing;
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
637 data->columnspacing = args.columnspacing;
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
638 data->rowspacing = args.rowspacing;
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
639
330
d615aa36c98e add tabview value/varname parameter
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 328
diff changeset
640 ui_tabview_get_func getfunc = NULL;
d615aa36c98e add tabview value/varname parameter
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 328
diff changeset
641 ui_tabview_set_func setfunc = NULL;
d615aa36c98e add tabview value/varname parameter
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 328
diff changeset
642
328
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
643 GtkWidget *widget = NULL;
331
cdad8b7e83db implement side navigation tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 330
diff changeset
644 GtkWidget *data_widget = NULL;
328
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
645 switch(args.tabview) {
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
646 case UI_TABVIEW_DOC: {
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
647 // TODO
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
648 break;
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
649 }
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
650 case UI_TABVIEW_NAVIGATION_SIDE: {
331
cdad8b7e83db implement side navigation tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 330
diff changeset
651 #if GTK_CHECK_VERSION(3, 10, 0)
cdad8b7e83db implement side navigation tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 330
diff changeset
652 widget = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
cdad8b7e83db implement side navigation tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 330
diff changeset
653 GtkWidget *sidebar = gtk_stack_sidebar_new();
cdad8b7e83db implement side navigation tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 330
diff changeset
654 BOX_ADD(widget, sidebar);
cdad8b7e83db implement side navigation tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 330
diff changeset
655 GtkWidget *stack = gtk_stack_new();
cdad8b7e83db implement side navigation tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 330
diff changeset
656 gtk_stack_set_transition_type (GTK_STACK(stack), GTK_STACK_TRANSITION_TYPE_SLIDE_UP_DOWN);
cdad8b7e83db implement side navigation tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 330
diff changeset
657 gtk_stack_sidebar_set_stack(GTK_STACK_SIDEBAR(sidebar), GTK_STACK(stack));
cdad8b7e83db implement side navigation tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 330
diff changeset
658 BOX_ADD_EXPAND(widget, stack);
cdad8b7e83db implement side navigation tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 330
diff changeset
659 data->select_tab = ui_stack_tab_select;
cdad8b7e83db implement side navigation tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 330
diff changeset
660 data->remove_tab = ui_stack_tab_remove;
cdad8b7e83db implement side navigation tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 330
diff changeset
661 data->add_tab = ui_stack_tab_add;
cdad8b7e83db implement side navigation tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 330
diff changeset
662 getfunc = ui_stack_get;
cdad8b7e83db implement side navigation tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 330
diff changeset
663 setfunc = ui_stack_set;
cdad8b7e83db implement side navigation tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 330
diff changeset
664 data_widget = stack;
cdad8b7e83db implement side navigation tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 330
diff changeset
665 #else
328
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
666 // TODO
331
cdad8b7e83db implement side navigation tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 330
diff changeset
667 #endif
328
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
668 break;
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
669 }
330
d615aa36c98e add tabview value/varname parameter
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 328
diff changeset
670 case UI_TABVIEW_DEFAULT: /* fall through */
d615aa36c98e add tabview value/varname parameter
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 328
diff changeset
671 case UI_TABVIEW_NAVIGATION_TOP: /* fall through */
333
634e3ce80afe implement gtk3 stack tabview
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 332
diff changeset
672 case UI_TABVIEW_INVISIBLE: /* fall through */
328
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
673 case UI_TABVIEW_NAVIGATION_TOP2: {
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
674 widget = gtk_notebook_new();
331
cdad8b7e83db implement side navigation tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 330
diff changeset
675 data_widget = widget;
328
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
676 data->select_tab = ui_notebook_tab_select;
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
677 data->remove_tab = ui_notebook_tab_remove;
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
678 data->add_tab = ui_notebook_tab_add;
330
d615aa36c98e add tabview value/varname parameter
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 328
diff changeset
679 getfunc = ui_notebook_get;
d615aa36c98e add tabview value/varname parameter
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 328
diff changeset
680 setfunc = ui_notebook_set;
333
634e3ce80afe implement gtk3 stack tabview
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 332
diff changeset
681 if(args.tabview == UI_TABVIEW_INVISIBLE) {
634e3ce80afe implement gtk3 stack tabview
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 332
diff changeset
682 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(widget), FALSE);
634e3ce80afe implement gtk3 stack tabview
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 332
diff changeset
683 gtk_notebook_set_show_border(GTK_NOTEBOOK(widget), FALSE);
634e3ce80afe implement gtk3 stack tabview
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 332
diff changeset
684 }
328
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
685 break;
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
686 }
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
687 }
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
688
330
d615aa36c98e add tabview value/varname parameter
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 328
diff changeset
689 UiObject* current = uic_current_obj(obj);
d615aa36c98e add tabview value/varname parameter
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 328
diff changeset
690 if(args.value || args.varname) {
d615aa36c98e add tabview value/varname parameter
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 328
diff changeset
691 UiVar *var = uic_widget_var(obj->ctx, current->ctx, args.value, args.varname, UI_VAR_INTEGER);
d615aa36c98e add tabview value/varname parameter
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 328
diff changeset
692 UiInteger *i = var->value;
d615aa36c98e add tabview value/varname parameter
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 328
diff changeset
693 i->get = getfunc;
d615aa36c98e add tabview value/varname parameter
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 328
diff changeset
694 i->set = setfunc;
332
7e7c05af8f3a implement stack set/get/remove (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 331
diff changeset
695 i->obj = data_widget;
330
d615aa36c98e add tabview value/varname parameter
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 328
diff changeset
696 }
d615aa36c98e add tabview value/varname parameter
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 328
diff changeset
697
328
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
698 g_object_set_data(G_OBJECT(widget), "ui_tabview", data);
331
cdad8b7e83db implement side navigation tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 330
diff changeset
699 data->widget = data_widget;
328
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
700 data->subcontainer = args.subcontainer;
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
701
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
702 UI_APPLY_LAYOUT1(current, args);
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
703 current->container->add(current->container, widget, TRUE);
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
704
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
705 UiObject *newobj = uic_object_new(obj, widget);
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
706 newobj->container = ui_tabview_container(obj, widget);
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
707 uic_obj_add(obj, newobj);
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
708 data->obj = newobj;
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
709
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
710 return widget;
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
711 }
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
712
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
713 void ui_tab_create(UiObject* obj, const char* title) {
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
714 UiObject* current = uic_current_obj(obj);
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
715 UiGtkTabView *data = ui_widget_get_tabview_data(current->widget);
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
716 if(!data) {
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
717 fprintf(stderr, "UI Error: widget is not a tabview\n");
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
718 return;
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
719 }
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
720
331
cdad8b7e83db implement side navigation tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 330
diff changeset
721 UiObject *newobj = ui_tabview_add(current->widget, title, -1);
328
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
722 current->next = newobj;
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
723 }
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
724
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
725
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
726
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
727 void ui_tabview_select(UIWIDGET tabview, int tab) {
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
728 UiGtkTabView *data = ui_widget_get_tabview_data(tabview);
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
729 if(!data) {
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
730 fprintf(stderr, "UI Error: widget is not a tabview\n");
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
731 return;
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
732 }
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
733 data->select_tab(tabview, tab);
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
734 }
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
735
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
736 void ui_tabview_remove(UIWIDGET tabview, int tab) {
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
737 UiGtkTabView *data = ui_widget_get_tabview_data(tabview);
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
738 if(!data) {
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
739 fprintf(stderr, "UI Error: widget is not a tabview\n");
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
740 return;
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
741 }
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
742 data->remove_tab(tabview, tab);
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
743 }
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
744
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
745 UiObject* ui_tabview_add(UIWIDGET tabview, const char *name, int tab_index) {
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
746 UiGtkTabView *data = ui_widget_get_tabview_data(tabview);
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
747 if(!data) {
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
748 fprintf(stderr, "UI Error: widget is not a tabview\n");
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
749 return NULL;
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
750 }
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
751
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
752 UiObject *newobj = cxCalloc(data->obj->ctx->allocator, 1, sizeof(UiObject));
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
753 newobj->ctx = data->obj->ctx;
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
754
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
755 GtkWidget *sub;
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
756 switch(data->subcontainer) {
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
757 default: {
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
758 sub = ui_gtk_vbox_new(data->spacing);
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
759 newobj->container = ui_box_container(newobj, sub, data->subcontainer);
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
760 break;
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
761 }
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
762 case UI_CONTAINER_HBOX: {
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
763 sub = ui_gtk_hbox_new(data->spacing);
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
764 newobj->container = ui_box_container(newobj, sub, data->subcontainer);
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
765 break;
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
766 }
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
767 case UI_CONTAINER_GRID: {
344
870dd3d41d83 add dialog window (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 336
diff changeset
768 sub = ui_create_grid_widget(data->columnspacing, data->rowspacing);
328
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
769 newobj->container = ui_grid_container(newobj, sub);
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
770 break;
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
771 }
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
772 }
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
773 newobj->widget = sub;
344
870dd3d41d83 add dialog window (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 336
diff changeset
774 GtkWidget *widget = ui_box_set_margin(sub, data->margin);
328
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
775
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
776 data->add_tab(data->widget, tab_index, name, widget);
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
777
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
778 return newobj;
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
779 }
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
780
336
56c12f44c2d3 add custom headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 333
diff changeset
781
56c12f44c2d3 add custom headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 333
diff changeset
782 /* -------------------- Headerbar -------------------- */
56c12f44c2d3 add custom headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 333
diff changeset
783
56c12f44c2d3 add custom headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 333
diff changeset
784 static void hb_set_part(UiObject *obj, int part) {
56c12f44c2d3 add custom headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 333
diff changeset
785 UiObject* current = uic_current_obj(obj);
56c12f44c2d3 add custom headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 333
diff changeset
786 GtkWidget *headerbar = current->widget;
56c12f44c2d3 add custom headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 333
diff changeset
787
56c12f44c2d3 add custom headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 333
diff changeset
788 UiHeaderbarContainer *hb = cxCalloc(
56c12f44c2d3 add custom headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 333
diff changeset
789 obj->ctx->allocator,
56c12f44c2d3 add custom headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 333
diff changeset
790 1,
56c12f44c2d3 add custom headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 333
diff changeset
791 sizeof(UiHeaderbarContainer));
56c12f44c2d3 add custom headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 333
diff changeset
792 memcpy(hb, current->container, sizeof(UiHeaderbarContainer));
56c12f44c2d3 add custom headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 333
diff changeset
793
56c12f44c2d3 add custom headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 333
diff changeset
794 UiObject *newobj = uic_object_new(obj, headerbar);
56c12f44c2d3 add custom headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 333
diff changeset
795 newobj->container = (UiContainer*)hb;
56c12f44c2d3 add custom headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 333
diff changeset
796 uic_obj_add(obj, newobj);
56c12f44c2d3 add custom headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 333
diff changeset
797
56c12f44c2d3 add custom headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 333
diff changeset
798 hb->part = part;
56c12f44c2d3 add custom headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 333
diff changeset
799 }
56c12f44c2d3 add custom headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 333
diff changeset
800
56c12f44c2d3 add custom headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 333
diff changeset
801 void ui_headerbar_start_create(UiObject *obj) {
56c12f44c2d3 add custom headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 333
diff changeset
802 hb_set_part(obj, 0);
56c12f44c2d3 add custom headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 333
diff changeset
803 }
56c12f44c2d3 add custom headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 333
diff changeset
804
56c12f44c2d3 add custom headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 333
diff changeset
805 void ui_headerbar_center_create(UiObject *obj) {
56c12f44c2d3 add custom headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 333
diff changeset
806 hb_set_part(obj, 2);
56c12f44c2d3 add custom headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 333
diff changeset
807 }
56c12f44c2d3 add custom headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 333
diff changeset
808
56c12f44c2d3 add custom headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 333
diff changeset
809 void ui_headerbar_end_create(UiObject *obj) {
56c12f44c2d3 add custom headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 333
diff changeset
810 hb_set_part(obj, 1);
56c12f44c2d3 add custom headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 333
diff changeset
811 }
56c12f44c2d3 add custom headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 333
diff changeset
812
56c12f44c2d3 add custom headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 333
diff changeset
813 UIWIDGET ui_headerbar_fallback_create(UiObject *obj, UiHeaderbarArgs args) {
56c12f44c2d3 add custom headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 333
diff changeset
814 UiObject *current = uic_current_obj(obj);
56c12f44c2d3 add custom headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 333
diff changeset
815 UiContainer *ct = current->container;
56c12f44c2d3 add custom headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 333
diff changeset
816 UI_APPLY_LAYOUT1(current, args);
56c12f44c2d3 add custom headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 333
diff changeset
817
56c12f44c2d3 add custom headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 333
diff changeset
818 GtkWidget *box = ui_gtk_hbox_new(args.alt_spacing);
56c12f44c2d3 add custom headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 333
diff changeset
819 ui_set_name_and_style(box, args.name, args.style_class);
56c12f44c2d3 add custom headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 333
diff changeset
820 ct->add(ct, box, FALSE);
56c12f44c2d3 add custom headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 333
diff changeset
821
56c12f44c2d3 add custom headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 333
diff changeset
822 UiObject *newobj = uic_object_new(obj, box);
56c12f44c2d3 add custom headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 333
diff changeset
823 newobj->container = ui_headerbar_fallback_container(obj, box);
56c12f44c2d3 add custom headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 333
diff changeset
824 uic_obj_add(obj, newobj);
56c12f44c2d3 add custom headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 333
diff changeset
825
56c12f44c2d3 add custom headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 333
diff changeset
826 return box;
56c12f44c2d3 add custom headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 333
diff changeset
827 }
56c12f44c2d3 add custom headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 333
diff changeset
828
56c12f44c2d3 add custom headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 333
diff changeset
829 static void hb_fallback_set_part(UiObject *obj, int part) {
56c12f44c2d3 add custom headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 333
diff changeset
830 UiObject* current = uic_current_obj(obj);
56c12f44c2d3 add custom headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 333
diff changeset
831 GtkWidget *headerbar = current->widget;
56c12f44c2d3 add custom headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 333
diff changeset
832
56c12f44c2d3 add custom headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 333
diff changeset
833 UiObject *newobj = uic_object_new(obj, headerbar);
56c12f44c2d3 add custom headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 333
diff changeset
834 newobj->container = ui_headerbar_container(obj, headerbar);
56c12f44c2d3 add custom headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 333
diff changeset
835 uic_obj_add(obj, newobj);
56c12f44c2d3 add custom headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 333
diff changeset
836
56c12f44c2d3 add custom headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 333
diff changeset
837 UiHeaderbarContainer *hb = (UiHeaderbarContainer*)newobj->container;
56c12f44c2d3 add custom headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 333
diff changeset
838 hb->part = part;
56c12f44c2d3 add custom headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 333
diff changeset
839 }
56c12f44c2d3 add custom headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 333
diff changeset
840
56c12f44c2d3 add custom headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 333
diff changeset
841 UiContainer* ui_headerbar_fallback_container(UiObject *obj, GtkWidget *headerbar) {
56c12f44c2d3 add custom headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 333
diff changeset
842 UiHeaderbarContainer *ct = cxCalloc(
56c12f44c2d3 add custom headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 333
diff changeset
843 obj->ctx->allocator,
56c12f44c2d3 add custom headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 333
diff changeset
844 1,
56c12f44c2d3 add custom headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 333
diff changeset
845 sizeof(UiHeaderbarContainer));
56c12f44c2d3 add custom headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 333
diff changeset
846 ct->container.widget = headerbar;
56c12f44c2d3 add custom headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 333
diff changeset
847 ct->container.add = ui_headerbar_fallback_container_add;
56c12f44c2d3 add custom headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 333
diff changeset
848 return (UiContainer*)ct;
56c12f44c2d3 add custom headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 333
diff changeset
849 }
56c12f44c2d3 add custom headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 333
diff changeset
850
56c12f44c2d3 add custom headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 333
diff changeset
851 void ui_headerbar_fallback_container_add(UiContainer *ct, GtkWidget *widget, UiBool fill) {
56c12f44c2d3 add custom headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 333
diff changeset
852 UiHeaderbarContainer *hb = (UiHeaderbarContainer*)ct;
56c12f44c2d3 add custom headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 333
diff changeset
853 BOX_ADD(ct->widget, widget);
56c12f44c2d3 add custom headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 333
diff changeset
854 }
56c12f44c2d3 add custom headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 333
diff changeset
855
56c12f44c2d3 add custom headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 333
diff changeset
856 #if GTK_CHECK_VERSION(3, 10, 0)
56c12f44c2d3 add custom headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 333
diff changeset
857
56c12f44c2d3 add custom headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 333
diff changeset
858 UIWIDGET ui_headerbar_create(UiObject *obj, UiHeaderbarArgs args) {
56c12f44c2d3 add custom headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 333
diff changeset
859 GtkWidget *headerbar = g_object_get_data(G_OBJECT(obj->widget), "ui_headerbar");
56c12f44c2d3 add custom headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 333
diff changeset
860 if(!headerbar) {
56c12f44c2d3 add custom headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 333
diff changeset
861 return ui_headerbar_fallback_create(obj, args);
56c12f44c2d3 add custom headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 333
diff changeset
862 }
56c12f44c2d3 add custom headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 333
diff changeset
863
56c12f44c2d3 add custom headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 333
diff changeset
864 UiObject *newobj = uic_object_new(obj, headerbar);
56c12f44c2d3 add custom headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 333
diff changeset
865 newobj->container = ui_headerbar_container(obj, headerbar);
56c12f44c2d3 add custom headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 333
diff changeset
866 uic_obj_add(obj, newobj);
56c12f44c2d3 add custom headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 333
diff changeset
867
56c12f44c2d3 add custom headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 333
diff changeset
868 return headerbar;
56c12f44c2d3 add custom headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 333
diff changeset
869 }
56c12f44c2d3 add custom headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 333
diff changeset
870
56c12f44c2d3 add custom headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 333
diff changeset
871 UiContainer* ui_headerbar_container(UiObject *obj, GtkWidget *headerbar) {
56c12f44c2d3 add custom headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 333
diff changeset
872 UiHeaderbarContainer *ct = cxCalloc(
56c12f44c2d3 add custom headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 333
diff changeset
873 obj->ctx->allocator,
56c12f44c2d3 add custom headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 333
diff changeset
874 1,
56c12f44c2d3 add custom headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 333
diff changeset
875 sizeof(UiHeaderbarContainer));
56c12f44c2d3 add custom headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 333
diff changeset
876 ct->container.widget = headerbar;
56c12f44c2d3 add custom headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 333
diff changeset
877 ct->container.add = ui_headerbar_container_add;
56c12f44c2d3 add custom headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 333
diff changeset
878 return (UiContainer*)ct;
56c12f44c2d3 add custom headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 333
diff changeset
879 }
56c12f44c2d3 add custom headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 333
diff changeset
880
56c12f44c2d3 add custom headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 333
diff changeset
881 void ui_headerbar_container_add(UiContainer *ct, GtkWidget *widget, UiBool fill) {
56c12f44c2d3 add custom headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 333
diff changeset
882 UiHeaderbarContainer *hb = (UiHeaderbarContainer*)ct;
56c12f44c2d3 add custom headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 333
diff changeset
883 if(hb->part == 0) {
56c12f44c2d3 add custom headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 333
diff changeset
884 UI_HEADERBAR_PACK_START(ct->widget, widget);
56c12f44c2d3 add custom headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 333
diff changeset
885 } else if(hb->part == 1) {
56c12f44c2d3 add custom headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 333
diff changeset
886 UI_HEADERBAR_PACK_END(ct->widget, widget);
56c12f44c2d3 add custom headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 333
diff changeset
887 } else if(hb->part == 2) {
56c12f44c2d3 add custom headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 333
diff changeset
888 if(!hb->centerbox) {
56c12f44c2d3 add custom headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 333
diff changeset
889 GtkWidget *box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 6);
56c12f44c2d3 add custom headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 333
diff changeset
890 hb->centerbox = box;
56c12f44c2d3 add custom headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 333
diff changeset
891 UI_HEADERBAR_SET_TITLE_WIDGET(ct->widget, box);
56c12f44c2d3 add custom headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 333
diff changeset
892 }
56c12f44c2d3 add custom headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 333
diff changeset
893 BOX_ADD(hb->centerbox, widget);
56c12f44c2d3 add custom headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 333
diff changeset
894 }
56c12f44c2d3 add custom headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 333
diff changeset
895 }
56c12f44c2d3 add custom headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 333
diff changeset
896
56c12f44c2d3 add custom headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 333
diff changeset
897 #else
56c12f44c2d3 add custom headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 333
diff changeset
898
56c12f44c2d3 add custom headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 333
diff changeset
899 UIWIDGET ui_headerbar_create(UiObject *obj, UiHeaderbarArgs args) {
56c12f44c2d3 add custom headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 333
diff changeset
900 return ui_headerbar_fallback_create(obj, args);
56c12f44c2d3 add custom headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 333
diff changeset
901 }
56c12f44c2d3 add custom headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 333
diff changeset
902
56c12f44c2d3 add custom headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 333
diff changeset
903 #endif
56c12f44c2d3 add custom headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 333
diff changeset
904
409
86fbc80f0be7 add sidebar (libadwaita)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 378
diff changeset
905 /* -------------------- Sidebar -------------------- */
86fbc80f0be7 add sidebar (libadwaita)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 378
diff changeset
906
86fbc80f0be7 add sidebar (libadwaita)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 378
diff changeset
907 #ifdef UI_LIBADWAITA
86fbc80f0be7 add sidebar (libadwaita)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 378
diff changeset
908 UIWIDGET ui_sidebar_create(UiObject *obj, UiSidebarArgs args) {
86fbc80f0be7 add sidebar (libadwaita)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 378
diff changeset
909 GtkWidget *sidebar_toolbar_view = g_object_get_data(G_OBJECT(obj->widget), "ui_sidebar");
86fbc80f0be7 add sidebar (libadwaita)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 378
diff changeset
910 if(!sidebar_toolbar_view) {
86fbc80f0be7 add sidebar (libadwaita)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 378
diff changeset
911 fprintf(stderr, "Error: window is not configured for sidebar\n");
86fbc80f0be7 add sidebar (libadwaita)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 378
diff changeset
912 return NULL;
86fbc80f0be7 add sidebar (libadwaita)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 378
diff changeset
913 }
86fbc80f0be7 add sidebar (libadwaita)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 378
diff changeset
914
86fbc80f0be7 add sidebar (libadwaita)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 378
diff changeset
915 GtkWidget *box = ui_gtk_vbox_new(args.spacing);
86fbc80f0be7 add sidebar (libadwaita)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 378
diff changeset
916 ui_box_set_margin(box, args.margin);
86fbc80f0be7 add sidebar (libadwaita)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 378
diff changeset
917 adw_toolbar_view_set_content(ADW_TOOLBAR_VIEW(sidebar_toolbar_view), box);
86fbc80f0be7 add sidebar (libadwaita)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 378
diff changeset
918
86fbc80f0be7 add sidebar (libadwaita)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 378
diff changeset
919 UiObject *newobj = uic_object_new(obj, box);
86fbc80f0be7 add sidebar (libadwaita)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 378
diff changeset
920 newobj->container = ui_box_container(obj, box, UI_CONTAINER_VBOX);
86fbc80f0be7 add sidebar (libadwaita)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 378
diff changeset
921 uic_obj_add(obj, newobj);
86fbc80f0be7 add sidebar (libadwaita)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 378
diff changeset
922
86fbc80f0be7 add sidebar (libadwaita)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 378
diff changeset
923 return box;
86fbc80f0be7 add sidebar (libadwaita)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 378
diff changeset
924 }
410
a080c69125d1 add sidebar implementation (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 409
diff changeset
925 #else
a080c69125d1 add sidebar implementation (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 409
diff changeset
926 UIWIDGET ui_sidebar_create(UiObject *obj, UiSidebarArgs args) {
a080c69125d1 add sidebar implementation (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 409
diff changeset
927 GtkWidget *sidebar_vbox = g_object_get_data(G_OBJECT(obj->widget), "ui_sidebar");
a080c69125d1 add sidebar implementation (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 409
diff changeset
928
a080c69125d1 add sidebar implementation (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 409
diff changeset
929 GtkWidget *box = ui_gtk_vbox_new(args.spacing);
a080c69125d1 add sidebar implementation (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 409
diff changeset
930 ui_box_set_margin(box, args.margin);
a080c69125d1 add sidebar implementation (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 409
diff changeset
931 BOX_ADD_EXPAND(sidebar_vbox, box);
a080c69125d1 add sidebar implementation (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 409
diff changeset
932
a080c69125d1 add sidebar implementation (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 409
diff changeset
933 UiObject *newobj = uic_object_new(obj, box);
a080c69125d1 add sidebar implementation (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 409
diff changeset
934 newobj->container = ui_box_container(obj, box, UI_CONTAINER_VBOX);
a080c69125d1 add sidebar implementation (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 409
diff changeset
935 uic_obj_add(obj, newobj);
a080c69125d1 add sidebar implementation (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 409
diff changeset
936
a080c69125d1 add sidebar implementation (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 409
diff changeset
937 return box;
a080c69125d1 add sidebar implementation (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 409
diff changeset
938 }
409
86fbc80f0be7 add sidebar (libadwaita)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 378
diff changeset
939 #endif
86fbc80f0be7 add sidebar (libadwaita)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 378
diff changeset
940
165
3f32db79a76e add splitpane (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 163
diff changeset
941 /* -------------------- Splitpane -------------------- */
59
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
942
165
3f32db79a76e add splitpane (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 163
diff changeset
943 static GtkWidget* create_paned(UiOrientation orientation) {
297
a73c60adf188 port container to gtk4
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 273
diff changeset
944 #if GTK_MAJOR_VERSION >= 3
165
3f32db79a76e add splitpane (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 163
diff changeset
945 switch(orientation) {
3f32db79a76e add splitpane (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 163
diff changeset
946 case UI_HORIZONTAL: return gtk_paned_new(GTK_ORIENTATION_HORIZONTAL);
3f32db79a76e add splitpane (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 163
diff changeset
947 case UI_VERTICAL: return gtk_paned_new(GTK_ORIENTATION_VERTICAL);
3f32db79a76e add splitpane (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 163
diff changeset
948 }
3f32db79a76e add splitpane (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 163
diff changeset
949 #else
3f32db79a76e add splitpane (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 163
diff changeset
950 switch(orientation) {
3f32db79a76e add splitpane (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 163
diff changeset
951 case UI_HORIZONTAL: return gtk_hpaned_new();
3f32db79a76e add splitpane (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 163
diff changeset
952 case UI_VERTICAL: return gtk_vpaned_new();
3f32db79a76e add splitpane (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 163
diff changeset
953 }
3f32db79a76e add splitpane (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 163
diff changeset
954 #endif
3f32db79a76e add splitpane (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 163
diff changeset
955 return NULL;
3f32db79a76e add splitpane (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 163
diff changeset
956 }
3f32db79a76e add splitpane (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 163
diff changeset
957
3f32db79a76e add splitpane (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 163
diff changeset
958
3f32db79a76e add splitpane (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 163
diff changeset
959
422
c1354a29a7e9 add item list container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 410
diff changeset
960 /* -------------------- ItemList Container -------------------- */
c1354a29a7e9 add item list container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 410
diff changeset
961
c1354a29a7e9 add item list container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 410
diff changeset
962 static void remove_item(void *data, void *item) {
c1354a29a7e9 add item list container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 410
diff changeset
963 UiGtkItemListContainer *ct = data;
c1354a29a7e9 add item list container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 410
diff changeset
964 UiObject *obj = item;
c1354a29a7e9 add item list container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 410
diff changeset
965 if(ct->remove_items) {
c1354a29a7e9 add item list container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 410
diff changeset
966 BOX_REMOVE(ct->widget, obj->widget);
c1354a29a7e9 add item list container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 410
diff changeset
967 }
c1354a29a7e9 add item list container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 410
diff changeset
968 uic_object_destroy(obj);
c1354a29a7e9 add item list container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 410
diff changeset
969 }
c1354a29a7e9 add item list container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 410
diff changeset
970
c1354a29a7e9 add item list container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 410
diff changeset
971 static void update_itemlist(UiList *list, int c) {
c1354a29a7e9 add item list container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 410
diff changeset
972 UiGtkItemListContainer *ct = list->obj;
c1354a29a7e9 add item list container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 410
diff changeset
973
c1354a29a7e9 add item list container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 410
diff changeset
974 CxMap *new_items = cxHashMapCreateSimple(CX_STORE_POINTERS);
c1354a29a7e9 add item list container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 410
diff changeset
975 new_items->collection.advanced_destructor = remove_item;
c1354a29a7e9 add item list container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 410
diff changeset
976 new_items->collection.destructor_data = ct;
c1354a29a7e9 add item list container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 410
diff changeset
977
c1354a29a7e9 add item list container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 410
diff changeset
978 // only create new widgets for new elements, so at first we have
c1354a29a7e9 add item list container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 410
diff changeset
979 // to find which elements are new
c1354a29a7e9 add item list container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 410
diff changeset
980 // check which elements in the list are already in the container
c1354a29a7e9 add item list container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 410
diff changeset
981 void *elm = list->first(list);
c1354a29a7e9 add item list container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 410
diff changeset
982 int j = 0;
c1354a29a7e9 add item list container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 410
diff changeset
983 while(elm) {
c1354a29a7e9 add item list container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 410
diff changeset
984 CxHashKey key = cx_hash_key(&elm, sizeof(void*));
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 422
diff changeset
985 UiObject *item_obj = NULL;
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 422
diff changeset
986 cxMapRemoveAndGet(ct->current_items, key, &item_obj);
422
c1354a29a7e9 add item list container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 410
diff changeset
987 if(item_obj) {
c1354a29a7e9 add item list container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 410
diff changeset
988 g_object_ref(G_OBJECT(item_obj->widget));
c1354a29a7e9 add item list container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 410
diff changeset
989 BOX_REMOVE(ct->widget, item_obj->widget);
c1354a29a7e9 add item list container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 410
diff changeset
990 cxMapPut(new_items, key, item_obj);
c1354a29a7e9 add item list container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 410
diff changeset
991 }
c1354a29a7e9 add item list container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 410
diff changeset
992 elm = list->next(list);
c1354a29a7e9 add item list container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 410
diff changeset
993 j++;
c1354a29a7e9 add item list container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 410
diff changeset
994 }
c1354a29a7e9 add item list container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 410
diff changeset
995
c1354a29a7e9 add item list container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 410
diff changeset
996 // ct->current_items only contains elements, that are not in the list
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 422
diff changeset
997 cxMapFree(ct->current_items); // calls destructor remove_item
422
c1354a29a7e9 add item list container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 410
diff changeset
998 ct->current_items = new_items;
c1354a29a7e9 add item list container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 410
diff changeset
999
c1354a29a7e9 add item list container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 410
diff changeset
1000 // add all items
c1354a29a7e9 add item list container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 410
diff changeset
1001 int index = 0;
c1354a29a7e9 add item list container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 410
diff changeset
1002 elm = list->first(list);
c1354a29a7e9 add item list container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 410
diff changeset
1003 while(elm) {
c1354a29a7e9 add item list container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 410
diff changeset
1004 CxHashKey key = cx_hash_key(&elm, sizeof(void*));
c1354a29a7e9 add item list container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 410
diff changeset
1005 UiObject *item_obj = cxMapGet(ct->current_items, key);
c1354a29a7e9 add item list container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 410
diff changeset
1006 if(item_obj) {
c1354a29a7e9 add item list container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 410
diff changeset
1007 // re-add previously created widget
c1354a29a7e9 add item list container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 410
diff changeset
1008 ui_box_container_add(ct->container, item_obj->widget, FALSE);
c1354a29a7e9 add item list container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 410
diff changeset
1009 } else {
c1354a29a7e9 add item list container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 410
diff changeset
1010 // create new widget and object for this list element
c1354a29a7e9 add item list container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 410
diff changeset
1011 CxMempool *mp = cxBasicMempoolCreate(256);
c1354a29a7e9 add item list container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 410
diff changeset
1012 const CxAllocator *a = mp->allocator;
c1354a29a7e9 add item list container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 410
diff changeset
1013 UiObject *obj = cxCalloc(a, 1, sizeof(UiObject));
c1354a29a7e9 add item list container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 410
diff changeset
1014 obj->ctx = uic_context(obj, mp);
c1354a29a7e9 add item list container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 410
diff changeset
1015 obj->window = NULL;
c1354a29a7e9 add item list container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 410
diff changeset
1016 obj->widget = ui_subcontainer_create(
c1354a29a7e9 add item list container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 410
diff changeset
1017 ct->subcontainer,
c1354a29a7e9 add item list container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 410
diff changeset
1018 obj,
c1354a29a7e9 add item list container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 410
diff changeset
1019 ct->spacing,
c1354a29a7e9 add item list container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 410
diff changeset
1020 ct->columnspacing,
c1354a29a7e9 add item list container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 410
diff changeset
1021 ct->rowspacing,
c1354a29a7e9 add item list container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 410
diff changeset
1022 ct->margin);
c1354a29a7e9 add item list container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 410
diff changeset
1023 ui_box_container_add(ct->container, obj->widget, FALSE);
c1354a29a7e9 add item list container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 410
diff changeset
1024 if(ct->create_ui) {
c1354a29a7e9 add item list container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 410
diff changeset
1025 ct->create_ui(obj, index, elm, ct->userdata);
c1354a29a7e9 add item list container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 410
diff changeset
1026 }
c1354a29a7e9 add item list container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 410
diff changeset
1027 cxMapPut(new_items, key, obj);
c1354a29a7e9 add item list container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 410
diff changeset
1028 }
c1354a29a7e9 add item list container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 410
diff changeset
1029 elm = list->next(list);
c1354a29a7e9 add item list container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 410
diff changeset
1030 index++;
c1354a29a7e9 add item list container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 410
diff changeset
1031 }
c1354a29a7e9 add item list container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 410
diff changeset
1032 }
c1354a29a7e9 add item list container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 410
diff changeset
1033
c1354a29a7e9 add item list container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 410
diff changeset
1034 static void destroy_itemlist_container(GtkWidget *w, UiGtkItemListContainer *container) {
c1354a29a7e9 add item list container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 410
diff changeset
1035 container->remove_items = FALSE;
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 422
diff changeset
1036 cxMapFree(container->current_items);
422
c1354a29a7e9 add item list container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 410
diff changeset
1037 free(container);
c1354a29a7e9 add item list container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 410
diff changeset
1038 }
c1354a29a7e9 add item list container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 410
diff changeset
1039
c1354a29a7e9 add item list container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 410
diff changeset
1040 UIWIDGET ui_itemlist_create(UiObject *obj, UiItemListContainerArgs args) {
c1354a29a7e9 add item list container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 410
diff changeset
1041 UiObject *current = uic_current_obj(obj);
c1354a29a7e9 add item list container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 410
diff changeset
1042 UiContainer *ct = current->container;
c1354a29a7e9 add item list container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 410
diff changeset
1043 UI_APPLY_LAYOUT1(current, args);
c1354a29a7e9 add item list container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 410
diff changeset
1044
c1354a29a7e9 add item list container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 410
diff changeset
1045 GtkWidget *box = args.container == UI_CONTAINER_VBOX ? ui_gtk_vbox_new(args.spacing) : ui_gtk_hbox_new(args.spacing);
c1354a29a7e9 add item list container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 410
diff changeset
1046 ui_set_name_and_style(box, args.name, args.style_class);
c1354a29a7e9 add item list container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 410
diff changeset
1047 GtkWidget *widget = args.margin > 0 ? ui_box_set_margin(box, args.margin) : box;
c1354a29a7e9 add item list container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 410
diff changeset
1048 ct->add(ct, widget, TRUE);
c1354a29a7e9 add item list container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 410
diff changeset
1049
c1354a29a7e9 add item list container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 410
diff changeset
1050 UiGtkItemListContainer *container = malloc(sizeof(UiGtkItemListContainer));
c1354a29a7e9 add item list container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 410
diff changeset
1051 container->parent = obj;
c1354a29a7e9 add item list container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 410
diff changeset
1052 container->widget = box;
c1354a29a7e9 add item list container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 410
diff changeset
1053 container->container = ui_box_container(current, box, args.container);
c1354a29a7e9 add item list container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 410
diff changeset
1054 container->create_ui = args.create_ui;
c1354a29a7e9 add item list container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 410
diff changeset
1055 container->userdata = args.userdata;
c1354a29a7e9 add item list container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 410
diff changeset
1056 container->subcontainer = args.subcontainer;
c1354a29a7e9 add item list container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 410
diff changeset
1057 container->current_items = cxHashMapCreateSimple(CX_STORE_POINTERS);
c1354a29a7e9 add item list container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 410
diff changeset
1058 container->current_items->collection.advanced_destructor = remove_item;
c1354a29a7e9 add item list container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 410
diff changeset
1059 container->current_items->collection.destructor_data = container;
c1354a29a7e9 add item list container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 410
diff changeset
1060 container->margin = args.sub_margin;
c1354a29a7e9 add item list container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 410
diff changeset
1061 container->spacing = args.sub_spacing;
c1354a29a7e9 add item list container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 410
diff changeset
1062 container->columnspacing = args.sub_columnspacing;
c1354a29a7e9 add item list container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 410
diff changeset
1063 container->rowspacing = args.sub_rowspacing;
c1354a29a7e9 add item list container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 410
diff changeset
1064 container->remove_items = TRUE;
c1354a29a7e9 add item list container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 410
diff changeset
1065
c1354a29a7e9 add item list container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 410
diff changeset
1066 UiVar* var = uic_widget_var(obj->ctx, current->ctx, args.value, args.varname, UI_VAR_LIST);
c1354a29a7e9 add item list container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 410
diff changeset
1067 if(var) {
c1354a29a7e9 add item list container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 410
diff changeset
1068 UiList *list = var->value;
c1354a29a7e9 add item list container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 410
diff changeset
1069 list->obj = container;
c1354a29a7e9 add item list container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 410
diff changeset
1070 list->update = update_itemlist;
c1354a29a7e9 add item list container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 410
diff changeset
1071 update_itemlist(list, 0);
c1354a29a7e9 add item list container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 410
diff changeset
1072 }
c1354a29a7e9 add item list container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 410
diff changeset
1073 g_signal_connect(
c1354a29a7e9 add item list container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 410
diff changeset
1074 box,
c1354a29a7e9 add item list container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 410
diff changeset
1075 "destroy",
c1354a29a7e9 add item list container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 410
diff changeset
1076 G_CALLBACK(destroy_itemlist_container),
c1354a29a7e9 add item list container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 410
diff changeset
1077 container);
c1354a29a7e9 add item list container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 410
diff changeset
1078
c1354a29a7e9 add item list container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 410
diff changeset
1079 return box;
c1354a29a7e9 add item list container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 410
diff changeset
1080 }
33
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
1081
59
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
1082
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
1083
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
1084 /*
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
1085 * -------------------- Layout Functions --------------------
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
1086 *
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
1087 * functions for setting layout attributes for the current container
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
1088 *
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
1089 */
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
1090
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
1091 void ui_layout_fill(UiObject *obj, UiBool fill) {
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
1092 UiContainer *ct = uic_get_current_container(obj);
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
1093 ct->layout.fill = ui_bool2lb(fill);
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
1094 }
65
4697592e24ba added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 62
diff changeset
1095
99
ea1a2d5de765 improved grid container (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 94
diff changeset
1096 void ui_layout_hexpand(UiObject *obj, UiBool expand) {
ea1a2d5de765 improved grid container (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 94
diff changeset
1097 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
1098 ct->layout.hexpand = expand;
99
ea1a2d5de765 improved grid container (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 94
diff changeset
1099 }
ea1a2d5de765 improved grid container (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 94
diff changeset
1100
ea1a2d5de765 improved grid container (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 94
diff changeset
1101 void ui_layout_vexpand(UiObject *obj, UiBool expand) {
ea1a2d5de765 improved grid container (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 94
diff changeset
1102 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
1103 ct->layout.vexpand = expand;
99
ea1a2d5de765 improved grid container (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 94
diff changeset
1104 }
ea1a2d5de765 improved grid container (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 94
diff changeset
1105
378
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 354
diff changeset
1106 void ui_layout_hfill(UiObject *obj, UiBool fill) {
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 354
diff changeset
1107 UiContainer *ct = uic_get_current_container(obj);
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 354
diff changeset
1108 ct->layout.hfill = fill;
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 354
diff changeset
1109 }
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 354
diff changeset
1110
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 354
diff changeset
1111 void ui_layout_vfill(UiObject *obj, UiBool fill) {
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 354
diff changeset
1112 UiContainer *ct = uic_get_current_container(obj);
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 354
diff changeset
1113 ct->layout.vfill = fill;
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 354
diff changeset
1114 }
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 354
diff changeset
1115
253
087cc9216f28 initial newapi GTK port
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 174
diff changeset
1116 void ui_layout_colspan(UiObject* obj, int cols) {
087cc9216f28 initial newapi GTK port
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 174
diff changeset
1117 UiContainer* ct = uic_get_current_container(obj);
087cc9216f28 initial newapi GTK port
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 174
diff changeset
1118 ct->layout.colspan = cols;
087cc9216f28 initial newapi GTK port
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 174
diff changeset
1119 }
087cc9216f28 initial newapi GTK port
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 174
diff changeset
1120
087cc9216f28 initial newapi GTK port
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 174
diff changeset
1121 void ui_layout_rowspan(UiObject* obj, int rows) {
087cc9216f28 initial newapi GTK port
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 174
diff changeset
1122 UiContainer* ct = uic_get_current_container(obj);
087cc9216f28 initial newapi GTK port
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 174
diff changeset
1123 ct->layout.rowspan = rows;
087cc9216f28 initial newapi GTK port
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 174
diff changeset
1124 }
087cc9216f28 initial newapi GTK port
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 174
diff changeset
1125
65
4697592e24ba added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 62
diff changeset
1126 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
1127 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
1128 ct->layout.newline = TRUE;
4697592e24ba added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 62
diff changeset
1129 }
99
ea1a2d5de765 improved grid container (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 94
diff changeset
1130

mercurial