make/vs/testapp/main.c

Wed, 30 Oct 2024 12:23:52 +0100

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Wed, 30 Oct 2024 12:23:52 +0100
branch
newapi
changeset 374
eae5d6623fd3
parent 252
7d176764756d
permissions
-rw-r--r--

add textarea (WINUI)

177
e79a60b3a7cb minimal working winui app
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 173
diff changeset
1 /*
e79a60b3a7cb minimal working winui app
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 173
diff changeset
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
e79a60b3a7cb minimal working winui app
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 173
diff changeset
3 *
e79a60b3a7cb minimal working winui app
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 173
diff changeset
4 * Copyright 2023 Olaf Wintermann. All rights reserved.
e79a60b3a7cb minimal working winui app
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 173
diff changeset
5 *
e79a60b3a7cb minimal working winui app
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 173
diff changeset
6 * Redistribution and use in source and binary forms, with or without
e79a60b3a7cb minimal working winui app
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 173
diff changeset
7 * modification, are permitted provided that the following conditions are met:
e79a60b3a7cb minimal working winui app
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 173
diff changeset
8 *
e79a60b3a7cb minimal working winui app
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 173
diff changeset
9 * 1. Redistributions of source code must retain the above copyright
e79a60b3a7cb minimal working winui app
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 173
diff changeset
10 * notice, this list of conditions and the following disclaimer.
e79a60b3a7cb minimal working winui app
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 173
diff changeset
11 *
e79a60b3a7cb minimal working winui app
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 173
diff changeset
12 * 2. Redistributions in binary form must reproduce the above copyright
e79a60b3a7cb minimal working winui app
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 173
diff changeset
13 * notice, this list of conditions and the following disclaimer in the
e79a60b3a7cb minimal working winui app
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 173
diff changeset
14 * documentation and/or other materials provided with the distribution.
e79a60b3a7cb minimal working winui app
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 173
diff changeset
15 *
e79a60b3a7cb minimal working winui app
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 173
diff changeset
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
e79a60b3a7cb minimal working winui app
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 173
diff changeset
17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
e79a60b3a7cb minimal working winui app
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 173
diff changeset
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
e79a60b3a7cb minimal working winui app
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 173
diff changeset
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
e79a60b3a7cb minimal working winui app
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 173
diff changeset
20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
e79a60b3a7cb minimal working winui app
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 173
diff changeset
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
e79a60b3a7cb minimal working winui app
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 173
diff changeset
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
e79a60b3a7cb minimal working winui app
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 173
diff changeset
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
e79a60b3a7cb minimal working winui app
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 173
diff changeset
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
e79a60b3a7cb minimal working winui app
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 173
diff changeset
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
e79a60b3a7cb minimal working winui app
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 173
diff changeset
26 * POSSIBILITY OF SUCH DAMAGE.
e79a60b3a7cb minimal working winui app
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 173
diff changeset
27 */
173
809581724cc7 add VS project
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
28
177
e79a60b3a7cb minimal working winui app
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 173
diff changeset
29 #include <Windows.h>
e79a60b3a7cb minimal working winui app
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 173
diff changeset
30
e79a60b3a7cb minimal working winui app
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 173
diff changeset
31 #include <stdio.h>
e79a60b3a7cb minimal working winui app
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 173
diff changeset
32 #include <stdlib.h>
186
5db4979bf482 implement new api style for ui_button (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 185
diff changeset
33 #include <stdbool.h>
177
e79a60b3a7cb minimal working winui app
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 173
diff changeset
34
e79a60b3a7cb minimal working winui app
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 173
diff changeset
35 #include <ui/ui.h>
e79a60b3a7cb minimal working winui app
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 173
diff changeset
36
374
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
37 #include <stdio.h>
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
38 #include <stdlib.h>
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
39
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
40 #include <ui/ui.h>
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
41
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
42
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
43 typedef struct {
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
44 UiString *str1;
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
45 UiString *str2;
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
46 UiString *path;
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
47 UiText *text;
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
48 UiDouble *progress;
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
49 UiList *list;
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
50 UiList *menulist;
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
51 UiInteger *radio;
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
52 UiInteger *tabview;
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
53 UiGeneric *image;
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
54 } MyDocument;
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
55
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
56 MyDocument *doc1;
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
57 MyDocument *doc2;
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
58
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
59 UIWIDGET tabview;
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
60
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
61 static UiCondVar *cond;
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
62 static int thr_end = 0;
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
63 static int thr_started = 0;
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
64
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
65 int threadfunc(void *data) {
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
66 printf("thr wait for data...\n");
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
67 ui_condvar_wait(cond);
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
68 printf("thr data received: {%s} [%d]\n", cond->data, cond->intdata);
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
69 ui_condvar_destroy(cond);
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
70 cond = NULL;
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
71
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
72 return 0;
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
73 }
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
74
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
75 void action_start_thread(UiEvent *event, void *data) {
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
76 if(!thr_started) {
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
77 cond = ui_condvar_create();
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
78 ui_job(event->obj, threadfunc, NULL, NULL, NULL);
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
79 thr_started = 1;
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
80 }
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
81 }
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
82
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
83 void action_notify_thread(UiEvent *event, void *data) {
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
84 if(!thr_end) {
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
85 ui_condvar_signal(cond, "hello thread", 123);
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
86 thr_end = 1;
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
87 }
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
88 }
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
89
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
90 void action_menu(UiEvent *event, void *userdata) {
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
91
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
92 }
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
93
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
94 void action_file_selected(UiEvent *event, void *userdata) {
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
95 UiFileList *files = event->eventdata;
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
96 MyDocument *doc = event->document;
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
97 printf("files: %d\n", (int)files->nfiles);
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
98 if(files->nfiles > 0) {
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
99 printf("selected file: %s\n", files->files[0]);
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
100 ui_image_load_file(doc->image, files->files[0]);
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
101 }
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
102 }
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
103
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
104 void action_button(UiEvent *event, void *userdata) {
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
105 ui_openfiledialog(event->obj, UI_FILEDIALOG_SELECT_SINGLE, action_file_selected, NULL);
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
106 }
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
107
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
108 void action_switch(UiEvent *event, void *userdata) {
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
109
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
110 }
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
111
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
112 void action_toolbar_button(UiEvent *event, void *userdata) {
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
113 printf("toolbar button\n");
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
114
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
115 ui_dialog(event->obj, .title = "Dialog Title", .content = "Content Label", .button1_label = "btn1", .button2_label = "btn2", .input = TRUE, .closebutton_label = "Cancel");
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
116 }
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
117
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
118 void action_dialog_button(UiEvent *event, void *userdata) {
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
119 ui_close(event->obj);
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
120 }
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
121
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
122 void action_toolbar_dialog(UiEvent *event, void *userdata) {
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
123
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
124 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);
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
125
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
126 ui_vbox(dialog, .margin = 10, .spacing = 10) {
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
127 ui_label(dialog, .label = "Enter password:");
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
128 ui_passwordfield(dialog, .varname = "password");
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
129 }
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
130
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
131 ui_show(dialog);
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
132 }
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
133
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
134 void action_toolbar_newwindow(UiEvent *event, void *userdata) {
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
135 UiObject *obj = ui_simple_window("New Window", NULL);
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
136
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
137 ui_headerbar0(obj) {
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
138 ui_headerbar_start(obj) {
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
139 ui_button(obj, .label = "Open");
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
140 }
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
141 ui_headerbar_end(obj) {
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
142 ui_button(obj, .label = "Test");
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
143 }
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
144 }
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
145
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
146 ui_textarea(obj, .varname="text");
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
147
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
148 ui_show(obj);
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
149 }
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
150
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
151 MyDocument* create_doc(void) {
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
152 MyDocument *doc = ui_document_new(sizeof(MyDocument));
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
153 UiContext *docctx = ui_document_context(doc);
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
154 doc->str1 = ui_string_new(docctx, "str1");
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
155 doc->str1 = ui_string_new(docctx, "str2");
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
156 doc->path = ui_string_new(docctx, "path");
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
157 doc->progress = ui_double_new(docctx, "progress");
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
158 doc->list = ui_list_new(docctx, "list");
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
159 ui_list_append(doc->list, "test1");
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
160 ui_list_append(doc->list, "test2");
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
161 ui_list_append(doc->list, "test3");
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
162 doc->radio = ui_int_new(docctx, "radio");
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
163 doc->tabview = ui_int_new(docctx, "tabview");
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
164 doc->image = ui_generic_new(docctx, "image");
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
165 //doc->text = ui_text_new(docctx, "text");
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
166 return doc;
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
167 }
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
168
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
169 UiIcon *icon = NULL;
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
170
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
171 static void* list_getvalue(void *elm, int col) {
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
172 /*
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
173 if(col == 0) {
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
174 if(!icon) {
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
175 icon = ui_icon("folder", 24);
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
176 }
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
177 return icon;
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
178 }
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
179 */
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
180
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
181 char *str = elm;
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
182 return col == 0 ? str : "x";
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
183 }
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
184
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
185 static UiList *menu_list;
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
186 int new_item_count = 0;
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
187
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
188 void action_add_menu_item(UiEvent *event, void *userdata) {
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
189 char str[64];
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
190 snprintf(str, 64, "new item %d", new_item_count++);
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
191
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
192 ui_list_append(menu_list, strdup(str));
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
193 ui_list_notify(menu_list);
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
194 }
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
195
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
196 void action_menu_list(UiEvent *event, void *userdata) {
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
197 printf("menu list item: %d\n", event->intval);
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
198 }
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
199
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
200 static int tab_x = 0;
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
201 void action_tab2_button(UiEvent *event, void *userdata) {
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
202 MyDocument *doc = event->document;
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
203 printf("current page: %d\n", (int)ui_get(doc->tabview));
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
204 ui_set(doc->tabview, 0);
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
205 }
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
206
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
207
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
208 void action_group1(UiEvent *event, void *userdata) {
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
209 UiContext *ctx = event->obj->ctx;
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
210 if(userdata) {
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
211 ui_unset_group(ctx, 1);
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
212 } else {
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
213 ui_set_group(ctx, 1);
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
214 }
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
215 }
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
216
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
217 void action_group2(UiEvent *event, void *userdata) {
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
218 UiContext *ctx = event->obj->ctx;
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
219 if(userdata) {
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
220 ui_unset_group(ctx, 2);
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
221 } else {
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
222 ui_set_group(ctx, 2);
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
223 }
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
224 }
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
225
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
226 void application_startup(UiEvent *event, void *data) {
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
227 // global list
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
228 UiContext *global = ui_global_context();
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
229 menu_list = ui_list_new(global, "menulist");
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
230 ui_list_append(menu_list, "menu list item 1");
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
231 ui_list_append(menu_list, "menu list item 2");
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
232 ui_list_append(menu_list, "menu list item 3");
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
233
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
234
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
235
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
236 UiObject *obj = ui_window("Test", NULL);
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
237
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
238 MyDocument *doc = create_doc();
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
239 ui_attach_document(obj->ctx, doc);
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
240
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
241 ui_tabview(obj, .spacing=10, .margin=10, .tabview = UI_TABVIEW_NAVIGATION_SIDE, .varname="tabview") {
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
242 ui_tab(obj, "Tab 1") {
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
243 ui_vbox(obj, .fill = UI_OFF, .margin = 15, .spacing = 15) {
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
244 ui_button(obj, .label = "Test Button", .icon = "application-x-generic", .onclick = action_button);
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
245 ui_togglebutton(obj, .label = "Toggle");
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
246 ui_checkbox(obj, .label = "My Checkbox");
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
247 }
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
248 ui_grid(obj, .fill = UI_OFF, .columnspacing = 15, .rowspacing = 15, .margin = 15) {
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
249 ui_button(obj, .label = "Activate Group 1", .hexpand = TRUE, .onclick = action_group1);
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
250 ui_button(obj, .label = "Disable Group 1", .onclick = action_group1, .onclickdata = "disable");
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
251 ui_newline(obj);
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
252 ui_button(obj, .label = "Activate Group 2", .hexpand = TRUE, .onclick = action_group2);
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
253 ui_button(obj, .label = "Disable Group 2", .onclick = action_group2, .onclickdata = "disable");
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
254 ui_newline(obj);
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
255
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
256 ui_button(obj, .label = "Groups 1,2", .colspan = 2, .groups = UI_GROUPS(1, 2));
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
257 ui_newline(obj);
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
258
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
259 ui_label(obj, .label = "Label Col 1", .align = UI_ALIGN_LEFT);
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
260 ui_label(obj, .label = "Label Col 2", .style = UI_LABEL_STYLE_TITLE, .align = UI_ALIGN_RIGHT);
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
261 ui_newline(obj);
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
262
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
263 //ui_spinner(obj, .step = 5);
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
264 //ui_newline(obj);
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
265
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
266 ui_progressbar(obj, .colspan = 2, .varname = "progress");
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
267 ui_set(doc->progress, 0.75);
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
268 ui_newline(obj);
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
269
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
270 ui_textfield(obj, .value = doc->str1);
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
271 ui_newline(obj);
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
272
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
273 //ui_button(obj, .label="Test");
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
274 ui_path_textfield(obj, .varname = "path");
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
275 ui_set(doc->path, "/test/path/longdirectoryname/123");
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
276 ui_newline(obj);
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
277
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
278 //UiModel *model = ui_model(obj->ctx, UI_ICON_TEXT, "Col 1", UI_STRING, "Col 2", -1);
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
279 //model->getvalue = list_getvalue;
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
280 ui_combobox(obj, .hexpand = true, .vexpand = false, .colspan = 2, .varname = "list", .getvalue = list_getvalue);
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
281 ui_newline(obj);
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
282
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
283 ui_hbox0(obj) {
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
284 ui_radiobutton(obj, .label = "Radio 1", .varname = "radio");
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
285 ui_radiobutton(obj, .label = "Radio 2", .varname = "radio");
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
286 ui_radiobutton(obj, .label = "Radio 3", .varname = "radio");
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
287 }
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
288 }
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
289 }
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
290 ui_tab(obj, "Tab 2") {
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
291 ui_button(obj, .label = "Button 1 Start Thread", .onclick=action_start_thread);
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
292 ui_button(obj, .label = "Button 2 Notify Thread", .onclick=action_notify_thread);
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
293 ui_button(obj, .label = "Button 3", .onclick=action_tab2_button);
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
294 ui_button(obj, .label = "Button 4", .onclick=action_tab2_button);
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
295 ui_button(obj, .label = "Button 5", .onclick=action_tab2_button);
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
296 ui_button(obj, .label = "Button 6", .onclick=action_tab2_button);
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
297 }
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
298 ui_tab(obj, "Tab 3") {
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
299 UiTabViewArgs args = {0};
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
300 UI_CTN(obj, tabview=ui_tabview_create(obj, args)) {
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
301 UiObject *tab1 = ui_tabview_add(tabview, "Sub 1", -1);
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
302 ui_button(tab1, .label = "Button 1");
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
303
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
304
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
305 UiObject *tab2 = ui_tabview_add(tabview, "Sub 2", -1);
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
306 ui_button(tab2, .label = "Button 2");
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
307 }
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
308 }
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
309 ui_tab(obj, "Tab 4") {
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
310 ui_textarea(obj, .varname = "text");
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
311 }
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
312 ui_tab(obj, "Tab 5") {
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
313 ui_button(obj, .label = "Test Button", .icon = "application-x-generic", .onclick = action_button);
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
314 ui_imageviewer(obj, .varname = "image", .style_class = "imageviewer");
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
315 }
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
316
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
317 ui_tab(obj, "Tab 6") {
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
318 ui_scrolledwindow(obj, .fill = UI_ON) {
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
319 ui_expander(obj, .label = "Expander", .margin = 10, .spacing = 10) {
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
320 ui_label(obj, .label = "Test");
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
321 ui_button(obj, .label = "Button");
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
322 }
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
323
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
324 ui_frame(obj, .label = "Frame", .margin = 10, .spacing = 10) {
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
325 ui_label(obj, .label = "Title", .style = UI_LABEL_STYLE_TITLE);
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
326 ui_label(obj, .label = "Sub-Title", .style = UI_LABEL_STYLE_SUBTITLE);
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
327 ui_label(obj, .label = "Dim Label", .style = UI_LABEL_STYLE_DIM);
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
328 ui_label(obj, .label = "No Style");
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
329 }
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
330
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
331 for(int i=0;i<100;i++) {
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
332 char labelstr[32];
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
333 snprintf(labelstr, 32, "button %d", i);
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
334 ui_button(obj, .label = labelstr);
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
335 }
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
336 }
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
337 }
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
338 }
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
339
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
340 /*
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
341
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
342 */
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
343
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
344 ui_show(obj);
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
345 }
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
346
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
347 /*
187
24ce2c326d85 implement toggle button (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 186
diff changeset
348 typedef struct WindowData {
24ce2c326d85 implement toggle button (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 186
diff changeset
349 UiInteger* check;
24ce2c326d85 implement toggle button (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 186
diff changeset
350 UiInteger* toggle;
188
fbbae6738252 implement radio button (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 187
diff changeset
351 UiInteger* radio;
192
bcacd00ea955 implement textfield (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 191
diff changeset
352 UiString* text;
bcacd00ea955 implement textfield (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 191
diff changeset
353 UiString* password;
196
320d85f3cd14 add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 195
diff changeset
354 UiList* list;
203
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 202
diff changeset
355 UiString* t1;
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 202
diff changeset
356 UiString* t2;
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 202
diff changeset
357 UiString* t3;
225
097f45f9c1fa add new path textfield (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
358 UiString* path;
203
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 202
diff changeset
359 UiList* list2;
204
4a258d47f964 add breadcrumb bar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 203
diff changeset
360 UiList* list3;
220
e377456302df add progressbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 219
diff changeset
361 UiDouble* progress;
221
a82d9beaa94a add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 220
diff changeset
362 UiInteger* spinner;
187
24ce2c326d85 implement toggle button (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 186
diff changeset
363 } WindowData;
177
e79a60b3a7cb minimal working winui app
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 173
diff changeset
364
215
1bd5534c395d add support for icons in the table widget (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
365 static UiIcon* folder_icon;
1bd5534c395d add support for icons in the table widget (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
366
229
a952760955b4 add menu item list (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 226
diff changeset
367 UiList* menuList;
a952760955b4 add menu item list (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 226
diff changeset
368
234
9036b346cd66 implement ui_job() and add ui_call_mainthread (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 231
diff changeset
369 void event_mt(UiEvent* event, void* data) {
9036b346cd66 implement ui_job() and add ui_call_mainthread (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 231
diff changeset
370 char* mt_str = data;
9036b346cd66 implement ui_job() and add ui_call_mainthread (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 231
diff changeset
371
9036b346cd66 implement ui_job() and add ui_call_mainthread (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 231
diff changeset
372 printf("%s\n", mt_str);
9036b346cd66 implement ui_job() and add ui_call_mainthread (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 231
diff changeset
373 }
9036b346cd66 implement ui_job() and add ui_call_mainthread (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 231
diff changeset
374
9036b346cd66 implement ui_job() and add ui_call_mainthread (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 231
diff changeset
375 int test_threadfunc(void *data) {
9036b346cd66 implement ui_job() and add ui_call_mainthread (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 231
diff changeset
376 char* str = data;
9036b346cd66 implement ui_job() and add ui_call_mainthread (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 231
diff changeset
377
9036b346cd66 implement ui_job() and add ui_call_mainthread (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 231
diff changeset
378 return 0;
9036b346cd66 implement ui_job() and add ui_call_mainthread (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 231
diff changeset
379 }
9036b346cd66 implement ui_job() and add ui_call_mainthread (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 231
diff changeset
380
9036b346cd66 implement ui_job() and add ui_call_mainthread (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 231
diff changeset
381 void action_thread_test(UiEvent* event, void* data) {
9036b346cd66 implement ui_job() and add ui_call_mainthread (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 231
diff changeset
382 ui_job(event->obj, test_threadfunc, "testdata", event_mt, "testdata2");
9036b346cd66 implement ui_job() and add ui_call_mainthread (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 231
diff changeset
383 }
229
a952760955b4 add menu item list (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 226
diff changeset
384
184
8c9b4b28aaa9 implement ui_button (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 180
diff changeset
385 void action1(UiEvent* event, void* data) {
8c9b4b28aaa9 implement ui_button (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 180
diff changeset
386 char* action = data;
187
24ce2c326d85 implement toggle button (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 186
diff changeset
387
24ce2c326d85 implement toggle button (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 186
diff changeset
388 WindowData* wdata = event->window;
231
e160bb392148 add getter/setter for ui number/string types
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 230
diff changeset
389 int64_t is_checked = ui_get(wdata->check);
e160bb392148 add getter/setter for ui number/string types
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 230
diff changeset
390 int64_t radio = ui_get(wdata->radio);
187
24ce2c326d85 implement toggle button (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 186
diff changeset
391
24ce2c326d85 implement toggle button (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 186
diff changeset
392 printf("data: %s %d\n", data, is_checked);
220
e377456302df add progressbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 219
diff changeset
393
231
e160bb392148 add getter/setter for ui number/string types
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 230
diff changeset
394 double d = ui_get(wdata->progress);
e160bb392148 add getter/setter for ui number/string types
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 230
diff changeset
395 ui_set(wdata->progress, d + 1);
221
a82d9beaa94a add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 220
diff changeset
396
231
e160bb392148 add getter/setter for ui number/string types
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 230
diff changeset
397 int spinner_active = ui_get(wdata->spinner);
e160bb392148 add getter/setter for ui number/string types
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 230
diff changeset
398 ui_set(wdata->spinner, !spinner_active);
229
a952760955b4 add menu item list (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 226
diff changeset
399
a952760955b4 add menu item list (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 226
diff changeset
400 ui_list_append(menuList, "List Item X");
a952760955b4 add menu item list (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 226
diff changeset
401 ui_list_append(menuList, "List Item X");
a952760955b4 add menu item list (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 226
diff changeset
402 ui_notify(menuList->observers, NULL);
187
24ce2c326d85 implement toggle button (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 186
diff changeset
403 }
24ce2c326d85 implement toggle button (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 186
diff changeset
404
24ce2c326d85 implement toggle button (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 186
diff changeset
405 void action_set_checkbox(UiEvent* event, void* data) {
24ce2c326d85 implement toggle button (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 186
diff changeset
406 char* action = data;
24ce2c326d85 implement toggle button (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 186
diff changeset
407
24ce2c326d85 implement toggle button (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 186
diff changeset
408 WindowData* wdata = event->window;
24ce2c326d85 implement toggle button (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 186
diff changeset
409 wdata->check->set(wdata->check, 1);
184
8c9b4b28aaa9 implement ui_button (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 180
diff changeset
410 }
177
e79a60b3a7cb minimal working winui app
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 173
diff changeset
411
189
4daddc326877 add onchange event for toggle buttons (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 188
diff changeset
412 void action_onchange(UiEvent* event, void* data) {
4daddc326877 add onchange event for toggle buttons (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 188
diff changeset
413 printf("onchange: %d\n", event->intval);
4daddc326877 add onchange event for toggle buttons (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 188
diff changeset
414 }
4daddc326877 add onchange event for toggle buttons (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 188
diff changeset
415
191
6113ed66d258 add toggle switch (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 190
diff changeset
416 void action_switch(UiEvent* event, void* data) {
6113ed66d258 add toggle switch (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 190
diff changeset
417 printf("onchange: %d\n", event->intval);
6113ed66d258 add toggle switch (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 190
diff changeset
418 }
6113ed66d258 add toggle switch (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 190
diff changeset
419
207
93b9f502cb88 add toolbar appmenu and menu buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 205
diff changeset
420 void action_toolbar_button(UiEvent* event, void *data) {
93b9f502cb88 add toolbar appmenu and menu buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 205
diff changeset
421 printf("toolbar action\n");
93b9f502cb88 add toolbar appmenu and menu buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 205
diff changeset
422 }
203
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 202
diff changeset
423
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 202
diff changeset
424
196
320d85f3cd14 add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 195
diff changeset
425 void action_listselection_changed(UiEvent* event, void* data) {
320d85f3cd14 add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 195
diff changeset
426 printf("selection changed\n");
320d85f3cd14 add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 195
diff changeset
427 UiListSelection* sel = event->eventdata;
320d85f3cd14 add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 195
diff changeset
428 for (int i = 0; i < sel->count; i++) {
320d85f3cd14 add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 195
diff changeset
429 int row = sel->rows[i];
320d85f3cd14 add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 195
diff changeset
430 printf("row: %d\n", row);
320d85f3cd14 add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 195
diff changeset
431 }
320d85f3cd14 add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 195
diff changeset
432 }
320d85f3cd14 add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 195
diff changeset
433
320d85f3cd14 add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 195
diff changeset
434 void action_onactivate(UiEvent* event, void* Data) {
320d85f3cd14 add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 195
diff changeset
435 printf("activate\n");
320d85f3cd14 add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 195
diff changeset
436 UiListSelection* sel = event->eventdata;
320d85f3cd14 add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 195
diff changeset
437 for (int i = 0; i < sel->count; i++) {
320d85f3cd14 add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 195
diff changeset
438 int row = sel->rows[i];
320d85f3cd14 add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 195
diff changeset
439 printf("row: %d\n", row);
320d85f3cd14 add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 195
diff changeset
440 }
320d85f3cd14 add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 195
diff changeset
441 }
320d85f3cd14 add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 195
diff changeset
442
203
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 202
diff changeset
443 typedef struct TableData {
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 202
diff changeset
444 char* col1;
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 202
diff changeset
445 char* col2;
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 202
diff changeset
446 char* col3;
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 202
diff changeset
447 } TableData;
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 202
diff changeset
448
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 202
diff changeset
449 void* table_getvalue(void* data, int i) {
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 202
diff changeset
450 TableData* t = data;
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 202
diff changeset
451 switch (i) {
215
1bd5534c395d add support for icons in the table widget (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
452 case 0: return folder_icon;
1bd5534c395d add support for icons in the table widget (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
453 case 1: return t->col1;
1bd5534c395d add support for icons in the table widget (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
454 case 2: return t->col2;
1bd5534c395d add support for icons in the table widget (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
455 case 3: return t->col3;
203
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 202
diff changeset
456 }
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 202
diff changeset
457 return NULL;
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 202
diff changeset
458 }
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 202
diff changeset
459
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 202
diff changeset
460 void action_add(UiEvent* event, void* data) {
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 202
diff changeset
461 WindowData* wdata = event->window;
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 202
diff changeset
462 char* t1 = wdata->t1->get(wdata->t1);
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 202
diff changeset
463 char* t2 = wdata->t2->get(wdata->t2);
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 202
diff changeset
464 char* t3 = wdata->t3->get(wdata->t3);
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 202
diff changeset
465
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 202
diff changeset
466 TableData* tdat = malloc(sizeof(TableData));
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 202
diff changeset
467 tdat->col1 = _strdup(t1);
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 202
diff changeset
468 tdat->col2 = _strdup(t2);
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 202
diff changeset
469 tdat->col3 = _strdup(t3);
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 202
diff changeset
470 ui_list_append(wdata->list2, tdat);
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 202
diff changeset
471 wdata->list2->update(wdata->list2, 0);
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 202
diff changeset
472
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 202
diff changeset
473 }
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 202
diff changeset
474
204
4a258d47f964 add breadcrumb bar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 203
diff changeset
475 void action_breadcrumb(UiEvent* event, void* data) {
4a258d47f964 add breadcrumb bar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 203
diff changeset
476 int i = event->intval;
225
097f45f9c1fa add new path textfield (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
477 char* c = event->eventdata;
204
4a258d47f964 add breadcrumb bar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 203
diff changeset
478 printf("index: %d\n", i);
4a258d47f964 add breadcrumb bar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 203
diff changeset
479 }
4a258d47f964 add breadcrumb bar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 203
diff changeset
480
223
8d7ca1b320e2 prepare table dnd (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 221
diff changeset
481 void dragstart(UiEvent* event, void* data) {
224
88bc21b19213 add minimal working dnd implementation (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 223
diff changeset
482 UiListDnd* ldnd = event->eventdata;
88bc21b19213 add minimal working dnd implementation (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 223
diff changeset
483 ui_selection_settext(ldnd->dnd, "Hello World!", -1);
88bc21b19213 add minimal working dnd implementation (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 223
diff changeset
484 }
88bc21b19213 add minimal working dnd implementation (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 223
diff changeset
485
88bc21b19213 add minimal working dnd implementation (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 223
diff changeset
486 void dragcomplete(UiEvent* event, void* data) {
223
8d7ca1b320e2 prepare table dnd (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 221
diff changeset
487
8d7ca1b320e2 prepare table dnd (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 221
diff changeset
488 }
8d7ca1b320e2 prepare table dnd (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 221
diff changeset
489
224
88bc21b19213 add minimal working dnd implementation (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 223
diff changeset
490 void dragover(UiEvent* event, void* data) {
223
8d7ca1b320e2 prepare table dnd (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 221
diff changeset
491
8d7ca1b320e2 prepare table dnd (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 221
diff changeset
492 }
8d7ca1b320e2 prepare table dnd (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 221
diff changeset
493
8d7ca1b320e2 prepare table dnd (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 221
diff changeset
494 void drop(UiEvent* event, void* data) {
8d7ca1b320e2 prepare table dnd (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 221
diff changeset
495
8d7ca1b320e2 prepare table dnd (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 221
diff changeset
496 }
8d7ca1b320e2 prepare table dnd (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 221
diff changeset
497
250
d2068517fbdd add function for creating dialogs (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 235
diff changeset
498 void dialog_result(UiEvent *evt, void *data) {
252
7d176764756d add input option to ui_dialog
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 250
diff changeset
499 char *str = evt->eventdata;
250
d2068517fbdd add function for creating dialogs (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 235
diff changeset
500 printf("dialog: %d\n", (int)evt->intval);
d2068517fbdd add function for creating dialogs (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 235
diff changeset
501 }
d2068517fbdd add function for creating dialogs (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 235
diff changeset
502
d2068517fbdd add function for creating dialogs (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 235
diff changeset
503 void btn_dialog(UiEvent *evt, void *data) {
252
7d176764756d add input option to ui_dialog
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 250
diff changeset
504 ui_dialog(evt->obj, .title = "Title", .input = TRUE, .content = "Hello World", .button1_label = "Yes", .button2_label = "No", .closebutton_label = "Close", .result = dialog_result);
250
d2068517fbdd add function for creating dialogs (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 235
diff changeset
505 }
d2068517fbdd add function for creating dialogs (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 235
diff changeset
506
d2068517fbdd add function for creating dialogs (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 235
diff changeset
507
229
a952760955b4 add menu item list (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 226
diff changeset
508
235
9c79f00fbf36 add threadpool (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 234
diff changeset
509
177
e79a60b3a7cb minimal working winui app
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 173
diff changeset
510 void application_startup(UiEvent* event, void* data) {
229
a952760955b4 add menu item list (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 226
diff changeset
511 UiContext* gctx = ui_global_context();
a952760955b4 add menu item list (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 226
diff changeset
512 menuList = ui_list_new(gctx, "menulist");
a952760955b4 add menu item list (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 226
diff changeset
513 ui_list_append(menuList, "List Item 1");
a952760955b4 add menu item list (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 226
diff changeset
514 ui_list_append(menuList, "List Item 2");
a952760955b4 add menu item list (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 226
diff changeset
515 ui_list_append(menuList, "List Item 3");
a952760955b4 add menu item list (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 226
diff changeset
516 ui_list_append(menuList, "List Item 4");
a952760955b4 add menu item list (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 226
diff changeset
517 ui_list_append(menuList, "List Item 5");
a952760955b4 add menu item list (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 226
diff changeset
518 ui_list_append(menuList, "List Item 6");
a952760955b4 add menu item list (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 226
diff changeset
519
177
e79a60b3a7cb minimal working winui app
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 173
diff changeset
520 UiObject* obj = ui_window("Test", NULL);
187
24ce2c326d85 implement toggle button (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 186
diff changeset
521 WindowData* wdata = ui_malloc(obj->ctx, sizeof(WindowData));
24ce2c326d85 implement toggle button (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 186
diff changeset
522 obj->window = wdata;
24ce2c326d85 implement toggle button (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 186
diff changeset
523 wdata->check = ui_int_new(obj->ctx, "check");
24ce2c326d85 implement toggle button (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 186
diff changeset
524 wdata->toggle = ui_int_new(obj->ctx, "toggle");
188
fbbae6738252 implement radio button (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 187
diff changeset
525 wdata->radio = ui_int_new(obj->ctx, "radio");
192
bcacd00ea955 implement textfield (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 191
diff changeset
526 wdata->text = ui_string_new(obj->ctx, "text");
bcacd00ea955 implement textfield (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 191
diff changeset
527 wdata->password = ui_string_new(obj->ctx, "password");
196
320d85f3cd14 add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 195
diff changeset
528 wdata->list = ui_list_new(obj->ctx, "list");
203
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 202
diff changeset
529 wdata->list2 = ui_list_new(obj->ctx, "list2");
204
4a258d47f964 add breadcrumb bar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 203
diff changeset
530 wdata->list3 = ui_list_new(obj->ctx, "list3");
203
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 202
diff changeset
531 wdata->t1 = ui_string_new(obj->ctx, "t1");
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 202
diff changeset
532 wdata->t2 = ui_string_new(obj->ctx, "t2");
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 202
diff changeset
533 wdata->t3 = ui_string_new(obj->ctx, "t3");
225
097f45f9c1fa add new path textfield (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
534 wdata->path = ui_string_new(obj->ctx, "path");
220
e377456302df add progressbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 219
diff changeset
535 wdata->progress = ui_double_new(obj->ctx, "progress");
221
a82d9beaa94a add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 220
diff changeset
536 wdata->spinner = ui_int_new(obj->ctx, "spinner");
196
320d85f3cd14 add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 195
diff changeset
537
320d85f3cd14 add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 195
diff changeset
538 ui_list_append(wdata->list, "Hello");
320d85f3cd14 add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 195
diff changeset
539 ui_list_append(wdata->list, "World");
320d85f3cd14 add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 195
diff changeset
540 ui_list_append(wdata->list, "Item3");
320d85f3cd14 add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 195
diff changeset
541 ui_list_append(wdata->list, "Item4");
320d85f3cd14 add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 195
diff changeset
542 ui_list_append(wdata->list, "Item5");
320d85f3cd14 add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 195
diff changeset
543 ui_list_append(wdata->list, "Item6");
177
e79a60b3a7cb minimal working winui app
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 173
diff changeset
544
204
4a258d47f964 add breadcrumb bar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 203
diff changeset
545 ui_list_append(wdata->list3, "usr");
4a258d47f964 add breadcrumb bar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 203
diff changeset
546 ui_list_append(wdata->list3, "share");
4a258d47f964 add breadcrumb bar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 203
diff changeset
547 ui_list_append(wdata->list3, "test");
4a258d47f964 add breadcrumb bar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 203
diff changeset
548 ui_list_append(wdata->list3, "dir");
4a258d47f964 add breadcrumb bar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 203
diff changeset
549
216
391c2c723029 add dll icon loader
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 215
diff changeset
550 //folder_icon = ui_icon("Folder", 32);
391c2c723029 add dll icon loader
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 215
diff changeset
551 folder_icon = ui_foldericon(16);
204
4a258d47f964 add breadcrumb bar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 203
diff changeset
552
203
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 202
diff changeset
553 TableData* td1 = malloc(sizeof(TableData));
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 202
diff changeset
554 TableData* td2 = malloc(sizeof(TableData));
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 202
diff changeset
555 TableData* td3 = malloc(sizeof(TableData));
214
279c0c81d3b1 improve table row selection, add support for multiple selections (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 213
diff changeset
556 TableData* td4 = malloc(sizeof(TableData));
279c0c81d3b1 improve table row selection, add support for multiple selections (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 213
diff changeset
557 TableData* td5 = malloc(sizeof(TableData));
279c0c81d3b1 improve table row selection, add support for multiple selections (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 213
diff changeset
558 TableData* td6 = malloc(sizeof(TableData));
203
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 202
diff changeset
559 td1->col1 = "a1";
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 202
diff changeset
560 td1->col2 = "b1";
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 202
diff changeset
561 td1->col3 = "c1";
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 202
diff changeset
562 td2->col1 = "a2";
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 202
diff changeset
563 td2->col2 = "b2";
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 202
diff changeset
564 td2->col3 = "b3";
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 202
diff changeset
565 td3->col1 = "a3";
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 202
diff changeset
566 td3->col2 = "b3";
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 202
diff changeset
567 td3->col3 = "c3";
214
279c0c81d3b1 improve table row selection, add support for multiple selections (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 213
diff changeset
568 td4->col1 = "a3";
279c0c81d3b1 improve table row selection, add support for multiple selections (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 213
diff changeset
569 td4->col2 = "b3";
279c0c81d3b1 improve table row selection, add support for multiple selections (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 213
diff changeset
570 td4->col3 = "c3";
279c0c81d3b1 improve table row selection, add support for multiple selections (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 213
diff changeset
571 td5->col1 = "a3";
279c0c81d3b1 improve table row selection, add support for multiple selections (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 213
diff changeset
572 td5->col2 = "b3";
279c0c81d3b1 improve table row selection, add support for multiple selections (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 213
diff changeset
573 td5->col3 = "c3";
279c0c81d3b1 improve table row selection, add support for multiple selections (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 213
diff changeset
574 td6->col1 = "a3";
279c0c81d3b1 improve table row selection, add support for multiple selections (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 213
diff changeset
575 td6->col2 = "b3";
279c0c81d3b1 improve table row selection, add support for multiple selections (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 213
diff changeset
576 td6->col3 = "c3";
203
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 202
diff changeset
577
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 202
diff changeset
578 ui_list_append(wdata->list2, td1);
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 202
diff changeset
579 ui_list_append(wdata->list2, td2);
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 202
diff changeset
580 ui_list_append(wdata->list2, td3);
214
279c0c81d3b1 improve table row selection, add support for multiple selections (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 213
diff changeset
581 ui_list_append(wdata->list2, td4);
279c0c81d3b1 improve table row selection, add support for multiple selections (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 213
diff changeset
582 ui_list_append(wdata->list2, td5);
279c0c81d3b1 improve table row selection, add support for multiple selections (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 213
diff changeset
583 ui_list_append(wdata->list2, td6);
203
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 202
diff changeset
584
194
e2281ace0769 add scrolledwindow (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 193
diff changeset
585 ui_scrolledwindow0(obj) {
e2281ace0769 add scrolledwindow (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 193
diff changeset
586 ui_grid(obj, .margin = 10, .columnspacing = 5, .rowspacing = 20) {
234
9036b346cd66 implement ui_job() and add ui_call_mainthread (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 231
diff changeset
587 ui_button(obj, .label = "Thread Test", .onclick = action_thread_test, .onclickdata = "action1");
230
4f5b32a2a60f add icon parameter for buttons (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 229
diff changeset
588 ui_button(obj, .label = "Button2", .icon = "Back", .onclick = action1, .onclickdata = "action2");
4f5b32a2a60f add icon parameter for buttons (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 229
diff changeset
589 ui_button(obj, .icon = "Forward", .onclick = action1, .onclickdata = "action3", .hexpand = true);
194
e2281ace0769 add scrolledwindow (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 193
diff changeset
590 ui_newline(obj);
185
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 184
diff changeset
591
250
d2068517fbdd add function for creating dialogs (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 235
diff changeset
592 ui_button(obj, .label = "Dialog Test", .onclick = btn_dialog, .onclickdata = "action4");
194
e2281ace0769 add scrolledwindow (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 193
diff changeset
593 ui_button(obj, .label = "Button5", .onclick = action1, .onclickdata = "action5", .colspan = 2);
e2281ace0769 add scrolledwindow (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 193
diff changeset
594 ui_newline(obj);
185
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 184
diff changeset
595
194
e2281ace0769 add scrolledwindow (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 193
diff changeset
596 ui_button(obj, .label = "Very Long Button Label Text ____________ Test", .onclick = action_set_checkbox);
e2281ace0769 add scrolledwindow (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 193
diff changeset
597 ui_newline(obj);
187
24ce2c326d85 implement toggle button (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 186
diff changeset
598
194
e2281ace0769 add scrolledwindow (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 193
diff changeset
599 ui_checkbox(obj, .label = "Option 1", .value = wdata->check, .onchange = action_onchange);
e2281ace0769 add scrolledwindow (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 193
diff changeset
600 ui_togglebutton(obj, .label = "Option 2", .value = wdata->toggle);
e2281ace0769 add scrolledwindow (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 193
diff changeset
601 ui_newline(obj);
188
fbbae6738252 implement radio button (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 187
diff changeset
602
221
a82d9beaa94a add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 220
diff changeset
603 ui_label(obj, .label = "Progress");
a82d9beaa94a add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 220
diff changeset
604 ui_progressspinner(obj, .value = wdata->spinner);
a82d9beaa94a add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 220
diff changeset
605 ui_newline(obj);
a82d9beaa94a add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 220
diff changeset
606
194
e2281ace0769 add scrolledwindow (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 193
diff changeset
607 ui_hbox(obj, .colspan = 3) {
e2281ace0769 add scrolledwindow (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 193
diff changeset
608 ui_radiobutton(obj, .label = "Radio 1", .value = wdata->radio);
e2281ace0769 add scrolledwindow (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 193
diff changeset
609 ui_radiobutton(obj, .label = "Radio 2", .value = wdata->radio);
e2281ace0769 add scrolledwindow (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 193
diff changeset
610 ui_radiobutton(obj, .label = "Radio 3", .value = wdata->radio);
e2281ace0769 add scrolledwindow (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 193
diff changeset
611 }
e2281ace0769 add scrolledwindow (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 193
diff changeset
612 ui_newline(obj);
e2281ace0769 add scrolledwindow (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 193
diff changeset
613 ui_radiobutton(obj, .label = "Radio 4", .value = wdata->radio);
e2281ace0769 add scrolledwindow (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 193
diff changeset
614 ui_switch(obj, .label = "test", .onchange = action_switch);
e2281ace0769 add scrolledwindow (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 193
diff changeset
615 ui_newline(obj);
e2281ace0769 add scrolledwindow (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 193
diff changeset
616
221
a82d9beaa94a add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 220
diff changeset
617 //ui_breadcrumbbar(obj, .list = wdata->list3, .onactivate=action_breadcrumb);
225
097f45f9c1fa add new path textfield (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
618 ui_textfield(obj, .varname = "newtext");
097f45f9c1fa add new path textfield (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
619 ui_path_textfield(obj, .colspan = 2, .value=wdata->path, .onactivate = action_breadcrumb);
204
4a258d47f964 add breadcrumb bar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 203
diff changeset
620 ui_newline(obj);
225
097f45f9c1fa add new path textfield (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
621 wdata->path->set(wdata->path, "/usr/path/test");
097f45f9c1fa add new path textfield (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
622
194
e2281ace0769 add scrolledwindow (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 193
diff changeset
623 ui_textfield(obj, .value = wdata->text);
e2281ace0769 add scrolledwindow (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 193
diff changeset
624 ui_passwordfield(obj, .value = wdata->password);
e2281ace0769 add scrolledwindow (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 193
diff changeset
625 ui_newline(obj);
e2281ace0769 add scrolledwindow (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 193
diff changeset
626
195
0f2e69873875 add expander (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 194
diff changeset
627 ui_frame(obj, .label = "Test", .colspan = 3) {
0f2e69873875 add expander (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 194
diff changeset
628 ui_button(obj, .label = "Button1", .onclick = action1, .onclickdata = "action1");
0f2e69873875 add expander (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 194
diff changeset
629 }
0f2e69873875 add expander (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 194
diff changeset
630 ui_newline(obj);
202
9f309d1914a2 finish navigationview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 198
diff changeset
631
196
320d85f3cd14 add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 195
diff changeset
632 ui_expander(obj, .label = "Expand", .colspan = 3, .margin = 10, .spacing = 5, .isexpanded = false) {
195
0f2e69873875 add expander (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 194
diff changeset
633 ui_button(obj, .label = "Button1", .onclick = action1, .onclickdata = "action1");
0f2e69873875 add expander (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 194
diff changeset
634 ui_button(obj, .label = "Button1", .onclick = action1, .onclickdata = "action1");
194
e2281ace0769 add scrolledwindow (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 193
diff changeset
635 ui_button(obj, .label = "Button1", .onclick = action1, .onclickdata = "action1");
e2281ace0769 add scrolledwindow (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 193
diff changeset
636 }
202
9f309d1914a2 finish navigationview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 198
diff changeset
637 ui_newline(obj);
196
320d85f3cd14 add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 195
diff changeset
638
197
8a82ebe23822 add combobox (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 196
diff changeset
639 ui_combobox(obj, .list = wdata->list, .onselection= action_listselection_changed, .onactivate= action_onactivate);
198
f2332d0d3318 add tabview based on winui the pivot control
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 197
diff changeset
640 ui_newline(obj);
f2332d0d3318 add tabview based on winui the pivot control
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 197
diff changeset
641
208
f632bc0589ab new menu api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 207
diff changeset
642 ui_tabview(obj, .colspan = 3, .vexpand = true, .hexpand = true, .tabview = UI_TABVIEW_NAVIGATION_SIDE) {
198
f2332d0d3318 add tabview based on winui the pivot control
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 197
diff changeset
643 ui_tab(obj, "Tab 1") {
f2332d0d3318 add tabview based on winui the pivot control
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 197
diff changeset
644 ui_button(obj, .label = "Tab 1 Button");
f2332d0d3318 add tabview based on winui the pivot control
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 197
diff changeset
645 }
f2332d0d3318 add tabview based on winui the pivot control
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 197
diff changeset
646 ui_tab(obj, "Tab 2") {
f2332d0d3318 add tabview based on winui the pivot control
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 197
diff changeset
647 ui_button(obj, .label = "Tab 2 Button");
f2332d0d3318 add tabview based on winui the pivot control
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 197
diff changeset
648 }
219
527a66c0afb2 add label (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 218
diff changeset
649 ui_tab(obj, "Tab 3") {
527a66c0afb2 add label (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 218
diff changeset
650
527a66c0afb2 add label (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 218
diff changeset
651 }
198
f2332d0d3318 add tabview based on winui the pivot control
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 197
diff changeset
652 }
219
527a66c0afb2 add label (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 218
diff changeset
653 ui_newline(obj);
527a66c0afb2 add label (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 218
diff changeset
654
527a66c0afb2 add label (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 218
diff changeset
655 ui_label(obj, .label = "Test Label");
220
e377456302df add progressbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 219
diff changeset
656 ui_progressbar(obj, .value = wdata->progress, .colspan = 2);
219
527a66c0afb2 add label (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 218
diff changeset
657 ui_newline(obj);
203
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 202
diff changeset
658
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 202
diff changeset
659 ui_newline(obj);
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 202
diff changeset
660 ui_textfield(obj, .value = wdata->t1);
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 202
diff changeset
661 ui_textfield(obj, .value = wdata->t2);
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 202
diff changeset
662 ui_textfield(obj, .value = wdata->t3);
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 202
diff changeset
663 ui_newline(obj);
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 202
diff changeset
664 ui_button(obj, .label = "Add", .onclick = action_add);
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 202
diff changeset
665 ui_newline(obj);
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 202
diff changeset
666
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 202
diff changeset
667
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 202
diff changeset
668 ui_newline(obj);
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 202
diff changeset
669
215
1bd5534c395d add support for icons in the table widget (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
670 UiModel* model = ui_model(obj->ctx, UI_ICON_TEXT, "Col 1", UI_STRING, "Col 2", UI_STRING, "Col 3", -1);
203
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 202
diff changeset
671 model->getvalue = table_getvalue;
221
a82d9beaa94a add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 220
diff changeset
672 ui_table(obj, .colspan = 3, .model = model, .list = wdata->list2, .onactivate = action_onactivate,
224
88bc21b19213 add minimal working dnd implementation (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 223
diff changeset
673 .onselection = action_listselection_changed,
223
8d7ca1b320e2 prepare table dnd (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 221
diff changeset
674 .ondragstart = dragstart, .ondragcomplete = dragcomplete, .ondrop = drop);
203
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 202
diff changeset
675 ui_model_free(obj->ctx, model);
188
fbbae6738252 implement radio button (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 187
diff changeset
676 }
194
e2281ace0769 add scrolledwindow (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 193
diff changeset
677 }
184
8c9b4b28aaa9 implement ui_button (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 180
diff changeset
678
177
e79a60b3a7cb minimal working winui app
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 173
diff changeset
679 ui_show(obj);
173
809581724cc7 add VS project
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
680 }
177
e79a60b3a7cb minimal working winui app
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 173
diff changeset
681
374
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
682 */
177
e79a60b3a7cb minimal working winui app
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 173
diff changeset
683
e79a60b3a7cb minimal working winui app
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 173
diff changeset
684 int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR lpCmdLine, int nCmdShow)
207
93b9f502cb88 add toolbar appmenu and menu buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 205
diff changeset
685 {
374
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
686 ui_init("app1", NULL, 0);
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
687 ui_onstartup(application_startup, NULL);
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
688
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
689 // menu
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
690 ui_menu("File") {
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
691 ui_menuitem(.label = "Test");
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
692 }
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
693
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
694 ui_toolbar_item("Test", .label = "Test", .onclick = action_toolbar_button);
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
695 ui_toolbar_item("Test2", .label = "New Window", .onclick = action_toolbar_newwindow);
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
696 ui_toolbar_item("Test3", .label = "Dialog", .onclick = action_toolbar_dialog);
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
697 ui_toolbar_item("Test4", .label = "Test 4", .onclick = action_toolbar_button);
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
698 ui_toolbar_item("Test5", .label = "Test 5", .onclick = action_toolbar_button);
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
699 ui_toolbar_item("Test6", .label = "Test 6", .onclick = action_toolbar_button);
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
700 ui_toolbar_toggleitem("Toggle", .label = "Toggle", .onchange = action_toolbar_button);
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
701 ui_toolbar_menu("Menu", .label = "Menu") {
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
702 ui_menuitem("Secondary Test", .onclick = action_toolbar_button, NULL);
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
703 ui_menu("Secondary Sub") {
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
704 ui_menuitem("Secondary subitem", NULL, NULL);
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
705 }
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
706 ui_menuseparator();
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
707 ui_menu_itemlist(.varname = "menulist", .onselect=action_menu_list);
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
708 ui_menuseparator();
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
709 ui_menuitem("last", .onclick = action_add_menu_item);
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
710 }
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
711
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
712 ui_toolbar_appmenu() {
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
713 ui_menuitem("New");
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
714 ui_menuitem("Open");
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
715 ui_menuitem("Save");
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
716
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
717 ui_menuseparator();
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
718
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
719 ui_menuitem("Close");
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
720 }
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
721
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
722 ui_toolbar_add_default("Test", UI_TOOLBAR_LEFT);
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
723 ui_toolbar_add_default("Test6", UI_TOOLBAR_LEFT);
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
724 ui_toolbar_add_default("Toggle", UI_TOOLBAR_LEFT);
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
725 ui_toolbar_add_default("Menu", UI_TOOLBAR_LEFT);
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
726
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
727 ui_toolbar_add_default("Test2", UI_TOOLBAR_CENTER);
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
728 ui_toolbar_add_default("Test3", UI_TOOLBAR_CENTER);
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
729
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
730 ui_toolbar_add_default("Test4", UI_TOOLBAR_RIGHT);
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
731 ui_toolbar_add_default("Test5", UI_TOOLBAR_RIGHT);
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
732
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
733 ui_main();
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
734
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
735 return (EXIT_SUCCESS);
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
736
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
737 /*
177
e79a60b3a7cb minimal working winui app
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 173
diff changeset
738 ui_init("app1", 0, NULL);
e79a60b3a7cb minimal working winui app
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 173
diff changeset
739 ui_onstartup(application_startup, NULL);
214
279c0c81d3b1 improve table row selection, add support for multiple selections (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 213
diff changeset
740
208
f632bc0589ab new menu api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 207
diff changeset
741 ui_menu("File") {
f632bc0589ab new menu api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 207
diff changeset
742 ui_menuitem(.label = "Item 1");
f632bc0589ab new menu api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 207
diff changeset
743 ui_menuitem(.label = "Item 2");
f632bc0589ab new menu api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 207
diff changeset
744 ui_menuseparator();
f632bc0589ab new menu api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 207
diff changeset
745 ui_menu("File Sub") {
f632bc0589ab new menu api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 207
diff changeset
746 ui_menuitem(.label = "Sub Item");
f632bc0589ab new menu api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 207
diff changeset
747 }
f632bc0589ab new menu api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 207
diff changeset
748
f632bc0589ab new menu api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 207
diff changeset
749 ui_menuitem(.label = "Exit");
f632bc0589ab new menu api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 207
diff changeset
750 }
180
f34953bf4ac7 add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 177
diff changeset
751
213
7e39db525fd9 add icons (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 211
diff changeset
752 ui_toolbar_item("Test", .label = "Home", .icon = "Home", .onclick = action_toolbar_button);
207
93b9f502cb88 add toolbar appmenu and menu buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 205
diff changeset
753 ui_toolbar_toggleitem("Toggle", .label = "Toggle", .onchange = action_toolbar_button);
93b9f502cb88 add toolbar appmenu and menu buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 205
diff changeset
754 ui_toolbar_toggleitem("Toggle2", .label = "Toggle2", .onchange = action_toolbar_button);
93b9f502cb88 add toolbar appmenu and menu buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 205
diff changeset
755 ui_toolbar_toggleitem("Toggle3", .label = "Toggle3", .onchange = action_toolbar_button);
93b9f502cb88 add toolbar appmenu and menu buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 205
diff changeset
756
93b9f502cb88 add toolbar appmenu and menu buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 205
diff changeset
757 ui_toolbar_menu("Menu", .label = "Menu") {
208
f632bc0589ab new menu api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 207
diff changeset
758
f632bc0589ab new menu api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 207
diff changeset
759 ui_menuitem(.label = "x", NULL, NULL);
211
5d71a36b833b add custom titlebar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 208
diff changeset
760 ui_menuitem(.label = "x", NULL, NULL);
229
a952760955b4 add menu item list (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 226
diff changeset
761 ui_menu_itemlist(.varname = "menulist");
211
5d71a36b833b add custom titlebar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 208
diff changeset
762 ui_menuitem(.label = "x", NULL, NULL);
5d71a36b833b add custom titlebar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 208
diff changeset
763 ui_menuitem(.label = "x", NULL, NULL);
5d71a36b833b add custom titlebar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 208
diff changeset
764 ui_menuitem(.label = "x", NULL, NULL);
208
f632bc0589ab new menu api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 207
diff changeset
765 ui_menu("TB Sub") {
f632bc0589ab new menu api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 207
diff changeset
766 ui_menuitem("TB subitem", NULL, NULL);
f632bc0589ab new menu api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 207
diff changeset
767 }
207
93b9f502cb88 add toolbar appmenu and menu buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 205
diff changeset
768 }
93b9f502cb88 add toolbar appmenu and menu buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 205
diff changeset
769
93b9f502cb88 add toolbar appmenu and menu buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 205
diff changeset
770 ui_toolbar_menu(NULL, .label = "Menu") {
93b9f502cb88 add toolbar appmenu and menu buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 205
diff changeset
771 ui_menuitem("Secondary Test", NULL, NULL);
208
f632bc0589ab new menu api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 207
diff changeset
772 ui_menu("Secondary Sub") {
f632bc0589ab new menu api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 207
diff changeset
773 ui_menuitem("Secondary subitem", NULL, NULL);
f632bc0589ab new menu api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 207
diff changeset
774 }
207
93b9f502cb88 add toolbar appmenu and menu buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 205
diff changeset
775 }
93b9f502cb88 add toolbar appmenu and menu buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 205
diff changeset
776
226
4eef1d49f794 split toolbar in left,center,right segments (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 225
diff changeset
777 ui_toolbar_add_default("Test", UI_TOOLBAR_LEFT);
4eef1d49f794 split toolbar in left,center,right segments (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 225
diff changeset
778 ui_toolbar_add_default("Toggle", UI_TOOLBAR_LEFT);
4eef1d49f794 split toolbar in left,center,right segments (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 225
diff changeset
779 ui_toolbar_add_default("Toggle2", UI_TOOLBAR_CENTER);
4eef1d49f794 split toolbar in left,center,right segments (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 225
diff changeset
780 ui_toolbar_add_default("Toggle3", UI_TOOLBAR_CENTER);
4eef1d49f794 split toolbar in left,center,right segments (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 225
diff changeset
781 ui_toolbar_add_default("Menu", UI_TOOLBAR_RIGHT);
205
b1ac0dd1d38b new winui vs project, add toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 204
diff changeset
782
177
e79a60b3a7cb minimal working winui app
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 173
diff changeset
783 ui_main();
e79a60b3a7cb minimal working winui app
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 173
diff changeset
784
e79a60b3a7cb minimal working winui app
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 173
diff changeset
785 return (EXIT_SUCCESS);
374
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 252
diff changeset
786 */
177
e79a60b3a7cb minimal working winui app
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 173
diff changeset
787 }

mercurial