GCC Code Coverage Report


Directory: src/gate/
File: src/gate/ui/gateui.c
Date: 2025-12-12 23:40:09
Exec Total Coverage
Lines: 314 407 77.1%
Functions: 38 52 73.1%
Branches: 114 180 63.3%

Line Branch Exec Source
1 /* GATE PROJECT LICENSE:
2 +----------------------------------------------------------------------------+
3 | Copyright(c) 2018-2025, Stefan Meislinger <sm@opengate.at> |
4 | All rights reserved. |
5 | |
6 | Redistribution and use in source and binary forms, with or without |
7 | modification, are permitted provided that the following conditions are met:|
8 | |
9 | 1. Redistributions of source code must retain the above copyright notice, |
10 | this list of conditions and the following disclaimer. |
11 | 2. Redistributions in binary form must reproduce the above copyright |
12 | notice, this list of conditions and the following disclaimer in the |
13 | documentation and/or other materials provided with the distribution. |
14 | |
15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"|
16 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
17 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
18 | ARE DISCLAIMED.IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE |
19 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
20 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
21 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
22 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
23 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
24 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
25 | THE POSSIBILITY OF SUCH DAMAGE. |
26 +----------------------------------------------------------------------------+
27 */
28
29 #include "gate/ui/gateui.h"
30 #include "gate/results.h"
31
32
33 /****************************
34 * generic implementation *
35 ****************************/
36
37 17 gate_result_t gate_ui_ctrl_init(gate_ui_ctrl_t* ctrl)
38 {
39 17 gate_mem_clear(ctrl, sizeof(gate_ui_ctrl_t));
40 17 return GATE_RESULT_OK;
41 }
42
43
44 6 gate_result_t gate_ui_layout_create(gate_ui_layout_t* layout)
45 {
46 6 layout->border = 0;
47 6 layout->colspace = 0;
48 6 layout->rowspace = 0;
49 6 layout->columns = gate_arraylist_create(sizeof(gate_ui_layout_def_t), NULL, 0, NULL, NULL);
50
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if (layout->columns == NULL)
51 {
52 return GATE_RESULT_OUTOFMEMORY;
53 }
54 6 layout->rows = gate_arraylist_create(sizeof(gate_ui_layout_def_t), NULL, 0, NULL, NULL);
55
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if (layout->rows == NULL)
56 {
57 gate_arraylist_release(layout->columns);
58 return GATE_RESULT_OUTOFMEMORY;
59 }
60 6 layout->cells = gate_arraylist_create(sizeof(gate_arraylist_t), NULL, 0, NULL, NULL);
61
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if (layout->cells == NULL)
62 {
63 gate_arraylist_release(layout->rows);
64 gate_arraylist_release(layout->columns);
65 return GATE_RESULT_OUTOFMEMORY;
66 }
67 6 return GATE_RESULT_OK;
68 }
69
70 6 gate_result_t gate_ui_layout_destroy(gate_ui_layout_t* layout)
71 {
72 6 gate_size_t maxrows = gate_arraylist_length(layout->cells);
73 gate_size_t ndx;
74
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 6 times.
12 for (ndx = 0; ndx < maxrows; ++ndx)
75 {
76 6 gate_arraylist_t* collist = (gate_arraylist_t*)gate_arraylist_get(layout->cells, ndx);
77 6 gate_arraylist_release(*collist);
78 }
79 6 gate_arraylist_release(layout->cells);
80 6 gate_arraylist_release(layout->rows);
81 6 gate_arraylist_release(layout->columns);
82 6 return GATE_RESULT_NOTIMPLEMENTED;
83 }
84
85 3 gate_result_t gate_ui_layout_clear(gate_ui_layout_t* layout)
86 {
87 3 gate_ui_layout_destroy(layout);
88 3 return gate_ui_layout_create(layout);
89 }
90
91 static gate_ui_layout_cell_t const gate_ui_layout_empty_cell = { NULL, 0, 0, 0, 0, 0, 0 };
92
93 6 gate_result_t gate_ui_layout_add_column(gate_ui_layout_t* layout, gate_uint32_t type, gate_real32_t value)
94 {
95 gate_result_t ret;
96 gate_ui_layout_def_t def;
97 6 def.type = type;
98 6 def.value = value;
99
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
6 if (NULL == gate_arraylist_add(layout->columns, &def))
100 {
101 ret = GATE_RESULT_FAILED;
102 }
103 else
104 {
105 6 ret = GATE_RESULT_OK;
106 }
107 6 return ret;
108 }
109
110 6 gate_result_t gate_ui_layout_add_row(gate_ui_layout_t* layout, gate_uint32_t type, gate_real32_t value)
111 {
112 gate_result_t ret;
113 gate_ui_layout_def_t def;
114 6 def.type = type;
115 6 def.value = value;
116
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
6 if (NULL == gate_arraylist_add(layout->rows, &def))
117 {
118 ret = GATE_RESULT_FAILED;
119 }
120 else
121 {
122 6 ret = GATE_RESULT_OK;
123 }
124 6 return ret;
125 }
126
127 6 gate_uint32_t gate_ui_layout_get_rows(gate_ui_layout_t* layout)
128 {
129 6 gate_uint32_t ret = 0;
130
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if (layout->rows != NULL)
131 {
132 6 ret = (gate_uint32_t)gate_arraylist_length(layout->rows);
133 }
134 6 return ret;
135 }
136 6 gate_uint32_t gate_ui_layout_get_columns(gate_ui_layout_t* layout)
137 {
138 6 gate_uint32_t ret = 0;
139
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if (layout->rows != NULL)
140 {
141 6 ret = (gate_uint32_t)gate_arraylist_length(layout->columns);
142 }
143 6 return ret;
144 }
145
146
147 10 gate_result_t gate_ui_layout_set_control(gate_ui_layout_t* layout,
148 gate_ui_ctrl_t* ctrl, gate_uint32_t row, gate_uint32_t col,
149 gate_uint32_t rowspan, gate_uint32_t colspan
150 )
151 {
152 gate_size_t rowcount;
153 gate_size_t colcount;
154 gate_arraylist_t* collist;
155 gate_arraylist_t newlist;
156 gate_ui_layout_cell_t* cell;
157
158 10 rowcount = gate_arraylist_length(layout->cells);
159
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 10 times.
16 for (; rowcount <= row; ++rowcount)
160 {
161 6 newlist = gate_arraylist_create(sizeof(gate_ui_layout_empty_cell), NULL, 0, NULL, NULL);
162
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if (newlist == NULL)
163 {
164 return GATE_RESULT_OUTOFMEMORY;
165 }
166
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
6 if (NULL == gate_arraylist_add(layout->cells, &newlist))
167 {
168 gate_arraylist_release(newlist);
169 return GATE_RESULT_OUTOFMEMORY;
170 }
171 }
172 10 collist = (gate_arraylist_t*)gate_arraylist_get(layout->cells, row);
173
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 if (collist == NULL)
174 {
175 return GATE_RESULT_FAILED;
176 }
177 10 colcount = gate_arraylist_length(*collist);
178
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 10 times.
21 for (; colcount <= col; ++colcount)
179 {
180
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 11 times.
11 if (NULL == gate_arraylist_add(*collist, &gate_ui_layout_empty_cell))
181 {
182 return GATE_RESULT_OUTOFMEMORY;
183 }
184 }
185 10 cell = (gate_ui_layout_cell_t*)gate_arraylist_get(*collist, col);
186
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 if (cell == NULL)
187 {
188 return GATE_RESULT_FAILED;
189 }
190 10 cell->ctrl = ctrl;
191 10 cell->rowspan = rowspan;
192 10 cell->colspan = colspan;
193
194 10 return GATE_RESULT_OK;
195 }
196 8 gate_result_t gate_ui_layout_apply(gate_ui_layout_t const* layout, gate_uint32_t unitLength, gate_ui_position_t const* pose)
197 {
198 gate_int32_t rowheights[256];
199 gate_int32_t colwidths[256];
200 gate_size_t rowcount;
201 gate_size_t colcount;
202
203 gate_int32_t width;
204 gate_int32_t height;
205 gate_int32_t remainwidth;
206 gate_int32_t remainheight;
207
208 gate_size_t ndx;
209 gate_size_t autocnt;
210 gate_ui_layout_def_t* currentdef;
211 gate_int32_t x, y, w, h;
212 gate_size_t row, col;
213 gate_ui_point_t ctrlpoint;
214 gate_ui_size_t ctrlsize;
215
216
3/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
8 if (!layout || !pose)
217 {
218 1 return GATE_RESULT_INVALIDDATA;
219 }
220
221 7 rowcount = gate_arraylist_length(layout->rows);
222 7 colcount = gate_arraylist_length(layout->columns);
223
224 7 width = pose->size.width - layout->border * 2;
225 7 height = pose->size.height - layout->border * 2;
226
227
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 if (rowcount > sizeof(rowheights) / sizeof(rowheights[0])) rowcount = sizeof(rowheights) / sizeof(rowheights[0]);
228
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 if (colcount > sizeof(colwidths) / sizeof(colwidths[0])) colcount = sizeof(colwidths) / sizeof(colwidths[0]);
229
230
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if (colcount > 0) width -= (gate_int32_t)(colcount) * (gate_int32_t)layout->colspace;
231
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if (rowcount > 0) height -= (gate_int32_t)(rowcount) * (gate_int32_t)layout->rowspace;
232 7 remainwidth = width;
233 7 remainheight = height;
234
235
236 /* calculating cell widths */
237 7 autocnt = 0;
238
2/2
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 7 times.
22 for (ndx = 0; ndx != colcount; ++ndx)
239 {
240 15 currentdef = (gate_ui_layout_def_t*)gate_arraylist_get(layout->columns, ndx);
241
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 11 times.
15 switch (currentdef->type)
242 {
243 case GATE_UI_LAYOUT_TYPE_PIXEL: colwidths[ndx] = (gate_int32_t)currentdef->value; break;
244 2 case GATE_UI_LAYOUT_TYPE_PERCENT: colwidths[ndx] = (gate_int32_t)((gate_real32_t)width * currentdef->value * 0.01f); break;
245 2 case GATE_UI_LAYOUT_TYPE_UNITSCALE: colwidths[ndx] = (gate_int32_t)((gate_real32_t)unitLength * currentdef->value); break;
246 11 default:
247 11 case GATE_UI_LAYOUT_TYPE_AUTO: colwidths[ndx] = 0; ++autocnt; break;
248 }
249 15 remainwidth -= colwidths[ndx];
250 }
251
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if (autocnt > 0)
252 {
253
2/2
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 7 times.
22 for (ndx = 0; ndx != colcount; ++ndx)
254 {
255 15 currentdef = (gate_ui_layout_def_t*)gate_arraylist_get(layout->columns, ndx);
256
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 11 times.
15 switch (currentdef->type)
257 {
258 4 case GATE_UI_LAYOUT_TYPE_PIXEL:
259 case GATE_UI_LAYOUT_TYPE_PERCENT:
260 case GATE_UI_LAYOUT_TYPE_UNITSCALE:
261 4 break;
262 11 default:
263 case GATE_UI_LAYOUT_TYPE_AUTO:
264 11 colwidths[ndx] = remainwidth / (gate_int32_t)autocnt;
265 11 break;
266 }
267 }
268 }
269
270 /* calculating cell heights */
271 7 autocnt = 0;
272
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 7 times.
20 for (ndx = 0; ndx != rowcount; ++ndx)
273 {
274 13 currentdef = (gate_ui_layout_def_t*)gate_arraylist_get(layout->rows, ndx);
275
2/4
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✓ Branch 3 taken 5 times.
13 switch (currentdef->type)
276 {
277 case GATE_UI_LAYOUT_TYPE_PIXEL: rowheights[ndx] = (gate_int32_t)currentdef->value; break;
278 case GATE_UI_LAYOUT_TYPE_PERCENT: rowheights[ndx] = (gate_int32_t)((gate_real32_t)height * currentdef->value * 0.01f); break;
279 8 case GATE_UI_LAYOUT_TYPE_UNITSCALE: rowheights[ndx] = (gate_int32_t)((gate_real32_t)unitLength * currentdef->value); break;
280 5 default:
281 5 case GATE_UI_LAYOUT_TYPE_AUTO: rowheights[ndx] = 0; ++autocnt; break;
282 }
283 13 remainheight -= rowheights[ndx];
284 }
285
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 4 times.
7 if (autocnt > 0)
286 {
287
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 3 times.
12 for (ndx = 0; ndx != rowcount; ++ndx)
288 {
289 9 currentdef = (gate_ui_layout_def_t*)gate_arraylist_get(layout->rows, ndx);
290
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 5 times.
9 switch (currentdef->type)
291 {
292 4 case GATE_UI_LAYOUT_TYPE_PIXEL:
293 case GATE_UI_LAYOUT_TYPE_PERCENT:
294 case GATE_UI_LAYOUT_TYPE_UNITSCALE:
295 4 break;
296 5 default:
297 case GATE_UI_LAYOUT_TYPE_AUTO:
298 5 rowheights[ndx] = remainheight / (gate_int32_t)autocnt;
299 5 break;
300 }
301 }
302 }
303
304 /**/
305 7 y = pose->pos.y + layout->border + layout->rowspace / 2;
306
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 7 times.
20 for (row = 0; row < rowcount; ++row)
307 {
308 gate_arraylist_t* currentcollist;
309 13 h = rowheights[row];
310
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 13 times.
13 if (row >= gate_arraylist_length(layout->cells))
311 {
312 /* there are no further rows with column cells, so we can cancel further processing */
313 break;
314 }
315 13 currentcollist = (gate_arraylist_t*)gate_arraylist_get(layout->cells, row);
316
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if (currentcollist != NULL)
317 {
318 13 x = pose->pos.x + layout->border + layout->colspace / 2;
319
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 9 times.
38 for (col = 0; col < colcount; ++col)
320 {
321 gate_ui_layout_cell_t* currentcell;
322 29 w = colwidths[col];
323
324
2/2
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 25 times.
29 if (col >= gate_arraylist_length(*currentcollist))
325 {
326 /* there are no more cells in the current row, so we can skip all remaining columns */
327 4 break;
328 }
329 25 currentcell = (gate_ui_layout_cell_t*)gate_arraylist_get(*currentcollist, col);
330
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if (currentcell != NULL)
331 {
332
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 2 times.
25 if (currentcell->ctrl != NULL)
333 {
334
1/2
✓ Branch 1 taken 23 times.
✗ Branch 2 not taken.
23 if (gate_ui_ctrl_is_created(currentcell->ctrl))
335 {
336 23 ctrlpoint.x = x;
337 23 ctrlpoint.y = y;
338 23 ctrlsize.width = w;
339 23 ctrlsize.height = h;
340
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 23 times.
31 for (ndx = 1; ndx < currentcell->colspan; ++ndx)
341 {
342 8 ctrlsize.width += colwidths[col + ndx] + layout->colspace;
343 }
344
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 23 times.
25 for (ndx = 1; ndx < currentcell->rowspan; ++ndx)
345 {
346 2 ctrlsize.height += rowheights[col + ndx] + layout->rowspace;
347 }
348
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23 times.
23 if (ctrlsize.width < 2) ctrlsize.width = 2;
349
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 21 times.
23 if (ctrlsize.height < 2) ctrlsize.height = 2;
350 23 gate_ui_ctrl_set_position(currentcell->ctrl, &ctrlpoint, &ctrlsize);
351 23 gate_ui_ctrl_refresh(currentcell->ctrl);
352 }
353 }
354 }
355 25 x += (w + layout->colspace);
356 }
357 }
358
359 13 y += (h + layout->rowspace);
360 }
361
362 7 return GATE_RESULT_OK;
363 }
364
365
366
367
368 #if defined(GATE_UI_WINAPI)
369
370 #include "gate/platforms.h"
371 #include "gate/ui/gateui_winapi.h"
372
373
374
375
376
377 gate_result_t gate_ui_host_init(gate_ui_host_t* host, gate_uintptr_t apphandle, void* userparam)
378 {
379 return gate_ui_winapi_host_init(host, apphandle, userparam);
380 }
381 gate_result_t gate_ui_host_uninit(gate_ui_host_t* host)
382 {
383 return gate_ui_winapi_host_uninit(host);
384 }
385 gate_result_t gate_ui_host_run(gate_ui_host_t* host)
386 {
387 gate_result_t ret = GATE_RESULT_OK;
388 while (GATE_SUCCEEDED(ret))
389 {
390 ret = gate_ui_winapi_host_process_msg(host);
391 }
392 if (ret == GATE_RESULT_CANCELED)
393 {
394 /* ui host has received a quit message, which is OK too */
395 ret = GATE_RESULT_OK;
396 }
397 return ret;
398 }
399 gate_result_t gate_ui_host_quit(gate_ui_host_t* host)
400 {
401 gate_result_t ret = GATE_RESULT_OK;
402 #if defined(GATE_SYS_WIN16)
403 GATE_UNUSED_ARG(host);
404 PostQuitMessage(0);
405 #else
406 DWORD threadId = GATE_UI_WINAPI_GET_HOST_THREADID(host);
407 if (PostThreadMessage(threadId, WM_QUIT, 0, 0))
408 {
409 ret = GATE_RESULT_OK;
410 }
411 else
412 {
413 gate_win32_print_lasterror(&ret, NULL, 0);
414 }
415 #endif
416 return ret;
417 }
418 void* gate_ui_host_get_userparam(gate_ui_host_t* host)
419 {
420 return GATE_UI_WINAPI_GET_HOST_USER_PARAM(host);
421 }
422 gate_uintptr_t gate_ui_host_get_apphandle(gate_ui_host_t* host)
423 {
424 return GATE_UI_WINAPI_GET_HOST_APPHANDLE(host);
425 }
426 gate_uint32_t gate_ui_host_default_line_height(gate_ui_host_t* host)
427 {
428 return GATE_UI_WINAPI_GET_HOST_LINEHEIGHT(host);
429 }
430 gate_uint32_t gate_ui_host_default_control_height(gate_ui_host_t* host, gate_uint32_t line_count)
431 {
432 const gate_uint32_t line_height = GATE_UI_WINAPI_GET_HOST_LINEHEIGHT(host);
433 gate_uint32_t height = line_height * 14 / 8;
434 if (line_count > 1)
435 {
436 height += (line_count - 1) * line_height;
437 }
438 ++height;
439 return height;
440 }
441
442
443
444 void* gate_ui_ctrl_get_userparam(gate_ui_ctrl_t* ctrl)
445 {
446 void* ret = NULL;
447 if (ctrl != NULL)
448 {
449 ret = GATE_UI_WINAPI_GET_USER_PARAM(ctrl);
450 }
451 return ret;
452 }
453 gate_ui_host_t* gate_ui_ctrl_get_host(gate_ui_ctrl_t* ctrl)
454 {
455 gate_ui_host_t* host = NULL;
456 if (ctrl != NULL)
457 {
458 host = GATE_UI_WINAPI_GET_HOST(ctrl);
459 }
460 return host;
461 }
462 gate_ui_ctrl_t* gate_ui_ctrl_get_parent(gate_ui_ctrl_t* ctrl)
463 {
464 gate_ui_ctrl_t* ret = NULL;
465 if (ctrl != NULL)
466 {
467 gate_ui_host_t* host = GATE_UI_WINAPI_GET_HOST(ctrl);
468 HWND hwndParent = GATE_UI_WINAPI_GET_HWND_PARENT(ctrl);
469 if ((host) && (hwndParent))
470 {
471 ret = gate_ui_winapi_resolve_ctrl(host, (void*)hwndParent);
472 }
473 }
474 return ret;
475 }
476
477
478
479 gate_result_t gate_ui_ctrl_destroy(gate_ui_ctrl_t* ctrl)
480 {
481 gate_ui_winapi_dispatchers_t* disp;
482 gate_array_t children;
483 gate_result_t ret;
484 gate_size_t children_count;
485 gate_ui_ctrl_t* const* ptr_child;
486 HWND hwnd = (HWND)NULL;
487
488 do
489 {
490 if (ctrl == NULL)
491 {
492 ret = GATE_RESULT_NULLPOINTER;
493 break;
494 }
495 disp = GATE_UI_WINAPI_GET_DISPATCHER(ctrl);
496 if ((disp == NULL) || (disp->destroy == NULL))
497 {
498 hwnd = GATE_UI_WINAPI_GET_HWND(ctrl);
499 if (!hwnd)
500 {
501 ret = GATE_RESULT_OK; /* already destroyed, nothing to do */
502 }
503 else
504 {
505 ret = gate_ui_ctrl_get_children(ctrl, &children);
506 if (GATE_SUCCEEDED(ret))
507 {
508 children_count = gate_array_length(&children);
509 ptr_child = (gate_ui_ctrl_t* const*)gate_array_get(&children, 0);
510 while (children_count-- != 0)
511 {
512 gate_ui_ctrl_destroy(*ptr_child);
513 ++ptr_child;
514 }
515 gate_array_release(&children);
516 }
517
518 ret = gate_ui_winapi_destroy_with_font(ctrl);
519 }
520 }
521 else
522 {
523 ret = disp->destroy(ctrl);
524 }
525
526 GATE_UI_WINAPI_SET_HWND(ctrl, NULL);
527 GATE_UI_WINAPI_SET_HWND_PARENT(ctrl, NULL);
528 GATE_UI_WINAPI_SET_HOST(ctrl, NULL);
529 GATE_UI_WINAPI_SET_HWND_PROC(ctrl, NULL);
530 GATE_UI_WINAPI_SET_USER_PARAM(ctrl, NULL);
531 GATE_UI_WINAPI_SET_DISPATCHER(ctrl, NULL);
532 GATE_UI_WINAPI_SET_CTRL_PARAM(ctrl, NULL);
533 } while (0);
534 return ret;
535 }
536 gate_bool_t gate_ui_ctrl_is_created(gate_ui_ctrl_t* ctrl)
537 {
538 return gate_ui_winapi_is_created(ctrl);
539 }
540 gate_bool_t gate_ui_ctrl_is_enabled(gate_ui_ctrl_t* ctrl)
541 {
542 gate_ui_winapi_dispatchers_t* disp;
543 if (ctrl == NULL)
544 {
545 return false;
546 }
547 disp = GATE_UI_WINAPI_GET_DISPATCHER(ctrl);
548 if ((disp == NULL) || (disp->is_enabled == NULL))
549 {
550 return gate_ui_winapi_is_enabled(ctrl);
551 }
552 return disp->is_enabled(ctrl);
553 }
554 gate_bool_t gate_ui_ctrl_is_visible(gate_ui_ctrl_t* ctrl)
555 {
556 gate_ui_winapi_dispatchers_t* disp;
557 if (ctrl == NULL)
558 {
559 return false;
560 }
561 disp = GATE_UI_WINAPI_GET_DISPATCHER(ctrl);
562 if ((disp == NULL) || (disp->is_visible == NULL))
563 {
564 return gate_ui_winapi_is_visible(ctrl);
565 }
566 return disp->is_visible(ctrl);
567
568 }
569 gate_bool_t gate_ui_ctrl_is_focused(gate_ui_ctrl_t* ctrl)
570 {
571 gate_ui_winapi_dispatchers_t* disp;
572 if (ctrl == NULL)
573 {
574 return false;
575 }
576 disp = GATE_UI_WINAPI_GET_DISPATCHER(ctrl);
577 if ((disp == NULL) || (disp->is_focused == NULL))
578 {
579 return gate_ui_winapi_is_focused(ctrl);
580 }
581 return disp->is_focused(ctrl);
582
583 }
584 gate_result_t gate_ui_ctrl_get_position(gate_ui_ctrl_t* ctrl, gate_ui_position_t* position)
585 {
586 gate_ui_winapi_dispatchers_t* disp;
587 if (ctrl == NULL)
588 {
589 return GATE_RESULT_NULLPOINTER;
590 }
591 disp = GATE_UI_WINAPI_GET_DISPATCHER(ctrl);
592 if ((disp == NULL) || (disp->get_position == NULL))
593 {
594 return gate_ui_winapi_get_position(ctrl, position);
595 }
596 return disp->get_position(ctrl, position);
597 }
598 gate_result_t gate_ui_ctrl_get_size(gate_ui_ctrl_t* ctrl, gate_ui_size_t* size)
599 {
600 gate_ui_winapi_dispatchers_t* disp;
601 if (ctrl == NULL)
602 {
603 return GATE_RESULT_NULLPOINTER;
604 }
605 disp = GATE_UI_WINAPI_GET_DISPATCHER(ctrl);
606 if ((disp == NULL) || (disp->get_size == NULL))
607 {
608 return gate_ui_winapi_get_size(ctrl, size);
609 }
610 return disp->get_size(ctrl, size);
611 }
612 gate_result_t gate_ui_ctrl_get_children(gate_ui_ctrl_t* ctrl, gate_array_t* children)
613 {
614 gate_ui_winapi_dispatchers_t* disp;
615 if (ctrl == NULL)
616 {
617 return GATE_RESULT_NULLPOINTER;
618 }
619 disp = GATE_UI_WINAPI_GET_DISPATCHER(ctrl);
620 if ((disp == NULL) || (disp->get_children == NULL))
621 {
622 return gate_ui_winapi_get_children(ctrl, children);
623 }
624 return disp->get_children(ctrl, children);
625 }
626 gate_result_t gate_ui_ctrl_get_text_length(gate_ui_ctrl_t* ctrl, gate_uint32_t* length)
627 {
628 gate_ui_winapi_dispatchers_t* disp;
629 if (ctrl == NULL)
630 {
631 return GATE_RESULT_NULLPOINTER;
632 }
633 disp = GATE_UI_WINAPI_GET_DISPATCHER(ctrl);
634 if ((disp == NULL) || (disp->get_text == NULL))
635 {
636 return gate_ui_winapi_get_text_length(ctrl, length);
637 }
638 return disp->get_text_length(ctrl, length);
639 }
640
641 gate_result_t gate_ui_ctrl_get_text(gate_ui_ctrl_t* ctrl, gate_string_t* text)
642 {
643 gate_ui_winapi_dispatchers_t* disp;
644 if (ctrl == NULL)
645 {
646 return GATE_RESULT_NULLPOINTER;
647 }
648 disp = GATE_UI_WINAPI_GET_DISPATCHER(ctrl);
649 if ((disp == NULL) || (disp->get_text == NULL))
650 {
651 return gate_ui_winapi_get_text(ctrl, text);
652 }
653 return disp->get_text(ctrl, text);
654 }
655 gate_result_t gate_ui_ctrl_get_state(gate_ui_ctrl_t* ctrl, gate_int32_t* state)
656 {
657 gate_ui_winapi_dispatchers_t* disp;
658 if (ctrl == NULL)
659 {
660 return GATE_RESULT_NULLPOINTER;
661 }
662 disp = GATE_UI_WINAPI_GET_DISPATCHER(ctrl);
663 if ((disp == NULL) || (disp->get_state == NULL))
664 {
665 return gate_ui_winapi_get_state(ctrl, state);
666 }
667 return disp->get_state(ctrl, state);
668 }
669
670 gate_result_t gate_ui_ctrl_set_enabled(gate_ui_ctrl_t* ctrl, gate_bool_t enabledstate)
671 {
672 gate_ui_winapi_dispatchers_t* disp;
673 if (ctrl == NULL)
674 {
675 return GATE_RESULT_NULLPOINTER;
676 }
677 disp = GATE_UI_WINAPI_GET_DISPATCHER(ctrl);
678 if ((disp == NULL) || (disp->set_enabled == NULL))
679 {
680 return gate_ui_winapi_set_enabled(ctrl, enabledstate);
681 }
682 return disp->set_enabled(ctrl, enabledstate);
683 }
684 gate_result_t gate_ui_ctrl_set_visible(gate_ui_ctrl_t* ctrl, gate_bool_t visibility)
685 {
686 gate_ui_winapi_dispatchers_t* disp;
687 if (ctrl == NULL)
688 {
689 return GATE_RESULT_NULLPOINTER;
690 }
691 disp = GATE_UI_WINAPI_GET_DISPATCHER(ctrl);
692 if ((disp == NULL) || (disp->set_visible == NULL))
693 {
694 return gate_ui_winapi_set_visible(ctrl, visibility);
695 }
696 return disp->set_visible(ctrl, visibility);
697 }
698 gate_result_t gate_ui_ctrl_set_focus(gate_ui_ctrl_t* ctrl)
699 {
700 gate_ui_winapi_dispatchers_t* disp;
701 if (ctrl == NULL)
702 {
703 return GATE_RESULT_NULLPOINTER;
704 }
705 disp = GATE_UI_WINAPI_GET_DISPATCHER(ctrl);
706 if ((disp == NULL) || (disp->set_focus == NULL))
707 {
708 return gate_ui_winapi_set_focus(ctrl);
709 }
710 return disp->set_focus(ctrl);
711 }
712 gate_result_t gate_ui_ctrl_set_position(gate_ui_ctrl_t* ctrl, gate_ui_point_t const* position, gate_ui_size_t const* size)
713 {
714 gate_ui_winapi_dispatchers_t* disp;
715 if (ctrl == NULL)
716 {
717 return GATE_RESULT_NULLPOINTER;
718 }
719 disp = GATE_UI_WINAPI_GET_DISPATCHER(ctrl);
720 if ((disp == NULL) || (disp->set_position == NULL))
721 {
722 return gate_ui_winapi_set_position(ctrl, position, size);
723 }
724 return disp->set_position(ctrl, position, size);
725 }
726 gate_result_t gate_ui_ctrl_set_text(gate_ui_ctrl_t* ctrl, gate_string_t const* text)
727 {
728 gate_ui_winapi_dispatchers_t* disp;
729 if (ctrl == NULL)
730 {
731 return GATE_RESULT_NULLPOINTER;
732 }
733 disp = GATE_UI_WINAPI_GET_DISPATCHER(ctrl);
734 if ((disp == NULL) || (disp->set_text == NULL))
735 {
736 return gate_ui_winapi_set_text(ctrl, text);
737 }
738 return disp->set_text(ctrl, text);
739 }
740 gate_result_t gate_ui_ctrl_set_state(gate_ui_ctrl_t* ctrl, gate_int32_t state)
741 {
742 gate_ui_winapi_dispatchers_t* disp;
743 if (ctrl == NULL)
744 {
745 return GATE_RESULT_NULLPOINTER;
746 }
747 disp = GATE_UI_WINAPI_GET_DISPATCHER(ctrl);
748 if ((disp == NULL) || (disp->set_state == NULL))
749 {
750 return gate_ui_winapi_set_state(ctrl, state);
751 }
752 return disp->set_state(ctrl, state);
753 }
754
755 gate_result_t gate_ui_ctrl_refresh(gate_ui_ctrl_t* ctrl)
756 {
757 gate_ui_winapi_dispatchers_t* disp;
758 if (ctrl == NULL)
759 {
760 return GATE_RESULT_NULLPOINTER;
761 }
762 disp = GATE_UI_WINAPI_GET_DISPATCHER(ctrl);
763 if ((disp == NULL) || (disp->refresh == NULL))
764 {
765 return gate_ui_winapi_refresh(ctrl);
766 }
767 return disp->refresh(ctrl);
768
769 }
770
771 typedef struct gate_ui_host_enum_fonts_helper
772 {
773 gate_ui_enum_fontnames_callback_t cb;
774 void* userparam;
775 } gate_ui_host_enum_fonts_helper_t;
776
777 #if defined(GATE_SYS_WIN16)
778 static int CALLBACK gate_ui_host_enum_fonts_callback(LOGFONT const FAR* lplf, TEXTMETRIC const FAR* lptm, int dwType, LPARAM lpData)
779 #else
780 static int CALLBACK gate_ui_host_enum_fonts_callback(LOGFONT const* lplf, TEXTMETRIC const* lptm, DWORD dwType, LPARAM lpData)
781 #endif
782 {
783 gate_ui_host_enum_fonts_helper_t* helper = (gate_ui_host_enum_fonts_helper_t*)(void*)(gate_intptr_t)lpData;
784 char fontname[128];
785
786 GATE_UNUSED_ARG(lptm);
787 GATE_UNUSED_ARG(dwType);
788 gate_win32_winstr_2_utf8(lplf->lfFaceName, gate_win32_str_len(lplf->lfFaceName), fontname, sizeof(fontname));
789
790 helper->cb(fontname, helper->userparam);
791 return TRUE;
792 }
793
794 gate_result_t gate_ui_host_enum_fonts(gate_ui_host_t* host, gate_ui_enum_fontnames_callback_t callback, void* userparam)
795 {
796 gate_result_t ret;
797 gate_ui_host_enum_fonts_helper_t helper;
798 HDC hdc;
799 GATE_UNUSED_ARG(host);
800 hdc = CreateDC(_T("DISPLAY"), NULL, NULL, NULL);
801 if (!hdc)
802 {
803 ret = GATE_RESULT_OUTOFRESOURCES;
804 }
805 else
806 {
807 helper.cb = callback;
808 helper.userparam = userparam;
809 EnumFonts(hdc, NULL, &gate_ui_host_enum_fonts_callback, (LPARAM)(gate_intptr_t)(void*)&helper);
810 ret = GATE_RESULT_OK;
811 }
812 return ret;
813
814 }
815 gate_result_t gate_ui_host_default_font(gate_ui_host_t* host, gate_uint32_t fonttype, gate_ui_font_t* font)
816 {
817 gate_result_t ret = GATE_RESULT_OK;
818 GATE_UNUSED_ARG(host);
819
820 ret = gate_ui_winapi_get_default_font(font);
821 if (GATE_SUCCEEDED(ret))
822 {
823 switch (fonttype)
824 {
825 case GATE_UI_FONT_TYPE_STANDARD:
826 {
827 break;
828 }
829 case GATE_UI_FONT_TYPE_SANSSERIF:
830 {
831 gate_mem_copy(&font->font_name[0], "Arial", 6);
832 break;
833 }
834 case GATE_UI_FONT_TYPE_SERIF:
835 {
836 gate_mem_copy(&font->font_name[0], "Times New Roman", 16);
837 break;
838 }
839 case GATE_UI_FONT_TYPE_MONOSPACE:
840 {
841 gate_mem_copy(&font->font_name[0], "Courier New", 12);
842 break;
843 }
844 default:
845 {
846 ret = GATE_RESULT_INVALIDARG;
847 break;
848 }
849 }
850 }
851 return ret;
852 }
853
854 #define GATE_UI_HOST_DEFAULT_DPI_VALUE 96
855
856 static gate_int32_t gate_ui_host_get_default_dpi()
857 {
858 static gate_int32_t cached_dpi_value = 0;
859 gate_int32_t ret = GATE_UI_HOST_DEFAULT_DPI_VALUE;
860
861 if (cached_dpi_value == 0)
862 {
863 int tmp = GATE_UI_HOST_DEFAULT_DPI_VALUE;
864 HDC hdc_screen = GetDC(NULL);
865 if (hdc_screen)
866 {
867 tmp = GetDeviceCaps(hdc_screen, LOGPIXELSY);
868 if (tmp == 0)
869 {
870 tmp = GATE_UI_HOST_DEFAULT_DPI_VALUE;
871 }
872 ReleaseDC(NULL, hdc_screen);
873 }
874 cached_dpi_value = tmp;
875 ret = tmp;
876 }
877 else
878 {
879 ret = cached_dpi_value;
880 }
881 return ret;
882 }
883
884 gate_int32_t gate_ui_host_get_pixels_in_points(gate_ui_host_t* host, gate_real32_t points)
885 {
886 gate_int32_t dpi = gate_ui_host_get_default_dpi();
887 (void)host;
888 return (gate_int32_t)((points * (gate_real32_t)dpi / 72.0f) + 0.5f);
889 }
890 gate_real32_t gate_ui_host_get_points_in_pixels(gate_ui_host_t* host, gate_int32_t pixels)
891 {
892 gate_int32_t dpi = gate_ui_host_get_default_dpi();
893 gate_int32_t tmp = (gate_int32_t)((pixels * 72.0f / (gate_real32_t)dpi) + 0.5f);
894 (void)host;
895 return (gate_real32_t)tmp;
896 }
897
898 #if defined(GATE_UI_WINAPI_DARKMODE_SUPPORT)
899 static gate_ui_color_t dark_color_window_background = { 0x00, 0x00, 0x00, 0xff };
900 static gate_ui_color_t dark_color_window_text = { 0xff, 0xff, 0xff, 0xff };
901 static gate_ui_color_t dark_color_window_text_disabled = { 0xcc, 0xcc, 0xcc, 0xff };
902
903 static gate_ui_color_t dark_color_menu_background = { 0x2b, 0x2b, 0x2b, 0xff };
904 static gate_ui_color_t dark_color_menu_selected = { 0x41, 0x41, 0x41, 0xff };
905 static gate_ui_color_t dark_color_menu_text = { 0xff, 0xff, 0xff, 0xff };
906
907 static gate_ui_color_t dark_color_content_background = { 0x19, 0x19, 0x19, 0xff };
908 static gate_ui_color_t dark_color_content_text = { 0xff, 0xff, 0xff, 0xff };
909 static gate_ui_color_t dark_color_content_text_disabled = { 0xcc, 0xcc, 0xcc, 0xff };
910 static gate_ui_color_t dark_color_content_selected = { 0x33, 0x33, 0x33, 0xff };
911 static gate_ui_color_t dark_color_content_focus = { 0x62, 0x62, 0x62, 0xff };
912 static gate_ui_color_t dark_color_content_hilight = { 0x77, 0x77, 0x77, 0xff };
913
914 static gate_ui_color_t dark_color_control_background = { 0x20, 0x20, 0x20, 0xff };
915 static gate_ui_color_t dark_color_control_text = { 0xff, 0xff, 0xff, 0xff };
916 static gate_ui_color_t dark_color_control_text_disabled = { 0xcc, 0xcc, 0xcc, 0xff };
917
918 static gate_ui_color_t dark_color_border_light = { 0xa0, 0xa0, 0xa0, 0xff };
919 static gate_ui_color_t dark_color_border_dark = { 0x12, 0x12, 0x12, 0xff };
920
921 /* Content - Hilight : 4d4d4d */
922
923 #endif
924
925 gate_result_t gate_ui_host_default_color(gate_ui_host_t* host, gate_uint32_t colortype, gate_ui_color_t* col)
926 {
927 int syscolor;
928 COLORREF color;
929 /*gate_result_t result; */
930 /*wchar_t const* theme_color_name = NULL;*/
931 #if !defined(GATE_SYS_WIN16)
932 gate_ui_color_t* ptr_col = NULL;
933 #endif
934 GATE_UNUSED_ARG(host);
935
936 #if defined(GATE_UI_WINAPI_DARKMODE_SUPPORT)
937 if (gate_ui_winapi_darkmode_enabled())
938 {
939 switch (colortype)
940 {
941 case GATE_UI_COLOR_BACKGROUND:
942 case GATE_UI_COLOR_WORKSPACE:
943 case GATE_UI_COLOR_WINDOW: ptr_col = &dark_color_window_background; break;
944 case GATE_UI_COLOR_WINDOWTEXT: ptr_col = &dark_color_window_text; break;
945 case GATE_UI_COLOR_WINDOWTEXTDISABLED: ptr_col = &dark_color_window_text_disabled; break;
946
947 case GATE_UI_COLOR_DIALOG: ptr_col = &dark_color_control_background; break;
948 case GATE_UI_COLOR_DIALOGTEXT: ptr_col = &dark_color_control_text; break;
949 case GATE_UI_COLOR_DIALOGTEXTDISABLED: ptr_col = &dark_color_control_text_disabled;break;
950
951 case GATE_UI_COLOR_CONTROL: ptr_col = &dark_color_control_background; break;
952 case GATE_UI_COLOR_CONTROLTEXT: ptr_col = &dark_color_control_text; break;
953 case GATE_UI_COLOR_CONTROLTEXTDISABLED: ptr_col = &dark_color_control_text_disabled;break;
954
955 case GATE_UI_COLOR_CONTROLBORDERLIGHT: ptr_col = &dark_color_border_light; break;
956 case GATE_UI_COLOR_CONTROLBORDERHILIGHT: ptr_col = &dark_color_border_light; break;
957 case GATE_UI_COLOR_CONTROLBORDERSHADOW: ptr_col = &dark_color_border_dark; break;
958 case GATE_UI_COLOR_CONTROLBORDERDARKSHADOW: ptr_col = &dark_color_border_dark; break;
959
960 case GATE_UI_COLOR_MENUBACKGROUND: ptr_col = &dark_color_menu_background; break;
961 case GATE_UI_COLOR_MENUTEXT: ptr_col = &dark_color_menu_text; break;
962 case GATE_UI_COLOR_SELECTEDMENUBACKGROUND: ptr_col = &dark_color_menu_selected; break;
963 case GATE_UI_COLOR_SELECTEDMENUTEXT: ptr_col = &dark_color_menu_text; break;
964 case GATE_UI_COLOR_HOVERMENUBACKGROUND: ptr_col = &dark_color_menu_selected; break;
965 case GATE_UI_COLOR_HOVERMENUTEXT: ptr_col = &dark_color_menu_text; break;
966
967 case GATE_UI_COLOR_CONTENTBACKGROUND: ptr_col = &dark_color_content_background; break;
968 case GATE_UI_COLOR_CONTENTTEXT: ptr_col = &dark_color_content_text; break;
969 case GATE_UI_COLOR_CONTENTTEXTDISABLED: ptr_col = &dark_color_content_text_disabled;break;
970 case GATE_UI_COLOR_CONTENTSELECTEDBACKGROUND: ptr_col = &dark_color_content_selected; break;
971 case GATE_UI_COLOR_CONTENTSELECTEDTEXT: ptr_col = &dark_color_content_text; break;
972 case GATE_UI_COLOR_CONTENTBORDERLIGHT: ptr_col = &dark_color_border_light; break;
973 case GATE_UI_COLOR_CONTENTBORDERHILIGHT: ptr_col = &dark_color_border_light; break;
974 case GATE_UI_COLOR_CONTENTBORDERSHADOW: ptr_col = &dark_color_border_dark; break;
975 case GATE_UI_COLOR_CONTENTBORDERDARKSHADOW: ptr_col = &dark_color_border_dark; break;
976 }
977
978 if (ptr_col != NULL)
979 {
980 if (col)
981 {
982 *col = *ptr_col;
983 }
984 return GATE_RESULT_OK;
985 }
986 }
987 #endif /* GATE_UI_WINAPI_DARKMODE_SUPPORT */
988
989 /* default win32 colors */
990 syscolor = gate_ui_winapi_get_syscolor_index(colortype);
991
992 if (syscolor == -1)
993 {
994 return GATE_RESULT_NOTSUPPORTED;
995 }
996 else
997 {
998 color = GetSysColor(syscolor);
999 if (col != NULL)
1000 {
1001 col->r = GetRValue(color);
1002 col->g = GetGValue(color);
1003 col->b = GetBValue(color);
1004 col->a = 255;
1005 }
1006 return GATE_RESULT_OK;
1007 }
1008 }
1009
1010 gate_result_t gate_ui_host_clipboard_get_text(gate_ui_host_t* host, gate_string_t* text)
1011 {
1012 gate_result_t ret;
1013 HWND appwnd = GATE_UI_WINAPI_GET_HOST_APPWND(host);
1014 HANDLE hdata;
1015 LPVOID ptrdata;
1016 gate_strbuilder_t builder;
1017 do
1018 {
1019 if (!appwnd)
1020 {
1021 ret = GATE_RESULT_NOTAVAILABLE;
1022 break;
1023 }
1024
1025 if (IsClipboardFormatAvailable(CF_TEXT))
1026 {
1027 if (!OpenClipboard(appwnd))
1028 {
1029 ret = GATE_RESULT_NOTAVAILABLE;
1030 break;
1031 }
1032
1033 ret = GATE_RESULT_OK;
1034 hdata = GetClipboardData(CF_TEXT);
1035
1036 if (hdata == NULL)
1037 {
1038 gate_string_create_empty(text);
1039 }
1040 else
1041 {
1042 ptrdata = GlobalLock(hdata);
1043 if (ptrdata == NULL)
1044 {
1045 gate_string_create_empty(text);
1046 }
1047 else
1048 {
1049 gate_string_create(text, (gate_char8_t const*)ptrdata, gate_str_length((gate_char8_t const*)ptrdata));
1050 }
1051 GlobalUnlock(hdata);
1052 }
1053 CloseClipboard();
1054 }
1055 else if (IsClipboardFormatAvailable(CF_OEMTEXT))
1056 {
1057 if (!OpenClipboard(appwnd))
1058 {
1059 ret = GATE_RESULT_NOTAVAILABLE;
1060 break;
1061 }
1062
1063 ret = GATE_RESULT_OK;
1064 hdata = GetClipboardData(CF_OEMTEXT);
1065
1066 if (hdata == NULL)
1067 {
1068 gate_string_create_empty(text);
1069 }
1070 else
1071 {
1072 ptrdata = GlobalLock(hdata);
1073 if (ptrdata == NULL)
1074 {
1075 gate_string_create_empty(text);
1076 }
1077 else
1078 {
1079 gate_string_create(text, (gate_char8_t const*)ptrdata, gate_str_length((gate_char8_t const*)ptrdata));
1080 }
1081 GlobalUnlock(hdata);
1082 }
1083 CloseClipboard();
1084 }
1085 #if !defined(GATE_SYS_WIN16)
1086 else if (IsClipboardFormatAvailable(CF_UNICODETEXT))
1087 {
1088 if (!OpenClipboard(appwnd))
1089 {
1090 ret = GATE_RESULT_NOTAVAILABLE;
1091 break;
1092 }
1093
1094 ret = GATE_RESULT_OK;
1095 hdata = GetClipboardData(CF_UNICODETEXT);
1096
1097 if (hdata == NULL)
1098 {
1099 gate_string_create_empty(text);
1100 }
1101 else
1102 {
1103 ptrdata = GlobalLock(hdata);
1104 if (ptrdata == NULL)
1105 {
1106 gate_string_create_empty(text);
1107 }
1108 else
1109 {
1110 gate_strbuilder_create(&builder, 0);
1111 gate_strbuilder_append_text16(&builder, (wchar_t const*)ptrdata, gate_str16_length((wchar_t const*)ptrdata));
1112 gate_strbuilder_to_string(&builder, text);
1113 gate_strbuilder_release(&builder);
1114 }
1115 GlobalUnlock(hdata);
1116 }
1117 CloseClipboard();
1118 }
1119 #endif /* GATE_SYS_WIN16 */
1120 else
1121 {
1122 ret = GATE_RESULT_INVALIDCONTENT;
1123 break;
1124 }
1125 } while (0);
1126
1127 return ret;
1128 }
1129 gate_result_t gate_ui_host_clipboard_set_text(gate_ui_host_t* host, gate_string_t const* text)
1130 {
1131 gate_result_t ret;
1132 HWND appwnd = GATE_UI_WINAPI_GET_HOST_APPWND(host);
1133 gate_size_t textlen;
1134 HGLOBAL memhandle;
1135 LPVOID memptr;
1136
1137 do
1138 {
1139 if (appwnd == NULL)
1140 {
1141 ret = GATE_RESULT_NOTAVAILABLE;
1142 break;
1143 }
1144 if (!OpenClipboard(appwnd))
1145 {
1146 ret = GATE_RESULT_NOTAVAILABLE;
1147 break;
1148 }
1149
1150 EmptyClipboard();
1151
1152 do
1153 {
1154 textlen = gate_string_length(text);
1155 if (textlen == 0)
1156 {
1157 ret = GATE_RESULT_OK;
1158 break; /* we are done */
1159 }
1160
1161 #if !defined(GATE_SYS_WIN16)
1162 /* write UTF16 text */
1163 memhandle = GlobalAlloc(GMEM_MOVEABLE, ((textlen + 2) * sizeof(gate_char16_t)));
1164 if (memhandle == NULL)
1165 {
1166 CloseClipboard();
1167 ret = GATE_RESULT_OUTOFMEMORY;
1168 break;
1169 }
1170 memptr = GlobalLock(memhandle);
1171 gate_str_utf8_2_utf16(text->str, text->length, memptr, textlen + 1);
1172 GlobalUnlock(memhandle);
1173 if (SetClipboardData(CF_UNICODETEXT, memhandle))
1174 {
1175 ret = GATE_RESULT_OK;
1176 break;
1177 }
1178 else
1179 {
1180 ret = GATE_RESULT_FAILED;
1181 GlobalFree(memhandle);
1182 break;
1183 }
1184 #endif /* GATE_SYS_WIN16 */
1185
1186 /* write plain text */
1187 memhandle = GlobalAlloc(GMEM_MOVEABLE, ((textlen + 2) * sizeof(gate_char8_t)));
1188 if (memhandle == NULL)
1189 {
1190 CloseClipboard();
1191 ret = GATE_RESULT_OUTOFMEMORY;
1192 break;
1193 }
1194 memptr = GlobalLock(memhandle);
1195 gate_str_print_text((gate_char8_t*)memptr, textlen + 2, text->str, text->length);
1196 GlobalUnlock(memhandle);
1197 if (!SetClipboardData(CF_OEMTEXT, memhandle))
1198 {
1199 GlobalFree(memhandle);
1200 ret = GATE_RESULT_FAILED;
1201 break;
1202 }
1203
1204 /* success state reached */
1205 ret = GATE_RESULT_OK;
1206 } while (0);
1207 CloseClipboard();
1208 } while (0);
1209
1210 return ret;
1211 }
1212
1213 gate_result_t gate_ui_host_default_workarea(gate_ui_host_t* host, gate_ui_position_t* area)
1214 {
1215 RECT r = GATE_INIT_EMPTY;
1216 #if !defined(GATE_SYS_WIN16)
1217 gate_win32_userapi_t const* const userapi = gate_win32_userapi();
1218 /* try param info first */
1219 if (userapi->UserSystemParametersInfo)
1220 {
1221 if (userapi->UserSystemParametersInfo(SPI_GETWORKAREA, 0, &r, 0))
1222 {
1223 area->pos.x = r.left;
1224 area->pos.y = r.top;
1225 area->size.width = r.right - r.left;
1226 area->size.height = r.bottom - r.top;
1227 return GATE_RESULT_OK;
1228 }
1229 }
1230 #endif
1231 /* fallback: */
1232 return gate_ui_host_total_workarea(host, area);
1233 }
1234
1235 #ifndef SM_XVIRTUALSCREEN
1236 #define SM_XVIRTUALSCREEN 76
1237 #endif
1238 #ifndef SM_YVIRTUALSCREEN
1239 #define SM_YVIRTUALSCREEN 77
1240 #endif
1241 #ifndef SM_CXVIRTUALSCREEN
1242 #define SM_CXVIRTUALSCREEN 78
1243 #endif
1244 #ifndef SM_CYVIRTUALSCREEN
1245 #define SM_CYVIRTUALSCREEN 79
1246 #endif
1247
1248 gate_result_t gate_ui_host_total_workarea(gate_ui_host_t* host, gate_ui_position_t* area)
1249 {
1250 GATE_UNUSED_ARG(host);
1251 area->pos.x = GetSystemMetrics(SM_XVIRTUALSCREEN);
1252 area->pos.y = GetSystemMetrics(SM_YVIRTUALSCREEN);
1253 area->size.width = GetSystemMetrics(SM_CXVIRTUALSCREEN);
1254 area->size.height = GetSystemMetrics(SM_CYVIRTUALSCREEN);
1255 if (area->size.width == 0)
1256 {
1257 area->size.width = GetSystemMetrics(SM_CXSCREEN);
1258 }
1259 if (area->size.height == 0)
1260 {
1261 area->size.height = GetSystemMetrics(SM_CYSCREEN);
1262 }
1263 return GATE_RESULT_OK;
1264 }
1265
1266 gate_result_t gate_ui_host_execute(gate_ui_host_t* host, gate_runnable_t* code)
1267 {
1268 return gate_ui_winapi_host_post_runner(host, code, true, true);
1269 }
1270
1271 gate_result_t gate_ui_host_process_events(gate_ui_host_t* host)
1272 {
1273 return gate_ui_winapi_host_process_msg(host);
1274 }
1275
1276
1277
1278 #endif /* GATE_SYS_WIN */
1279
1280
1281
1282 #if defined(GATE_UI_GTK)
1283
1284 #include "gate/ui/gateui_gtk.h"
1285
1286 gate_result_t gate_ui_host_init(gate_ui_host_t* host, gate_uintptr_t apphandle, void* userparam)
1287 {
1288 return gate_ui_gtk_host_init(host, apphandle, userparam);
1289 }
1290 gate_result_t gate_ui_host_uninit(gate_ui_host_t* host)
1291 {
1292 return gate_ui_gtk_host_uninit(host);
1293 }
1294 gate_result_t gate_ui_host_run(gate_ui_host_t* host)
1295 {
1296 return gate_ui_gtk_host_run(host);
1297 }
1298 gate_result_t gate_ui_host_quit(gate_ui_host_t* host)
1299 {
1300 return gate_ui_gtk_host_quit(host);
1301 }
1302 void* gate_ui_host_get_userparam(gate_ui_host_t* host)
1303 {
1304 return GATE_UI_GTK_GET_HOST_USER_PARAM(host);
1305 }
1306 gate_uintptr_t gate_ui_host_get_apphandle(gate_ui_host_t* host)
1307 {
1308 return GATE_UI_GTK_GET_HOST_APPHANDLE(host);
1309 }
1310 gate_uint32_t gate_ui_host_default_line_height(gate_ui_host_t* host)
1311 {
1312 return 16;
1313 }
1314 gate_uint32_t gate_ui_host_default_control_height(gate_ui_host_t* host, gate_uint32_t line_count)
1315 {
1316 gate_uint32_t height = 14 + line_count * gate_ui_host_default_line_height(host);
1317 return height;
1318 }
1319
1320 gate_result_t gate_ui_host_enum_fonts(gate_ui_host_t* host, gate_ui_enum_fontnames_callback_t callback, void* userparam)
1321 {
1322 gate_result_t ret = GATE_RESULT_FAILED;
1323 PangoFontMap* font_map = pango_cairo_font_map_get_default(); /* must not be freed */
1324 PangoFontFamily** families = NULL;
1325 int families_count = 0;
1326 int index;
1327 char const* name = NULL;
1328
1329 do
1330 {
1331 if (!font_map)
1332 {
1333 ret = GATE_RESULT_OUTOFRESOURCES;
1334 break;
1335 }
1336 pango_font_map_list_families(font_map, &families, &families_count);
1337
1338 if (families_count <= 0)
1339 {
1340 ret = GATE_RESULT_NOTAVAILABLE;
1341 break;
1342 }
1343
1344 ret = GATE_RESULT_OK;
1345
1346 for (index = 0; index != families_count; ++index)
1347 {
1348 name = pango_font_family_get_name(families[index]);
1349 if (!name)
1350 {
1351 continue;
1352 }
1353 pango_font_family_is_monospace(families[index]);
1354
1355 if (callback)
1356 {
1357 if (!callback(name, userparam))
1358 {
1359 /* cancelled by user */
1360 break;
1361 }
1362 }
1363 }
1364
1365 } while (0);
1366
1367 if (families)
1368 {
1369 g_free(families);
1370 }
1371
1372 return ret;
1373 }
1374
1375 static gate_bool_t gate_ui_enum_fontnames_callback_test(char const* font_name, void* userparam)
1376 {
1377 return true;
1378 }
1379
1380 gate_result_t gate_ui_host_default_font(gate_ui_host_t* host, gate_uint32_t fonttype, gate_ui_font_t* font)
1381 {
1382 gate_ui_host_enum_fonts(host, &gate_ui_enum_fontnames_callback_test, NULL);
1383 gate_str_print_text(font->font_name, sizeof(font->font_name), "Monospace", 9);
1384 font->size = 12;
1385 font->orientation = 0;
1386 font->bold = false;
1387 font->italic = false;
1388 font->underline = false;
1389 font->strikeout = false;
1390
1391 return GATE_RESULT_OK;
1392 }
1393 gate_int32_t gate_ui_host_get_pixels_in_points(gate_ui_host_t* host, gate_real32_t points)
1394 {
1395 gate_int32_t dpi = 96;
1396 gate_int32_t fppi = 72;
1397 return (gate_int32_t)(points * dpi / fppi);
1398 }
1399 gate_real32_t gate_ui_host_get_points_in_pixels(gate_ui_host_t* host, gate_int32_t pixels)
1400 {
1401 gate_real32_t dpi = 96.0f;
1402 gate_real32_t fppi = 72.0f;
1403 return (gate_real32_t)pixels * fppi / dpi;
1404 }
1405
1406 gate_result_t gate_ui_host_default_color(gate_ui_host_t* host, gate_uint32_t colortype, gate_ui_color_t* col)
1407 {
1408 return GATE_RESULT_NOTIMPLEMENTED;
1409 }
1410 gate_result_t gate_ui_host_clipboard_get_text(gate_ui_host_t* host, gate_string_t* text)
1411 {
1412 return GATE_RESULT_NOTIMPLEMENTED;
1413 }
1414 gate_result_t gate_ui_host_clipboard_set_text(gate_ui_host_t* host, gate_string_t const* text)
1415 {
1416 return GATE_RESULT_NOTIMPLEMENTED;
1417 }
1418 gate_result_t gate_ui_host_default_workarea(gate_ui_host_t* host, gate_ui_position_t* area)
1419 {
1420 return GATE_RESULT_NOTIMPLEMENTED;
1421 }
1422 gate_result_t gate_ui_host_total_workarea(gate_ui_host_t* host, gate_ui_position_t* area)
1423 {
1424 return GATE_RESULT_NOTIMPLEMENTED;
1425 }
1426 gate_result_t gate_ui_host_process_events(gate_ui_host_t* host)
1427 {
1428 /* TODO */
1429 return GATE_RESULT_OK;
1430 }
1431
1432
1433
1434
1435
1436 void* gate_ui_ctrl_get_userparam(gate_ui_ctrl_t* ctrl)
1437 {
1438 if (ctrl != NULL)
1439 {
1440 return GATE_UI_GTK_GET_CTRL_USER_PARAM(ctrl);
1441 }
1442 return NULL;
1443 }
1444 gate_ui_host_t* gate_ui_ctrl_get_host(gate_ui_ctrl_t* ctrl)
1445 {
1446 if (ctrl != NULL)
1447 {
1448 return GATE_UI_GTK_GET_CTRL_HOST(ctrl);
1449 }
1450 return NULL;
1451 }
1452 gate_ui_ctrl_t* gate_ui_ctrl_get_parent(gate_ui_ctrl_t* ctrl)
1453 {
1454 if (ctrl != NULL)
1455 {
1456
1457 }
1458 return NULL;
1459 }
1460
1461 gate_result_t gate_ui_ctrl_destroy(gate_ui_ctrl_t* ctrl)
1462 {
1463 gate_array_t children;
1464 gate_result_t ret;
1465 gate_size_t children_count;
1466 gate_ui_ctrl_t* const* ptr_child;
1467
1468 do
1469 {
1470 if (ctrl == NULL)
1471 {
1472 ret = GATE_RESULT_NULLPOINTER;
1473 break;
1474 }
1475 ret = gate_ui_ctrl_get_children(ctrl, &children);
1476 if (GATE_SUCCEEDED(ret))
1477 {
1478 children_count = gate_array_length(&children);
1479 ptr_child = (gate_ui_ctrl_t* const*)gate_array_get(&children, 0);
1480 while (children_count-- != 0)
1481 {
1482 if (*ptr_child)
1483 {
1484 gate_ui_ctrl_destroy(*ptr_child);
1485 }
1486 ++ptr_child;
1487 }
1488 gate_array_release(&children);
1489 }
1490
1491 ret = gate_ui_gtk_ctrl_destroy(ctrl);
1492 } while (0);
1493 return ret;
1494 }
1495 gate_bool_t gate_ui_ctrl_is_created(gate_ui_ctrl_t* ctrl)
1496 {
1497 gate_bool_t ret = false;
1498 if (ctrl != NULL)
1499 {
1500 ret = GATE_UI_GTK_GET_CTRL_WIDGET(ctrl) != NULL;
1501 }
1502 return ret;
1503 }
1504 gate_bool_t gate_ui_ctrl_is_enabled(gate_ui_ctrl_t* ctrl)
1505 {
1506 gate_bool_t ret = false;
1507 if (ctrl != NULL)
1508 {
1509 ret = gate_ui_gtk_ctrl_is_enabled(ctrl);
1510 }
1511 return ret;
1512 }
1513 gate_bool_t gate_ui_ctrl_is_visible(gate_ui_ctrl_t* ctrl)
1514 {
1515 gate_bool_t ret = false;
1516 if (ctrl != NULL)
1517 {
1518 ret = gate_ui_gtk_ctrl_is_visible(ctrl);
1519 }
1520 return ret;
1521 }
1522 gate_bool_t gate_ui_ctrl_is_focused(gate_ui_ctrl_t* ctrl)
1523 {
1524 gate_bool_t ret = false;
1525 if (ctrl != NULL)
1526 {
1527 ret = gate_ui_gtk_ctrl_has_focus(ctrl);
1528 }
1529 return ret;
1530 }
1531 gate_result_t gate_ui_ctrl_get_position(gate_ui_ctrl_t* ctrl, gate_ui_position_t* position)
1532 {
1533 if (ctrl != NULL)
1534 {
1535 return gate_ui_gtk_ctrl_get_position(ctrl, position);
1536 }
1537 return GATE_RESULT_NULLPOINTER;
1538 }
1539 gate_result_t gate_ui_ctrl_get_size(gate_ui_ctrl_t* ctrl, gate_ui_size_t* size)
1540 {
1541 if (ctrl != NULL)
1542 {
1543 return gate_ui_gtk_ctrl_get_size(ctrl, size);
1544 }
1545 return GATE_RESULT_NULLPOINTER;
1546 }
1547 gate_result_t gate_ui_ctrl_get_children(gate_ui_ctrl_t* ctrl, gate_array_t* children)
1548 {
1549 if ((ctrl == NULL) || (children == NULL))
1550 {
1551 return GATE_RESULT_NULLPOINTER;
1552 }
1553
1554 return gate_ui_gtk_ctrl_get_children(ctrl, children);
1555 }
1556 gate_result_t gate_ui_ctrl_get_text(gate_ui_ctrl_t* ctrl, gate_string_t* text)
1557 {
1558 gate_ui_gtk_dispatcher_t* disp;
1559 if (ctrl == NULL)
1560 {
1561 return GATE_RESULT_NULLPOINTER;
1562 }
1563 disp = GATE_UI_GTK_GET_CTRL_DISP(ctrl);
1564 if ((disp == NULL) || (disp->get_text == NULL))
1565 {
1566 return GATE_RESULT_NOTSUPPORTED;
1567 }
1568 return disp->get_text(ctrl, text);
1569 }
1570 gate_result_t gate_ui_ctrl_get_text_length(gate_ui_ctrl_t* ctrl, gate_uint32_t* length)
1571 {
1572 gate_ui_gtk_dispatcher_t* disp;
1573 gate_uint32_t l;
1574 if (ctrl == NULL)
1575 {
1576 return GATE_RESULT_NULLPOINTER;
1577 }
1578 disp = GATE_UI_GTK_GET_CTRL_DISP(ctrl);
1579 if ((disp == NULL) || (disp->get_text_length == NULL))
1580 {
1581 return GATE_RESULT_NOTSUPPORTED;
1582 }
1583 l = disp->get_text_length(ctrl);
1584 if (length != NULL)
1585 {
1586 *length = l;
1587 }
1588 return GATE_RESULT_OK;
1589 }
1590 gate_result_t gate_ui_ctrl_set_text(gate_ui_ctrl_t* ctrl, gate_string_t const* text)
1591 {
1592 gate_ui_gtk_dispatcher_t* disp;
1593 if (ctrl == NULL)
1594 {
1595 return GATE_RESULT_NULLPOINTER;
1596 }
1597 disp = GATE_UI_GTK_GET_CTRL_DISP(ctrl);
1598 if ((disp == NULL) || (disp->set_text == NULL))
1599 {
1600 return GATE_RESULT_NOTSUPPORTED;
1601 }
1602 return disp->set_text(ctrl, text);
1603 }
1604 gate_result_t gate_ui_ctrl_get_state(gate_ui_ctrl_t* ctrl, gate_int32_t* state)
1605 {
1606 gate_ui_gtk_dispatcher_t* disp;
1607 if (ctrl == NULL)
1608 {
1609 return GATE_RESULT_NULLPOINTER;
1610 }
1611 disp = GATE_UI_GTK_GET_CTRL_DISP(ctrl);
1612 if ((disp == NULL) || (disp->get_state == NULL))
1613 {
1614 return GATE_RESULT_NOTSUPPORTED;
1615 }
1616 return disp->get_state(ctrl, state);
1617 }
1618 gate_result_t gate_ui_ctrl_set_state(gate_ui_ctrl_t* ctrl, gate_int32_t state)
1619 {
1620 gate_ui_gtk_dispatcher_t* disp;
1621 if (ctrl == NULL)
1622 {
1623 return GATE_RESULT_NULLPOINTER;
1624 }
1625 disp = GATE_UI_GTK_GET_CTRL_DISP(ctrl);
1626 if ((disp == NULL) || (disp->set_state == NULL))
1627 {
1628 return GATE_RESULT_NOTSUPPORTED;
1629 }
1630 return disp->set_state(ctrl, state);
1631 }
1632 gate_result_t gate_ui_ctrl_refresh(gate_ui_ctrl_t* ctrl)
1633 {
1634 gate_ui_gtk_dispatcher_t* disp;
1635 if (ctrl == NULL)
1636 {
1637 return GATE_RESULT_NULLPOINTER;
1638 }
1639 disp = GATE_UI_GTK_GET_CTRL_DISP(ctrl);
1640 if ((disp == NULL) || (disp->refresh == NULL))
1641 {
1642 return gate_ui_gtk_ctrl_refresh(ctrl);
1643 }
1644 return disp->refresh(ctrl);
1645 }
1646
1647
1648 gate_result_t gate_ui_ctrl_set_enabled(gate_ui_ctrl_t* ctrl, gate_bool_t enabledstate)
1649 {
1650 return gate_ui_gtk_ctrl_set_enabled(ctrl, enabledstate);
1651 }
1652 gate_result_t gate_ui_ctrl_set_visible(gate_ui_ctrl_t* ctrl, gate_bool_t visibility)
1653 {
1654 return gate_ui_gtk_ctrl_set_visible(ctrl, visibility);
1655 }
1656 gate_result_t gate_ui_ctrl_set_focus(gate_ui_ctrl_t* ctrl)
1657 {
1658 return gate_ui_gtk_ctrl_set_focus(ctrl);
1659 }
1660 gate_result_t gate_ui_ctrl_set_position(gate_ui_ctrl_t* ctrl, gate_ui_point_t const* position, gate_ui_size_t const* size)
1661 {
1662 return gate_ui_gtk_ctrl_set_position(ctrl, position, size);
1663 }
1664
1665 #endif /*GATE_UI_GTK*/
1666
1667
1668
1669 #if defined(GATE_UI_MOTIF)
1670
1671 #include "gate/ui/gateui_motif.h"
1672 #include "gate/memalloc.h"
1673 #include "gate/debugging.h"
1674
1675 static char gate_ui_motif_app_class[] = "GATE_UI_MOTIF_APP_CLASS";
1676 static char gate_ui_motif_app_name[] = "GATE_UI_MOTIF_APP_NAME";
1677 static char empty_str[] = "";
1678
1679 1 gate_result_t gate_ui_host_init(gate_ui_host_t* host, gate_uintptr_t apphandle, void* userparam)
1680 {
1681 1 gate_result_t ret = GATE_RESULT_FAILED;
1682 1 XtAppContext app = NULL;
1683 1 Display* disp = NULL;
1684 1 Widget root = NULL;
1685 1 char* display_name = NULL;
1686 1 char default_display_name[] = ":0";
1687 1 char* app_name = gate_ui_motif_app_name;
1688 1 char* app_class = gate_ui_motif_app_class;
1689 1 int argc = 0;
1690 1 char* argv[] = { empty_str };
1691
1692 do
1693 {
1694 1 gate_mem_clear(host, sizeof(gate_ui_host_t));
1695 1 XtToolkitInitialize();
1696 1 app = XtCreateApplicationContext();
1697
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if (!app)
1698 {
1699 GATE_DEBUG_TRACE("XtCreateApplicationContext() failed");
1700 ret = GATE_RESULT_OUTOFMEMORY;
1701 break;
1702 }
1703 1 disp = XtOpenDisplay(app, NULL, app_name, app_class, NULL, 0, &argc, argv);
1704
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if (!disp)
1705 {
1706 GATE_DEBUG_TRACE("XtOpenDisplay(NULL) failed");
1707 disp = XtOpenDisplay(app, default_display_name, app_name, app_class, NULL, 0, &argc, argv);
1708 }
1709
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if (!disp)
1710 {
1711 GATE_DEBUG_TRACE("XtOpenDisplay(...) failed");
1712 ret = GATE_RESULT_OUTOFMEMORY;
1713 break;
1714 }
1715
1716 1 GATE_UI_MOTIF_SET_HOST_APPHANDLE(host, app);
1717 1 GATE_UI_MOTIF_SET_HOST_DISPLAY(host, disp);
1718 1 GATE_UI_MOTIF_SET_HOST_USER_PARAM(host, userparam);
1719 1 GATE_UI_MOTIF_SET_HOST_ROOT(host, root);
1720
1721 1 ret = GATE_RESULT_OK;
1722 } while (0);
1723
1724 1 return ret;
1725 }
1726 1 gate_result_t gate_ui_host_uninit(gate_ui_host_t* host)
1727 {
1728 1 XtAppContext ctx = (XtAppContext)GATE_UI_MOTIF_GET_HOST_APPHANDLE(host);
1729 1 Display* disp = GATE_UI_MOTIF_GET_HOST_DISPLAY(host);
1730 1 gate_ui_motif_host_dispatch_pending_events(host, true);
1731
1732 1 XtCloseDisplay(disp);
1733 1 XtDestroyApplicationContext(ctx);
1734 1 gate_mem_clear(host, sizeof(gate_ui_host_t));
1735 1 return GATE_RESULT_OK;
1736 }
1737 1 gate_result_t gate_ui_host_run(gate_ui_host_t* host)
1738 {
1739 1 return gate_ui_motif_host_dispatch_events(host);
1740 }
1741
1742 297415 static Boolean motif_host_quit_worker(XtPointer param)
1743 {
1744 297415 XtAppContext ctx = (XtAppContext)param;
1745
1/2
✓ Branch 0 taken 297415 times.
✗ Branch 1 not taken.
297415 if (ctx)
1746 {
1747 297415 XtAppSetExitFlag(ctx);
1748 }
1749 297415 return FALSE; /* do not call this worker again */
1750 }
1751
1752 1 gate_result_t gate_ui_host_quit(gate_ui_host_t* host)
1753 {
1754 1 XtAppContext ctx = (XtAppContext)GATE_UI_MOTIF_GET_HOST_APPHANDLE(host);
1755 1 return gate_ui_motif_host_add_native_workproc(host, &motif_host_quit_worker, ctx);
1756 }
1757 void* gate_ui_host_get_userparam(gate_ui_host_t* host)
1758 {
1759 return GATE_UI_MOTIF_GET_HOST_USER_PARAM(host);
1760 }
1761 gate_uintptr_t gate_ui_host_get_apphandle(gate_ui_host_t* host)
1762 {
1763 return GATE_UI_MOTIF_GET_HOST_APPHANDLE(host);
1764 }
1765 6 gate_uint32_t gate_ui_host_default_line_height(gate_ui_host_t* host)
1766 {
1767 6 gate_real32_t default_font_size_pt = 10.0f;
1768 6 return (gate_uint32_t)gate_ui_host_get_pixels_in_points(host, default_font_size_pt);
1769 }
1770 6 gate_uint32_t gate_ui_host_default_control_height(gate_ui_host_t* host, gate_uint32_t line_count)
1771 {
1772 6 gate_uint32_t line_height = gate_ui_host_default_line_height(host);
1773 6 return line_height * line_count + (line_height + 5);
1774 }
1775 gate_result_t gate_ui_host_enum_fonts(gate_ui_host_t* host, gate_ui_enum_fontnames_callback_t callback, void* userparam)
1776 {
1777 return GATE_RESULT_NOTIMPLEMENTED;
1778 }
1779 2 gate_result_t gate_ui_host_default_font(gate_ui_host_t* host, gate_uint32_t fonttype, gate_ui_font_t* font)
1780 {
1781 //gate_ui_host_enum_fonts(host, &gate_ui_enum_fontnames_callback_test, NULL);
1782 2 gate_str_print_text(font->font_name, sizeof(font->font_name), "fixed", 5);
1783 2 font->size = 12;
1784 2 font->orientation = 0;
1785 2 font->bold = false;
1786 2 font->italic = false;
1787 2 font->underline = false;
1788 2 font->strikeout = false;
1789
1790 2 return GATE_RESULT_OK;
1791 }
1792
1793 6 static gate_int32_t gate_ui_host_get_default_dpi()
1794 {
1795 6 return 96;
1796 }
1797 6 gate_int32_t gate_ui_host_get_pixels_in_points(gate_ui_host_t* host, gate_real32_t points)
1798 {
1799 6 gate_int32_t dpi = gate_ui_host_get_default_dpi();
1800 (void)host;
1801 6 return (gate_int32_t)((points * (gate_real32_t)dpi / 72.0f) + 0.5f);
1802 }
1803 gate_real32_t gate_ui_host_get_points_in_pixels(gate_ui_host_t* host, gate_int32_t pixels)
1804 {
1805 gate_int32_t dpi = gate_ui_host_get_default_dpi();
1806 gate_int32_t tmp = (gate_int32_t)((pixels * 72.0f / (gate_real32_t)dpi) + 0.5f);
1807 (void)host;
1808 return (gate_real32_t)tmp;
1809 }
1810 gate_result_t gate_ui_host_default_color(gate_ui_host_t* host, gate_uint32_t colortype, gate_ui_color_t* col)
1811 {
1812 return GATE_RESULT_NOTIMPLEMENTED;
1813 }
1814 gate_result_t gate_ui_host_clipboard_get_text(gate_ui_host_t* host, gate_string_t* text)
1815 {
1816 return GATE_RESULT_NOTIMPLEMENTED;
1817 }
1818 gate_result_t gate_ui_host_clipboard_set_text(gate_ui_host_t* host, gate_string_t const* text)
1819 {
1820 return GATE_RESULT_NOTIMPLEMENTED;
1821 }
1822 gate_result_t gate_ui_host_default_workarea(gate_ui_host_t* host, gate_ui_position_t* area)
1823 {
1824 return GATE_RESULT_NOTIMPLEMENTED;
1825 }
1826 gate_result_t gate_ui_host_total_workarea(gate_ui_host_t* host, gate_ui_position_t* area)
1827 {
1828 return GATE_RESULT_NOTIMPLEMENTED;
1829 }
1830 gate_result_t gate_ui_host_execute(gate_ui_host_t* host, gate_runnable_t* code)
1831 {
1832 return gate_ui_motif_host_add_workproc(host, code);
1833 }
1834 gate_result_t gate_ui_host_process_events(gate_ui_host_t* host)
1835 {
1836 return gate_ui_motif_host_dispatch_pending_events(host, false);
1837 }
1838
1839
1840
1841 9 void* gate_ui_ctrl_get_userparam(gate_ui_ctrl_t* ctrl)
1842 {
1843 9 return GATE_UI_MOTIF_GET_CTRL_USER_PARAM(ctrl);
1844 }
1845
1846 5 gate_ui_host_t* gate_ui_ctrl_get_host(gate_ui_ctrl_t* ctrl)
1847 {
1848 5 return GATE_UI_MOTIF_GET_CTRL_HOST(ctrl);
1849 }
1850
1851 gate_ui_ctrl_t* gate_ui_ctrl_get_parent(gate_ui_ctrl_t* ctrl)
1852 {
1853 return GATE_UI_MOTIF_GET_CTRL_PARENT(ctrl);
1854 }
1855
1856 19 gate_result_t gate_ui_ctrl_destroy(gate_ui_ctrl_t* ctrl)
1857 {
1858 19 return gate_ui_motif_ctrl_destroy(ctrl);
1859 }
1860
1861 212 gate_bool_t gate_ui_ctrl_is_created(gate_ui_ctrl_t* ctrl)
1862 {
1863 212 Widget w = GATE_UI_MOTIF_GET_CTRL_WIDGET(ctrl);
1864 212 return w != NULL;
1865 }
1866
1867 3 gate_bool_t gate_ui_ctrl_is_enabled(gate_ui_ctrl_t* ctrl)
1868 {
1869 3 Widget w = GATE_UI_MOTIF_GET_CTRL_WIDGET(ctrl);
1870 3 return XtIsSensitive(w) ? true : false;
1871 }
1872
1873 3 gate_bool_t gate_ui_ctrl_is_visible(gate_ui_ctrl_t* ctrl)
1874 {
1875 3 Widget w = GATE_UI_MOTIF_GET_CTRL_WIDGET(ctrl);
1876 3 return XtIsRealized(w) ? true : false;
1877 }
1878
1879 3 gate_bool_t gate_ui_ctrl_is_focused(gate_ui_ctrl_t* ctrl)
1880 {
1881 3 return false;
1882 }
1883
1884 4 gate_result_t gate_ui_ctrl_get_position(gate_ui_ctrl_t* ctrl, gate_ui_position_t* position)
1885 {
1886 gate_result_t ret;
1887 Dimension x, y, width, height;
1888 Widget w;
1889 do
1890 {
1891
2/4
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
4 if (!ctrl || !position)
1892 {
1893 ret = GATE_RESULT_INVALIDARG;
1894 break;
1895 }
1896
1897 4 w = GATE_UI_MOTIF_GET_CTRL_WIDGET(ctrl);
1898 4 ret = gate_ui_motif_widget_get_position(w, &position->pos, &position->size);
1899 } while (0);
1900
1901 4 return ret;
1902 }
1903
1904 7 gate_result_t gate_ui_ctrl_get_size(gate_ui_ctrl_t* ctrl, gate_ui_size_t* size)
1905 {
1906 gate_result_t ret;
1907 Dimension width, height;
1908 Widget w;
1909 do
1910 {
1911
2/4
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
7 if (!ctrl || !size)
1912 {
1913 ret = GATE_RESULT_INVALIDARG;
1914 break;
1915 }
1916
1917 7 w = GATE_UI_MOTIF_GET_CTRL_WIDGET(ctrl);
1918 7 ret = gate_ui_motif_widget_get_position(w, NULL, size);
1919 } while (0);
1920 7 return ret;
1921 }
1922
1923 34 gate_result_t gate_ui_ctrl_get_children(gate_ui_ctrl_t* ctrl, gate_array_t* children)
1924 {
1925 34 gate_result_t ret = GATE_RESULT_FAILED;
1926 34 Widget child = NULL;
1927 34 WidgetList list = NULL;
1928 34 gate_size_t list_count = 0;
1929 gate_size_t ndx;
1930 34 gate_ui_ctrl_t* ptr_ctrl = NULL;
1931 34 gate_arraylist_t arr = NULL;
1932
1933 do
1934 {
1935 34 arr = gate_arraylist_create(sizeof(gate_ui_ctrl_t*), NULL, 0, NULL, NULL);
1936
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 34 times.
34 if (!arr)
1937 {
1938 ret = GATE_RESULT_OUTOFMEMORY;
1939 break;
1940 }
1941
1942 34 ret = gate_ui_motif_ctrl_get_children(ctrl, (void**)&list, &list_count);
1943
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 17 times.
34 GATE_BREAK_IF_FAILED(ret);
1944
1945
2/2
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 17 times.
36 for (ndx = 0; ndx != list_count; ++ndx)
1946 {
1947 19 child = list[ndx];
1948
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19 times.
19 if (!child)
1949 {
1950 continue;
1951 }
1952 19 ptr_ctrl = gate_ui_motif_widget_get_ctrl(child);
1953
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 16 times.
19 if (!ptr_ctrl)
1954 {
1955 3 continue;
1956 }
1957 16 gate_arraylist_add(arr, &ptr_ctrl);
1958 }
1959
1960
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 17 times.
17 if (NULL == gate_array_create(children, arr))
1961 {
1962 ret = GATE_RESULT_OUTOFMEMORY;
1963 break;
1964 }
1965 17 ret = GATE_RESULT_OK;
1966 } while (0);
1967
1968 34 gate_arraylist_release(arr);
1969 34 return ret;
1970 }
1971
1972 3 gate_result_t gate_ui_ctrl_get_text(gate_ui_ctrl_t* ctrl, gate_string_t* text)
1973 {
1974 3 gate_ui_motif_dispatcher_t* ptr_disp = NULL;
1975 3 Widget w = NULL;
1976
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
3 if (!ctrl || !text)
1977 {
1978 return GATE_RESULT_INVALIDARG;
1979 }
1980 3 ptr_disp = GATE_UI_MOTIF_GET_CTRL_DISP(ctrl);
1981
4/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 1 times.
3 if (ptr_disp && ptr_disp->get_text)
1982 {
1983 1 return ptr_disp->get_text(ctrl, text);
1984 }
1985 2 w = GATE_UI_MOTIF_GET_CTRL_WIDGET(ctrl);
1986
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if (!w)
1987 {
1988 return GATE_RESULT_INVALIDARG;
1989 }
1990 2 return gate_ui_motif_widget_get_label(w, text);
1991 }
1992
1993 gate_result_t gate_ui_ctrl_get_text_length(gate_ui_ctrl_t* ctrl, gate_uint32_t* length)
1994 {
1995 gate_string_t text = GATE_STRING_INIT_EMPTY;
1996 gate_result_t ret = gate_ui_ctrl_get_text(ctrl, &text);
1997 if (GATE_SUCCEEDED(ret) && length)
1998 {
1999 *length = (gate_uint32_t)gate_string_length(&text);
2000 }
2001 gate_string_release(&text);
2002 return ret;
2003 }
2004
2005 2 gate_result_t gate_ui_ctrl_get_state(gate_ui_ctrl_t* ctrl, gate_int32_t* ptr_state)
2006 {
2007 2 gate_ui_motif_dispatcher_t* ptr_disp = NULL;
2008 2 Widget w = NULL;
2009
2/4
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
2 if (!ctrl || !ptr_state)
2010 {
2011 return GATE_RESULT_INVALIDARG;
2012 }
2013 2 ptr_disp = GATE_UI_MOTIF_GET_CTRL_DISP(ctrl);
2014
2/4
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
2 if (ptr_disp && ptr_disp->get_state)
2015 {
2016 2 return ptr_disp->get_state(ctrl, ptr_state);
2017 }
2018 return GATE_RESULT_NOTSUPPORTED;
2019 }
2020
2021 3 gate_result_t gate_ui_ctrl_set_enabled(gate_ui_ctrl_t* ctrl, gate_bool_t enabledstate)
2022 {
2023 Widget w;
2024
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if (!ctrl)
2025 {
2026 return GATE_RESULT_INVALIDARG;
2027 }
2028 3 w = GATE_UI_MOTIF_GET_CTRL_WIDGET(ctrl);
2029
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if (!w)
2030 {
2031 return GATE_RESULT_INVALIDSTATE;
2032 }
2033 3 XtSetSensitive(w, enabledstate);
2034 3 return GATE_RESULT_OK;
2035 }
2036 4 gate_result_t gate_ui_ctrl_set_visible(gate_ui_ctrl_t* ctrl, gate_bool_t visibility)
2037 {
2038 Widget w;
2039
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if (!ctrl)
2040 {
2041 return GATE_RESULT_INVALIDARG;
2042 }
2043 4 w = GATE_UI_MOTIF_GET_CTRL_WIDGET(ctrl);
2044
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if (!w)
2045 {
2046 return GATE_RESULT_INVALIDSTATE;
2047 }
2048
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if (visibility)
2049 {
2050 4 gate_ui_host_t* host = gate_ui_ctrl_get_host(ctrl);
2051 4 XtMapWidget(w);
2052 4 gate_ui_motif_host_dispatch_pending_events(host, false);
2053 4 return gate_ui_ctrl_refresh(ctrl);
2054 }
2055 else
2056 {
2057 XtUnmapWidget(w);
2058 return GATE_RESULT_OK;
2059 }
2060 }
2061 gate_result_t gate_ui_ctrl_set_focus(gate_ui_ctrl_t* ctrl)
2062 {
2063 Widget w;
2064 if (!ctrl)
2065 {
2066 return GATE_RESULT_INVALIDARG;
2067 }
2068 w = GATE_UI_MOTIF_GET_CTRL_WIDGET(ctrl);
2069 if (!w)
2070 {
2071 return GATE_RESULT_INVALIDSTATE;
2072 }
2073 XmProcessTraversal(w, XmTRAVERSE_CURRENT);
2074 return GATE_RESULT_OK;
2075 }
2076 26 gate_result_t gate_ui_ctrl_set_position(gate_ui_ctrl_t* ctrl, gate_ui_point_t const* position, gate_ui_size_t const* size)
2077 {
2078 Widget w;
2079
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26 times.
26 if (!ctrl)
2080 {
2081 return GATE_RESULT_INVALIDARG;
2082 }
2083 26 w = GATE_UI_MOTIF_GET_CTRL_WIDGET(ctrl);
2084
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26 times.
26 if (!w)
2085 {
2086 return GATE_RESULT_INVALIDSTATE;
2087 }
2088 26 return gate_ui_motif_widget_set_position(w, position, size);
2089 }
2090 3 gate_result_t gate_ui_ctrl_set_text(gate_ui_ctrl_t* ctrl, gate_string_t const* text)
2091 {
2092 3 gate_ui_motif_dispatcher_t* ptr_disp = NULL;
2093 Widget w;
2094
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
3 if (!ctrl || !text)
2095 {
2096 return GATE_RESULT_INVALIDARG;
2097 }
2098 3 ptr_disp = GATE_UI_MOTIF_GET_CTRL_DISP(ctrl);
2099
4/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 1 times.
3 if (ptr_disp && ptr_disp->set_text)
2100 {
2101 1 return ptr_disp->set_text(ctrl, text);
2102 }
2103 2 w = GATE_UI_MOTIF_GET_CTRL_WIDGET(ctrl);
2104
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if (!w)
2105 {
2106 return GATE_RESULT_INVALIDSTATE;
2107 }
2108 2 return gate_ui_motif_widget_set_label(w, text);
2109 }
2110 2 gate_result_t gate_ui_ctrl_set_state(gate_ui_ctrl_t* ctrl, gate_int32_t state)
2111 {
2112 2 gate_ui_motif_dispatcher_t* ptr_disp = NULL;
2113 2 Widget w = NULL;
2114
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if (!ctrl)
2115 {
2116 return GATE_RESULT_INVALIDARG;
2117 }
2118 2 ptr_disp = GATE_UI_MOTIF_GET_CTRL_DISP(ctrl);
2119
2/4
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
2 if (ptr_disp && ptr_disp->set_state)
2120 {
2121 2 return ptr_disp->set_state(ctrl, state);
2122 }
2123 return GATE_RESULT_NOTSUPPORTED;
2124 }
2125 27 gate_result_t gate_ui_ctrl_refresh(gate_ui_ctrl_t* ctrl)
2126 {
2127 27 gate_ui_motif_dispatcher_t* disp = NULL;
2128
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27 times.
27 if (!ctrl)
2129 {
2130 return GATE_RESULT_INVALIDARG;
2131 }
2132 27 disp = GATE_UI_MOTIF_GET_CTRL_DISP(ctrl);
2133
4/4
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 10 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 14 times.
27 if (disp && disp->refresh)
2134 {
2135 3 return disp->refresh(ctrl);
2136 }
2137 else
2138 {
2139 24 return gate_ui_motif_ctrl_refresh(ctrl);
2140 }
2141 }
2142
2143
2144 #endif /* GATE_UI_MOTIF */
2145
2146
2147
2148 #if defined(GATE_UI_WASMHTML)
2149
2150 #include "gate/ui/gateui_wasmhtml.h"
2151
2152
2153 gate_result_t gate_ui_host_init(gate_ui_host_t* host, gate_uintptr_t apphandle, void* userparam)
2154 {
2155 return gate_ui_wasm_host_init(host, apphandle, userparam);
2156 }
2157 gate_result_t gate_ui_host_uninit(gate_ui_host_t* host)
2158 {
2159 return gate_ui_wasm_host_uninit(host);
2160 }
2161 gate_result_t gate_ui_host_run(gate_ui_host_t* host)
2162 {
2163 gate_result_t ret = GATE_RESULT_OK;
2164 return ret;
2165 }
2166 gate_result_t gate_ui_host_quit(gate_ui_host_t* host)
2167 {
2168 gate_result_t ret = GATE_RESULT_OK;
2169 return ret;
2170 }
2171 void* gate_ui_host_get_userparam(gate_ui_host_t* host)
2172 {
2173 return GATE_UI_WASM_GET_HOST_USER_PARAM(host);
2174 }
2175 gate_uintptr_t gate_ui_host_get_apphandle(gate_ui_host_t* host)
2176 {
2177 return GATE_UI_WASM_GET_HOST_APPHANDLE(host);
2178 }
2179 gate_uint32_t gate_ui_host_default_line_height(gate_ui_host_t* host)
2180 {
2181 return GATE_UI_WASM_GET_HOST_LINEHEIGHT(host);
2182 }
2183 gate_uint32_t gate_ui_host_default_control_height(gate_ui_host_t* host, gate_uint32_t line_count)
2184 {
2185 const gate_uint32_t line_height = GATE_UI_WASM_GET_HOST_LINEHEIGHT(host);
2186 gate_uint32_t height = line_height * 14 / 8;
2187 if (line_count > 1)
2188 {
2189 height += (line_count - 1) * line_height;
2190 }
2191 ++height;
2192 return height;
2193 }
2194
2195 static gate_int32_t gate_ui_host_get_default_dpi()
2196 {
2197 return 96;
2198 }
2199
2200 gate_int32_t gate_ui_host_get_pixels_in_points(gate_ui_host_t* host, gate_real32_t points)
2201 {
2202 gate_int32_t dpi = gate_ui_host_get_default_dpi();
2203 (void)host;
2204 return (gate_int32_t)((points * (gate_real32_t)dpi / 72.0f) + 0.5f);
2205 }
2206 gate_real32_t gate_ui_host_get_points_in_pixels(gate_ui_host_t* host, gate_int32_t pixels)
2207 {
2208 gate_int32_t dpi = gate_ui_host_get_default_dpi();
2209 gate_int32_t tmp = (gate_int32_t)((pixels * 72.0f / (gate_real32_t)dpi) + 0.5f);
2210 (void)host;
2211 return (gate_real32_t)tmp;
2212 }
2213 gate_result_t gate_ui_host_default_color(gate_ui_host_t* host, gate_uint32_t colortype, gate_ui_color_t* col)
2214 {
2215 return GATE_RESULT_NOTIMPLEMENTED;
2216 }
2217 gate_result_t gate_ui_host_clipboard_get_text(gate_ui_host_t* host, gate_string_t* text)
2218 {
2219 return GATE_RESULT_NOTIMPLEMENTED;
2220 }
2221 gate_result_t gate_ui_host_clipboard_set_text(gate_ui_host_t* host, gate_string_t const* text)
2222 {
2223 return GATE_RESULT_NOTIMPLEMENTED;
2224 }
2225 gate_result_t gate_ui_host_default_workarea(gate_ui_host_t* host, gate_ui_position_t* area)
2226 {
2227 return GATE_RESULT_NOTIMPLEMENTED;
2228 }
2229 gate_result_t gate_ui_host_total_workarea(gate_ui_host_t* host, gate_ui_position_t* area)
2230 {
2231 return GATE_RESULT_NOTIMPLEMENTED;
2232 }
2233 gate_result_t gate_ui_host_execute(gate_ui_host_t* host, gate_runnable_t* code)
2234 {
2235 return GATE_RESULT_NOTIMPLEMENTED;
2236 }
2237 gate_result_t gate_ui_host_process_events(gate_ui_host_t* host)
2238 {
2239 return GATE_RESULT_NOTIMPLEMENTED;
2240 }
2241
2242
2243
2244 void* gate_ui_ctrl_get_userparam(gate_ui_ctrl_t* ctrl)
2245 {
2246 return GATE_UI_WASM_GET_CTRL_USER_PARAM(ctrl);
2247 }
2248
2249 gate_ui_host_t* gate_ui_ctrl_get_host(gate_ui_ctrl_t* ctrl)
2250 {
2251 return GATE_UI_WASM_GET_CTRL_HOST(ctrl);
2252 }
2253
2254 gate_ui_ctrl_t* gate_ui_ctrl_get_parent(gate_ui_ctrl_t* ctrl)
2255 {
2256 return NULL;
2257 }
2258
2259 gate_result_t gate_ui_ctrl_destroy(gate_ui_ctrl_t* ctrl)
2260 {
2261 return GATE_RESULT_NOTIMPLEMENTED;
2262 }
2263
2264 gate_bool_t gate_ui_ctrl_is_created(gate_ui_ctrl_t* ctrl)
2265 {
2266 return false;
2267 }
2268
2269 gate_bool_t gate_ui_ctrl_is_enabled(gate_ui_ctrl_t* ctrl)
2270 {
2271 return false;
2272 }
2273
2274 gate_bool_t gate_ui_ctrl_is_visible(gate_ui_ctrl_t* ctrl)
2275 {
2276 return false;
2277 }
2278
2279 gate_bool_t gate_ui_ctrl_is_focused(gate_ui_ctrl_t* ctrl)
2280 {
2281 return false;
2282 }
2283
2284 gate_result_t gate_ui_ctrl_get_position(gate_ui_ctrl_t* ctrl, gate_ui_position_t* position)
2285 {
2286 return GATE_RESULT_NOTIMPLEMENTED;
2287 }
2288
2289 gate_result_t gate_ui_ctrl_get_size(gate_ui_ctrl_t* ctrl, gate_ui_size_t* size)
2290 {
2291 return GATE_RESULT_NOTIMPLEMENTED;
2292 }
2293
2294 gate_result_t gate_ui_ctrl_get_children(gate_ui_ctrl_t* ctrl, gate_array_t* children)
2295 {
2296 return GATE_RESULT_NOTIMPLEMENTED;
2297 }
2298
2299 gate_result_t gate_ui_ctrl_get_text(gate_ui_ctrl_t* ctrl, gate_string_t* text)
2300 {
2301 return GATE_RESULT_NOTIMPLEMENTED;
2302 }
2303
2304 gate_result_t gate_ui_ctrl_get_text_length(gate_ui_ctrl_t* ctrl, gate_uint32_t* length)
2305 {
2306 return GATE_RESULT_NOTIMPLEMENTED;
2307 }
2308
2309 gate_result_t gate_ui_ctrl_get_state(gate_ui_ctrl_t* ctrl, gate_int32_t* ptr_state)
2310 {
2311 return GATE_RESULT_NOTIMPLEMENTED;
2312 }
2313
2314 gate_result_t gate_ui_ctrl_set_enabled(gate_ui_ctrl_t* ctrl, gate_bool_t enabledstate)
2315 {
2316 return GATE_RESULT_NOTIMPLEMENTED;
2317 }
2318 gate_result_t gate_ui_ctrl_set_visible(gate_ui_ctrl_t* ctrl, gate_bool_t visibility)
2319 {
2320 return GATE_RESULT_NOTIMPLEMENTED;
2321 }
2322 gate_result_t gate_ui_ctrl_set_focus(gate_ui_ctrl_t* ctrl)
2323 {
2324 return GATE_RESULT_NOTIMPLEMENTED;
2325 }
2326 gate_result_t gate_ui_ctrl_set_position(gate_ui_ctrl_t* ctrl, gate_ui_point_t const* position, gate_ui_size_t const* size)
2327 {
2328 return GATE_RESULT_NOTIMPLEMENTED;
2329 }
2330 gate_result_t gate_ui_ctrl_set_text(gate_ui_ctrl_t* ctrl, gate_string_t const* text)
2331 {
2332 return GATE_RESULT_NOTIMPLEMENTED;
2333 }
2334 gate_result_t gate_ui_ctrl_set_state(gate_ui_ctrl_t* ctrl, gate_int32_t state)
2335 {
2336 return GATE_RESULT_NOTIMPLEMENTED;
2337 }
2338
2339 gate_result_t gate_ui_ctrl_refresh(gate_ui_ctrl_t* ctrl)
2340 {
2341 return GATE_RESULT_NOTIMPLEMENTED;
2342 }
2343
2344
2345 #endif
2346