Sun, 15 Dec 2024 22:13:05 +0100
implement menu item callbacks (Motif)
/* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 2014 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 CONTAINER_H #define CONTAINER_H #include "../ui/toolkit.h" #include "../ui/container.h" #include <cx/list.h> #include <string.h> #ifdef __cplusplus extern "C" { #endif #define UI_APPLY_LAYOUT(layout, args) \ layout.fill = args.fill; \ layout.hexpand = args.hexpand; \ layout.vexpand = args.vexpand; \ layout.hfill = args.hfill; \ layout.vfill = args.vfill; \ layout.colspan = args.colspan; \ layout.rowspan = args.rowspan typedef enum UiBoxOrientation UiBoxOrientation; #define ui_reset_layout(layout) memset(&(layout), 0, sizeof(UiLayout)) #define ui_lb2bool(b) ((b) == UI_LAYOUT_TRUE ? TRUE : FALSE) #define ui_bool2lb(b) ((b) ? UI_LAYOUT_TRUE : UI_LAYOUT_FALSE) #define ui_obj_container(obj) (UiContainerPrivate*)obj->container_end typedef struct UiLayout UiLayout; struct UiLayout { UiTri fill; UiBool newline; char *label; UiBool hexpand; UiBool vexpand; UiBool hfill; UiBool vfill; int width; int colspan; int rowspan; }; enum UiBoxOrientation { UI_BOX_VERTICAL = 0, UI_BOX_HORIZONTAL }; typedef struct UiContainerPrivate UiContainerPrivate; struct UiContainerPrivate { UiContainerX container; Widget (*prepare)(UiContainerPrivate*, Arg *, int*); void (*add)(UiContainerPrivate*, Widget); Widget widget; UiLayout layout; }; typedef struct UiBoxContainer { UiContainerPrivate container; Dimension n; } UiBoxContainer; typedef struct UiGridContainer { UiContainerPrivate container; Dimension x; Dimension y; } UiGridContainer; UiContainerX* ui_box_container(UiObject *obj, Widget grid, UiBoxOrientation orientation); Widget ui_vbox_prepare(UiContainerPrivate *ctn, Arg *args, int *n); Widget ui_hbox_prepare(UiContainerPrivate *ctn, Arg *args, int *n); void ui_box_container_add(UiContainerPrivate *ctn, Widget widget); UiContainerX* ui_grid_container(UiObject *obj, Widget grid); Widget ui_grid_container_prepare(UiContainerPrivate *ctn, Arg *args, int *n); void ui_grid_container_add(UiContainerPrivate *ctn, Widget widget); #ifdef __cplusplus } #endif #endif /* CONTAINER_H */