2 weeks ago
move ui_customwidget to separate file
ui/motif/container.c | file | annotate | diff | comparison | revisions | |
ui/motif/objs.mk | file | annotate | diff | comparison | revisions | |
ui/motif/widget.c | file | annotate | diff | comparison | revisions | |
ui/ui/container.h | file | annotate | diff | comparison | revisions | |
ui/ui/display.h | file | annotate | diff | comparison | revisions | |
ui/ui/widget.h | file | annotate | diff | comparison | revisions |
--- a/ui/motif/container.c Wed Feb 26 18:59:21 2025 +0100 +++ b/ui/motif/container.c Wed Feb 26 21:14:24 2025 +0100 @@ -39,20 +39,7 @@ #include "Grid.h" -UIWIDGET ui_customwidget_create(UiObject *obj, ui_createwidget_func create_widget, void *userdata, UiWidgetArgs args) { - Arg xargs[64]; - int n = 0; - - UiContainerPrivate *ctn = ui_obj_container(obj); - UI_APPLY_LAYOUT(ctn->layout, args); - - Widget parent = ctn->prepare(ctn, xargs, &n); - Widget widget = create_widget(obj, args, userdata, parent, xargs, n); - XtManageChild(widget); - ctn->add(ctn, widget); - - return widget; -} + /* ---------------------------- Box Container ---------------------------- */
--- a/ui/motif/objs.mk Wed Feb 26 18:59:21 2025 +0100 +++ b/ui/motif/objs.mk Wed Feb 26 21:14:24 2025 +0100 @@ -32,6 +32,7 @@ MOTIFOBJ = toolkit.o MOTIFOBJ += stock.o MOTIFOBJ += window.o +MOTIFOBJ += widget.o MOTIFOBJ += container.o MOTIFOBJ += menu.o MOTIFOBJ += toolbar.o
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ui/motif/widget.c Wed Feb 26 21:14:24 2025 +0100 @@ -0,0 +1,54 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2025 Olaf Wintermann. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include <stdio.h> +#include <stdlib.h> +#include <inttypes.h> + +#include "../ui/widget.h" + +#include "container.h" +#include "../common/context.h" +#include "../common/object.h" + + +UIWIDGET ui_customwidget_create(UiObject *obj, ui_createwidget_func create_widget, void *userdata, UiWidgetArgs args) { + Arg xargs[64]; + int n = 0; + + UiContainerPrivate *ctn = ui_obj_container(obj); + UI_APPLY_LAYOUT(ctn->layout, args); + + Widget parent = ctn->prepare(ctn, xargs, &n); + Widget widget = create_widget(obj, args, userdata, parent, xargs, n); + XtManageChild(widget); + ctn->add(ctn, widget); + + return widget; +} +
--- a/ui/ui/container.h Wed Feb 26 18:59:21 2025 +0100 +++ b/ui/ui/container.h Wed Feb 26 21:14:24 2025 +0100 @@ -57,18 +57,6 @@ UI_HEADERBAR_ALTERNATIVE_BOX } UiHeaderbarAlternative; -typedef struct UiWidgetArgs { - UiTri fill; - UiBool hexpand; - UiBool vexpand; - UiBool hfill; - UiBool vfill; - UiBool override_defaults; - int colspan; - int rowspan; - const char *name; - const char *style_class; -} UiWidgetArgs; typedef struct UiContainerArgs { UiTri fill; @@ -330,19 +318,6 @@ UIEXPORT UiObject* ui_document_tab(UiTabbedPane *view); -#ifdef UI_GTK -typedef UIWIDGET (*ui_createwidget_func)(UiObject *obj, UiWidgetArgs args, void *userdata); -#elif defined(UI_MOTIF) -typedef UIWIDGET (*ui_createwidget_func)(UiObject *obj, UiWidgetArgs args, void *userdata, Widget parent, Arg *a, int n); -#elif defined(UI_COCOA) -typedef UIWIDGET (*ui_createwidget_func)(UiObject *obj, UiWidgetArgs args, void *userdata); -#elif defined(UI_WINUI) -typedef UIWIDGET(*ui_createwidget_func)(UiObject *obj, UiWidgetArgs args, void *userdata); -#endif -UIEXPORT UIWIDGET ui_customwidget_create(UiObject *obj, ui_createwidget_func create_widget, void *userdata, UiWidgetArgs args); - -#define ui_customwidget(obj, create_widget, userdata, ...) ui_customwidget_create(obj, create_widget, userdata, (UiWidgetArgs) { __VA_ARGS__ }) - /* used for macro */ UIEXPORT void ui_container_begin_close(UiObject *obj);
--- a/ui/ui/display.h Wed Feb 26 18:59:21 2025 +0100 +++ b/ui/ui/display.h Wed Feb 26 21:14:24 2025 +0100 @@ -123,7 +123,6 @@ UIEXPORT UIWIDGET ui_rlabel_create(UiObject* obj, UiLabelArgs args); UIWIDGET ui_space_deprecated(UiObject *obj); -UIWIDGET ui_separator_deprecated(UiObject *obj); /* progress bar/spinner */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ui/ui/widget.h Wed Feb 26 21:14:24 2025 +0100 @@ -0,0 +1,72 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2025 Olaf Wintermann. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ +#ifndef UI_WIDGET_H +#define UI_WIDGET_H + +#include "toolkit.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct UiWidgetArgs { + UiTri fill; + UiBool hexpand; + UiBool vexpand; + UiBool hfill; + UiBool vfill; + UiBool override_defaults; + int colspan; + int rowspan; + const char *name; + const char *style_class; +} UiWidgetArgs; + +#ifdef UI_GTK +typedef UIWIDGET (*ui_createwidget_func)(UiObject *obj, UiWidgetArgs args, void *userdata); +#elif defined(UI_MOTIF) +typedef UIWIDGET (*ui_createwidget_func)(UiObject *obj, UiWidgetArgs args, void *userdata, Widget parent, Arg *a, int n); +#elif defined(UI_COCOA) +typedef UIWIDGET (*ui_createwidget_func)(UiObject *obj, UiWidgetArgs args, void *userdata); +#elif defined(UI_WINUI) +typedef UIWIDGET(*ui_createwidget_func)(UiObject *obj, UiWidgetArgs args, void *userdata); +#endif +UIEXPORT UIWIDGET ui_customwidget_create(UiObject *obj, ui_createwidget_func create_widget, void *userdata, UiWidgetArgs args); + +#define ui_customwidget(obj, create_widget, userdata, ...) ui_customwidget_create(obj, create_widget, userdata, (UiWidgetArgs) { __VA_ARGS__ }) + + + + + +#ifdef __cplusplus +} +#endif + +#endif /* UI_WIDGET_H */ +