make/vs/testapp/main.c

Thu, 19 Oct 2023 18:30:19 +0200

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Thu, 19 Oct 2023 18:30:19 +0200
branch
newapi
changeset 221
a82d9beaa94a
parent 220
e377456302df
child 223
8d7ca1b320e2
permissions
-rw-r--r--

add semi-functional pathbar (WinUI3)

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
187
24ce2c326d85 implement toggle button (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 186
diff changeset
37 typedef struct WindowData {
24ce2c326d85 implement toggle button (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 186
diff changeset
38 UiInteger* check;
24ce2c326d85 implement toggle button (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 186
diff changeset
39 UiInteger* toggle;
188
fbbae6738252 implement radio button (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 187
diff changeset
40 UiInteger* radio;
192
bcacd00ea955 implement textfield (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 191
diff changeset
41 UiString* text;
bcacd00ea955 implement textfield (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 191
diff changeset
42 UiString* password;
196
320d85f3cd14 add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 195
diff changeset
43 UiList* list;
203
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 202
diff changeset
44 UiString* t1;
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 202
diff changeset
45 UiString* t2;
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 202
diff changeset
46 UiString* t3;
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 202
diff changeset
47 UiList* list2;
204
4a258d47f964 add breadcrumb bar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 203
diff changeset
48 UiList* list3;
220
e377456302df add progressbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 219
diff changeset
49 UiDouble* progress;
221
a82d9beaa94a add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 220
diff changeset
50 UiInteger* spinner;
187
24ce2c326d85 implement toggle button (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 186
diff changeset
51 } WindowData;
177
e79a60b3a7cb minimal working winui app
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 173
diff changeset
52
215
1bd5534c395d add support for icons in the table widget (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
53 static UiIcon* folder_icon;
1bd5534c395d add support for icons in the table widget (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
54
184
8c9b4b28aaa9 implement ui_button (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 180
diff changeset
55 void action1(UiEvent* event, void* data) {
8c9b4b28aaa9 implement ui_button (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 180
diff changeset
56 char* action = data;
187
24ce2c326d85 implement toggle button (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 186
diff changeset
57
24ce2c326d85 implement toggle button (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 186
diff changeset
58 WindowData* wdata = event->window;
24ce2c326d85 implement toggle button (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 186
diff changeset
59 int64_t is_checked = wdata->check->get(wdata->check);
188
fbbae6738252 implement radio button (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 187
diff changeset
60 int64_t radio = wdata->radio->get(wdata->radio);
187
24ce2c326d85 implement toggle button (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 186
diff changeset
61
24ce2c326d85 implement toggle button (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 186
diff changeset
62 printf("data: %s %d\n", data, is_checked);
220
e377456302df add progressbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 219
diff changeset
63
e377456302df add progressbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 219
diff changeset
64 double d = wdata->progress->get(wdata->progress);
e377456302df add progressbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 219
diff changeset
65 wdata->progress->set(wdata->progress, d + 1);
221
a82d9beaa94a add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 220
diff changeset
66
a82d9beaa94a add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 220
diff changeset
67 int spinner_active = wdata->spinner->get(wdata->spinner);
a82d9beaa94a add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 220
diff changeset
68 wdata->spinner->set(wdata->spinner, !spinner_active);
187
24ce2c326d85 implement toggle button (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 186
diff changeset
69 }
24ce2c326d85 implement toggle button (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 186
diff changeset
70
24ce2c326d85 implement toggle button (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 186
diff changeset
71 void action_set_checkbox(UiEvent* event, void* data) {
24ce2c326d85 implement toggle button (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 186
diff changeset
72 char* action = data;
24ce2c326d85 implement toggle button (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 186
diff changeset
73
24ce2c326d85 implement toggle button (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 186
diff changeset
74 WindowData* wdata = event->window;
24ce2c326d85 implement toggle button (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 186
diff changeset
75 wdata->check->set(wdata->check, 1);
184
8c9b4b28aaa9 implement ui_button (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 180
diff changeset
76 }
177
e79a60b3a7cb minimal working winui app
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 173
diff changeset
77
189
4daddc326877 add onchange event for toggle buttons (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 188
diff changeset
78 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
79 printf("onchange: %d\n", event->intval);
4daddc326877 add onchange event for toggle buttons (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 188
diff changeset
80 }
4daddc326877 add onchange event for toggle buttons (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 188
diff changeset
81
191
6113ed66d258 add toggle switch (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 190
diff changeset
82 void action_switch(UiEvent* event, void* data) {
6113ed66d258 add toggle switch (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 190
diff changeset
83 printf("onchange: %d\n", event->intval);
6113ed66d258 add toggle switch (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 190
diff changeset
84 }
6113ed66d258 add toggle switch (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 190
diff changeset
85
207
93b9f502cb88 add toolbar appmenu and menu buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 205
diff changeset
86 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
87 printf("toolbar action\n");
93b9f502cb88 add toolbar appmenu and menu buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 205
diff changeset
88 }
203
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 202
diff changeset
89
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 202
diff changeset
90
196
320d85f3cd14 add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 195
diff changeset
91 void action_listselection_changed(UiEvent* event, void* data) {
320d85f3cd14 add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 195
diff changeset
92 printf("selection changed\n");
320d85f3cd14 add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 195
diff changeset
93 UiListSelection* sel = event->eventdata;
320d85f3cd14 add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 195
diff changeset
94 for (int i = 0; i < sel->count; i++) {
320d85f3cd14 add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 195
diff changeset
95 int row = sel->rows[i];
320d85f3cd14 add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 195
diff changeset
96 printf("row: %d\n", row);
320d85f3cd14 add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 195
diff changeset
97 }
320d85f3cd14 add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 195
diff changeset
98 }
320d85f3cd14 add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 195
diff changeset
99
320d85f3cd14 add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 195
diff changeset
100 void action_onactivate(UiEvent* event, void* Data) {
320d85f3cd14 add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 195
diff changeset
101 printf("activate\n");
320d85f3cd14 add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 195
diff changeset
102 UiListSelection* sel = event->eventdata;
320d85f3cd14 add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 195
diff changeset
103 for (int i = 0; i < sel->count; i++) {
320d85f3cd14 add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 195
diff changeset
104 int row = sel->rows[i];
320d85f3cd14 add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 195
diff changeset
105 printf("row: %d\n", row);
320d85f3cd14 add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 195
diff changeset
106 }
320d85f3cd14 add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 195
diff changeset
107 }
320d85f3cd14 add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 195
diff changeset
108
203
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 202
diff changeset
109 typedef struct TableData {
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 202
diff changeset
110 char* col1;
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 202
diff changeset
111 char* col2;
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 202
diff changeset
112 char* col3;
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 202
diff changeset
113 } TableData;
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 202
diff changeset
114
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 202
diff changeset
115 void* table_getvalue(void* data, int i) {
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 202
diff changeset
116 TableData* t = data;
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 202
diff changeset
117 switch (i) {
215
1bd5534c395d add support for icons in the table widget (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
118 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
119 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
120 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
121 case 3: return t->col3;
203
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 202
diff changeset
122 }
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 202
diff changeset
123 return NULL;
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 202
diff changeset
124 }
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 202
diff changeset
125
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 202
diff changeset
126 void action_add(UiEvent* event, void* data) {
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 202
diff changeset
127 WindowData* wdata = event->window;
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 202
diff changeset
128 char* t1 = wdata->t1->get(wdata->t1);
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 202
diff changeset
129 char* t2 = wdata->t2->get(wdata->t2);
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 202
diff changeset
130 char* t3 = wdata->t3->get(wdata->t3);
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 202
diff changeset
131
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 202
diff changeset
132 TableData* tdat = malloc(sizeof(TableData));
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 202
diff changeset
133 tdat->col1 = _strdup(t1);
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 202
diff changeset
134 tdat->col2 = _strdup(t2);
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 202
diff changeset
135 tdat->col3 = _strdup(t3);
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 202
diff changeset
136 ui_list_append(wdata->list2, tdat);
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 202
diff changeset
137 wdata->list2->update(wdata->list2, 0);
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 202
diff changeset
138
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 202
diff changeset
139 }
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 202
diff changeset
140
204
4a258d47f964 add breadcrumb bar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 203
diff changeset
141 void action_breadcrumb(UiEvent* event, void* data) {
4a258d47f964 add breadcrumb bar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 203
diff changeset
142 int i = event->intval;
4a258d47f964 add breadcrumb bar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 203
diff changeset
143 printf("index: %d\n", i);
4a258d47f964 add breadcrumb bar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 203
diff changeset
144 }
4a258d47f964 add breadcrumb bar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 203
diff changeset
145
177
e79a60b3a7cb minimal working winui app
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 173
diff changeset
146 void application_startup(UiEvent* event, void* data) {
e79a60b3a7cb minimal working winui app
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 173
diff changeset
147 UiObject* obj = ui_window("Test", NULL);
187
24ce2c326d85 implement toggle button (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 186
diff changeset
148 WindowData* wdata = ui_malloc(obj->ctx, sizeof(WindowData));
24ce2c326d85 implement toggle button (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 186
diff changeset
149 obj->window = wdata;
24ce2c326d85 implement toggle button (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 186
diff changeset
150 wdata->check = ui_int_new(obj->ctx, "check");
24ce2c326d85 implement toggle button (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 186
diff changeset
151 wdata->toggle = ui_int_new(obj->ctx, "toggle");
188
fbbae6738252 implement radio button (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 187
diff changeset
152 wdata->radio = ui_int_new(obj->ctx, "radio");
192
bcacd00ea955 implement textfield (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 191
diff changeset
153 wdata->text = ui_string_new(obj->ctx, "text");
bcacd00ea955 implement textfield (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 191
diff changeset
154 wdata->password = ui_string_new(obj->ctx, "password");
196
320d85f3cd14 add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 195
diff changeset
155 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
156 wdata->list2 = ui_list_new(obj->ctx, "list2");
204
4a258d47f964 add breadcrumb bar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 203
diff changeset
157 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
158 wdata->t1 = ui_string_new(obj->ctx, "t1");
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 202
diff changeset
159 wdata->t2 = ui_string_new(obj->ctx, "t2");
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 202
diff changeset
160 wdata->t3 = ui_string_new(obj->ctx, "t3");
220
e377456302df add progressbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 219
diff changeset
161 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
162 wdata->spinner = ui_int_new(obj->ctx, "spinner");
196
320d85f3cd14 add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 195
diff changeset
163
320d85f3cd14 add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 195
diff changeset
164 ui_list_append(wdata->list, "Hello");
320d85f3cd14 add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 195
diff changeset
165 ui_list_append(wdata->list, "World");
320d85f3cd14 add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 195
diff changeset
166 ui_list_append(wdata->list, "Item3");
320d85f3cd14 add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 195
diff changeset
167 ui_list_append(wdata->list, "Item4");
320d85f3cd14 add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 195
diff changeset
168 ui_list_append(wdata->list, "Item5");
320d85f3cd14 add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 195
diff changeset
169 ui_list_append(wdata->list, "Item6");
177
e79a60b3a7cb minimal working winui app
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 173
diff changeset
170
204
4a258d47f964 add breadcrumb bar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 203
diff changeset
171 ui_list_append(wdata->list3, "usr");
4a258d47f964 add breadcrumb bar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 203
diff changeset
172 ui_list_append(wdata->list3, "share");
4a258d47f964 add breadcrumb bar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 203
diff changeset
173 ui_list_append(wdata->list3, "test");
4a258d47f964 add breadcrumb bar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 203
diff changeset
174 ui_list_append(wdata->list3, "dir");
4a258d47f964 add breadcrumb bar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 203
diff changeset
175
216
391c2c723029 add dll icon loader
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 215
diff changeset
176 //folder_icon = ui_icon("Folder", 32);
391c2c723029 add dll icon loader
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 215
diff changeset
177 folder_icon = ui_foldericon(16);
204
4a258d47f964 add breadcrumb bar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 203
diff changeset
178
203
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 202
diff changeset
179 TableData* td1 = malloc(sizeof(TableData));
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 202
diff changeset
180 TableData* td2 = malloc(sizeof(TableData));
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 202
diff changeset
181 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
182 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
183 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
184 TableData* td6 = malloc(sizeof(TableData));
203
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 202
diff changeset
185 td1->col1 = "a1";
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 202
diff changeset
186 td1->col2 = "b1";
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 202
diff changeset
187 td1->col3 = "c1";
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 202
diff changeset
188 td2->col1 = "a2";
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 202
diff changeset
189 td2->col2 = "b2";
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 202
diff changeset
190 td2->col3 = "b3";
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 202
diff changeset
191 td3->col1 = "a3";
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 202
diff changeset
192 td3->col2 = "b3";
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 202
diff changeset
193 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
194 td4->col1 = "a3";
279c0c81d3b1 improve table row selection, add support for multiple selections (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 213
diff changeset
195 td4->col2 = "b3";
279c0c81d3b1 improve table row selection, add support for multiple selections (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 213
diff changeset
196 td4->col3 = "c3";
279c0c81d3b1 improve table row selection, add support for multiple selections (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 213
diff changeset
197 td5->col1 = "a3";
279c0c81d3b1 improve table row selection, add support for multiple selections (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 213
diff changeset
198 td5->col2 = "b3";
279c0c81d3b1 improve table row selection, add support for multiple selections (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 213
diff changeset
199 td5->col3 = "c3";
279c0c81d3b1 improve table row selection, add support for multiple selections (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 213
diff changeset
200 td6->col1 = "a3";
279c0c81d3b1 improve table row selection, add support for multiple selections (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 213
diff changeset
201 td6->col2 = "b3";
279c0c81d3b1 improve table row selection, add support for multiple selections (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 213
diff changeset
202 td6->col3 = "c3";
203
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 202
diff changeset
203
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 202
diff changeset
204 ui_list_append(wdata->list2, td1);
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 202
diff changeset
205 ui_list_append(wdata->list2, td2);
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 202
diff changeset
206 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
207 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
208 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
209 ui_list_append(wdata->list2, td6);
203
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 202
diff changeset
210
194
e2281ace0769 add scrolledwindow (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 193
diff changeset
211 ui_scrolledwindow0(obj) {
e2281ace0769 add scrolledwindow (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 193
diff changeset
212 ui_grid(obj, .margin = 10, .columnspacing = 5, .rowspacing = 20) {
e2281ace0769 add scrolledwindow (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 193
diff changeset
213 ui_button(obj, .label = "Button1", .onclick = action1, .onclickdata = "action1");
e2281ace0769 add scrolledwindow (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 193
diff changeset
214 ui_button(obj, .label = "Button2", .onclick = action1, .onclickdata = "action2");
e2281ace0769 add scrolledwindow (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 193
diff changeset
215 ui_button(obj, .label = "Button3", .onclick = action1, .onclickdata = "action3", .hexpand = true);
e2281ace0769 add scrolledwindow (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 193
diff changeset
216 ui_newline(obj);
185
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 184
diff changeset
217
194
e2281ace0769 add scrolledwindow (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 193
diff changeset
218 ui_button(obj, .label = "Button4", .onclick = action1, .onclickdata = "action4");
e2281ace0769 add scrolledwindow (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 193
diff changeset
219 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
220 ui_newline(obj);
185
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 184
diff changeset
221
194
e2281ace0769 add scrolledwindow (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 193
diff changeset
222 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
223 ui_newline(obj);
187
24ce2c326d85 implement toggle button (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 186
diff changeset
224
194
e2281ace0769 add scrolledwindow (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 193
diff changeset
225 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
226 ui_togglebutton(obj, .label = "Option 2", .value = wdata->toggle);
e2281ace0769 add scrolledwindow (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 193
diff changeset
227 ui_newline(obj);
188
fbbae6738252 implement radio button (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 187
diff changeset
228
221
a82d9beaa94a add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 220
diff changeset
229 ui_label(obj, .label = "Progress");
a82d9beaa94a add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 220
diff changeset
230 ui_progressspinner(obj, .value = wdata->spinner);
a82d9beaa94a add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 220
diff changeset
231 ui_newline(obj);
a82d9beaa94a add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 220
diff changeset
232
194
e2281ace0769 add scrolledwindow (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 193
diff changeset
233 ui_hbox(obj, .colspan = 3) {
e2281ace0769 add scrolledwindow (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 193
diff changeset
234 ui_radiobutton(obj, .label = "Radio 1", .value = wdata->radio);
e2281ace0769 add scrolledwindow (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 193
diff changeset
235 ui_radiobutton(obj, .label = "Radio 2", .value = wdata->radio);
e2281ace0769 add scrolledwindow (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 193
diff changeset
236 ui_radiobutton(obj, .label = "Radio 3", .value = wdata->radio);
e2281ace0769 add scrolledwindow (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 193
diff changeset
237 }
e2281ace0769 add scrolledwindow (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 193
diff changeset
238 ui_newline(obj);
e2281ace0769 add scrolledwindow (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 193
diff changeset
239 ui_radiobutton(obj, .label = "Radio 4", .value = wdata->radio);
e2281ace0769 add scrolledwindow (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 193
diff changeset
240 ui_switch(obj, .label = "test", .onchange = action_switch);
e2281ace0769 add scrolledwindow (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 193
diff changeset
241 ui_newline(obj);
e2281ace0769 add scrolledwindow (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 193
diff changeset
242
221
a82d9beaa94a add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 220
diff changeset
243 //ui_breadcrumbbar(obj, .list = wdata->list3, .onactivate=action_breadcrumb);
a82d9beaa94a add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 220
diff changeset
244 ui_pathbar(obj, .colspan = 3, .list = wdata->list3, .onactivate = action_breadcrumb);
204
4a258d47f964 add breadcrumb bar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 203
diff changeset
245 ui_newline(obj);
4a258d47f964 add breadcrumb bar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 203
diff changeset
246
194
e2281ace0769 add scrolledwindow (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 193
diff changeset
247 ui_textfield(obj, .value = wdata->text);
e2281ace0769 add scrolledwindow (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 193
diff changeset
248 ui_passwordfield(obj, .value = wdata->password);
e2281ace0769 add scrolledwindow (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 193
diff changeset
249 ui_newline(obj);
e2281ace0769 add scrolledwindow (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 193
diff changeset
250
195
0f2e69873875 add expander (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 194
diff changeset
251 ui_frame(obj, .label = "Test", .colspan = 3) {
0f2e69873875 add expander (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 194
diff changeset
252 ui_button(obj, .label = "Button1", .onclick = action1, .onclickdata = "action1");
0f2e69873875 add expander (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 194
diff changeset
253 }
0f2e69873875 add expander (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 194
diff changeset
254 ui_newline(obj);
202
9f309d1914a2 finish navigationview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 198
diff changeset
255
196
320d85f3cd14 add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 195
diff changeset
256 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
257 ui_button(obj, .label = "Button1", .onclick = action1, .onclickdata = "action1");
0f2e69873875 add expander (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 194
diff changeset
258 ui_button(obj, .label = "Button1", .onclick = action1, .onclickdata = "action1");
194
e2281ace0769 add scrolledwindow (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 193
diff changeset
259 ui_button(obj, .label = "Button1", .onclick = action1, .onclickdata = "action1");
e2281ace0769 add scrolledwindow (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 193
diff changeset
260 }
202
9f309d1914a2 finish navigationview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 198
diff changeset
261 ui_newline(obj);
196
320d85f3cd14 add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 195
diff changeset
262
197
8a82ebe23822 add combobox (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 196
diff changeset
263 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
264 ui_newline(obj);
f2332d0d3318 add tabview based on winui the pivot control
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 197
diff changeset
265
208
f632bc0589ab new menu api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 207
diff changeset
266 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
267 ui_tab(obj, "Tab 1") {
f2332d0d3318 add tabview based on winui the pivot control
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 197
diff changeset
268 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
269 }
f2332d0d3318 add tabview based on winui the pivot control
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 197
diff changeset
270 ui_tab(obj, "Tab 2") {
f2332d0d3318 add tabview based on winui the pivot control
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 197
diff changeset
271 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
272 }
219
527a66c0afb2 add label (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 218
diff changeset
273 ui_tab(obj, "Tab 3") {
527a66c0afb2 add label (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 218
diff changeset
274
527a66c0afb2 add label (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 218
diff changeset
275 }
198
f2332d0d3318 add tabview based on winui the pivot control
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 197
diff changeset
276 }
219
527a66c0afb2 add label (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 218
diff changeset
277 ui_newline(obj);
527a66c0afb2 add label (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 218
diff changeset
278
527a66c0afb2 add label (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 218
diff changeset
279 ui_label(obj, .label = "Test Label");
220
e377456302df add progressbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 219
diff changeset
280 ui_progressbar(obj, .value = wdata->progress, .colspan = 2);
219
527a66c0afb2 add label (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 218
diff changeset
281 ui_newline(obj);
203
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 202
diff changeset
282
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 202
diff changeset
283 ui_newline(obj);
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 202
diff changeset
284 ui_textfield(obj, .value = wdata->t1);
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 202
diff changeset
285 ui_textfield(obj, .value = wdata->t2);
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 202
diff changeset
286 ui_textfield(obj, .value = wdata->t3);
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 202
diff changeset
287 ui_newline(obj);
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 202
diff changeset
288 ui_button(obj, .label = "Add", .onclick = action_add);
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 202
diff changeset
289 ui_newline(obj);
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 202
diff changeset
290
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 202
diff changeset
291
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 202
diff changeset
292 ui_newline(obj);
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 202
diff changeset
293
215
1bd5534c395d add support for icons in the table widget (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
294 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
295 model->getvalue = table_getvalue;
221
a82d9beaa94a add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 220
diff changeset
296 ui_table(obj, .colspan = 3, .model = model, .list = wdata->list2, .onactivate = action_onactivate,
a82d9beaa94a add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 220
diff changeset
297 .onselection = action_listselection_changed, .enabledrag = true, .enabledrop = true);
203
0e94be3d9722 add semi-functional table (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 202
diff changeset
298 ui_model_free(obj->ctx, model);
188
fbbae6738252 implement radio button (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 187
diff changeset
299 }
194
e2281ace0769 add scrolledwindow (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 193
diff changeset
300 }
184
8c9b4b28aaa9 implement ui_button (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 180
diff changeset
301
177
e79a60b3a7cb minimal working winui app
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 173
diff changeset
302 ui_show(obj);
173
809581724cc7 add VS project
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
303 }
177
e79a60b3a7cb minimal working winui app
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 173
diff changeset
304
e79a60b3a7cb minimal working winui app
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 173
diff changeset
305
e79a60b3a7cb minimal working winui app
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 173
diff changeset
306 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
307 {
177
e79a60b3a7cb minimal working winui app
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 173
diff changeset
308 ui_init("app1", 0, NULL);
e79a60b3a7cb minimal working winui app
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 173
diff changeset
309 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
310
208
f632bc0589ab new menu api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 207
diff changeset
311 ui_menu("File") {
f632bc0589ab new menu api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 207
diff changeset
312 ui_menuitem(.label = "Item 1");
f632bc0589ab new menu api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 207
diff changeset
313 ui_menuitem(.label = "Item 2");
f632bc0589ab new menu api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 207
diff changeset
314 ui_menuseparator();
f632bc0589ab new menu api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 207
diff changeset
315 ui_menu("File Sub") {
f632bc0589ab new menu api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 207
diff changeset
316 ui_menuitem(.label = "Sub Item");
f632bc0589ab new menu api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 207
diff changeset
317 }
f632bc0589ab new menu api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 207
diff changeset
318
f632bc0589ab new menu api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 207
diff changeset
319 ui_menuitem(.label = "Exit");
f632bc0589ab new menu api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 207
diff changeset
320 }
180
f34953bf4ac7 add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 177
diff changeset
321
213
7e39db525fd9 add icons (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 211
diff changeset
322 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
323 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
324 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
325 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
326
93b9f502cb88 add toolbar appmenu and menu buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 205
diff changeset
327 ui_toolbar_menu("Menu", .label = "Menu") {
208
f632bc0589ab new menu api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 207
diff changeset
328
f632bc0589ab new menu api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 207
diff changeset
329 ui_menuitem(.label = "x", NULL, NULL);
211
5d71a36b833b add custom titlebar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 208
diff changeset
330 ui_menuitem(.label = "x", NULL, NULL);
5d71a36b833b add custom titlebar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 208
diff changeset
331 ui_menuitem(.label = "x", NULL, NULL);
5d71a36b833b add custom titlebar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 208
diff changeset
332 ui_menuitem(.label = "x", NULL, NULL);
5d71a36b833b add custom titlebar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 208
diff changeset
333 ui_menuitem(.label = "x", NULL, NULL);
208
f632bc0589ab new menu api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 207
diff changeset
334 ui_menu("TB Sub") {
f632bc0589ab new menu api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 207
diff changeset
335 ui_menuitem("TB subitem", NULL, NULL);
f632bc0589ab new menu api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 207
diff changeset
336 }
207
93b9f502cb88 add toolbar appmenu and menu buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 205
diff changeset
337 }
93b9f502cb88 add toolbar appmenu and menu buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 205
diff changeset
338
93b9f502cb88 add toolbar appmenu and menu buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 205
diff changeset
339 ui_toolbar_menu(NULL, .label = "Menu") {
93b9f502cb88 add toolbar appmenu and menu buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 205
diff changeset
340 ui_menuitem("Secondary Test", NULL, NULL);
208
f632bc0589ab new menu api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 207
diff changeset
341 ui_menu("Secondary Sub") {
f632bc0589ab new menu api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 207
diff changeset
342 ui_menuitem("Secondary subitem", NULL, NULL);
f632bc0589ab new menu api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 207
diff changeset
343 }
207
93b9f502cb88 add toolbar appmenu and menu buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 205
diff changeset
344 }
93b9f502cb88 add toolbar appmenu and menu buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 205
diff changeset
345
205
b1ac0dd1d38b new winui vs project, add toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 204
diff changeset
346 ui_toolbar_add_default("Test");
207
93b9f502cb88 add toolbar appmenu and menu buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 205
diff changeset
347 ui_toolbar_add_default("Toggle");
93b9f502cb88 add toolbar appmenu and menu buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 205
diff changeset
348 ui_toolbar_add_default("Toggle2");
93b9f502cb88 add toolbar appmenu and menu buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 205
diff changeset
349 ui_toolbar_add_default("Toggle3");
93b9f502cb88 add toolbar appmenu and menu buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 205
diff changeset
350 ui_toolbar_add_default("Menu");
205
b1ac0dd1d38b new winui vs project, add toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 204
diff changeset
351
177
e79a60b3a7cb minimal working winui app
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 173
diff changeset
352 ui_main();
e79a60b3a7cb minimal working winui app
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 173
diff changeset
353
e79a60b3a7cb minimal working winui app
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 173
diff changeset
354 return (EXIT_SUCCESS);
e79a60b3a7cb minimal working winui app
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 173
diff changeset
355 }

mercurial