Sun, 19 Oct 2025 21:20:08 +0200
update toolkit
/* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 2017 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 "toolkit.h" #include <string.h> #include <cx/allocator.h> #include <cx/hash_map.h> #include <cx/list.h> #include <cx/array_list.h> #ifdef __cplusplus extern "C" { #endif #define ui_reset_layout(layout) memset(&(layout), 0, sizeof(UiLayout)) typedef struct UiDocumentView UiDocumentView; typedef struct UiContainerPrivate UiContainerPrivate; struct UiContainerPrivate { UiContainerX container; GtkWidget *widget; UIMENU menu; GtkWidget *current; // TODO: remove void (*add)(UiContainerPrivate*, GtkWidget*, UiLayout *layout); UiLayout layout; int close; }; typedef struct UiBoxContainer { UiContainerPrivate container; UiSubContainerType type; UiBool has_fill; } UiBoxContainer; typedef struct UiGridContainer { UiContainerPrivate container; UiBool def_hexpand; UiBool def_vexpand; UiBool def_hfill; UiBool def_vfill; int x; int y; #ifdef UI_GTK2 int width; int height; #endif } UiGridContainer; typedef struct UiTabViewContainer { UiContainerPrivate container; } UiTabViewContainer; typedef void (*ui_select_tab_func)(UIWIDGET widget, int tab); typedef void (*ui_add_tab_func)(UIWIDGET widget, int index, const char *name, UIWIDGET child); typedef struct UiGtkTabView { UiObject *obj; GtkWidget *widget; ui_select_tab_func select_tab; ui_select_tab_func remove_tab; ui_add_tab_func add_tab; UiSubContainerType subcontainer; int padding; int spacing; int columnspacing; int rowspacing; ui_callback onchange; void *onchangedata; } UiGtkTabView; typedef struct UiSplitPane { GtkWidget *current_pane; CxList *children; UiOrientation orientation; int pos; int max; int nchildren; int initial_position; } UiSplitPane; typedef struct UiSplitPaneContainer { UiContainerPrivate container; UiSplitPane *splitpane; } UiSplitPaneContainer; typedef struct UiHeaderbarContainer { UiContainerPrivate container; GtkWidget *centerbox; int part; UiHeaderbarAlternative alternative; /* only used by fallback headerbar */ } UiHeaderbarContainer; typedef struct UiGtkItemListContainer { UiObject *parent; GtkWidget *widget; UiContainerPrivate *container; void (*create_ui)(UiObject *, int, void *, void *); void *userdata; UiSubContainerType subcontainer; CxMap *current_items; int margin; int spacing; int columnspacing; int rowspacing; bool remove_items; } UiGtkItemListContainer; GtkWidget* ui_gtk_vbox_new(int spacing); GtkWidget* ui_gtk_hbox_new(int spacing); GtkWidget* ui_subcontainer_create( UiSubContainerType type, UiObject *newobj, int spacing, int columnspacing, int rowspacing, int margin); GtkWidget* ui_gtk_set_margin(GtkWidget *widget, int margin, int margin_left, int margin_right, int margin_top, int margin_bottom); UIWIDGET ui_box_create(UiObject *obj, UiContainerArgs *args, UiSubContainerType type); UiContainerX* ui_box_container(UiObject *obj, GtkWidget *box, UiSubContainerType type); void ui_box_container_add(UiContainerPrivate *ct, GtkWidget *widget, UiLayout *layout); GtkWidget* ui_create_grid_widget(int colspacing, int rowspacing); UiContainerX* ui_grid_container( UiObject *obj, GtkWidget *grid, UiBool def_hexpand, UiBool def_vexpand, UiBool def_hfill, UiBool def_vfill); void ui_grid_container_add(UiContainerPrivate *ct, GtkWidget *widget, UiLayout *layout); UiContainerX* ui_frame_container(UiObject *obj, GtkWidget *frame); void ui_frame_container_add(UiContainerPrivate *ct, GtkWidget *widget, UiLayout *layout); UiContainerX* ui_expander_container(UiObject *obj, GtkWidget *expander); void ui_expander_container_add(UiContainerPrivate *ct, GtkWidget *widget, UiLayout *layout); UiContainerX* ui_scrolledwindow_container(UiObject *obj, GtkWidget *scrolledwindow); void ui_scrolledwindow_container_add(UiContainerPrivate *ct, GtkWidget *widget, UiLayout *layout); UiContainerX* ui_tabview_container(UiObject *obj, GtkWidget *tabview); void ui_tabview_container_add(UiContainerPrivate *ct, GtkWidget *widget, UiLayout *layout); UiSplitPane* ui_create_splitpane_data(GtkWidget *pane, UiOrientation orientation, int max, int init); UiContainerX* ui_splitpane_container(UiObject *obj, GtkWidget *pane, UiSplitPane *data); void ui_splitpane_container_add(UiContainerPrivate *ct, GtkWidget *widget, UiLayout *layout); int64_t ui_splitpane_get(UiInteger *i); void ui_splitpane_set(UiInteger *i, int64_t value); UiGtkTabView* ui_widget_get_tabview_data(UIWIDGET tabview); void ui_gtk_notebook_select_tab(GtkWidget *widget, int tab); #if GTK_CHECK_VERSION(3, 10, 0) UiContainerX* ui_headerbar_container(UiObject *obj, GtkWidget *headerbar); void ui_headerbar_container_add(UiContainerPrivate *ct, GtkWidget *widget, UiLayout *layout); #endif UiContainerX* ui_headerbar_fallback_container(UiObject *obj, GtkWidget *headerbar); void ui_headerbar_fallback_container_add(UiContainerPrivate *ct, GtkWidget *widget, UiLayout *layout); #ifdef __cplusplus } #endif #endif /* CONTAINER_H */