GCC Code Coverage Report


Directory: src/gate/
File: src/gate/ui/splitters.c
Date: 2025-12-12 23:40:09
Exec Total Coverage
Lines: 0 68 0.0%
Functions: 0 7 0.0%
Branches: 0 32 0.0%

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/splitters.h"
30 #include "gate/results.h"
31
32 #if defined(GATE_UI_WINAPI)
33
34 #include "gate/ui/gateui_winapi.h"
35 #include "gate/platforms.h"
36 #include <windowsx.h>
37
38 static BOOL SetWindowPosIfRequired(HWND hWnd, HWND hWndInsertAfter, int X, int Y, int cx, int cy, UINT uFlags)
39 {
40 RECT rect;
41 BOOL ret = TRUE;
42
43 #if !defined(GATE_SYS_WIN16)
44 ret =
45 #endif
46 GetWindowRect(hWnd, &rect);
47 if (ret)
48 {
49 HWND hWndParent = GetParent(hWnd);
50 POINT point;
51 point.x = rect.left;
52 point.y = rect.top;
53
54 if (hWndParent != NULL)
55 {
56 ScreenToClient(hWndParent, &point);
57 }
58 if ((X != point.x) || (Y != point.y) ||
59 (cx != rect.right - rect.left) || (cy != rect.bottom - rect.top)
60 )
61 {
62 ret = SetWindowPos(hWnd, hWndInsertAfter, X, Y, cx, cy, uFlags);
63 }
64 else
65 {
66 ret = FALSE;
67 }
68 }
69 return ret;
70 }
71
72
73 static void gate_ui_splitter_resize(gate_ui_splitter_t* splitter, HWND hwndFirst, HWND hwndSecond)
74 {
75 do
76 {
77 gate_ui_size_t sz;
78 gate_result_t ret;
79 gate_ui_host_t* host = GATE_UI_WINAPI_GET_HOST(&splitter->ctrl);
80 gate_uint32_t lineheight = gate_ui_host_default_line_height(host);
81 gate_uint32_t length;
82 gate_int32_t separator;
83 UINT showflags = SWP_NOACTIVATE | SWP_NOOWNERZORDER | SWP_NOZORDER | SWP_DRAWFRAME;
84
85 ret = gate_ui_winapi_get_size(&splitter->ctrl, &sz);
86 if (GATE_FAILED(ret)) break;
87
88 separator = lineheight / 5;
89 if (separator < 1) separator = 1;
90
91 if (splitter->vertical)
92 {
93 length = sz.height;
94 }
95 else
96 {
97 length = sz.width;
98 }
99 if (length < splitter->minimum * 3 / 2)
100 {
101 ret = GATE_RESULT_FAILED;
102 break;
103 }
104
105
106 if (splitter->value > length - splitter->minimum)
107 {
108 splitter->value = length - splitter->minimum;
109 }
110
111 if (splitter->value < splitter->minimum)
112 {
113 splitter->value = splitter->minimum;
114 }
115
116 if (splitter->vertical)
117 {
118 if (hwndFirst != NULL)
119 {
120 SetWindowPosIfRequired(hwndFirst, NULL, 0, 0, sz.width, splitter->value - separator, showflags);
121 }
122 if (hwndSecond != NULL)
123 {
124 SetWindowPosIfRequired(hwndSecond, NULL, 0, splitter->value + separator, sz.width, sz.height - splitter->value - separator, showflags);
125 }
126 }
127 else
128 {
129 if (hwndFirst != NULL)
130 {
131 SetWindowPosIfRequired(hwndFirst, NULL, 0, 0, splitter->value - separator, sz.height, showflags);
132 }
133 if (hwndSecond != NULL)
134 {
135 SetWindowPosIfRequired(hwndSecond, NULL, splitter->value + separator, 0, sz.width - splitter->value - separator, sz.height, showflags);
136 }
137 }
138 } while (0);
139
140 }
141
142 static gate_bool_t gate_ui_splitter_events(void* hwnd, gate_ui_ctrl_t* ctrl, gate_uint32_t msg, gate_uintptr_t wParam, gate_intptr_t lParam, gate_intptr_t* lresult)
143 {
144 if (ctrl != NULL)
145 {
146 HWND hwnd_ctrl = GATE_UI_WINAPI_GET_HWND(ctrl);
147 if (hwnd == hwnd_ctrl)
148 {
149 gate_ui_splitter_t* splitter = (gate_ui_splitter_t*)ctrl;
150 switch (msg)
151 {
152 #if !defined(GATE_SYS_WIN16)
153 case WM_CTLCOLOREDIT:
154 case WM_CTLCOLORBTN:
155 case WM_CTLCOLORLISTBOX:
156 case WM_CTLCOLORMSGBOX:
157 case WM_CTLCOLORSCROLLBAR:
158 case WM_CTLCOLORDLG:
159 case WM_CTLCOLORSTATIC:
160 {
161 *lresult = SendMessage(GetParent((HWND)hwnd), msg, wParam, lParam);
162 return true;
163 }
164 #endif /* GATE_SYS_WIN16 */
165 case WM_ERASEBKGND:
166 {
167 HWND hwnd_parent = GetParent(hwnd_ctrl);
168 HDC hdc = (HDC)wParam;
169 HBRUSH hbr_bk_gnd = NULL;
170 #if defined(GATE_UI_WINAPI_DARKMODE_SUPPORT)
171 if (gate_ui_winapi_is_darkmode_applied(hwnd_ctrl))
172 {
173 gate_ui_color_t col;
174 gate_ui_host_t* host = GATE_UI_WINAPI_GET_HOST(ctrl);
175
176 gate_ui_host_default_color(host, GATE_UI_COLOR_CONTROL, &col);
177 hbr_bk_gnd = (HBRUSH)gate_ui_winapi_host_get_brush(host, &col);
178 }
179 else
180 #endif /* GATE_UI_WINAPI_DARKMODE_SUPPORT */
181 {
182 hbr_bk_gnd = (HBRUSH)gate_ui_winapi_get_syscolor_brush(
183 gate_ui_winapi_get_syscolor_index(GATE_UI_COLOR_CONTROL));
184 }
185
186 if (hbr_bk_gnd)
187 {
188 RECT rect;
189 GetClientRect(hwnd_ctrl, &rect);
190 FillRect(hdc, &rect, hbr_bk_gnd);
191 *lresult = 1;
192 return true;
193 }
194 break;
195 }
196 case WM_SIZE:
197 {
198 gate_ui_splitter_update(splitter);
199 break;
200 }
201 case WM_SETCURSOR:
202 {
203 POINT pnt;
204 GetCursorPos(&pnt);
205 if (hwnd == WindowFromPoint(pnt))
206 {
207 static HCURSOR hcursor = NULL;
208 if (hcursor == NULL)
209 {
210 hcursor = LoadCursor(NULL, IDC_SIZEWE);
211 }
212 SetCursor(hcursor);
213 *lresult = TRUE;
214 return true;
215 }
216 break;
217 }
218 case WM_LBUTTONDOWN:
219 {
220 splitter->drag_mode = true;
221 splitter->click_point.x = GET_X_LPARAM(lParam);
222 splitter->click_point.y = GET_Y_LPARAM(lParam);
223 SetCapture(hwnd_ctrl);
224 break;
225 }
226 case WM_MOUSEMOVE:
227 {
228 if (splitter->drag_mode)
229 {
230 if ((splitter->click_point.x != GET_X_LPARAM(lParam))
231 || (splitter->click_point.y != GET_Y_LPARAM(lParam))
232 )
233 {
234 if (splitter->vertical)
235 {
236 splitter->click_point.y = GET_Y_LPARAM(lParam);
237 if (splitter->click_point.y < 0) splitter->click_point.y = 0;
238 splitter->value = splitter->click_point.y;
239 }
240 else
241 {
242 splitter->click_point.x = GET_X_LPARAM(lParam);
243 if (splitter->click_point.x < 0) splitter->click_point.x = 0;
244 splitter->value = splitter->click_point.x;
245 }
246 gate_ui_splitter_update(splitter);
247 }
248 }
249 break;
250 }
251 case WM_LBUTTONUP:
252 {
253 splitter->drag_mode = false;
254 ReleaseCapture();
255 break;
256 }
257 }
258 }
259 }
260 return false;
261 }
262
263 gate_result_t gate_ui_splitter_create(
264 gate_ui_splitter_t* splitter, gate_ui_ctrl_t* parent,
265 gate_ui_position_t const* position,
266 gate_bool_t vertical,
267 gate_uint32_t flags,
268 void* userparam
269 )
270 {
271 gate_result_t ret;
272
273 do
274 {
275 gate_uint32_t styles = WS_CHILD | WS_CLIPCHILDREN;
276 gate_uint32_t exstyles = 0;
277 HWND hwndParent;
278 gate_ui_host_t* host = gate_ui_ctrl_get_host(parent);
279 if (host == NULL)
280 {
281 ret = GATE_RESULT_INVALIDSTATE;
282 break;
283 }
284 hwndParent = GATE_UI_WINAPI_GET_HWND(parent);
285 if (hwndParent == NULL)
286 {
287 ret = GATE_RESULT_INVALIDSTATE;
288 break;
289 }
290
291 gate_mem_clear(splitter, sizeof(gate_ui_splitter_t));
292 splitter->minimum = 32;
293 splitter->vertical = vertical;
294 #if !defined(GATE_SYS_WINCE) && !defined(GATE_SYS_WIN16)
295 exstyles |= WS_EX_CONTROLPARENT;
296 #endif
297
298 if (!GATE_FLAG_ENABLED(flags, GATE_UI_FLAG_ENABLED)) styles |= WS_DISABLED;
299 if (GATE_FLAG_ENABLED(flags, GATE_UI_FLAG_VISIBLE)) styles |= WS_VISIBLE;
300
301 ret = gate_ui_winapi_create(&splitter->ctrl, host, hwndParent, NULL, position, styles, exstyles, NULL, userparam, false);
302 if (GATE_SUCCEEDED(ret))
303 {
304 HWND hwnd = GATE_UI_WINAPI_GET_HWND(&splitter->ctrl);
305 gate_ui_size_t clientsize;
306 gate_ui_winapi_get_size(&splitter->ctrl, &clientsize);
307 splitter->value = (vertical ? clientsize.height : clientsize.width) / 2;
308
309 gate_ui_winapi_register_event(host, hwnd, WM_SIZE, &gate_ui_splitter_events, &splitter->ctrl);
310 gate_ui_winapi_register_event(host, hwnd, WM_SETCURSOR, &gate_ui_splitter_events, &splitter->ctrl);
311 gate_ui_winapi_register_event(host, hwnd, WM_LBUTTONDOWN, &gate_ui_splitter_events, &splitter->ctrl);
312 gate_ui_winapi_register_event(host, hwnd, WM_LBUTTONUP, &gate_ui_splitter_events, &splitter->ctrl);
313 gate_ui_winapi_register_event(host, hwnd, WM_MOUSEMOVE, &gate_ui_splitter_events, &splitter->ctrl);
314 gate_ui_winapi_register_event(host, hwnd, WM_ERASEBKGND, &gate_ui_splitter_events, &splitter->ctrl);
315
316 #if !defined(GATE_SYS_WIN16)
317 gate_ui_winapi_register_event(host, hwnd, WM_CTLCOLORDLG, &gate_ui_splitter_events, &splitter->ctrl);
318 gate_ui_winapi_register_event(host, hwnd, WM_CTLCOLORSTATIC, &gate_ui_splitter_events, &splitter->ctrl);
319 gate_ui_winapi_register_event(host, hwnd, WM_CTLCOLOREDIT, &gate_ui_splitter_events, &splitter->ctrl);
320 gate_ui_winapi_register_event(host, hwnd, WM_CTLCOLORBTN, &gate_ui_splitter_events, &splitter->ctrl);
321 gate_ui_winapi_register_event(host, hwnd, WM_CTLCOLORLISTBOX, &gate_ui_splitter_events, &splitter->ctrl);
322 gate_ui_winapi_register_event(host, hwnd, WM_CTLCOLORMSGBOX, &gate_ui_splitter_events, &splitter->ctrl);
323 gate_ui_winapi_register_event(host, hwnd, WM_CTLCOLORSCROLLBAR, &gate_ui_splitter_events, &splitter->ctrl);
324 #endif
325
326 }
327 } while (0);
328
329 return ret;
330 }
331
332 gate_result_t gate_ui_splitter_set(gate_ui_splitter_t* splitter, gate_uint32_t const* minimum, gate_uint32_t const* value)
333 {
334 gate_result_t ret = GATE_RESULT_OK;
335 HWND hwnd = GATE_UI_WINAPI_GET_HWND(&splitter->ctrl);
336
337 if (minimum != NULL)
338 {
339 splitter->minimum = *minimum;
340 }
341 if (value != NULL)
342 {
343 splitter->value = *value;
344 }
345
346 if (hwnd != NULL)
347 {
348 ret = gate_ui_splitter_update(splitter);
349 }
350 return ret;
351 }
352
353 struct gate_ui_splitter_enum_child_windows
354 {
355 HWND parent;
356 HWND first;
357 HWND second;
358 };
359
360 static BOOL CALLBACK gate_ui_splitter_enum_children(HWND hwnd, LPARAM lParam)
361 {
362 struct gate_ui_splitter_enum_child_windows* param = (struct gate_ui_splitter_enum_child_windows*)(gate_intptr_t)lParam;
363 if (GetParent(hwnd) == param->parent)
364 {
365 if (param->first == NULL)
366 {
367 param->first = hwnd;
368 }
369 else if (param->second == NULL)
370 {
371 param->second = hwnd;
372 }
373 }
374 return TRUE;
375 }
376
377
378 gate_result_t gate_ui_splitter_update(gate_ui_splitter_t* splitter)
379 {
380 gate_result_t ret = GATE_RESULT_INVALIDARG;
381 HWND hwnd = GATE_UI_WINAPI_GET_HWND(&splitter->ctrl);
382
383 if (hwnd != NULL)
384 {
385 struct gate_ui_splitter_enum_child_windows children;
386 children.parent = hwnd;
387 children.first = NULL;
388 children.second = NULL;
389 #if defined(GATE_SYS_WINCE)
390 children.first = GetWindow(hwnd, GW_CHILD);
391 if (children.first != NULL)
392 {
393 children.second = GetWindow(children.first, GW_HWNDNEXT);
394 }
395 #else
396 EnumChildWindows(hwnd, &gate_ui_splitter_enum_children, (LPARAM)(gate_intptr_t)&children);
397 #endif
398 if ((children.first != NULL) || (children.second != NULL))
399 {
400 gate_ui_splitter_resize(splitter, children.first, children.second);
401 }
402 ret = GATE_RESULT_OK;
403 }
404 return ret;
405 }
406
407 gate_result_t gate_ui_splitter_set_first(gate_ui_splitter_t* splitter, gate_ui_ctrl_t* ctrl)
408 {
409 GATE_UNUSED_ARG(splitter);
410 GATE_UNUSED_ARG(ctrl);
411 return GATE_RESULT_OK;
412 }
413 gate_result_t gate_ui_splitter_set_second(gate_ui_splitter_t* splitter, gate_ui_ctrl_t* ctrl)
414 {
415 GATE_UNUSED_ARG(splitter);
416 GATE_UNUSED_ARG(ctrl);
417 return GATE_RESULT_OK;
418 }
419
420 #endif /* GATE_UI_WINAPI */
421
422
423
424 #if defined(GATE_UI_GTK)
425
426 #include "gate/ui/gateui_gtk.h"
427
428
429 static gboolean gate_ui_gtk_splitter_refresh_idle_callback(gpointer user_data)
430 {
431 gate_ui_splitter_t* splitter = (gate_ui_splitter_t*)user_data;
432 gate_ui_gtk_ctrl_refresh(&splitter->ctrl);
433 return FALSE; /* FALSE means: do not invoke this callback again (until next call to g_idle_add()) */
434 }
435
436
437 static gate_result_t gate_ui_gtk_splitter_refresh(gate_ui_ctrl_t* ctrl)
438 {
439 gate_ui_splitter_t* splitter = (gate_ui_splitter_t*)ctrl;
440 g_idle_add(&gate_ui_gtk_splitter_refresh_idle_callback, splitter);
441 return gate_ui_gtk_ctrl_refresh(ctrl);
442 }
443
444 static gate_result_t gate_ui_gtk_splitter_destroy(gate_ui_ctrl_t* ctrl)
445 {
446 return gate_ui_gtk_ctrl_destroy_native(ctrl);
447 }
448
449
450 static gate_ui_gtk_dispatcher_t gate_ui_gtk_splitter_dispatcher =
451 {
452 NULL /*get_text_length*/,
453 NULL /*get_text*/,
454 NULL /*set_text*/,
455 NULL /*get_state*/,
456 NULL /*set_state*/,
457 &gate_ui_gtk_splitter_refresh,
458 &gate_ui_gtk_splitter_destroy
459 };
460
461
462 gate_result_t gate_ui_splitter_create(
463 gate_ui_splitter_t* splitter, gate_ui_ctrl_t* parent,
464 gate_ui_position_t const* position,
465 gate_bool_t vertical,
466 gate_uint32_t flags,
467 void* userparam
468 )
469 {
470 GtkWidget* widget;
471 gate_ui_host_t* host = GATE_UI_GTK_GET_CTRL_HOST(parent);
472
473 gate_mem_clear(splitter, sizeof(gate_ui_splitter_t));
474 widget = gtk_paned_new(vertical ? GTK_ORIENTATION_VERTICAL : GTK_ORIENTATION_HORIZONTAL);
475 if (widget == NULL)
476 {
477 return GATE_RESULT_FAILED;
478 }
479
480 gate_ui_gtk_ctrl_init(&splitter->ctrl, widget, host, userparam, parent,
481 &gate_ui_gtk_splitter_dispatcher, false, true, position, &flags);
482
483 return GATE_RESULT_OK;
484 }
485
486 gate_result_t gate_ui_splitter_set(gate_ui_splitter_t* splitter,
487 gate_uint32_t const* minimum, gate_uint32_t const* value)
488 {
489 gate_result_t ret = GATE_RESULT_OK;
490
491 if (value)
492 {
493 GtkWidget* container = GATE_UI_GTK_GET_CTRL_WIDGET(&splitter->ctrl);
494 gtk_paned_set_position(GTK_PANED(container), (gint)*value);
495 }
496 return ret;
497 }
498
499 gate_result_t gate_ui_splitter_update(gate_ui_splitter_t* splitter)
500 {
501 gate_result_t ret = GATE_RESULT_OK;
502 GtkWidget* container = GATE_UI_GTK_GET_CTRL_WIDGET(&splitter->ctrl);
503 /* TODO */
504 return ret;
505 }
506
507 gate_result_t gate_ui_splitter_set_first(gate_ui_splitter_t* splitter, gate_ui_ctrl_t* ctrl)
508 {
509 gate_result_t ret = GATE_RESULT_OK;
510 GtkWidget* widget = GATE_UI_GTK_GET_CTRL_WIDGET(&splitter->ctrl);
511 GtkWidget* child = GATE_UI_GTK_GET_CTRL_WIDGET(ctrl);
512
513 gtk_paned_add1(GTK_PANED(widget), child);
514 if (!gtk_widget_get_realized(child))
515 {
516 gtk_widget_realize(child);
517 }
518
519 return ret;
520 }
521 gate_result_t gate_ui_splitter_set_second(gate_ui_splitter_t* splitter, gate_ui_ctrl_t* ctrl)
522 {
523 gate_result_t ret = GATE_RESULT_OK;
524 GtkWidget* widget = GATE_UI_GTK_GET_CTRL_WIDGET(&splitter->ctrl);
525 GtkWidget* child = GATE_UI_GTK_GET_CTRL_WIDGET(ctrl);
526
527 gtk_paned_add2(GTK_PANED(widget), child);
528 if (!gtk_widget_get_realized(child))
529 {
530 gtk_widget_realize(child);
531 }
532
533 return ret;
534 }
535
536 #endif /* GATE_UI_GTK */
537
538
539
540 #if defined(GATE_UI_MOTIF)
541
542 #include "gate/ui/gateui_motif.h"
543 #include <Xm/Paned.h>
544
545 gate_result_t gate_ui_splitter_create(gate_ui_splitter_t* splitter, gate_ui_ctrl_t* parent, gate_ui_position_t const* position,
546 gate_bool_t vertical, gate_uint32_t flags, void* userparam)
547 {
548 gate_result_t ret = GATE_RESULT_FAILED;
549
550 do
551 {
552 Arg args[8];
553 unsigned args_count = 0;
554 Widget w = NULL;
555
556 if (!splitter || !parent)
557 {
558 ret = GATE_RESULT_INVALIDARG;
559 break;
560 }
561
562 XtSetArg(args[args_count], XmNorientation, (vertical ? XmVERTICAL : XmHORIZONTAL)); ++args_count;
563
564 ret = gate_ui_motif_ctrl_create(&splitter->ctrl, xmPanedWidgetClass, userparam, NULL, parent,
565 position, &flags, false, NULL, args, args_count);
566 GATE_BREAK_IF_FAILED(ret);
567
568 splitter->vertical = vertical;
569 splitter->minimum = 0;
570 splitter->drag_mode = false;
571 splitter->value = 0;
572
573 } while (0);
574
575 return ret;
576 }
577
578
579 static void apply_splitter_settings_to_children(gate_ui_splitter_t* splitter)
580 {
581 Widget w = NULL;
582 WidgetList children = NULL;
583 int count = 0;
584
585 w = GATE_UI_MOTIF_GET_CTRL_WIDGET(&splitter->ctrl);
586 XmPanedGetPanes(w, &children, &count);
587 if (count > 0)
588 {
589 if (splitter->value != 0)
590 {
591 XtVaSetValues(children[0],
592 XmNpreferredPaneSize, (Cardinal)splitter->value,
593 XmNresizeToPreferred, TRUE,
594 NULL, NULL);
595 }
596 if (splitter->minimum != 0)
597 {
598 int ndx;
599 for (ndx = 0; ndx != count; ++ndx)
600 {
601 XtVaSetValues(children[ndx],
602 XmNpaneMinimum, (Cardinal)splitter->minimum,
603 NULL, NULL);
604 }
605 }
606 }
607 }
608
609 gate_result_t gate_ui_splitter_set(gate_ui_splitter_t* splitter, gate_uint32_t const* minimum, gate_uint32_t const* value)
610 {
611 gate_result_t ret = GATE_RESULT_FAILED;
612
613 do
614 {
615 Widget w = NULL;
616 if (!gate_ui_ctrl_is_created(&splitter->ctrl))
617 {
618 ret = GATE_RESULT_INVALIDSTATE;
619 break;
620 }
621 w = GATE_UI_MOTIF_GET_CTRL_WIDGET(&splitter->ctrl);
622 if (!w)
623 {
624 ret = GATE_RESULT_INVALIDSTATE;
625 break;
626 }
627
628 if (minimum)
629 {
630 splitter->minimum = *minimum;
631 }
632 if (value)
633 {
634 splitter->value = *value;
635 }
636
637 apply_splitter_settings_to_children(splitter);
638
639 ret = GATE_RESULT_OK;
640 } while (0);
641 return ret;
642 }
643
644 gate_result_t gate_ui_splitter_update(gate_ui_splitter_t* splitter)
645 {
646 return GATE_RESULT_NOTIMPLEMENTED;
647 }
648
649 static gate_result_t gate_ui_splitter_add_child(gate_ui_splitter_t* splitter, gate_ui_ctrl_t* ctrl)
650 {
651 gate_result_t ret = GATE_RESULT_FAILED;
652
653 do
654 {
655 Widget w = NULL;
656 Widget c = NULL;
657 gate_ui_host_t* ptr_host;
658 XtAppContext app_context;
659
660 if (!gate_ui_ctrl_is_created(&splitter->ctrl) || !gate_ui_ctrl_is_created(ctrl))
661 {
662 ret = GATE_RESULT_INVALIDSTATE;
663 break;
664 }
665 w = GATE_UI_MOTIF_GET_CTRL_WIDGET(&splitter->ctrl);
666 c = GATE_UI_MOTIF_GET_CTRL_WIDGET(ctrl);
667 if (!w || !c)
668 {
669 ret = GATE_RESULT_INVALIDSTATE;
670 break;
671 }
672
673 apply_splitter_settings_to_children(splitter);
674 ret = GATE_RESULT_OK;
675 } while (0);
676 return ret;
677 }
678
679 gate_result_t gate_ui_splitter_set_first(gate_ui_splitter_t* splitter, gate_ui_ctrl_t* ctrl)
680 {
681 return gate_ui_splitter_add_child(splitter, ctrl);
682 }
683
684 gate_result_t gate_ui_splitter_set_second(gate_ui_splitter_t* splitter, gate_ui_ctrl_t* ctrl)
685 {
686 return gate_ui_splitter_add_child(splitter, ctrl);
687 }
688
689 #endif /* GATE_UI_MOTIF */
690