Sun, 10 Nov 2024 15:27:44 +0100
implement some missing WinUI functions
0 | 1 | /* |
2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. | |
3 | * | |
144
29d98cff4f56
UiInteger uses int64 now
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
143
diff
changeset
|
4 | * Copyright 2017 Olaf Wintermann. All rights reserved. |
0 | 5 | * |
6 | * Redistribution and use in source and binary forms, with or without | |
7 | * modification, are permitted provided that the following conditions are met: | |
8 | * | |
9 | * 1. Redistributions of source code must retain the above copyright | |
10 | * notice, this list of conditions and the following disclaimer. | |
11 | * | |
12 | * 2. Redistributions in binary form must reproduce the above copyright | |
13 | * notice, this list of conditions and the following disclaimer in the | |
14 | * documentation and/or other materials provided with the distribution. | |
15 | * | |
16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | |
17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE | |
20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
26 | * POSSIBILITY OF SUCH DAMAGE. | |
27 | */ | |
28 | ||
29 | #include <stdio.h> | |
30 | #include <stdlib.h> | |
31 | ||
32 | #include <ui/ui.h> | |
174 | 33 | #include <cx/buffer.h> |
34 | #include <cx/utils.h> | |
0 | 35 | |
163
b70e2a77dea0
refactore document system to support document trees
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
162
diff
changeset
|
36 | typedef struct { |
253
087cc9216f28
initial newapi GTK port
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
174
diff
changeset
|
37 | UiString *str1; |
087cc9216f28
initial newapi GTK port
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
174
diff
changeset
|
38 | UiString *str2; |
282
3a77b9048664
add path textfield (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
279
diff
changeset
|
39 | UiString *path; |
335
91d4f0391282
add new textarea (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
333
diff
changeset
|
40 | UiText *text; |
266
37d5b49b1c91
fix progressbar using the wrong var type (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
265
diff
changeset
|
41 | UiDouble *progress; |
268
1b321a0c624f
port table to new API, replace custom tree model with GtkListStore
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
267
diff
changeset
|
42 | UiList *list; |
311
450a813dc2a5
implement GTK4 gmenu item and item list
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
310
diff
changeset
|
43 | UiList *menulist; |
275
132c7bcc6997
implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
270
diff
changeset
|
44 | UiInteger *radio; |
332
7e7c05af8f3a
implement stack set/get/remove (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
331
diff
changeset
|
45 | UiInteger *tabview; |
339
b68b5f984074
add minimally working image viewer (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
336
diff
changeset
|
46 | UiGeneric *image; |
163
b70e2a77dea0
refactore document system to support document trees
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
162
diff
changeset
|
47 | } MyDocument; |
b70e2a77dea0
refactore document system to support document trees
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
162
diff
changeset
|
48 | |
b70e2a77dea0
refactore document system to support document trees
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
162
diff
changeset
|
49 | MyDocument *doc1; |
b70e2a77dea0
refactore document system to support document trees
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
162
diff
changeset
|
50 | MyDocument *doc2; |
b70e2a77dea0
refactore document system to support document trees
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
162
diff
changeset
|
51 | |
333
634e3ce80afe
implement gtk3 stack tabview
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
332
diff
changeset
|
52 | UIWIDGET tabview; |
163
b70e2a77dea0
refactore document system to support document trees
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
162
diff
changeset
|
53 | |
347
6f0d0b0d97f5
add conditional variable API
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
345
diff
changeset
|
54 | static UiCondVar *cond; |
6f0d0b0d97f5
add conditional variable API
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
345
diff
changeset
|
55 | static int thr_end = 0; |
6f0d0b0d97f5
add conditional variable API
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
345
diff
changeset
|
56 | static int thr_started = 0; |
6f0d0b0d97f5
add conditional variable API
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
345
diff
changeset
|
57 | |
6f0d0b0d97f5
add conditional variable API
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
345
diff
changeset
|
58 | int threadfunc(void *data) { |
6f0d0b0d97f5
add conditional variable API
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
345
diff
changeset
|
59 | printf("thr wait for data...\n"); |
6f0d0b0d97f5
add conditional variable API
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
345
diff
changeset
|
60 | ui_condvar_wait(cond); |
6f0d0b0d97f5
add conditional variable API
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
345
diff
changeset
|
61 | printf("thr data received: {%s} [%d]\n", cond->data, cond->intdata); |
6f0d0b0d97f5
add conditional variable API
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
345
diff
changeset
|
62 | ui_condvar_destroy(cond); |
6f0d0b0d97f5
add conditional variable API
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
345
diff
changeset
|
63 | cond = NULL; |
6f0d0b0d97f5
add conditional variable API
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
345
diff
changeset
|
64 | |
6f0d0b0d97f5
add conditional variable API
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
345
diff
changeset
|
65 | return 0; |
6f0d0b0d97f5
add conditional variable API
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
345
diff
changeset
|
66 | } |
6f0d0b0d97f5
add conditional variable API
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
345
diff
changeset
|
67 | |
6f0d0b0d97f5
add conditional variable API
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
345
diff
changeset
|
68 | void action_start_thread(UiEvent *event, void *data) { |
6f0d0b0d97f5
add conditional variable API
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
345
diff
changeset
|
69 | if(!thr_started) { |
6f0d0b0d97f5
add conditional variable API
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
345
diff
changeset
|
70 | cond = ui_condvar_create(); |
6f0d0b0d97f5
add conditional variable API
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
345
diff
changeset
|
71 | ui_job(event->obj, threadfunc, NULL, NULL, NULL); |
6f0d0b0d97f5
add conditional variable API
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
345
diff
changeset
|
72 | thr_started = 1; |
6f0d0b0d97f5
add conditional variable API
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
345
diff
changeset
|
73 | } |
6f0d0b0d97f5
add conditional variable API
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
345
diff
changeset
|
74 | } |
6f0d0b0d97f5
add conditional variable API
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
345
diff
changeset
|
75 | |
6f0d0b0d97f5
add conditional variable API
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
345
diff
changeset
|
76 | void action_notify_thread(UiEvent *event, void *data) { |
6f0d0b0d97f5
add conditional variable API
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
345
diff
changeset
|
77 | if(!thr_end) { |
6f0d0b0d97f5
add conditional variable API
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
345
diff
changeset
|
78 | ui_condvar_signal(cond, "hello thread", 123); |
6f0d0b0d97f5
add conditional variable API
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
345
diff
changeset
|
79 | thr_end = 1; |
6f0d0b0d97f5
add conditional variable API
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
345
diff
changeset
|
80 | } |
6f0d0b0d97f5
add conditional variable API
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
345
diff
changeset
|
81 | } |
6f0d0b0d97f5
add conditional variable API
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
345
diff
changeset
|
82 | |
162 | 83 | void action_menu(UiEvent *event, void *userdata) { |
253
087cc9216f28
initial newapi GTK port
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
174
diff
changeset
|
84 | |
145
853685152c1d
adds spinner widget (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
144
diff
changeset
|
85 | } |
853685152c1d
adds spinner widget (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
144
diff
changeset
|
86 | |
279
2ad83650d797
implement file dialog (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
278
diff
changeset
|
87 | void action_file_selected(UiEvent *event, void *userdata) { |
2ad83650d797
implement file dialog (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
278
diff
changeset
|
88 | UiFileList *files = event->eventdata; |
339
b68b5f984074
add minimally working image viewer (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
336
diff
changeset
|
89 | MyDocument *doc = event->document; |
279
2ad83650d797
implement file dialog (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
278
diff
changeset
|
90 | printf("files: %d\n", (int)files->nfiles); |
2ad83650d797
implement file dialog (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
278
diff
changeset
|
91 | if(files->nfiles > 0) { |
2ad83650d797
implement file dialog (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
278
diff
changeset
|
92 | printf("selected file: %s\n", files->files[0]); |
339
b68b5f984074
add minimally working image viewer (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
336
diff
changeset
|
93 | ui_image_load_file(doc->image, files->files[0]); |
279
2ad83650d797
implement file dialog (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
278
diff
changeset
|
94 | } |
2ad83650d797
implement file dialog (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
278
diff
changeset
|
95 | } |
2ad83650d797
implement file dialog (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
278
diff
changeset
|
96 | |
163
b70e2a77dea0
refactore document system to support document trees
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
162
diff
changeset
|
97 | void action_button(UiEvent *event, void *userdata) { |
339
b68b5f984074
add minimally working image viewer (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
336
diff
changeset
|
98 | ui_openfiledialog(event->obj, UI_FILEDIALOG_SELECT_SINGLE, action_file_selected, NULL); |
163
b70e2a77dea0
refactore document system to support document trees
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
162
diff
changeset
|
99 | } |
b70e2a77dea0
refactore document system to support document trees
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
162
diff
changeset
|
100 | |
b70e2a77dea0
refactore document system to support document trees
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
162
diff
changeset
|
101 | void action_switch(UiEvent *event, void *userdata) { |
253
087cc9216f28
initial newapi GTK port
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
174
diff
changeset
|
102 | |
163
b70e2a77dea0
refactore document system to support document trees
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
162
diff
changeset
|
103 | } |
b70e2a77dea0
refactore document system to support document trees
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
162
diff
changeset
|
104 | |
275
132c7bcc6997
implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
270
diff
changeset
|
105 | void action_toolbar_button(UiEvent *event, void *userdata) { |
320
be224cf1f50e
add alternative ui_dialog implementation for libadwaita
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
317
diff
changeset
|
106 | printf("toolbar button\n"); |
275
132c7bcc6997
implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
270
diff
changeset
|
107 | |
320
be224cf1f50e
add alternative ui_dialog implementation for libadwaita
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
317
diff
changeset
|
108 | ui_dialog(event->obj, .title = "Dialog Title", .content = "Content Label", .button1_label = "btn1", .button2_label = "btn2", .input = TRUE, .closebutton_label = "Cancel"); |
275
132c7bcc6997
implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
270
diff
changeset
|
109 | } |
163
b70e2a77dea0
refactore document system to support document trees
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
162
diff
changeset
|
110 | |
344
870dd3d41d83
add dialog window (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
343
diff
changeset
|
111 | void action_dialog_button(UiEvent *event, void *userdata) { |
870dd3d41d83
add dialog window (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
343
diff
changeset
|
112 | ui_close(event->obj); |
870dd3d41d83
add dialog window (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
343
diff
changeset
|
113 | } |
870dd3d41d83
add dialog window (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
343
diff
changeset
|
114 | |
870dd3d41d83
add dialog window (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
343
diff
changeset
|
115 | void action_toolbar_dialog(UiEvent *event, void *userdata) { |
870dd3d41d83
add dialog window (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
343
diff
changeset
|
116 | |
345
d2ccc543f432
add style for dialog window default button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
344
diff
changeset
|
117 | UiObject *dialog = ui_dialog_window(event->obj, .title = "Dialog Window", .lbutton1 = "Cancel 1", .lbutton2 = "Btn2", .rbutton3 = "Btn3", .rbutton4 = "Login 4", .onclick = action_dialog_button, .default_button = 4, .show_closebutton = UI_OFF); |
344
870dd3d41d83
add dialog window (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
343
diff
changeset
|
118 | |
870dd3d41d83
add dialog window (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
343
diff
changeset
|
119 | ui_vbox(dialog, .margin = 10, .spacing = 10) { |
870dd3d41d83
add dialog window (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
343
diff
changeset
|
120 | ui_label(dialog, .label = "Enter password:"); |
870dd3d41d83
add dialog window (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
343
diff
changeset
|
121 | ui_passwordfield(dialog, .varname = "password"); |
870dd3d41d83
add dialog window (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
343
diff
changeset
|
122 | } |
870dd3d41d83
add dialog window (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
343
diff
changeset
|
123 | |
870dd3d41d83
add dialog window (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
343
diff
changeset
|
124 | ui_show(dialog); |
870dd3d41d83
add dialog window (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
343
diff
changeset
|
125 | } |
870dd3d41d83
add dialog window (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
343
diff
changeset
|
126 | |
336
56c12f44c2d3
add custom headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
335
diff
changeset
|
127 | void action_toolbar_newwindow(UiEvent *event, void *userdata) { |
56c12f44c2d3
add custom headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
335
diff
changeset
|
128 | UiObject *obj = ui_simple_window("New Window", NULL); |
56c12f44c2d3
add custom headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
335
diff
changeset
|
129 | |
56c12f44c2d3
add custom headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
335
diff
changeset
|
130 | ui_headerbar0(obj) { |
56c12f44c2d3
add custom headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
335
diff
changeset
|
131 | ui_headerbar_start(obj) { |
56c12f44c2d3
add custom headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
335
diff
changeset
|
132 | ui_button(obj, .label = "Open"); |
56c12f44c2d3
add custom headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
335
diff
changeset
|
133 | } |
56c12f44c2d3
add custom headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
335
diff
changeset
|
134 | ui_headerbar_end(obj) { |
56c12f44c2d3
add custom headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
335
diff
changeset
|
135 | ui_button(obj, .label = "Test"); |
56c12f44c2d3
add custom headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
335
diff
changeset
|
136 | } |
56c12f44c2d3
add custom headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
335
diff
changeset
|
137 | } |
56c12f44c2d3
add custom headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
335
diff
changeset
|
138 | |
56c12f44c2d3
add custom headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
335
diff
changeset
|
139 | ui_textarea(obj, .varname="text"); |
56c12f44c2d3
add custom headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
335
diff
changeset
|
140 | |
56c12f44c2d3
add custom headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
335
diff
changeset
|
141 | ui_show(obj); |
56c12f44c2d3
add custom headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
335
diff
changeset
|
142 | } |
56c12f44c2d3
add custom headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
335
diff
changeset
|
143 | |
163
b70e2a77dea0
refactore document system to support document trees
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
162
diff
changeset
|
144 | MyDocument* create_doc(void) { |
b70e2a77dea0
refactore document system to support document trees
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
162
diff
changeset
|
145 | MyDocument *doc = ui_document_new(sizeof(MyDocument)); |
b70e2a77dea0
refactore document system to support document trees
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
162
diff
changeset
|
146 | UiContext *docctx = ui_document_context(doc); |
253
087cc9216f28
initial newapi GTK port
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
174
diff
changeset
|
147 | doc->str1 = ui_string_new(docctx, "str1"); |
087cc9216f28
initial newapi GTK port
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
174
diff
changeset
|
148 | doc->str1 = ui_string_new(docctx, "str2"); |
282
3a77b9048664
add path textfield (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
279
diff
changeset
|
149 | doc->path = ui_string_new(docctx, "path"); |
266
37d5b49b1c91
fix progressbar using the wrong var type (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
265
diff
changeset
|
150 | doc->progress = ui_double_new(docctx, "progress"); |
268
1b321a0c624f
port table to new API, replace custom tree model with GtkListStore
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
267
diff
changeset
|
151 | doc->list = ui_list_new(docctx, "list"); |
1b321a0c624f
port table to new API, replace custom tree model with GtkListStore
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
267
diff
changeset
|
152 | ui_list_append(doc->list, "test1"); |
1b321a0c624f
port table to new API, replace custom tree model with GtkListStore
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
267
diff
changeset
|
153 | ui_list_append(doc->list, "test2"); |
1b321a0c624f
port table to new API, replace custom tree model with GtkListStore
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
267
diff
changeset
|
154 | ui_list_append(doc->list, "test3"); |
275
132c7bcc6997
implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
270
diff
changeset
|
155 | doc->radio = ui_int_new(docctx, "radio"); |
332
7e7c05af8f3a
implement stack set/get/remove (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
331
diff
changeset
|
156 | doc->tabview = ui_int_new(docctx, "tabview"); |
339
b68b5f984074
add minimally working image viewer (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
336
diff
changeset
|
157 | doc->image = ui_generic_new(docctx, "image"); |
335
91d4f0391282
add new textarea (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
333
diff
changeset
|
158 | //doc->text = ui_text_new(docctx, "text"); |
163
b70e2a77dea0
refactore document system to support document trees
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
162
diff
changeset
|
159 | return doc; |
b70e2a77dea0
refactore document system to support document trees
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
162
diff
changeset
|
160 | } |
b70e2a77dea0
refactore document system to support document trees
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
162
diff
changeset
|
161 | |
268
1b321a0c624f
port table to new API, replace custom tree model with GtkListStore
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
267
diff
changeset
|
162 | UiIcon *icon = NULL; |
1b321a0c624f
port table to new API, replace custom tree model with GtkListStore
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
267
diff
changeset
|
163 | |
1b321a0c624f
port table to new API, replace custom tree model with GtkListStore
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
267
diff
changeset
|
164 | static void* list_getvalue(void *elm, int col) { |
269
3380100e20f5
implement listview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
268
diff
changeset
|
165 | /* |
268
1b321a0c624f
port table to new API, replace custom tree model with GtkListStore
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
267
diff
changeset
|
166 | if(col == 0) { |
1b321a0c624f
port table to new API, replace custom tree model with GtkListStore
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
267
diff
changeset
|
167 | if(!icon) { |
1b321a0c624f
port table to new API, replace custom tree model with GtkListStore
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
267
diff
changeset
|
168 | icon = ui_icon("folder", 24); |
1b321a0c624f
port table to new API, replace custom tree model with GtkListStore
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
267
diff
changeset
|
169 | } |
1b321a0c624f
port table to new API, replace custom tree model with GtkListStore
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
267
diff
changeset
|
170 | return icon; |
1b321a0c624f
port table to new API, replace custom tree model with GtkListStore
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
267
diff
changeset
|
171 | } |
269
3380100e20f5
implement listview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
268
diff
changeset
|
172 | */ |
3380100e20f5
implement listview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
268
diff
changeset
|
173 | |
268
1b321a0c624f
port table to new API, replace custom tree model with GtkListStore
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
267
diff
changeset
|
174 | char *str = elm; |
270
9389313ac00f
port combobox to new API (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
269
diff
changeset
|
175 | return col == 0 ? str : "x"; |
268
1b321a0c624f
port table to new API, replace custom tree model with GtkListStore
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
267
diff
changeset
|
176 | } |
1b321a0c624f
port table to new API, replace custom tree model with GtkListStore
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
267
diff
changeset
|
177 | |
311
450a813dc2a5
implement GTK4 gmenu item and item list
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
310
diff
changeset
|
178 | static UiList *menu_list; |
450a813dc2a5
implement GTK4 gmenu item and item list
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
310
diff
changeset
|
179 | int new_item_count = 0; |
450a813dc2a5
implement GTK4 gmenu item and item list
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
310
diff
changeset
|
180 | |
450a813dc2a5
implement GTK4 gmenu item and item list
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
310
diff
changeset
|
181 | void action_add_menu_item(UiEvent *event, void *userdata) { |
450a813dc2a5
implement GTK4 gmenu item and item list
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
310
diff
changeset
|
182 | char str[64]; |
450a813dc2a5
implement GTK4 gmenu item and item list
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
310
diff
changeset
|
183 | snprintf(str, 64, "new item %d", new_item_count++); |
450a813dc2a5
implement GTK4 gmenu item and item list
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
310
diff
changeset
|
184 | |
450a813dc2a5
implement GTK4 gmenu item and item list
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
310
diff
changeset
|
185 | ui_list_append(menu_list, strdup(str)); |
450a813dc2a5
implement GTK4 gmenu item and item list
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
310
diff
changeset
|
186 | ui_list_notify(menu_list); |
450a813dc2a5
implement GTK4 gmenu item and item list
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
310
diff
changeset
|
187 | } |
450a813dc2a5
implement GTK4 gmenu item and item list
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
310
diff
changeset
|
188 | |
450a813dc2a5
implement GTK4 gmenu item and item list
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
310
diff
changeset
|
189 | void action_menu_list(UiEvent *event, void *userdata) { |
450a813dc2a5
implement GTK4 gmenu item and item list
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
310
diff
changeset
|
190 | printf("menu list item: %d\n", event->intval); |
450a813dc2a5
implement GTK4 gmenu item and item list
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
310
diff
changeset
|
191 | } |
450a813dc2a5
implement GTK4 gmenu item and item list
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
310
diff
changeset
|
192 | |
332
7e7c05af8f3a
implement stack set/get/remove (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
331
diff
changeset
|
193 | static int tab_x = 0; |
7e7c05af8f3a
implement stack set/get/remove (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
331
diff
changeset
|
194 | void action_tab2_button(UiEvent *event, void *userdata) { |
7e7c05af8f3a
implement stack set/get/remove (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
331
diff
changeset
|
195 | MyDocument *doc = event->document; |
7e7c05af8f3a
implement stack set/get/remove (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
331
diff
changeset
|
196 | printf("current page: %d\n", (int)ui_get(doc->tabview)); |
7e7c05af8f3a
implement stack set/get/remove (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
331
diff
changeset
|
197 | ui_set(doc->tabview, 0); |
7e7c05af8f3a
implement stack set/get/remove (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
331
diff
changeset
|
198 | } |
7e7c05af8f3a
implement stack set/get/remove (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
331
diff
changeset
|
199 | |
343
54f5d7eb1335
implement widget groups for buttons (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
340
diff
changeset
|
200 | |
54f5d7eb1335
implement widget groups for buttons (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
340
diff
changeset
|
201 | void action_group1(UiEvent *event, void *userdata) { |
54f5d7eb1335
implement widget groups for buttons (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
340
diff
changeset
|
202 | UiContext *ctx = event->obj->ctx; |
54f5d7eb1335
implement widget groups for buttons (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
340
diff
changeset
|
203 | if(userdata) { |
54f5d7eb1335
implement widget groups for buttons (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
340
diff
changeset
|
204 | ui_unset_group(ctx, 1); |
54f5d7eb1335
implement widget groups for buttons (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
340
diff
changeset
|
205 | } else { |
54f5d7eb1335
implement widget groups for buttons (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
340
diff
changeset
|
206 | ui_set_group(ctx, 1); |
54f5d7eb1335
implement widget groups for buttons (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
340
diff
changeset
|
207 | } |
54f5d7eb1335
implement widget groups for buttons (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
340
diff
changeset
|
208 | } |
54f5d7eb1335
implement widget groups for buttons (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
340
diff
changeset
|
209 | |
54f5d7eb1335
implement widget groups for buttons (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
340
diff
changeset
|
210 | void action_group2(UiEvent *event, void *userdata) { |
54f5d7eb1335
implement widget groups for buttons (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
340
diff
changeset
|
211 | UiContext *ctx = event->obj->ctx; |
54f5d7eb1335
implement widget groups for buttons (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
340
diff
changeset
|
212 | if(userdata) { |
54f5d7eb1335
implement widget groups for buttons (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
340
diff
changeset
|
213 | ui_unset_group(ctx, 2); |
54f5d7eb1335
implement widget groups for buttons (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
340
diff
changeset
|
214 | } else { |
54f5d7eb1335
implement widget groups for buttons (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
340
diff
changeset
|
215 | ui_set_group(ctx, 2); |
54f5d7eb1335
implement widget groups for buttons (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
340
diff
changeset
|
216 | } |
54f5d7eb1335
implement widget groups for buttons (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
340
diff
changeset
|
217 | } |
54f5d7eb1335
implement widget groups for buttons (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
340
diff
changeset
|
218 | |
133
6dd780cbc8c6
using GtkApplication now
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
219 | void application_startup(UiEvent *event, void *data) { |
311
450a813dc2a5
implement GTK4 gmenu item and item list
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
310
diff
changeset
|
220 | // global list |
450a813dc2a5
implement GTK4 gmenu item and item list
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
310
diff
changeset
|
221 | UiContext *global = ui_global_context(); |
450a813dc2a5
implement GTK4 gmenu item and item list
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
310
diff
changeset
|
222 | menu_list = ui_list_new(global, "menulist"); |
450a813dc2a5
implement GTK4 gmenu item and item list
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
310
diff
changeset
|
223 | ui_list_append(menu_list, "menu list item 1"); |
450a813dc2a5
implement GTK4 gmenu item and item list
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
310
diff
changeset
|
224 | ui_list_append(menu_list, "menu list item 2"); |
450a813dc2a5
implement GTK4 gmenu item and item list
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
310
diff
changeset
|
225 | ui_list_append(menu_list, "menu list item 3"); |
450a813dc2a5
implement GTK4 gmenu item and item list
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
310
diff
changeset
|
226 | |
450a813dc2a5
implement GTK4 gmenu item and item list
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
310
diff
changeset
|
227 | |
450a813dc2a5
implement GTK4 gmenu item and item list
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
310
diff
changeset
|
228 | |
140
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
139
diff
changeset
|
229 | UiObject *obj = ui_window("Test", NULL); |
137
c9b8b9e0cfe8
adds drawingarea (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
136
diff
changeset
|
230 | |
266
37d5b49b1c91
fix progressbar using the wrong var type (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
265
diff
changeset
|
231 | MyDocument *doc = create_doc(); |
37d5b49b1c91
fix progressbar using the wrong var type (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
265
diff
changeset
|
232 | ui_attach_document(obj->ctx, doc); |
37d5b49b1c91
fix progressbar using the wrong var type (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
265
diff
changeset
|
233 | |
332
7e7c05af8f3a
implement stack set/get/remove (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
331
diff
changeset
|
234 | ui_tabview(obj, .spacing=10, .margin=10, .tabview = UI_TABVIEW_NAVIGATION_SIDE, .varname="tabview") { |
328
059cba080ab4
implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
322
diff
changeset
|
235 | ui_tab(obj, "Tab 1") { |
059cba080ab4
implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
322
diff
changeset
|
236 | ui_vbox(obj, .fill = UI_OFF, .margin = 15, .spacing = 15) { |
059cba080ab4
implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
322
diff
changeset
|
237 | ui_button(obj, .label = "Test Button", .icon = "application-x-generic", .onclick = action_button); |
059cba080ab4
implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
322
diff
changeset
|
238 | ui_togglebutton(obj, .label = "Toggle"); |
059cba080ab4
implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
322
diff
changeset
|
239 | ui_checkbox(obj, .label = "My Checkbox"); |
059cba080ab4
implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
322
diff
changeset
|
240 | } |
059cba080ab4
implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
322
diff
changeset
|
241 | ui_grid(obj, .fill = UI_OFF, .columnspacing = 15, .rowspacing = 15, .margin = 15) { |
343
54f5d7eb1335
implement widget groups for buttons (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
340
diff
changeset
|
242 | ui_button(obj, .label = "Activate Group 1", .hexpand = TRUE, .onclick = action_group1); |
54f5d7eb1335
implement widget groups for buttons (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
340
diff
changeset
|
243 | ui_button(obj, .label = "Disable Group 1", .onclick = action_group1, .onclickdata = "disable"); |
328
059cba080ab4
implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
322
diff
changeset
|
244 | ui_newline(obj); |
343
54f5d7eb1335
implement widget groups for buttons (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
340
diff
changeset
|
245 | ui_button(obj, .label = "Activate Group 2", .hexpand = TRUE, .onclick = action_group2); |
54f5d7eb1335
implement widget groups for buttons (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
340
diff
changeset
|
246 | ui_button(obj, .label = "Disable Group 2", .onclick = action_group2, .onclickdata = "disable"); |
54f5d7eb1335
implement widget groups for buttons (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
340
diff
changeset
|
247 | ui_newline(obj); |
54f5d7eb1335
implement widget groups for buttons (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
340
diff
changeset
|
248 | |
54f5d7eb1335
implement widget groups for buttons (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
340
diff
changeset
|
249 | ui_button(obj, .label = "Groups 1,2", .colspan = 2, .groups = UI_GROUPS(1, 2)); |
328
059cba080ab4
implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
322
diff
changeset
|
250 | ui_newline(obj); |
059cba080ab4
implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
322
diff
changeset
|
251 | |
059cba080ab4
implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
322
diff
changeset
|
252 | ui_label(obj, .label = "Label Col 1", .align = UI_ALIGN_LEFT); |
358
98b26a19cbeb
add more label styles (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
354
diff
changeset
|
253 | ui_label(obj, .label = "Label Col 2", .style = UI_LABEL_STYLE_TITLE, .align = UI_ALIGN_RIGHT); |
328
059cba080ab4
implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
322
diff
changeset
|
254 | ui_newline(obj); |
059cba080ab4
implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
322
diff
changeset
|
255 | |
059cba080ab4
implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
322
diff
changeset
|
256 | ui_spinner(obj, .step = 5); |
059cba080ab4
implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
322
diff
changeset
|
257 | ui_newline(obj); |
059cba080ab4
implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
322
diff
changeset
|
258 | |
059cba080ab4
implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
322
diff
changeset
|
259 | ui_progressbar(obj, .colspan = 2, .varname = "progress"); |
059cba080ab4
implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
322
diff
changeset
|
260 | ui_set(doc->progress, 0.75); |
059cba080ab4
implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
322
diff
changeset
|
261 | ui_newline(obj); |
059cba080ab4
implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
322
diff
changeset
|
262 | |
059cba080ab4
implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
322
diff
changeset
|
263 | ui_textfield(obj, .value = doc->str1); |
059cba080ab4
implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
322
diff
changeset
|
264 | ui_newline(obj); |
059cba080ab4
implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
322
diff
changeset
|
265 | |
059cba080ab4
implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
322
diff
changeset
|
266 | //ui_button(obj, .label="Test"); |
059cba080ab4
implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
322
diff
changeset
|
267 | ui_path_textfield(obj, .varname = "path"); |
059cba080ab4
implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
322
diff
changeset
|
268 | ui_set(doc->path, "/test/path/longdirectoryname/123"); |
059cba080ab4
implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
322
diff
changeset
|
269 | ui_newline(obj); |
059cba080ab4
implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
322
diff
changeset
|
270 | |
059cba080ab4
implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
322
diff
changeset
|
271 | //UiModel *model = ui_model(obj->ctx, UI_ICON_TEXT, "Col 1", UI_STRING, "Col 2", -1); |
059cba080ab4
implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
322
diff
changeset
|
272 | //model->getvalue = list_getvalue; |
059cba080ab4
implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
322
diff
changeset
|
273 | ui_combobox(obj, .hexpand = true, .vexpand = false, .colspan = 2, .varname = "list", .getvalue = list_getvalue); |
059cba080ab4
implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
322
diff
changeset
|
274 | ui_newline(obj); |
059cba080ab4
implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
322
diff
changeset
|
275 | |
059cba080ab4
implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
322
diff
changeset
|
276 | ui_hbox0(obj) { |
059cba080ab4
implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
322
diff
changeset
|
277 | ui_radiobutton(obj, .label = "Radio 1", .varname = "radio"); |
059cba080ab4
implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
322
diff
changeset
|
278 | ui_radiobutton(obj, .label = "Radio 2", .varname = "radio"); |
059cba080ab4
implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
322
diff
changeset
|
279 | ui_radiobutton(obj, .label = "Radio 3", .varname = "radio"); |
059cba080ab4
implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
322
diff
changeset
|
280 | } |
059cba080ab4
implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
322
diff
changeset
|
281 | } |
275
132c7bcc6997
implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
270
diff
changeset
|
282 | } |
331
cdad8b7e83db
implement side navigation tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
328
diff
changeset
|
283 | ui_tab(obj, "Tab 2") { |
347
6f0d0b0d97f5
add conditional variable API
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
345
diff
changeset
|
284 | ui_button(obj, .label = "Button 1 Start Thread", .onclick=action_start_thread); |
6f0d0b0d97f5
add conditional variable API
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
345
diff
changeset
|
285 | ui_button(obj, .label = "Button 2 Notify Thread", .onclick=action_notify_thread); |
344
870dd3d41d83
add dialog window (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
343
diff
changeset
|
286 | ui_button(obj, .label = "Button 3", .onclick=action_tab2_button); |
870dd3d41d83
add dialog window (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
343
diff
changeset
|
287 | ui_button(obj, .label = "Button 4", .onclick=action_tab2_button); |
870dd3d41d83
add dialog window (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
343
diff
changeset
|
288 | ui_button(obj, .label = "Button 5", .onclick=action_tab2_button); |
870dd3d41d83
add dialog window (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
343
diff
changeset
|
289 | ui_button(obj, .label = "Button 6", .onclick=action_tab2_button); |
331
cdad8b7e83db
implement side navigation tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
328
diff
changeset
|
290 | } |
335
91d4f0391282
add new textarea (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
333
diff
changeset
|
291 | ui_tab(obj, "Tab 3") { |
333
634e3ce80afe
implement gtk3 stack tabview
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
332
diff
changeset
|
292 | UiTabViewArgs args = {0}; |
335
91d4f0391282
add new textarea (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
333
diff
changeset
|
293 | UI_CTN(obj, tabview=ui_tabview_create(obj, args)) { |
91d4f0391282
add new textarea (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
333
diff
changeset
|
294 | UiObject *tab1 = ui_tabview_add(tabview, "Sub 1", -1); |
91d4f0391282
add new textarea (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
333
diff
changeset
|
295 | ui_button(tab1, .label = "Button 1"); |
91d4f0391282
add new textarea (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
333
diff
changeset
|
296 | |
91d4f0391282
add new textarea (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
333
diff
changeset
|
297 | |
91d4f0391282
add new textarea (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
333
diff
changeset
|
298 | UiObject *tab2 = ui_tabview_add(tabview, "Sub 2", -1); |
91d4f0391282
add new textarea (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
333
diff
changeset
|
299 | ui_button(tab2, .label = "Button 2"); |
91d4f0391282
add new textarea (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
333
diff
changeset
|
300 | } |
91d4f0391282
add new textarea (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
333
diff
changeset
|
301 | } |
91d4f0391282
add new textarea (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
333
diff
changeset
|
302 | ui_tab(obj, "Tab 4") { |
91d4f0391282
add new textarea (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
333
diff
changeset
|
303 | ui_textarea(obj, .varname = "text"); |
333
634e3ce80afe
implement gtk3 stack tabview
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
332
diff
changeset
|
304 | } |
339
b68b5f984074
add minimally working image viewer (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
336
diff
changeset
|
305 | ui_tab(obj, "Tab 5") { |
b68b5f984074
add minimally working image viewer (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
336
diff
changeset
|
306 | ui_button(obj, .label = "Test Button", .icon = "application-x-generic", .onclick = action_button); |
340
2dd42bd4fe5d
add imageviewer (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
339
diff
changeset
|
307 | ui_imageviewer(obj, .varname = "image", .style_class = "imageviewer"); |
339
b68b5f984074
add minimally working image viewer (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
336
diff
changeset
|
308 | } |
350
70305d427f25
fix ui_scrolledwindow (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
347
diff
changeset
|
309 | |
70305d427f25
fix ui_scrolledwindow (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
347
diff
changeset
|
310 | ui_tab(obj, "Tab 6") { |
354
baf9bcc98d87
add expander container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
352
diff
changeset
|
311 | ui_scrolledwindow(obj, .fill = UI_ON) { |
baf9bcc98d87
add expander container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
352
diff
changeset
|
312 | ui_expander(obj, .label = "Expander", .margin = 10, .spacing = 10) { |
baf9bcc98d87
add expander container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
352
diff
changeset
|
313 | ui_label(obj, .label = "Test"); |
baf9bcc98d87
add expander container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
352
diff
changeset
|
314 | ui_button(obj, .label = "Button"); |
baf9bcc98d87
add expander container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
352
diff
changeset
|
315 | } |
baf9bcc98d87
add expander container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
352
diff
changeset
|
316 | |
baf9bcc98d87
add expander container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
352
diff
changeset
|
317 | ui_frame(obj, .label = "Frame", .margin = 10, .spacing = 10) { |
358
98b26a19cbeb
add more label styles (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
354
diff
changeset
|
318 | ui_label(obj, .label = "Title", .style = UI_LABEL_STYLE_TITLE); |
98b26a19cbeb
add more label styles (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
354
diff
changeset
|
319 | ui_label(obj, .label = "Sub-Title", .style = UI_LABEL_STYLE_SUBTITLE); |
98b26a19cbeb
add more label styles (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
354
diff
changeset
|
320 | ui_label(obj, .label = "Dim Label", .style = UI_LABEL_STYLE_DIM); |
98b26a19cbeb
add more label styles (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
354
diff
changeset
|
321 | ui_label(obj, .label = "No Style"); |
354
baf9bcc98d87
add expander container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
352
diff
changeset
|
322 | } |
baf9bcc98d87
add expander container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
352
diff
changeset
|
323 | |
351
63db7e35e2e9
implement scrolledwindow sub container type (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
350
diff
changeset
|
324 | for(int i=0;i<100;i++) { |
63db7e35e2e9
implement scrolledwindow sub container type (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
350
diff
changeset
|
325 | char labelstr[32]; |
63db7e35e2e9
implement scrolledwindow sub container type (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
350
diff
changeset
|
326 | snprintf(labelstr, 32, "button %d", i); |
63db7e35e2e9
implement scrolledwindow sub container type (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
350
diff
changeset
|
327 | ui_button(obj, .label = labelstr); |
350
70305d427f25
fix ui_scrolledwindow (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
347
diff
changeset
|
328 | } |
70305d427f25
fix ui_scrolledwindow (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
347
diff
changeset
|
329 | } |
70305d427f25
fix ui_scrolledwindow (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
347
diff
changeset
|
330 | } |
260
eebb0626d020
implement grid colspan/rowspan (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
259
diff
changeset
|
331 | } |
eebb0626d020
implement grid colspan/rowspan (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
259
diff
changeset
|
332 | |
328
059cba080ab4
implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
322
diff
changeset
|
333 | /* |
059cba080ab4
implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
322
diff
changeset
|
334 | |
059cba080ab4
implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
322
diff
changeset
|
335 | */ |
059cba080ab4
implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
322
diff
changeset
|
336 | |
133
6dd780cbc8c6
using GtkApplication now
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
337 | ui_show(obj); |
95
29f5cd5f5367
added drawing area (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
94
diff
changeset
|
338 | } |
111
40dbf1a7526a
added close handler to UiContext (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
110
diff
changeset
|
339 | |
29
c96169444d88
added locale support (Cocoa) and ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
28
diff
changeset
|
340 | int main(int argc, char** argv) { |
88
04c81be1c5a0
added textarea (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
86
diff
changeset
|
341 | ui_init("app1", argc, argv); |
133
6dd780cbc8c6
using GtkApplication now
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
342 | ui_onstartup(application_startup, NULL); |
88
04c81be1c5a0
added textarea (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
86
diff
changeset
|
343 | |
133
6dd780cbc8c6
using GtkApplication now
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
344 | // menu |
255
ebdce2bb62be
minimal working menubar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
253
diff
changeset
|
345 | ui_menu("File") { |
ebdce2bb62be
minimal working menubar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
253
diff
changeset
|
346 | ui_menuitem(.label = "Test"); |
ebdce2bb62be
minimal working menubar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
253
diff
changeset
|
347 | } |
253
087cc9216f28
initial newapi GTK port
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
174
diff
changeset
|
348 | |
308
4efc7c19e31d
simplify gtk button code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
306
diff
changeset
|
349 | ui_toolbar_item("Test", .label = "Test", .onclick = action_toolbar_button); |
336
56c12f44c2d3
add custom headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
335
diff
changeset
|
350 | ui_toolbar_item("Test2", .label = "New Window", .onclick = action_toolbar_newwindow); |
344
870dd3d41d83
add dialog window (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
343
diff
changeset
|
351 | ui_toolbar_item("Test3", .label = "Dialog", .onclick = action_toolbar_dialog); |
308
4efc7c19e31d
simplify gtk button code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
306
diff
changeset
|
352 | ui_toolbar_item("Test4", .label = "Test 4", .onclick = action_toolbar_button); |
4efc7c19e31d
simplify gtk button code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
306
diff
changeset
|
353 | ui_toolbar_item("Test5", .label = "Test 5", .onclick = action_toolbar_button); |
4efc7c19e31d
simplify gtk button code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
306
diff
changeset
|
354 | ui_toolbar_item("Test6", .label = "Test 6", .onclick = action_toolbar_button); |
275
132c7bcc6997
implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
270
diff
changeset
|
355 | ui_toolbar_toggleitem("Toggle", .label = "Toggle", .onchange = action_toolbar_button); |
132c7bcc6997
implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
270
diff
changeset
|
356 | ui_toolbar_menu("Menu", .label = "Menu") { |
311
450a813dc2a5
implement GTK4 gmenu item and item list
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
310
diff
changeset
|
357 | ui_menuitem("Secondary Test", .onclick = action_toolbar_button, NULL); |
275
132c7bcc6997
implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
270
diff
changeset
|
358 | ui_menu("Secondary Sub") { |
132c7bcc6997
implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
270
diff
changeset
|
359 | ui_menuitem("Secondary subitem", NULL, NULL); |
132c7bcc6997
implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
270
diff
changeset
|
360 | } |
322
22f6dadd9f46
implement ui_menuseparator (GTK4)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
320
diff
changeset
|
361 | ui_menuseparator(); |
311
450a813dc2a5
implement GTK4 gmenu item and item list
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
310
diff
changeset
|
362 | ui_menu_itemlist(.varname = "menulist", .onselect=action_menu_list); |
322
22f6dadd9f46
implement ui_menuseparator (GTK4)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
320
diff
changeset
|
363 | ui_menuseparator(); |
311
450a813dc2a5
implement GTK4 gmenu item and item list
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
310
diff
changeset
|
364 | ui_menuitem("last", .onclick = action_add_menu_item); |
275
132c7bcc6997
implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
270
diff
changeset
|
365 | } |
132c7bcc6997
implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
270
diff
changeset
|
366 | |
322
22f6dadd9f46
implement ui_menuseparator (GTK4)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
320
diff
changeset
|
367 | ui_toolbar_appmenu() { |
22f6dadd9f46
implement ui_menuseparator (GTK4)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
320
diff
changeset
|
368 | ui_menuitem("New"); |
22f6dadd9f46
implement ui_menuseparator (GTK4)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
320
diff
changeset
|
369 | ui_menuitem("Open"); |
22f6dadd9f46
implement ui_menuseparator (GTK4)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
320
diff
changeset
|
370 | ui_menuitem("Save"); |
22f6dadd9f46
implement ui_menuseparator (GTK4)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
320
diff
changeset
|
371 | |
22f6dadd9f46
implement ui_menuseparator (GTK4)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
320
diff
changeset
|
372 | ui_menuseparator(); |
22f6dadd9f46
implement ui_menuseparator (GTK4)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
320
diff
changeset
|
373 | |
22f6dadd9f46
implement ui_menuseparator (GTK4)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
320
diff
changeset
|
374 | ui_menuitem("Close"); |
22f6dadd9f46
implement ui_menuseparator (GTK4)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
320
diff
changeset
|
375 | } |
22f6dadd9f46
implement ui_menuseparator (GTK4)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
320
diff
changeset
|
376 | |
275
132c7bcc6997
implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
270
diff
changeset
|
377 | ui_toolbar_add_default("Test", UI_TOOLBAR_LEFT); |
306
d02e1149cdb9
add headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
304
diff
changeset
|
378 | ui_toolbar_add_default("Test6", UI_TOOLBAR_LEFT); |
275
132c7bcc6997
implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
270
diff
changeset
|
379 | ui_toolbar_add_default("Toggle", UI_TOOLBAR_LEFT); |
132c7bcc6997
implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
270
diff
changeset
|
380 | ui_toolbar_add_default("Menu", UI_TOOLBAR_LEFT); |
89
9a7e4a335b2b
added toolbar (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
88
diff
changeset
|
381 | |
306
d02e1149cdb9
add headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
304
diff
changeset
|
382 | ui_toolbar_add_default("Test2", UI_TOOLBAR_CENTER); |
d02e1149cdb9
add headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
304
diff
changeset
|
383 | ui_toolbar_add_default("Test3", UI_TOOLBAR_CENTER); |
d02e1149cdb9
add headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
304
diff
changeset
|
384 | |
d02e1149cdb9
add headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
304
diff
changeset
|
385 | ui_toolbar_add_default("Test4", UI_TOOLBAR_RIGHT); |
d02e1149cdb9
add headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
304
diff
changeset
|
386 | ui_toolbar_add_default("Test5", UI_TOOLBAR_RIGHT); |
d02e1149cdb9
add headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
304
diff
changeset
|
387 | |
88
04c81be1c5a0
added textarea (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
86
diff
changeset
|
388 | ui_main(); |
29
c96169444d88
added locale support (Cocoa) and ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
28
diff
changeset
|
389 | |
0 | 390 | return (EXIT_SUCCESS); |
391 | } |