#ifndef CONTAINER_H
#define CONTAINER_H
#include "../ui/toolkit.h"
#include "../ui/container.h"
#include <string.h>
#include <cx/allocator.h>
#include <cx/hash_map.h>
#ifdef __cplusplus
extern "C" {
#endif
#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)
typedef void (*ui_container_add_f)(UiContainer*, GtkWidget*, UiBool);
typedef struct UiDocumentView UiDocumentView;
typedef struct UiLayout UiLayout;
typedef enum UiLayoutBool UiLayoutBool;
enum UiLayoutBool {
UI_LAYOUT_UNDEFINED =
0,
UI_LAYOUT_TRUE,
UI_LAYOUT_FALSE,
};
struct UiLayout {
UiLayoutBool fill;
UiBool newline;
char *label;
UiBool hexpand;
UiBool vexpand;
UiBool hfill;
UiBool vfill;
int width;
int colspan;
int rowspan;
};
struct UiContainer {
GtkWidget *widget;
UIMENU menu;
GtkWidget *current;
void (*add)(UiContainer*, GtkWidget*, UiBool);
UiLayout layout;
int close;
};
typedef struct UiBoxContainer {
UiContainer container;
UiSubContainerType type;
UiBool has_fill;
} UiBoxContainer;
typedef struct UiGridContainer {
UiContainer container;
int x;
int y;
#ifdef UI_GTK2
int width;
int height;
#endif
} UiGridContainer;
typedef struct UiTabViewContainer {
UiContainer 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 margin;
int spacing;
int columnspacing;
int rowspacing;
} UiGtkTabView;
typedef struct UiHeaderbarContainer {
UiContainer container;
GtkWidget *centerbox;
int part;
UiHeaderbarAlternative alternative;
} UiHeaderbarContainer;
typedef struct UiGtkItemListContainer {
UiObject *parent;
GtkWidget *widget;
UiContainer *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);
UiContainer* ui_frame_container(UiObject *obj, GtkWidget *frame);
void ui_frame_container_add(UiContainer *ct, GtkWidget *widget, UiBool fill);
GtkWidget* ui_box_set_margin(GtkWidget *box,
int margin);
UIWIDGET ui_box_create(UiObject *obj, UiContainerArgs args, UiSubContainerType type);
UiContainer* ui_box_container(UiObject *obj, GtkWidget *box, UiSubContainerType type);
void ui_box_container_add(UiContainer *ct, GtkWidget *widget, UiBool fill);
GtkWidget* ui_create_grid_widget(
int colspacing,
int rowspacing);
UiContainer* ui_grid_container(UiObject *obj, GtkWidget *grid);
void ui_grid_container_add(UiContainer *ct, GtkWidget *widget, UiBool fill);
UiContainer* ui_frame_container(UiObject *obj, GtkWidget *frame);
void ui_frame_container_add(UiContainer *ct, GtkWidget *widget, UiBool fill);
UiContainer* ui_expander_container(UiObject *obj, GtkWidget *expander);
void ui_expander_container_add(UiContainer *ct, GtkWidget *widget, UiBool fill);
UiContainer* ui_scrolledwindow_container(UiObject *obj, GtkWidget *scrolledwindow);
void ui_scrolledwindow_container_add(UiContainer *ct, GtkWidget *widget, UiBool fill);
UiContainer* ui_tabview_container(UiObject *obj, GtkWidget *tabview);
void ui_tabview_container_add(UiContainer *ct, GtkWidget *widget, UiBool fill);
void ui_paned_container_add(UiContainer *ct, GtkWidget *widget, UiBool fill);
void ui_split_container_add1(UiContainer *ct, GtkWidget *widget, UiBool fill);
void ui_split_container_add2(UiContainer *ct, GtkWidget *widget, UiBool fill);
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)
UiContainer* ui_headerbar_container(UiObject *obj, GtkWidget *headerbar);
void ui_headerbar_container_add(UiContainer *ct, GtkWidget *widget, UiBool fill);
#endif
UiContainer* ui_headerbar_fallback_container(UiObject *obj, GtkWidget *headerbar);
void ui_headerbar_fallback_container_add(UiContainer *ct, GtkWidget *widget, UiBool fill);
#ifdef __cplusplus
}
#endif
#endif