ui/gtk/container.c

Sun, 11 Jan 2015 15:29:38 +0100

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Sun, 11 Jan 2015 15:29:38 +0100
changeset 70
3d801e8dda3a
parent 66
8d490d97aab8
child 74
55718d4ed227
permissions
-rw-r--r--

added label and textfield (Qt)

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 *
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
4 * Copyright 2014 Olaf Wintermann. All rights reserved.
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>
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
31
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
32 #include "container.h"
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
33 #include "../common/context.h"
33
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
34 #include "../common/object.h"
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
35
59
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
36 GtkWidget* ui_gtk_vbox_new() {
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
37 #ifdef UI_GTK3
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
38 return gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
39 #else
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
40 return gtk_vbox_new(FALSE, 0);
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
41 #endif
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
42 }
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
43
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
44 GtkWidget* ui_gtk_hbox_new() {
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
45 #ifdef UI_GTK3
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
46 return gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
47 #else
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
48 return gtk_hbox_new(FALSE, 0);
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
49 #endif
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
50 }
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
51
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
52 /* -------------------- Frame Container (deprecated) -------------------- */
4
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
53 UiContainer* ui_frame_container(UiObject *obj, GtkWidget *frame) {
59
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
54 UiContainer *ct = ucx_mempool_calloc(
4
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
55 obj->ctx->mempool,
59
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
56 1,
4
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
57 sizeof(UiContainer));
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
58 ct->widget = frame;
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
59 ct->add = ui_frame_container_add;
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
60 return ct;
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
61 }
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
62
59
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
63 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
64 gtk_container_add(GTK_CONTAINER(ct->widget), widget);
59
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
65 ui_reset_layout(ct->layout);
4
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
66 }
33
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
67
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
68
59
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
69 /* -------------------- Box Container -------------------- */
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
70 UiContainer* ui_box_container(UiObject *obj, GtkWidget *box) {
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
71 UiBoxContainer *ct = ucx_mempool_calloc(
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
72 obj->ctx->mempool,
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
73 1,
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
74 sizeof(UiBoxContainer));
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
75 ct->container.widget = box;
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
76 ct->container.add = ui_box_container_add;
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
77 return (UiContainer*)ct;
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
78 }
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
79
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
80 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
81 UiBoxContainer *bc = (UiBoxContainer*)ct;
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
82 if(ct->layout.fill != UI_LAYOUT_UNDEFINED) {
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
83 fill = ui_lb2bool(ct->layout.fill);
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
84 }
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
85
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
86 if(bc->has_fill && fill) {
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
87 fprintf(stderr, "UiError: container has 2 filled widgets");
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
88 fill = FALSE;
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
89 }
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
90 if(fill) {
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
91 bc->has_fill = TRUE;
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
92 }
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
93
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
94 UiBool expand = fill;
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
95 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
96
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
97 ui_reset_layout(ct->layout);
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
65
4697592e24ba added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 62
diff changeset
100 UiContainer* ui_grid_container(UiObject *obj, GtkWidget *grid) {
4697592e24ba added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 62
diff changeset
101 UiGridContainer *ct = ucx_mempool_calloc(
4697592e24ba added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 62
diff changeset
102 obj->ctx->mempool,
4697592e24ba added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 62
diff changeset
103 1,
4697592e24ba added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 62
diff changeset
104 sizeof(UiGridContainer));
4697592e24ba added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 62
diff changeset
105 ct->container.widget = grid;
4697592e24ba added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 62
diff changeset
106 ct->container.add = ui_grid_container_add;
4697592e24ba added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 62
diff changeset
107 return (UiContainer*)ct;
4697592e24ba added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 62
diff changeset
108 }
4697592e24ba added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 62
diff changeset
109
4697592e24ba added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 62
diff changeset
110 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
111 UiGridContainer *grid = (UiGridContainer*)ct;
4697592e24ba added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 62
diff changeset
112
4697592e24ba added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 62
diff changeset
113 if(ct->layout.newline) {
4697592e24ba added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 62
diff changeset
114 grid->x = 0;
4697592e24ba added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 62
diff changeset
115 grid->y++;
4697592e24ba added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 62
diff changeset
116 ct->layout.newline = FALSE;
4697592e24ba added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 62
diff changeset
117 }
4697592e24ba added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 62
diff changeset
118
4697592e24ba added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 62
diff changeset
119 gtk_grid_attach(GTK_GRID(ct->widget), widget, grid->x, grid->y, 1, 1);
4697592e24ba added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 62
diff changeset
120 grid->x++;
4697592e24ba added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 62
diff changeset
121
4697592e24ba added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 62
diff changeset
122 ui_reset_layout(ct->layout);
4697592e24ba added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 62
diff changeset
123 }
4697592e24ba added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 62
diff changeset
124
4697592e24ba added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 62
diff changeset
125 UiContainer* ui_tabview_container(UiObject *obj, GtkWidget *tabview) {
4697592e24ba added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 62
diff changeset
126 UiTabViewContainer *ct = ucx_mempool_calloc(
4697592e24ba added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 62
diff changeset
127 obj->ctx->mempool,
4697592e24ba added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 62
diff changeset
128 1,
4697592e24ba added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 62
diff changeset
129 sizeof(UiTabViewContainer));
4697592e24ba added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 62
diff changeset
130 ct->container.widget = tabview;
4697592e24ba added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 62
diff changeset
131 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
132 return (UiContainer*)ct;
4697592e24ba added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 62
diff changeset
133 }
4697592e24ba added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 62
diff changeset
134
4697592e24ba added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 62
diff changeset
135 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
136 gtk_notebook_append_page(
4697592e24ba added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 62
diff changeset
137 GTK_NOTEBOOK(ct->widget),
4697592e24ba added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 62
diff changeset
138 widget,
4697592e24ba added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 62
diff changeset
139 gtk_label_new(ct->layout.label));
4697592e24ba added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 62
diff changeset
140 }
4697592e24ba added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 62
diff changeset
141
4697592e24ba added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 62
diff changeset
142
62
70d2aee84432 added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 59
diff changeset
143 UIWIDGET ui_vbox(UiObject *obj) {
70d2aee84432 added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 59
diff changeset
144 UiContainer *ct = uic_get_current_container(obj);
70d2aee84432 added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 59
diff changeset
145
70d2aee84432 added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 59
diff changeset
146 GtkWidget *vbox = ui_gtk_vbox_new();
70d2aee84432 added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 59
diff changeset
147 ct->add(ct, vbox, TRUE);
70d2aee84432 added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 59
diff changeset
148
70d2aee84432 added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 59
diff changeset
149 UiObject *newobj = uic_object_new(obj, vbox);
70d2aee84432 added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 59
diff changeset
150 newobj->container = ui_box_container(obj, vbox);
70d2aee84432 added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 59
diff changeset
151 uic_obj_add(obj, newobj);
70d2aee84432 added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 59
diff changeset
152
70d2aee84432 added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 59
diff changeset
153 return vbox;
70d2aee84432 added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 59
diff changeset
154 }
70d2aee84432 added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 59
diff changeset
155
70d2aee84432 added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 59
diff changeset
156 UIWIDGET ui_hbox(UiObject *obj) {
70d2aee84432 added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 59
diff changeset
157 UiContainer *ct = uic_get_current_container(obj);
70d2aee84432 added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 59
diff changeset
158
70d2aee84432 added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 59
diff changeset
159 GtkWidget *hbox = ui_gtk_hbox_new();
70d2aee84432 added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 59
diff changeset
160 ct->add(ct, hbox, TRUE);
70d2aee84432 added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 59
diff changeset
161
70d2aee84432 added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 59
diff changeset
162 UiObject *newobj = uic_object_new(obj, hbox);
70d2aee84432 added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 59
diff changeset
163 newobj->container = ui_box_container(obj, hbox);
70d2aee84432 added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 59
diff changeset
164 uic_obj_add(obj, newobj);
70d2aee84432 added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 59
diff changeset
165
70d2aee84432 added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 59
diff changeset
166 return hbox;
70d2aee84432 added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 59
diff changeset
167 }
70d2aee84432 added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 59
diff changeset
168
65
4697592e24ba added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 62
diff changeset
169 UIWIDGET ui_grid(UiObject *obj) {
4697592e24ba added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 62
diff changeset
170 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
171
4697592e24ba added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 62
diff changeset
172 GtkWidget *grid = gtk_grid_new();
4697592e24ba added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 62
diff changeset
173 ct->add(ct, grid, TRUE);
4697592e24ba added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 62
diff changeset
174
4697592e24ba added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 62
diff changeset
175 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
176 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
177 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
178
4697592e24ba added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 62
diff changeset
179 return grid;
4697592e24ba added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 62
diff changeset
180 }
4697592e24ba added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 62
diff changeset
181
4697592e24ba added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 62
diff changeset
182 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
183 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
184 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
185 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
186
4697592e24ba added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 62
diff changeset
187 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
188 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
189
4697592e24ba added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 62
diff changeset
190 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
191 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
192 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
193
4697592e24ba added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 62
diff changeset
194 return tabview;
4697592e24ba added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 62
diff changeset
195 }
4697592e24ba added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 62
diff changeset
196
4697592e24ba added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 62
diff changeset
197 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
198 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
199 ct->layout.label = title;
4697592e24ba added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 62
diff changeset
200 ui_vbox(obj);
4697592e24ba added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 62
diff changeset
201 }
4697592e24ba added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 62
diff changeset
202
4697592e24ba added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 62
diff changeset
203 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
204 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
205 }
4697592e24ba added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 62
diff changeset
206
59
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
207
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
208 /* -------------------- Sidebar -------------------- */
33
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
209 UIWIDGET ui_sidebar(UiObject *obj) {
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
210 #ifdef UI_GTK3
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
211 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
212 #else
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
213 GtkWidget *paned = gtk_hpaned_new();
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
214 #endif
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
215 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
216
59
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
217 GtkWidget *sidebar = ui_gtk_vbox_new();
33
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
218 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
219
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
220 UiObject *left = uic_object_new(obj, sidebar);
59
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
221 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
222 left->container = ct1;
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
223
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
224 UiObject *right = uic_object_new(obj, sidebar);
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
225 UiContainer *ct2 = ucx_mempool_malloc(
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
226 obj->ctx->mempool,
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
227 sizeof(UiContainer));
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
228 ct2->widget = paned;
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
229 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
230 right->container = ct2;
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
231
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
232 UiContainer *ct = uic_get_current_container(obj);
59
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
233 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
234
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
235 uic_obj_add(obj, right);
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
236 uic_obj_add(obj, left);
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
237
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
238 return sidebar;
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
239 }
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
240
59
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
241 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
242 // TODO: remove
33
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
243 gtk_paned_pack1(GTK_PANED(ct->widget), widget, TRUE, FALSE);
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
244 }
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
245
59
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
246 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
247 gtk_paned_pack2(GTK_PANED(ct->widget), widget, TRUE, FALSE);
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
248 }
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
249
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
250
59
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
251 /* -------------------- Document Tabview -------------------- */
52
25e5390cce41 added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
252 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
253 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
254 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
255 if(!tab) {
25e5390cce41 added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
256 return;
25e5390cce41 added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
257 }
25e5390cce41 added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
258
25e5390cce41 added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
259 printf("page_change: %d\n", page_num);
25e5390cce41 added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
260 UiContext *ctx = tab->ctx;
25e5390cce41 added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
261 ctx->parent->set_document(ctx->parent, ctx->document);
25e5390cce41 added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
262 }
25e5390cce41 added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
263
25e5390cce41 added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
264 UiTabbedPane* ui_tabbed_document_view(UiObject *obj) {
25e5390cce41 added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
265 GtkWidget *tabview = gtk_notebook_new();
25e5390cce41 added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
266 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
267
25e5390cce41 added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
268 g_signal_connect(
25e5390cce41 added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
269 tabview,
25e5390cce41 added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
270 "switch-page",
25e5390cce41 added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
271 G_CALLBACK(page_change),
25e5390cce41 added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
272 NULL);
25e5390cce41 added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
273
25e5390cce41 added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
274 UiContainer *ct = uic_get_current_container(obj);
59
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
275 ct->add(ct, tabview, TRUE);
52
25e5390cce41 added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
276
25e5390cce41 added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
277 UiTabbedPane *tabbedpane = ui_malloc(obj->ctx, sizeof(UiTabbedPane));
25e5390cce41 added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
278 tabbedpane->ctx = uic_current_obj(obj)->ctx;
25e5390cce41 added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
279 tabbedpane->widget = tabview;
25e5390cce41 added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
280 tabbedpane->document = NULL;
25e5390cce41 added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
281
25e5390cce41 added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
282 return tabbedpane;
25e5390cce41 added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
283 }
25e5390cce41 added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
284
25e5390cce41 added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
285 UiObject* ui_document_tab(UiTabbedPane *view) {
25e5390cce41 added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
286 GtkWidget *frame = gtk_alignment_new(0.5, 0.5, 1, 1);
25e5390cce41 added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
287 // TODO: label
25e5390cce41 added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
288 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
289
25e5390cce41 added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
290 UiObject *tab = ui_malloc(view->ctx, sizeof(UiObject));
25e5390cce41 added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
291 tab->widget = NULL; // initialization for uic_context()
25e5390cce41 added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
292 tab->ctx = uic_context(tab, view->ctx->mempool);
25e5390cce41 added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
293 tab->ctx->parent = view->ctx;
25e5390cce41 added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
294 tab->ctx->set_document = ui_tab_set_document;
25e5390cce41 added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
295 tab->ctx->detach_document = ui_tab_detach_document;
25e5390cce41 added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
296 tab->widget = frame;
25e5390cce41 added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
297 tab->window = view->ctx->obj->window;
25e5390cce41 added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
298 tab->container = ui_frame_container(tab, frame);
25e5390cce41 added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
299 tab->next = NULL;
25e5390cce41 added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
300
25e5390cce41 added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
301 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
302 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
303
25e5390cce41 added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
304 return tab;
25e5390cce41 added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
305 }
25e5390cce41 added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
306
25e5390cce41 added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
307 void ui_tab_set_document(UiContext *ctx, void *document) {
25e5390cce41 added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
308 if(ctx->parent->document) {
25e5390cce41 added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
309 //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
310 }
25e5390cce41 added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
311 uic_context_set_document(ctx, document);
25e5390cce41 added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
312 //uic_context_set_document(ctx->parent, document);
25e5390cce41 added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
313 //ctx->parent->document = document;
25e5390cce41 added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
314 }
25e5390cce41 added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
315
25e5390cce41 added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
316 void ui_tab_detach_document(UiContext *ctx, void *document) {
25e5390cce41 added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
317 uic_context_detach_document(ctx->parent, document);
25e5390cce41 added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
318 }
59
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
319
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
320
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
321 /*
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
322 * -------------------- Layout Functions --------------------
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
323 *
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
324 * functions for setting layout attributes for the current container
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
325 *
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
326 */
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
327
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
328 void ui_layout_fill(UiObject *obj, UiBool fill) {
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
329 UiContainer *ct = uic_get_current_container(obj);
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
330 ct->layout.fill = ui_bool2lb(fill);
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
331 }
65
4697592e24ba added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 62
diff changeset
332
4697592e24ba added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 62
diff changeset
333 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
334 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
335 ct->layout.newline = TRUE;
4697592e24ba added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 62
diff changeset
336 }

mercurial