2 weeks ago
move ui_customwidget to separate file
/* * 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; enum UiContainerType { UI_CONTAINER_GENERIC = 0, UI_CONTAINER_TABVIEW }; typedef enum UiContainerType UiContainerType; #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; UiContainerType type; UiLayout layout; }; typedef struct UiBoxContainer { UiContainerPrivate container; Dimension n; } UiBoxContainer; typedef struct UiGridContainer { UiContainerPrivate container; Dimension x; Dimension y; } UiGridContainer; typedef struct UiTab { Widget tab_button; Widget child; } UiTab; typedef struct UiMotifTabView UiMotifTabView; struct UiMotifTabView { UiObject *obj; Widget form; Widget tabbar; Widget content; Widget current; UiTab *current_tab; int current_index; int height; Pixel bg1; Pixel bg2; Pixel fg1; GC gc; int gc_initialized; UiTabViewType tabview; UiSubContainerType subcontainer; CxList *tabs; void (*select)(UiMotifTabView *tabview, int tab); void (*add)(UiMotifTabView *tabview, int index, const char *name, Widget child); void (*remove)(UiMotifTabView *tabview, int index); }; typedef struct UiTabViewContainer { UiContainerPrivate container; UiMotifTabView *tabview; } UiTabViewContainer; void ui_motif_tabview_select(UiMotifTabView *tabview, int tab); void ui_motif_tabview_add_tab(UiMotifTabView *tabview, int index, const char *name, Widget child); void ui_motif_tabview_remove(UiMotifTabView *tabview, int index); void ui_motif_tabview_change_tab(UiMotifTabView *tabview, UiTab *tab); int64_t ui_tabview_get(UiInteger *i); void ui_tabview_set(UiInteger *i, int64_t value); Widget ui_tabview_container_prepare(UiContainerPrivate *ctn, Arg *args, int *n); void ui_tabview_container_add(UiContainerPrivate *ctn, Widget widget); 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 */