Sun, 28 Jan 2024 10:06:54 +0100
add getter/setter for ui number/string types
4
39b9b86ec452
added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
1 | /* |
39b9b86ec452
added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. |
39b9b86ec452
added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
3 | * |
140
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
121
diff
changeset
|
4 | * Copyright 2017 Olaf Wintermann. All rights reserved. |
4
39b9b86ec452
added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
5 | * |
39b9b86ec452
added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
6 | * Redistribution and use in source and binary forms, with or without |
39b9b86ec452
added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
7 | * modification, are permitted provided that the following conditions are met: |
39b9b86ec452
added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
8 | * |
39b9b86ec452
added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
9 | * 1. Redistributions of source code must retain the above copyright |
39b9b86ec452
added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
10 | * notice, this list of conditions and the following disclaimer. |
39b9b86ec452
added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
11 | * |
39b9b86ec452
added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
12 | * 2. Redistributions in binary form must reproduce the above copyright |
39b9b86ec452
added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
13 | * notice, this list of conditions and the following disclaimer in the |
39b9b86ec452
added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
14 | * documentation and/or other materials provided with the distribution. |
39b9b86ec452
added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
15 | * |
39b9b86ec452
added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
39b9b86ec452
added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
39b9b86ec452
added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
39b9b86ec452
added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE |
39b9b86ec452
added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
39b9b86ec452
added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
39b9b86ec452
added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
39b9b86ec452
added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
39b9b86ec452
added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
39b9b86ec452
added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
39b9b86ec452
added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
26 | * POSSIBILITY OF SUCH DAMAGE. |
39b9b86ec452
added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
27 | */ |
39b9b86ec452
added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
28 | |
39b9b86ec452
added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
29 | #include <stdio.h> |
39b9b86ec452
added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
30 | #include <stdlib.h> |
165
3f32db79a76e
add splitpane (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
31 | #include <limits.h> |
4
39b9b86ec452
added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
32 | |
39b9b86ec452
added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
33 | #include "container.h" |
165
3f32db79a76e
add splitpane (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
34 | #include "toolkit.h" |
3f32db79a76e
add splitpane (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
35 | |
4
39b9b86ec452
added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
36 | #include "../common/context.h" |
33
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
4
diff
changeset
|
37 | #include "../common/object.h" |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
4
diff
changeset
|
38 | |
166
6e48030cf2db
add container macros (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
165
diff
changeset
|
39 | |
6e48030cf2db
add container macros (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
165
diff
changeset
|
40 | void ui_container_begin_close(UiObject *obj) { |
6e48030cf2db
add container macros (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
165
diff
changeset
|
41 | UiContainer *ct = uic_get_current_container(obj); |
6e48030cf2db
add container macros (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
165
diff
changeset
|
42 | ct->close = 1; |
6e48030cf2db
add container macros (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
165
diff
changeset
|
43 | } |
6e48030cf2db
add container macros (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
165
diff
changeset
|
44 | |
6e48030cf2db
add container macros (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
165
diff
changeset
|
45 | int ui_container_finish(UiObject *obj) { |
6e48030cf2db
add container macros (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
165
diff
changeset
|
46 | UiContainer *ct = uic_get_current_container(obj); |
6e48030cf2db
add container macros (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
165
diff
changeset
|
47 | if(ct->close) { |
6e48030cf2db
add container macros (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
165
diff
changeset
|
48 | ui_end(obj); |
6e48030cf2db
add container macros (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
165
diff
changeset
|
49 | return 0; |
6e48030cf2db
add container macros (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
165
diff
changeset
|
50 | } |
6e48030cf2db
add container macros (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
165
diff
changeset
|
51 | return 1; |
6e48030cf2db
add container macros (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
165
diff
changeset
|
52 | } |
6e48030cf2db
add container macros (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
165
diff
changeset
|
53 | |
107
9aff1dc3990d
improved box container and added radio button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
100
diff
changeset
|
54 | GtkWidget* ui_gtk_vbox_new(int spacing) { |
59
eb6611be50c7
added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
52
diff
changeset
|
55 | #ifdef UI_GTK3 |
107
9aff1dc3990d
improved box container and added radio button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
100
diff
changeset
|
56 | return gtk_box_new(GTK_ORIENTATION_VERTICAL, spacing); |
59
eb6611be50c7
added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
52
diff
changeset
|
57 | #else |
107
9aff1dc3990d
improved box container and added radio button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
100
diff
changeset
|
58 | return gtk_vbox_new(FALSE, spacing); |
59
eb6611be50c7
added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
52
diff
changeset
|
59 | #endif |
eb6611be50c7
added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
52
diff
changeset
|
60 | } |
eb6611be50c7
added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
52
diff
changeset
|
61 | |
107
9aff1dc3990d
improved box container and added radio button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
100
diff
changeset
|
62 | GtkWidget* ui_gtk_hbox_new(int spacing) { |
59
eb6611be50c7
added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
52
diff
changeset
|
63 | #ifdef UI_GTK3 |
107
9aff1dc3990d
improved box container and added radio button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
100
diff
changeset
|
64 | return gtk_box_new(GTK_ORIENTATION_HORIZONTAL, spacing); |
59
eb6611be50c7
added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
52
diff
changeset
|
65 | #else |
107
9aff1dc3990d
improved box container and added radio button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
100
diff
changeset
|
66 | return gtk_hbox_new(FALSE, spacing); |
59
eb6611be50c7
added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
52
diff
changeset
|
67 | #endif |
eb6611be50c7
added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
52
diff
changeset
|
68 | } |
eb6611be50c7
added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
52
diff
changeset
|
69 | |
eb6611be50c7
added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
52
diff
changeset
|
70 | /* -------------------- Frame Container (deprecated) -------------------- */ |
4
39b9b86ec452
added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
71 | UiContainer* ui_frame_container(UiObject *obj, GtkWidget *frame) { |
174 | 72 | UiContainer *ct = cxCalloc( |
73 | obj->ctx->allocator, | |
59
eb6611be50c7
added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
52
diff
changeset
|
74 | 1, |
4
39b9b86ec452
added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
75 | sizeof(UiContainer)); |
39b9b86ec452
added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
76 | ct->widget = frame; |
39b9b86ec452
added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
77 | ct->add = ui_frame_container_add; |
39b9b86ec452
added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
78 | return ct; |
39b9b86ec452
added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
79 | } |
39b9b86ec452
added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
80 | |
59
eb6611be50c7
added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
52
diff
changeset
|
81 | void ui_frame_container_add(UiContainer *ct, GtkWidget *widget, UiBool fill) { |
4
39b9b86ec452
added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
82 | gtk_container_add(GTK_CONTAINER(ct->widget), widget); |
59
eb6611be50c7
added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
52
diff
changeset
|
83 | ui_reset_layout(ct->layout); |
75
efe2f65bea17
added context menus (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
74
diff
changeset
|
84 | ct->current = widget; |
4
39b9b86ec452
added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
85 | } |
33
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
4
diff
changeset
|
86 | |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
4
diff
changeset
|
87 | |
59
eb6611be50c7
added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
52
diff
changeset
|
88 | /* -------------------- Box Container -------------------- */ |
eb6611be50c7
added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
52
diff
changeset
|
89 | UiContainer* ui_box_container(UiObject *obj, GtkWidget *box) { |
174 | 90 | UiBoxContainer *ct = cxCalloc( |
91 | obj->ctx->allocator, | |
59
eb6611be50c7
added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
52
diff
changeset
|
92 | 1, |
eb6611be50c7
added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
52
diff
changeset
|
93 | sizeof(UiBoxContainer)); |
eb6611be50c7
added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
52
diff
changeset
|
94 | ct->container.widget = box; |
eb6611be50c7
added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
52
diff
changeset
|
95 | ct->container.add = ui_box_container_add; |
eb6611be50c7
added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
52
diff
changeset
|
96 | return (UiContainer*)ct; |
eb6611be50c7
added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
52
diff
changeset
|
97 | } |
eb6611be50c7
added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
52
diff
changeset
|
98 | |
eb6611be50c7
added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
52
diff
changeset
|
99 | 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
|
100 | UiBoxContainer *bc = (UiBoxContainer*)ct; |
eb6611be50c7
added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
52
diff
changeset
|
101 | if(ct->layout.fill != UI_LAYOUT_UNDEFINED) { |
eb6611be50c7
added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
52
diff
changeset
|
102 | fill = ui_lb2bool(ct->layout.fill); |
eb6611be50c7
added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
52
diff
changeset
|
103 | } |
eb6611be50c7
added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
52
diff
changeset
|
104 | |
eb6611be50c7
added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
52
diff
changeset
|
105 | if(bc->has_fill && fill) { |
eb6611be50c7
added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
52
diff
changeset
|
106 | fprintf(stderr, "UiError: container has 2 filled widgets"); |
eb6611be50c7
added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
52
diff
changeset
|
107 | fill = FALSE; |
eb6611be50c7
added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
52
diff
changeset
|
108 | } |
eb6611be50c7
added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
52
diff
changeset
|
109 | if(fill) { |
eb6611be50c7
added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
52
diff
changeset
|
110 | bc->has_fill = TRUE; |
eb6611be50c7
added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
52
diff
changeset
|
111 | } |
eb6611be50c7
added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
52
diff
changeset
|
112 | |
eb6611be50c7
added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
52
diff
changeset
|
113 | UiBool expand = fill; |
eb6611be50c7
added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
52
diff
changeset
|
114 | gtk_box_pack_start(GTK_BOX(ct->widget), widget, expand, fill, 0); |
eb6611be50c7
added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
52
diff
changeset
|
115 | |
eb6611be50c7
added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
52
diff
changeset
|
116 | ui_reset_layout(ct->layout); |
75
efe2f65bea17
added context menus (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
74
diff
changeset
|
117 | ct->current = widget; |
59
eb6611be50c7
added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
52
diff
changeset
|
118 | } |
eb6611be50c7
added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
52
diff
changeset
|
119 | |
65
4697592e24ba
added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
62
diff
changeset
|
120 | UiContainer* ui_grid_container(UiObject *obj, GtkWidget *grid) { |
174 | 121 | UiGridContainer *ct = cxCalloc( |
122 | obj->ctx->allocator, | |
65
4697592e24ba
added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
62
diff
changeset
|
123 | 1, |
4697592e24ba
added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
62
diff
changeset
|
124 | sizeof(UiGridContainer)); |
4697592e24ba
added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
62
diff
changeset
|
125 | ct->container.widget = grid; |
4697592e24ba
added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
62
diff
changeset
|
126 | ct->container.add = ui_grid_container_add; |
74
55718d4ed227
fixed grid container when using gtk2
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
66
diff
changeset
|
127 | #ifdef UI_GTK2 |
55718d4ed227
fixed grid container when using gtk2
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
66
diff
changeset
|
128 | ct->width = 0; |
55718d4ed227
fixed grid container when using gtk2
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
66
diff
changeset
|
129 | ct->height = 1; |
55718d4ed227
fixed grid container when using gtk2
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
66
diff
changeset
|
130 | #endif |
65
4697592e24ba
added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
62
diff
changeset
|
131 | return (UiContainer*)ct; |
4697592e24ba
added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
62
diff
changeset
|
132 | } |
4697592e24ba
added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
62
diff
changeset
|
133 | |
74
55718d4ed227
fixed grid container when using gtk2
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
66
diff
changeset
|
134 | #ifdef UI_GTK3 |
65
4697592e24ba
added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
62
diff
changeset
|
135 | void ui_grid_container_add(UiContainer *ct, GtkWidget *widget, UiBool fill) { |
4697592e24ba
added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
62
diff
changeset
|
136 | UiGridContainer *grid = (UiGridContainer*)ct; |
4697592e24ba
added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
62
diff
changeset
|
137 | |
4697592e24ba
added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
62
diff
changeset
|
138 | if(ct->layout.newline) { |
4697592e24ba
added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
62
diff
changeset
|
139 | grid->x = 0; |
4697592e24ba
added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
62
diff
changeset
|
140 | grid->y++; |
4697592e24ba
added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
62
diff
changeset
|
141 | ct->layout.newline = FALSE; |
4697592e24ba
added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
62
diff
changeset
|
142 | } |
4697592e24ba
added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
62
diff
changeset
|
143 | |
99
ea1a2d5de765
improved grid container (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
94
diff
changeset
|
144 | int hexpand = FALSE; |
ea1a2d5de765
improved grid container (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
94
diff
changeset
|
145 | int vexpand = FALSE; |
ea1a2d5de765
improved grid container (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
94
diff
changeset
|
146 | if(ct->layout.hexpand != UI_LAYOUT_UNDEFINED) { |
ea1a2d5de765
improved grid container (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
94
diff
changeset
|
147 | hexpand = ct->layout.hexpand; |
94
d51e334c1439
added checkbox and labels with alignment (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
75
diff
changeset
|
148 | } |
99
ea1a2d5de765
improved grid container (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
94
diff
changeset
|
149 | if(ct->layout.vexpand != UI_LAYOUT_UNDEFINED) { |
ea1a2d5de765
improved grid container (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
94
diff
changeset
|
150 | vexpand = ct->layout.vexpand; |
ea1a2d5de765
improved grid container (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
94
diff
changeset
|
151 | } |
ea1a2d5de765
improved grid container (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
94
diff
changeset
|
152 | |
ea1a2d5de765
improved grid container (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
94
diff
changeset
|
153 | if(hexpand) { |
94
d51e334c1439
added checkbox and labels with alignment (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
75
diff
changeset
|
154 | gtk_widget_set_hexpand(widget, TRUE); |
d51e334c1439
added checkbox and labels with alignment (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
75
diff
changeset
|
155 | } |
99
ea1a2d5de765
improved grid container (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
94
diff
changeset
|
156 | if(vexpand) { |
ea1a2d5de765
improved grid container (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
94
diff
changeset
|
157 | gtk_widget_set_vexpand(widget, TRUE); |
ea1a2d5de765
improved grid container (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
94
diff
changeset
|
158 | } |
94
d51e334c1439
added checkbox and labels with alignment (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
75
diff
changeset
|
159 | |
109
b9808f916687
added gridwidth layout option (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
107
diff
changeset
|
160 | int gwidth = ct->layout.gridwidth > 0 ? ct->layout.gridwidth : 1; |
b9808f916687
added gridwidth layout option (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
107
diff
changeset
|
161 | |
b9808f916687
added gridwidth layout option (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
107
diff
changeset
|
162 | gtk_grid_attach(GTK_GRID(ct->widget), widget, grid->x, grid->y, gwidth, 1); |
110
36f1581b43e2
added radio buttons and gridwidth layout option (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
109
diff
changeset
|
163 | grid->x += gwidth; |
65
4697592e24ba
added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
62
diff
changeset
|
164 | |
4697592e24ba
added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
62
diff
changeset
|
165 | ui_reset_layout(ct->layout); |
75
efe2f65bea17
added context menus (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
74
diff
changeset
|
166 | ct->current = widget; |
65
4697592e24ba
added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
62
diff
changeset
|
167 | } |
74
55718d4ed227
fixed grid container when using gtk2
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
66
diff
changeset
|
168 | #endif |
55718d4ed227
fixed grid container when using gtk2
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
66
diff
changeset
|
169 | #ifdef UI_GTK2 |
55718d4ed227
fixed grid container when using gtk2
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
66
diff
changeset
|
170 | 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
|
171 | UiGridContainer *grid = (UiGridContainer*)ct; |
55718d4ed227
fixed grid container when using gtk2
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
66
diff
changeset
|
172 | |
55718d4ed227
fixed grid container when using gtk2
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
66
diff
changeset
|
173 | if(ct->layout.newline) { |
55718d4ed227
fixed grid container when using gtk2
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
66
diff
changeset
|
174 | grid->x = 0; |
55718d4ed227
fixed grid container when using gtk2
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
66
diff
changeset
|
175 | grid->y++; |
55718d4ed227
fixed grid container when using gtk2
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
66
diff
changeset
|
176 | ct->layout.newline = FALSE; |
55718d4ed227
fixed grid container when using gtk2
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
66
diff
changeset
|
177 | } |
55718d4ed227
fixed grid container when using gtk2
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
66
diff
changeset
|
178 | |
100
d276306d801f
improved gtk2 implementation of grid container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
99
diff
changeset
|
179 | int hexpand = FALSE; |
d276306d801f
improved gtk2 implementation of grid container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
99
diff
changeset
|
180 | int vexpand = FALSE; |
d276306d801f
improved gtk2 implementation of grid container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
99
diff
changeset
|
181 | if(ct->layout.hexpand != UI_LAYOUT_UNDEFINED) { |
d276306d801f
improved gtk2 implementation of grid container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
99
diff
changeset
|
182 | hexpand = ct->layout.hexpand; |
d276306d801f
improved gtk2 implementation of grid container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
99
diff
changeset
|
183 | } |
d276306d801f
improved gtk2 implementation of grid container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
99
diff
changeset
|
184 | if(ct->layout.vexpand != UI_LAYOUT_UNDEFINED) { |
d276306d801f
improved gtk2 implementation of grid container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
99
diff
changeset
|
185 | vexpand = ct->layout.vexpand; |
d276306d801f
improved gtk2 implementation of grid container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
99
diff
changeset
|
186 | } |
d276306d801f
improved gtk2 implementation of grid container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
99
diff
changeset
|
187 | 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
|
188 | 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
|
189 | |
d276306d801f
improved gtk2 implementation of grid container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
99
diff
changeset
|
190 | 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
|
191 | grid->x++; |
55718d4ed227
fixed grid container when using gtk2
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
66
diff
changeset
|
192 | 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
|
193 | 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
|
194 | grid->width = nw; |
55718d4ed227
fixed grid container when using gtk2
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
66
diff
changeset
|
195 | grid->height = grid->y + 1; |
55718d4ed227
fixed grid container when using gtk2
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
66
diff
changeset
|
196 | 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
|
197 | } |
75
efe2f65bea17
added context menus (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
74
diff
changeset
|
198 | |
efe2f65bea17
added context menus (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
74
diff
changeset
|
199 | ui_reset_layout(ct->layout); |
efe2f65bea17
added context menus (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
74
diff
changeset
|
200 | ct->current = widget; |
74
55718d4ed227
fixed grid container when using gtk2
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
66
diff
changeset
|
201 | } |
55718d4ed227
fixed grid container when using gtk2
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
66
diff
changeset
|
202 | #endif |
65
4697592e24ba
added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
62
diff
changeset
|
203 | |
120
49bc645df8b7
added scrolledwindow (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
116
diff
changeset
|
204 | UiContainer* ui_scrolledwindow_container(UiObject *obj, GtkWidget *scrolledwindow) { |
174 | 205 | UiContainer *ct = cxCalloc( |
206 | obj->ctx->allocator, | |
120
49bc645df8b7
added scrolledwindow (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
116
diff
changeset
|
207 | 1, |
49bc645df8b7
added scrolledwindow (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
116
diff
changeset
|
208 | sizeof(UiContainer)); |
49bc645df8b7
added scrolledwindow (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
116
diff
changeset
|
209 | ct->widget = scrolledwindow; |
49bc645df8b7
added scrolledwindow (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
116
diff
changeset
|
210 | ct->add = ui_scrolledwindow_container_add; |
49bc645df8b7
added scrolledwindow (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
116
diff
changeset
|
211 | return ct; |
49bc645df8b7
added scrolledwindow (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
116
diff
changeset
|
212 | } |
49bc645df8b7
added scrolledwindow (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
116
diff
changeset
|
213 | |
49bc645df8b7
added scrolledwindow (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
116
diff
changeset
|
214 | void ui_scrolledwindow_container_add(UiContainer *ct, GtkWidget *widget, UiBool fill) { |
121
1cc365c34125
added some special textfields (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
120
diff
changeset
|
215 | // TODO: check if the widget implements GtkScrollable |
1cc365c34125
added some special textfields (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
120
diff
changeset
|
216 | #ifdef UI_GTK3 |
120
49bc645df8b7
added scrolledwindow (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
116
diff
changeset
|
217 | gtk_container_add(GTK_CONTAINER(ct->widget), widget); |
121
1cc365c34125
added some special textfields (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
120
diff
changeset
|
218 | #else |
1cc365c34125
added some special textfields (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
120
diff
changeset
|
219 | gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(ct->widget), widget); |
1cc365c34125
added some special textfields (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
120
diff
changeset
|
220 | #endif |
120
49bc645df8b7
added scrolledwindow (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
116
diff
changeset
|
221 | ui_reset_layout(ct->layout); |
49bc645df8b7
added scrolledwindow (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
116
diff
changeset
|
222 | ct->current = widget; |
49bc645df8b7
added scrolledwindow (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
116
diff
changeset
|
223 | } |
49bc645df8b7
added scrolledwindow (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
116
diff
changeset
|
224 | |
65
4697592e24ba
added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
62
diff
changeset
|
225 | UiContainer* ui_tabview_container(UiObject *obj, GtkWidget *tabview) { |
174 | 226 | UiTabViewContainer *ct = cxCalloc( |
227 | obj->ctx->allocator, | |
65
4697592e24ba
added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
62
diff
changeset
|
228 | 1, |
4697592e24ba
added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
62
diff
changeset
|
229 | sizeof(UiTabViewContainer)); |
4697592e24ba
added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
62
diff
changeset
|
230 | ct->container.widget = tabview; |
4697592e24ba
added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
62
diff
changeset
|
231 | 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
|
232 | return (UiContainer*)ct; |
4697592e24ba
added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
62
diff
changeset
|
233 | } |
4697592e24ba
added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
62
diff
changeset
|
234 | |
4697592e24ba
added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
62
diff
changeset
|
235 | void ui_tabview_container_add(UiContainer *ct, GtkWidget *widget, UiBool fill) { |
4697592e24ba
added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
62
diff
changeset
|
236 | gtk_notebook_append_page( |
4697592e24ba
added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
62
diff
changeset
|
237 | GTK_NOTEBOOK(ct->widget), |
4697592e24ba
added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
62
diff
changeset
|
238 | widget, |
4697592e24ba
added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
62
diff
changeset
|
239 | gtk_label_new(ct->layout.label)); |
75
efe2f65bea17
added context menus (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
74
diff
changeset
|
240 | |
efe2f65bea17
added context menus (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
74
diff
changeset
|
241 | ui_reset_layout(ct->layout); |
efe2f65bea17
added context menus (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
74
diff
changeset
|
242 | ct->current = widget; |
65
4697592e24ba
added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
62
diff
changeset
|
243 | } |
4697592e24ba
added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
62
diff
changeset
|
244 | |
4697592e24ba
added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
62
diff
changeset
|
245 | |
62
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
59
diff
changeset
|
246 | UIWIDGET ui_vbox(UiObject *obj) { |
107
9aff1dc3990d
improved box container and added radio button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
100
diff
changeset
|
247 | return ui_vbox_sp(obj, 0, 0); |
9aff1dc3990d
improved box container and added radio button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
100
diff
changeset
|
248 | } |
9aff1dc3990d
improved box container and added radio button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
100
diff
changeset
|
249 | |
9aff1dc3990d
improved box container and added radio button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
100
diff
changeset
|
250 | UIWIDGET ui_hbox(UiObject *obj) { |
9aff1dc3990d
improved box container and added radio button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
100
diff
changeset
|
251 | return ui_hbox_sp(obj, 0, 0); |
9aff1dc3990d
improved box container and added radio button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
100
diff
changeset
|
252 | } |
9aff1dc3990d
improved box container and added radio button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
100
diff
changeset
|
253 | |
9aff1dc3990d
improved box container and added radio button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
100
diff
changeset
|
254 | static GtkWidget* box_set_margin(GtkWidget *box, int margin) { |
9aff1dc3990d
improved box container and added radio button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
100
diff
changeset
|
255 | GtkWidget *ret = box; |
9aff1dc3990d
improved box container and added radio button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
100
diff
changeset
|
256 | #ifdef UI_GTK3 |
9aff1dc3990d
improved box container and added radio button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
100
diff
changeset
|
257 | #if GTK_MAJOR_VERSION == 3 && GTK_MINOR_VERSION >= 12 |
9aff1dc3990d
improved box container and added radio button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
100
diff
changeset
|
258 | gtk_widget_set_margin_start(box, margin); |
9aff1dc3990d
improved box container and added radio button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
100
diff
changeset
|
259 | gtk_widget_set_margin_end(box, margin); |
9aff1dc3990d
improved box container and added radio button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
100
diff
changeset
|
260 | #else |
9aff1dc3990d
improved box container and added radio button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
100
diff
changeset
|
261 | gtk_widget_set_margin_left(box, margin); |
9aff1dc3990d
improved box container and added radio button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
100
diff
changeset
|
262 | gtk_widget_set_margin_right(box, margin); |
9aff1dc3990d
improved box container and added radio button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
100
diff
changeset
|
263 | #endif |
9aff1dc3990d
improved box container and added radio button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
100
diff
changeset
|
264 | gtk_widget_set_margin_top(box, margin); |
9aff1dc3990d
improved box container and added radio button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
100
diff
changeset
|
265 | gtk_widget_set_margin_bottom(box, margin); |
9aff1dc3990d
improved box container and added radio button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
100
diff
changeset
|
266 | #elif defined(UI_GTK2) |
9aff1dc3990d
improved box container and added radio button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
100
diff
changeset
|
267 | GtkWidget *a = gtk_alignment_new(0.5, 0.5, 1, 1); |
9aff1dc3990d
improved box container and added radio button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
100
diff
changeset
|
268 | gtk_alignment_set_padding(GTK_ALIGNMENT(a), margin, margin, margin, margin); |
9aff1dc3990d
improved box container and added radio button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
100
diff
changeset
|
269 | gtk_container_add(GTK_CONTAINER(a), box); |
9aff1dc3990d
improved box container and added radio button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
100
diff
changeset
|
270 | ret = a; |
9aff1dc3990d
improved box container and added radio button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
100
diff
changeset
|
271 | #endif |
9aff1dc3990d
improved box container and added radio button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
100
diff
changeset
|
272 | return ret; |
9aff1dc3990d
improved box container and added radio button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
100
diff
changeset
|
273 | } |
9aff1dc3990d
improved box container and added radio button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
100
diff
changeset
|
274 | |
9aff1dc3990d
improved box container and added radio button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
100
diff
changeset
|
275 | UIWIDGET ui_vbox_sp(UiObject *obj, int margin, int spacing) { |
62
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
59
diff
changeset
|
276 | UiContainer *ct = uic_get_current_container(obj); |
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
59
diff
changeset
|
277 | |
116
480354705c2f
added combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
111
diff
changeset
|
278 | GtkWidget *vbox = ui_gtk_vbox_new(spacing); |
107
9aff1dc3990d
improved box container and added radio button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
100
diff
changeset
|
279 | GtkWidget *widget = margin > 0 ? box_set_margin(vbox, margin) : vbox; |
9aff1dc3990d
improved box container and added radio button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
100
diff
changeset
|
280 | ct->add(ct, widget, TRUE); |
62
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
59
diff
changeset
|
281 | |
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
59
diff
changeset
|
282 | UiObject *newobj = uic_object_new(obj, vbox); |
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
59
diff
changeset
|
283 | newobj->container = ui_box_container(obj, vbox); |
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
59
diff
changeset
|
284 | uic_obj_add(obj, newobj); |
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
59
diff
changeset
|
285 | |
107
9aff1dc3990d
improved box container and added radio button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
100
diff
changeset
|
286 | return widget; |
62
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
59
diff
changeset
|
287 | } |
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
59
diff
changeset
|
288 | |
107
9aff1dc3990d
improved box container and added radio button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
100
diff
changeset
|
289 | UIWIDGET ui_hbox_sp(UiObject *obj, int margin, int spacing) { |
62
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
59
diff
changeset
|
290 | UiContainer *ct = uic_get_current_container(obj); |
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
59
diff
changeset
|
291 | |
107
9aff1dc3990d
improved box container and added radio button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
100
diff
changeset
|
292 | GtkWidget *hbox = ui_gtk_hbox_new(spacing); |
9aff1dc3990d
improved box container and added radio button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
100
diff
changeset
|
293 | GtkWidget *widget = margin > 0 ? box_set_margin(hbox, margin) : hbox; |
9aff1dc3990d
improved box container and added radio button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
100
diff
changeset
|
294 | ct->add(ct, widget, TRUE); |
62
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
59
diff
changeset
|
295 | |
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
59
diff
changeset
|
296 | UiObject *newobj = uic_object_new(obj, hbox); |
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
59
diff
changeset
|
297 | newobj->container = ui_box_container(obj, hbox); |
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
59
diff
changeset
|
298 | uic_obj_add(obj, newobj); |
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
59
diff
changeset
|
299 | |
107
9aff1dc3990d
improved box container and added radio button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
100
diff
changeset
|
300 | return widget; |
62
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
59
diff
changeset
|
301 | } |
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
59
diff
changeset
|
302 | |
65
4697592e24ba
added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
62
diff
changeset
|
303 | UIWIDGET ui_grid(UiObject *obj) { |
99
ea1a2d5de765
improved grid container (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
94
diff
changeset
|
304 | return ui_grid_sp(obj, 0, 0, 0); |
94
d51e334c1439
added checkbox and labels with alignment (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
75
diff
changeset
|
305 | } |
d51e334c1439
added checkbox and labels with alignment (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
75
diff
changeset
|
306 | |
99
ea1a2d5de765
improved grid container (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
94
diff
changeset
|
307 | UIWIDGET ui_grid_sp(UiObject *obj, int margin, int columnspacing, int rowspacing) { |
65
4697592e24ba
added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
62
diff
changeset
|
308 | UiContainer *ct = uic_get_current_container(obj); |
100
d276306d801f
improved gtk2 implementation of grid container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
99
diff
changeset
|
309 | GtkWidget *widget; |
65
4697592e24ba
added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
62
diff
changeset
|
310 | |
74
55718d4ed227
fixed grid container when using gtk2
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
66
diff
changeset
|
311 | #ifdef UI_GTK3 |
65
4697592e24ba
added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
62
diff
changeset
|
312 | GtkWidget *grid = gtk_grid_new(); |
94
d51e334c1439
added checkbox and labels with alignment (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
75
diff
changeset
|
313 | gtk_grid_set_column_spacing(GTK_GRID(grid), columnspacing); |
99
ea1a2d5de765
improved grid container (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
94
diff
changeset
|
314 | gtk_grid_set_row_spacing(GTK_GRID(grid), rowspacing); |
ea1a2d5de765
improved grid container (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
94
diff
changeset
|
315 | #if GTK_MAJOR_VERSION == 3 && GTK_MINOR_VERSION >= 12 |
ea1a2d5de765
improved grid container (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
94
diff
changeset
|
316 | gtk_widget_set_margin_start(grid, margin); |
ea1a2d5de765
improved grid container (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
94
diff
changeset
|
317 | gtk_widget_set_margin_end(grid, margin); |
ea1a2d5de765
improved grid container (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
94
diff
changeset
|
318 | #else |
ea1a2d5de765
improved grid container (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
94
diff
changeset
|
319 | gtk_widget_set_margin_left(grid, margin); |
ea1a2d5de765
improved grid container (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
94
diff
changeset
|
320 | gtk_widget_set_margin_right(grid, margin); |
ea1a2d5de765
improved grid container (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
94
diff
changeset
|
321 | #endif |
ea1a2d5de765
improved grid container (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
94
diff
changeset
|
322 | gtk_widget_set_margin_top(grid, margin); |
ea1a2d5de765
improved grid container (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
94
diff
changeset
|
323 | gtk_widget_set_margin_bottom(grid, margin); |
94
d51e334c1439
added checkbox and labels with alignment (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
75
diff
changeset
|
324 | |
100
d276306d801f
improved gtk2 implementation of grid container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
99
diff
changeset
|
325 | widget = grid; |
74
55718d4ed227
fixed grid container when using gtk2
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
66
diff
changeset
|
326 | #elif defined(UI_GTK2) |
55718d4ed227
fixed grid container when using gtk2
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
66
diff
changeset
|
327 | GtkWidget *grid = gtk_table_new(1, 1, FALSE); |
100
d276306d801f
improved gtk2 implementation of grid container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
99
diff
changeset
|
328 | |
d276306d801f
improved gtk2 implementation of grid container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
99
diff
changeset
|
329 | gtk_table_set_col_spacings(GTK_TABLE(grid), columnspacing); |
d276306d801f
improved gtk2 implementation of grid container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
99
diff
changeset
|
330 | gtk_table_set_row_spacings(GTK_TABLE(grid), rowspacing); |
d276306d801f
improved gtk2 implementation of grid container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
99
diff
changeset
|
331 | |
d276306d801f
improved gtk2 implementation of grid container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
99
diff
changeset
|
332 | if(margin > 0) { |
d276306d801f
improved gtk2 implementation of grid container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
99
diff
changeset
|
333 | GtkWidget *a = gtk_alignment_new(0.5, 0.5, 1, 1); |
d276306d801f
improved gtk2 implementation of grid container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
99
diff
changeset
|
334 | gtk_alignment_set_padding(GTK_ALIGNMENT(a), margin, margin, margin, margin); |
d276306d801f
improved gtk2 implementation of grid container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
99
diff
changeset
|
335 | gtk_container_add(GTK_CONTAINER(a), grid); |
d276306d801f
improved gtk2 implementation of grid container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
99
diff
changeset
|
336 | widget = a; |
d276306d801f
improved gtk2 implementation of grid container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
99
diff
changeset
|
337 | } else { |
d276306d801f
improved gtk2 implementation of grid container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
99
diff
changeset
|
338 | widget = grid; |
d276306d801f
improved gtk2 implementation of grid container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
99
diff
changeset
|
339 | } |
74
55718d4ed227
fixed grid container when using gtk2
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
66
diff
changeset
|
340 | #endif |
100
d276306d801f
improved gtk2 implementation of grid container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
99
diff
changeset
|
341 | ct->add(ct, widget, TRUE); |
65
4697592e24ba
added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
62
diff
changeset
|
342 | |
4697592e24ba
added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
62
diff
changeset
|
343 | 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
|
344 | 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
|
345 | 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
|
346 | |
100
d276306d801f
improved gtk2 implementation of grid container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
99
diff
changeset
|
347 | return widget; |
65
4697592e24ba
added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
62
diff
changeset
|
348 | } |
4697592e24ba
added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
62
diff
changeset
|
349 | |
120
49bc645df8b7
added scrolledwindow (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
116
diff
changeset
|
350 | UIWIDGET ui_scrolledwindow(UiObject *obj) { |
49bc645df8b7
added scrolledwindow (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
116
diff
changeset
|
351 | UiContainer *ct = uic_get_current_container(obj); |
49bc645df8b7
added scrolledwindow (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
116
diff
changeset
|
352 | GtkWidget *sw = gtk_scrolled_window_new(NULL, NULL); |
49bc645df8b7
added scrolledwindow (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
116
diff
changeset
|
353 | ct->add(ct, sw, TRUE); |
49bc645df8b7
added scrolledwindow (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
116
diff
changeset
|
354 | |
49bc645df8b7
added scrolledwindow (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
116
diff
changeset
|
355 | UiObject *newobj = uic_object_new(obj, sw); |
49bc645df8b7
added scrolledwindow (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
116
diff
changeset
|
356 | newobj->container = ui_scrolledwindow_container(obj, sw); |
49bc645df8b7
added scrolledwindow (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
116
diff
changeset
|
357 | uic_obj_add(obj, newobj); |
49bc645df8b7
added scrolledwindow (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
116
diff
changeset
|
358 | |
49bc645df8b7
added scrolledwindow (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
116
diff
changeset
|
359 | return sw; |
49bc645df8b7
added scrolledwindow (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
116
diff
changeset
|
360 | } |
49bc645df8b7
added scrolledwindow (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
116
diff
changeset
|
361 | |
65
4697592e24ba
added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
62
diff
changeset
|
362 | UIWIDGET ui_tabview(UiObject *obj) { |
4697592e24ba
added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
62
diff
changeset
|
363 | GtkWidget *tabview = gtk_notebook_new(); |
4697592e24ba
added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
62
diff
changeset
|
364 | gtk_notebook_set_show_border(GTK_NOTEBOOK(tabview), FALSE); |
4697592e24ba
added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
62
diff
changeset
|
365 | gtk_notebook_set_show_tabs(GTK_NOTEBOOK(tabview), FALSE); |
4697592e24ba
added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
62
diff
changeset
|
366 | |
4697592e24ba
added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
62
diff
changeset
|
367 | 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
|
368 | ct->add(ct, tabview, TRUE); |
4697592e24ba
added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
62
diff
changeset
|
369 | |
4697592e24ba
added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
62
diff
changeset
|
370 | UiObject *tabviewobj = uic_object_new(obj, tabview); |
4697592e24ba
added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
62
diff
changeset
|
371 | tabviewobj->container = ui_tabview_container(obj, tabview); |
4697592e24ba
added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
62
diff
changeset
|
372 | uic_obj_add(obj, tabviewobj); |
4697592e24ba
added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
62
diff
changeset
|
373 | |
4697592e24ba
added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
62
diff
changeset
|
374 | return tabview; |
4697592e24ba
added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
62
diff
changeset
|
375 | } |
4697592e24ba
added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
62
diff
changeset
|
376 | |
4697592e24ba
added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
62
diff
changeset
|
377 | void ui_tab(UiObject *obj, char *title) { |
4697592e24ba
added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
62
diff
changeset
|
378 | 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
|
379 | ct->layout.label = title; |
4697592e24ba
added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
62
diff
changeset
|
380 | ui_vbox(obj); |
4697592e24ba
added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
62
diff
changeset
|
381 | } |
4697592e24ba
added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
62
diff
changeset
|
382 | |
4697592e24ba
added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
62
diff
changeset
|
383 | void ui_select_tab(UIWIDGET tabview, int tab) { |
4697592e24ba
added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
62
diff
changeset
|
384 | gtk_notebook_set_current_page(GTK_NOTEBOOK(tabview), tab); |
4697592e24ba
added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
62
diff
changeset
|
385 | } |
4697592e24ba
added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
62
diff
changeset
|
386 | |
165
3f32db79a76e
add splitpane (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
387 | /* -------------------- Splitpane -------------------- */ |
59
eb6611be50c7
added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
52
diff
changeset
|
388 | |
165
3f32db79a76e
add splitpane (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
389 | static GtkWidget* create_paned(UiOrientation orientation) { |
3f32db79a76e
add splitpane (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
390 | #ifdef UI_GTK3 |
3f32db79a76e
add splitpane (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
391 | switch(orientation) { |
3f32db79a76e
add splitpane (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
392 | case UI_HORIZONTAL: return gtk_paned_new(GTK_ORIENTATION_HORIZONTAL); |
3f32db79a76e
add splitpane (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
393 | case UI_VERTICAL: return gtk_paned_new(GTK_ORIENTATION_VERTICAL); |
3f32db79a76e
add splitpane (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
394 | } |
3f32db79a76e
add splitpane (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
395 | #else |
3f32db79a76e
add splitpane (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
396 | switch(orientation) { |
3f32db79a76e
add splitpane (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
397 | case UI_HORIZONTAL: return gtk_hpaned_new(); |
3f32db79a76e
add splitpane (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
398 | case UI_VERTICAL: return gtk_vpaned_new(); |
3f32db79a76e
add splitpane (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
399 | } |
3f32db79a76e
add splitpane (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
400 | #endif |
3f32db79a76e
add splitpane (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
401 | return NULL; |
3f32db79a76e
add splitpane (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
402 | } |
3f32db79a76e
add splitpane (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
403 | |
3f32db79a76e
add splitpane (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
404 | UIWIDGET ui_splitpane(UiObject *obj, int max, UiOrientation orientation) { |
3f32db79a76e
add splitpane (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
405 | GtkWidget *paned = create_paned(orientation); |
3f32db79a76e
add splitpane (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
406 | UiContainer *ct = uic_get_current_container(obj); |
3f32db79a76e
add splitpane (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
407 | ct->add(ct, paned, TRUE); |
3f32db79a76e
add splitpane (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
408 | |
3f32db79a76e
add splitpane (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
409 | if(max <= 0) max = INT_MAX; |
3f32db79a76e
add splitpane (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
410 | |
174 | 411 | UiPanedContainer *pctn = cxCalloc( |
412 | obj->ctx->allocator, | |
165
3f32db79a76e
add splitpane (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
413 | 1, |
3f32db79a76e
add splitpane (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
414 | sizeof(UiPanedContainer)); |
3f32db79a76e
add splitpane (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
415 | pctn->container.widget = paned; |
3f32db79a76e
add splitpane (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
416 | pctn->container.add = ui_paned_container_add; |
3f32db79a76e
add splitpane (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
417 | pctn->current_pane = paned; |
3f32db79a76e
add splitpane (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
418 | pctn->orientation = orientation; |
3f32db79a76e
add splitpane (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
419 | pctn->max = max; |
3f32db79a76e
add splitpane (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
420 | pctn->cur = 0; |
3f32db79a76e
add splitpane (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
421 | |
3f32db79a76e
add splitpane (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
422 | UiObject *pobj = uic_object_new(obj, paned); |
3f32db79a76e
add splitpane (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
423 | pobj->container = (UiContainer*)pctn; |
3f32db79a76e
add splitpane (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
424 | |
3f32db79a76e
add splitpane (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
425 | uic_obj_add(obj, pobj); |
3f32db79a76e
add splitpane (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
426 | |
3f32db79a76e
add splitpane (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
427 | return paned; |
3f32db79a76e
add splitpane (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
428 | } |
3f32db79a76e
add splitpane (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
429 | |
3f32db79a76e
add splitpane (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
430 | UIWIDGET ui_hsplitpane(UiObject *obj, int max) { |
3f32db79a76e
add splitpane (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
431 | return ui_splitpane(obj, max, UI_HORIZONTAL); |
3f32db79a76e
add splitpane (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
432 | } |
3f32db79a76e
add splitpane (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
433 | |
3f32db79a76e
add splitpane (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
434 | UIWIDGET ui_vsplitpane(UiObject *obj, int max) { |
3f32db79a76e
add splitpane (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
435 | return ui_splitpane(obj, max, UI_VERTICAL); |
3f32db79a76e
add splitpane (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
436 | } |
3f32db79a76e
add splitpane (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
437 | |
3f32db79a76e
add splitpane (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
438 | void ui_paned_container_add(UiContainer *ct, GtkWidget *widget, UiBool fill) { |
3f32db79a76e
add splitpane (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
439 | UiPanedContainer *pctn = (UiPanedContainer*)ct; |
3f32db79a76e
add splitpane (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
440 | |
3f32db79a76e
add splitpane (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
441 | gboolean resize = (ct->layout.hexpand || ct->layout.vexpand) ? TRUE : FALSE; |
3f32db79a76e
add splitpane (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
442 | int width = ct->layout.width; |
3f32db79a76e
add splitpane (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
443 | ui_reset_layout(ct->layout); |
3f32db79a76e
add splitpane (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
444 | |
3f32db79a76e
add splitpane (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
445 | if(pctn->cur == 0) { |
3f32db79a76e
add splitpane (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
446 | gtk_paned_pack1(GTK_PANED(pctn->current_pane), widget, resize, resize); |
3f32db79a76e
add splitpane (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
447 | } else if(pctn->cur < pctn->max-1) { |
3f32db79a76e
add splitpane (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
448 | GtkWidget *nextPane = create_paned(pctn->orientation); |
3f32db79a76e
add splitpane (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
449 | gtk_paned_pack2(GTK_PANED(pctn->current_pane), nextPane, TRUE, TRUE); |
3f32db79a76e
add splitpane (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
450 | gtk_paned_pack1(GTK_PANED(nextPane), widget, resize, resize); |
3f32db79a76e
add splitpane (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
451 | pctn->current_pane = nextPane; |
3f32db79a76e
add splitpane (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
452 | } else if(pctn->cur == pctn->max-1) { |
3f32db79a76e
add splitpane (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
453 | gtk_paned_pack2(GTK_PANED(pctn->current_pane), widget, resize, resize); |
3f32db79a76e
add splitpane (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
454 | width = 0; // disable potential call of gtk_paned_set_position |
3f32db79a76e
add splitpane (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
455 | } else { |
3f32db79a76e
add splitpane (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
456 | fprintf(stderr, "Splitpane max reached: %d\n", pctn->max); |
3f32db79a76e
add splitpane (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
457 | return; |
3f32db79a76e
add splitpane (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
458 | } |
3f32db79a76e
add splitpane (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
459 | |
3f32db79a76e
add splitpane (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
460 | if(width > 0) { |
3f32db79a76e
add splitpane (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
461 | gtk_paned_set_position(GTK_PANED(pctn->current_pane), width); |
3f32db79a76e
add splitpane (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
462 | } |
3f32db79a76e
add splitpane (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
463 | |
3f32db79a76e
add splitpane (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
464 | pctn->cur++; |
3f32db79a76e
add splitpane (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
465 | } |
3f32db79a76e
add splitpane (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
466 | |
3f32db79a76e
add splitpane (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
467 | |
3f32db79a76e
add splitpane (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
468 | /* -------------------- Sidebar (deprecated) -------------------- */ |
33
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
4
diff
changeset
|
469 | UIWIDGET ui_sidebar(UiObject *obj) { |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
4
diff
changeset
|
470 | #ifdef UI_GTK3 |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
4
diff
changeset
|
471 | GtkWidget *paned = gtk_paned_new(GTK_ORIENTATION_HORIZONTAL); |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
4
diff
changeset
|
472 | #else |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
4
diff
changeset
|
473 | GtkWidget *paned = gtk_hpaned_new(); |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
4
diff
changeset
|
474 | #endif |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
4
diff
changeset
|
475 | gtk_paned_set_position(GTK_PANED(paned), 200); |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
4
diff
changeset
|
476 | |
107
9aff1dc3990d
improved box container and added radio button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
100
diff
changeset
|
477 | GtkWidget *sidebar = ui_gtk_vbox_new(0); |
33
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
4
diff
changeset
|
478 | gtk_paned_pack1(GTK_PANED(paned), sidebar, TRUE, FALSE); |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
4
diff
changeset
|
479 | |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
4
diff
changeset
|
480 | UiObject *left = uic_object_new(obj, sidebar); |
59
eb6611be50c7
added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
52
diff
changeset
|
481 | UiContainer *ct1 = ui_box_container(obj, sidebar); |
33
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
4
diff
changeset
|
482 | left->container = ct1; |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
4
diff
changeset
|
483 | |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
4
diff
changeset
|
484 | UiObject *right = uic_object_new(obj, sidebar); |
174 | 485 | UiContainer *ct2 = cxCalloc( |
486 | obj->ctx->allocator, | |
487 | 1, | |
33
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
4
diff
changeset
|
488 | sizeof(UiContainer)); |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
4
diff
changeset
|
489 | ct2->widget = paned; |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
4
diff
changeset
|
490 | ct2->add = ui_split_container_add2; |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
4
diff
changeset
|
491 | right->container = ct2; |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
4
diff
changeset
|
492 | |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
4
diff
changeset
|
493 | UiContainer *ct = uic_get_current_container(obj); |
59
eb6611be50c7
added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
52
diff
changeset
|
494 | ct->add(ct, paned, TRUE); |
33
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
4
diff
changeset
|
495 | |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
4
diff
changeset
|
496 | uic_obj_add(obj, right); |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
4
diff
changeset
|
497 | uic_obj_add(obj, left); |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
4
diff
changeset
|
498 | |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
4
diff
changeset
|
499 | return sidebar; |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
4
diff
changeset
|
500 | } |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
4
diff
changeset
|
501 | |
59
eb6611be50c7
added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
52
diff
changeset
|
502 | void ui_split_container_add1(UiContainer *ct, GtkWidget *widget, UiBool fill) { |
eb6611be50c7
added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
52
diff
changeset
|
503 | // TODO: remove |
33
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
4
diff
changeset
|
504 | gtk_paned_pack1(GTK_PANED(ct->widget), widget, TRUE, FALSE); |
75
efe2f65bea17
added context menus (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
74
diff
changeset
|
505 | |
efe2f65bea17
added context menus (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
74
diff
changeset
|
506 | ui_reset_layout(ct->layout); |
efe2f65bea17
added context menus (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
74
diff
changeset
|
507 | ct->current = widget; |
33
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
4
diff
changeset
|
508 | } |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
4
diff
changeset
|
509 | |
59
eb6611be50c7
added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
52
diff
changeset
|
510 | void ui_split_container_add2(UiContainer *ct, GtkWidget *widget, UiBool fill) { |
33
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
4
diff
changeset
|
511 | gtk_paned_pack2(GTK_PANED(ct->widget), widget, TRUE, FALSE); |
75
efe2f65bea17
added context menus (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
74
diff
changeset
|
512 | |
efe2f65bea17
added context menus (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
74
diff
changeset
|
513 | ui_reset_layout(ct->layout); |
efe2f65bea17
added context menus (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
74
diff
changeset
|
514 | ct->current = widget; |
33
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
4
diff
changeset
|
515 | } |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
4
diff
changeset
|
516 | |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
4
diff
changeset
|
517 | |
59
eb6611be50c7
added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
52
diff
changeset
|
518 | /* -------------------- Document Tabview -------------------- */ |
52
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
519 | static void page_change(GtkNotebook *notebook, GtkWidget *page, guint page_num, gpointer data) { |
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
520 | GQuark q = g_quark_from_static_string("ui.tab.object"); |
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
521 | UiObject *tab = g_object_get_qdata(G_OBJECT(page), q); |
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
522 | if(!tab) { |
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
523 | return; |
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
524 | } |
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
525 | |
99
ea1a2d5de765
improved grid container (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
94
diff
changeset
|
526 | //printf("page_change: %d\n", page_num); |
52
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
527 | UiContext *ctx = tab->ctx; |
163
b70e2a77dea0
refactore document system to support document trees
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
148
diff
changeset
|
528 | uic_context_detach_all(ctx->parent); // TODO: fix? |
b70e2a77dea0
refactore document system to support document trees
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
148
diff
changeset
|
529 | ctx->parent->attach_document(ctx->parent, ctx->document); |
52
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
530 | } |
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
531 | |
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
532 | UiTabbedPane* ui_tabbed_document_view(UiObject *obj) { |
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
533 | GtkWidget *tabview = gtk_notebook_new(); |
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
534 | gtk_notebook_set_show_border(GTK_NOTEBOOK(tabview), FALSE); |
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
535 | |
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
536 | g_signal_connect( |
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
537 | tabview, |
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
538 | "switch-page", |
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
539 | G_CALLBACK(page_change), |
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
540 | NULL); |
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
541 | |
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
542 | UiContainer *ct = uic_get_current_container(obj); |
59
eb6611be50c7
added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
52
diff
changeset
|
543 | ct->add(ct, tabview, TRUE); |
52
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
544 | |
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
545 | UiTabbedPane *tabbedpane = ui_malloc(obj->ctx, sizeof(UiTabbedPane)); |
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
546 | tabbedpane->ctx = uic_current_obj(obj)->ctx; |
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
547 | tabbedpane->widget = tabview; |
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
548 | tabbedpane->document = NULL; |
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
549 | |
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
550 | return tabbedpane; |
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
551 | } |
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
552 | |
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
553 | UiObject* ui_document_tab(UiTabbedPane *view) { |
148
4e0b38bbd6c4
replaces usage of some deprecated functions (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
140
diff
changeset
|
554 | GtkWidget *frame = gtk_frame_new(NULL); |
4e0b38bbd6c4
replaces usage of some deprecated functions (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
140
diff
changeset
|
555 | gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_NONE); |
52
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
556 | // TODO: label |
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
557 | gtk_notebook_append_page(GTK_NOTEBOOK(view->widget), frame, NULL); |
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
558 | |
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
559 | UiObject *tab = ui_malloc(view->ctx, sizeof(UiObject)); |
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
560 | tab->widget = NULL; // initialization for uic_context() |
174 | 561 | tab->ctx = uic_context(tab, view->ctx->allocator); |
52
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
562 | tab->ctx->parent = view->ctx; |
163
b70e2a77dea0
refactore document system to support document trees
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
148
diff
changeset
|
563 | tab->ctx->attach_document = uic_context_attach_document; |
b70e2a77dea0
refactore document system to support document trees
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
148
diff
changeset
|
564 | tab->ctx->detach_document2 = uic_context_detach_document2; |
52
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
565 | tab->widget = frame; |
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
566 | tab->window = view->ctx->obj->window; |
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
567 | tab->container = ui_frame_container(tab, frame); |
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
568 | tab->next = NULL; |
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
569 | |
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
570 | GQuark q = g_quark_from_static_string("ui.tab.object"); |
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
571 | g_object_set_qdata(G_OBJECT(frame), q, tab); |
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
572 | |
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
573 | return tab; |
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
574 | } |
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
575 | |
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
576 | void ui_tab_set_document(UiContext *ctx, void *document) { |
163
b70e2a77dea0
refactore document system to support document trees
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
148
diff
changeset
|
577 | // TODO: remove? |
52
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
578 | if(ctx->parent->document) { |
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
579 | //ctx->parent->detach_document(ctx->parent, ctx->parent->document); |
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
580 | } |
163
b70e2a77dea0
refactore document system to support document trees
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
148
diff
changeset
|
581 | //uic_context_set_document(ctx, document); |
52
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
582 | //uic_context_set_document(ctx->parent, document); |
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
583 | //ctx->parent->document = document; |
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
584 | } |
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
585 | |
140
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
121
diff
changeset
|
586 | void ui_tab_detach_document(UiContext *ctx) { |
163
b70e2a77dea0
refactore document system to support document trees
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
148
diff
changeset
|
587 | // TODO: remove? |
b70e2a77dea0
refactore document system to support document trees
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
148
diff
changeset
|
588 | //uic_context_detach_document(ctx->parent); |
52
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
589 | } |
59
eb6611be50c7
added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
52
diff
changeset
|
590 | |
eb6611be50c7
added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
52
diff
changeset
|
591 | |
eb6611be50c7
added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
52
diff
changeset
|
592 | /* |
eb6611be50c7
added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
52
diff
changeset
|
593 | * -------------------- Layout Functions -------------------- |
eb6611be50c7
added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
52
diff
changeset
|
594 | * |
eb6611be50c7
added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
52
diff
changeset
|
595 | * functions for setting layout attributes for the current container |
eb6611be50c7
added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
52
diff
changeset
|
596 | * |
eb6611be50c7
added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
52
diff
changeset
|
597 | */ |
eb6611be50c7
added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
52
diff
changeset
|
598 | |
eb6611be50c7
added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
52
diff
changeset
|
599 | void ui_layout_fill(UiObject *obj, UiBool fill) { |
eb6611be50c7
added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
52
diff
changeset
|
600 | UiContainer *ct = uic_get_current_container(obj); |
eb6611be50c7
added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
52
diff
changeset
|
601 | ct->layout.fill = ui_bool2lb(fill); |
eb6611be50c7
added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
52
diff
changeset
|
602 | } |
65
4697592e24ba
added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
62
diff
changeset
|
603 | |
99
ea1a2d5de765
improved grid container (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
94
diff
changeset
|
604 | void ui_layout_hexpand(UiObject *obj, UiBool expand) { |
ea1a2d5de765
improved grid container (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
94
diff
changeset
|
605 | 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
|
606 | ct->layout.hexpand = expand; |
99
ea1a2d5de765
improved grid container (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
94
diff
changeset
|
607 | } |
ea1a2d5de765
improved grid container (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
94
diff
changeset
|
608 | |
ea1a2d5de765
improved grid container (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
94
diff
changeset
|
609 | void ui_layout_vexpand(UiObject *obj, UiBool expand) { |
ea1a2d5de765
improved grid container (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
94
diff
changeset
|
610 | 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
|
611 | ct->layout.vexpand = expand; |
99
ea1a2d5de765
improved grid container (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
94
diff
changeset
|
612 | } |
ea1a2d5de765
improved grid container (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
94
diff
changeset
|
613 | |
165
3f32db79a76e
add splitpane (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
614 | void ui_layout_width(UiObject *obj, int width) { |
3f32db79a76e
add splitpane (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
615 | UiContainer *ct = uic_get_current_container(obj); |
3f32db79a76e
add splitpane (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
616 | ct->layout.width = width; |
3f32db79a76e
add splitpane (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
617 | } |
3f32db79a76e
add splitpane (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
618 | |
109
b9808f916687
added gridwidth layout option (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
107
diff
changeset
|
619 | void ui_layout_gridwidth(UiObject *obj, int width) { |
b9808f916687
added gridwidth layout option (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
107
diff
changeset
|
620 | UiContainer *ct = uic_get_current_container(obj); |
b9808f916687
added gridwidth layout option (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
107
diff
changeset
|
621 | ct->layout.gridwidth = width; |
b9808f916687
added gridwidth layout option (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
107
diff
changeset
|
622 | } |
b9808f916687
added gridwidth layout option (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
107
diff
changeset
|
623 | |
65
4697592e24ba
added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
62
diff
changeset
|
624 | 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
|
625 | 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
|
626 | ct->layout.newline = TRUE; |
4697592e24ba
added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
62
diff
changeset
|
627 | } |
99
ea1a2d5de765
improved grid container (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
94
diff
changeset
|
628 |