GCC Code Coverage Report


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