From: Olaf Wintermann Date: Sat, 19 Jul 2025 18:34:55 +0000 (+0200) Subject: update UI: change fill parameter X-Git-Url: https://uap-core.de/gitweb/?a=commitdiff_plain;h=a9d31b8236c97a12d4c9ebd683979d5fded190aa;p=note.git update UI: change fill parameter --- diff --git a/application/nbconfig.c b/application/nbconfig.c index 9cca033..275d639 100644 --- a/application/nbconfig.c +++ b/application/nbconfig.c @@ -250,13 +250,13 @@ void notebook_config_dialog(void) { // UI - ui_grid(obj, .margin = 10, .columnspacing = 10, .rowspacing = 10, .fill = UI_ON) { + ui_grid(obj, .margin = 10, .columnspacing = 10, .rowspacing = 10, .fill = TRUE) { ui_tabview(obj, .hfill = TRUE, .hexpand = TRUE, .vfill = TRUE, .vexpand = TRUE) { ui_tab(obj, "Groups") { - ui_hbox(obj, .margin = 10, .spacing = 10, .fill = UI_ON) { - ui_vbox(obj, .fill = UI_OFF) { - ui_listview(obj, .list = wdata->tab1_groups, .getvalue = reslist_getvalue, .fill = UI_ON, .onactivate = nbconfig_grouplist_activate); - ui_hbox(obj, .fill = UI_OFF) { + ui_hbox(obj, .margin = 10, .spacing = 10, .fill = TRUE) { + ui_vbox(obj, .fill = FALSE) { + ui_listview(obj, .list = wdata->tab1_groups, .getvalue = reslist_getvalue, .fill = TRUE, .onactivate = nbconfig_grouplist_activate); + ui_hbox(obj, .fill = FALSE) { ui_button(obj, .icon = UI_ICON_NEW_FOLDER, .onclick = nbconfig_grouplist_add); ui_button(obj, .icon = UI_ICON_DELETE, .onclick = nbconfig_grouplist_delete); ui_button(obj, .icon = UI_ICON_GO_UP, .onclick = nbconfig_grouplist_move_up); @@ -264,7 +264,7 @@ void notebook_config_dialog(void) { } } - ui_grid(obj, .columnspacing = 10, .rowspacing = 10, .fill = UI_ON, .def_vfill = TRUE) { + ui_grid(obj, .columnspacing = 10, .rowspacing = 10, .fill = TRUE, .def_vfill = TRUE) { ui_rlabel(obj, .label = "Name"); ui_textfield(obj, .value = wdata->tab1_group_name, .onchange = nbconfig_grouplist_name_changed); ui_newline(obj); @@ -280,10 +280,10 @@ void notebook_config_dialog(void) { } } ui_tab(obj, "Notebooks") { - ui_hbox(obj, .margin = 10, .spacing = 10, .fill = UI_ON) { - ui_vbox(obj, .fill = UI_OFF) { - ui_listview(obj, .list = wdata->tab2_notebooks, .getvalue = reslist_getvalue, .fill = UI_ON, .onactivate = nbconfig_notebooklist_activate); - ui_hbox(obj, .fill = UI_OFF) { + ui_hbox(obj, .margin = 10, .spacing = 10, .fill = TRUE) { + ui_vbox(obj) { + ui_listview(obj, .list = wdata->tab2_notebooks, .getvalue = reslist_getvalue, .fill = TRUE, .onactivate = nbconfig_notebooklist_activate); + ui_hbox(obj) { ui_button(obj, .icon = UI_ICON_NEW_FOLDER, .onclick = nbconfig_notebooklist_add); ui_button(obj, .icon = UI_ICON_DELETE, .onclick = nbconfig_notebooklist_delete); ui_button(obj, .icon = UI_ICON_GO_UP, .onclick = nbconfig_notebooklist_move_up); @@ -291,7 +291,7 @@ void notebook_config_dialog(void) { } } - ui_grid(obj, .columnspacing = 10, .rowspacing = 10, .fill = UI_ON, .def_vfill = TRUE) { + ui_grid(obj, .columnspacing = 10, .rowspacing = 10, .fill = TRUE, .def_vfill = TRUE) { ui_rlabel(obj, .label = "Group"); ui_combobox(obj, .list = wdata->tab2_groups, .getvalue = reslist_getvalue); ui_newline(obj); diff --git a/application/window.c b/application/window.c index 576c7ff..6388993 100644 --- a/application/window.c +++ b/application/window.c @@ -52,21 +52,28 @@ void window_create() { }; */ ui_sidebar(obj) { - ui_sourcelist(obj, .dynamic_sublist = wdata->notebooks, .getvalue = window_sidebar_getvalue, .onactivate = action_notebook_selected, .fill = UI_ON); - ui_hbox(obj, .spacing = 2, .fill = UI_OFF) { + ui_sourcelist(obj, .dynamic_sublist = wdata->notebooks, .getvalue = window_sidebar_getvalue, .onactivate = action_notebook_selected, .fill = TRUE); + ui_hbox(obj, .spacing = 2) { ui_button(obj, .icon = "folder-new-symbolic", .style_class = "flat", .onclick = action_notebook_add); - ui_label(obj, .fill = UI_ON); + ui_label(obj, .fill = TRUE); ui_button(obj, .icon = "emblem-system-symbolic", .style_class = "flat", .onclick = action_notebook_config); } } - ui_hsplitpane_w(obj, wdata->splitpane, .initial_position = 500) { + ui_hsplitpane_w(obj, wdata->splitpane, .initial_position = 500, .fill = TRUE) { // splitpane left: table UiModel* model = ui_model(obj->ctx, UI_STRING, "Name", UI_STRING_FREE, "Last Modified", -1); model->columnsize[0] = -1; model->getvalue = window_notelist_getvalue; - ui_table(obj, .model = model, .varname = "notes", .contextmenu = get_notelist_context_menu(), .multiselection = TRUE, .onselection = action_note_selected, .onactivate = action_note_activated); + ui_table(obj, + .model = model, + .varname = "notes", + .contextmenu = get_notelist_context_menu(), + .multiselection = TRUE, + .onselection = action_note_selected, + .onactivate = action_note_activated, + .fill = TRUE); // splitpane right: content ui_tabview_w(obj, wdata->document_tabview, .tabview = UI_TABVIEW_INVISIBLE, .varname = "note_type") { @@ -74,13 +81,13 @@ void window_create() { } ui_tab(obj, "textnote") { - ui_vbox0(obj) { - ui_grid(obj, .margin = 10, .columnspacing = 10, .rowspacing = 10, .def_vfill = TRUE, .fill = UI_OFF) { + ui_vbox(obj, .fill = TRUE) { + ui_grid(obj, .margin = 10, .columnspacing = 10, .rowspacing = 10, .def_vfill = TRUE) { //ui_label(obj, .label = "Title", .vfill = TRUE); ui_textfield(obj, .varname = "note_title", .onchange = action_note_title_changed, .hexpand = TRUE, .groups = UI_GROUPS(APP_STATE_NOTE_SELECTED)); ui_newline(obj); } - ui_hbox(obj, .style_class = "note_toolbar", .margin = 10, .spacing = 4, .fill = UI_OFF) { + ui_hbox(obj, .style_class = "note_toolbar", .margin = 10, .spacing = 4) { ui_combobox(obj, .varname = "note_textnote_para", .onactivate = action_textnote_paragraph); ui_togglebutton(obj, .icon = "format-text-bold", .varname = "note_textnote_strong", .onchange = action_textnote_style_strong); ui_togglebutton(obj, .icon = "format-text-italic", .varname = "note_textnote_emphasis", .onchange = action_textnote_style_emphasis); @@ -91,7 +98,7 @@ void window_create() { ui_button(obj, .icon = "insert-image"); ui_button(obj, .icon = "insert-link"); } - ui_hbox_w(obj, wdata->attachments, .margin = 10, .fill = UI_OFF) { + ui_hbox_w(obj, wdata->attachments, .margin = 10) { UIWIDGET sw; ui_scrolledwindow_w(obj, sw, .name = "note_attachments_sw") { ui_itemlist(obj, .varname = "note_attachments", .container = UI_CONTAINER_HBOX, .create_ui = attachment_item, .userdata = wdata); @@ -136,7 +143,7 @@ void window_notelist_setvisible(MainWindow *window, UiBool visible) { window->notelist_isvisible = visible; } -void window_sidebar_getvalue(void *sublist_userdata, void *rowdata, int index, UiSubListItem *item, void *userdata) { +void window_sidebar_getvalue(UiList *list, void *sublist_userdata, void *rowdata, int index, UiSubListItem *item, void *userdata) { Resource *notebook = rowdata; item->label = strdup(notebook->displayname ? notebook->displayname : notebook->nodename); @@ -336,7 +343,7 @@ void action_notebook_add(UiEvent *event, void *userdata) { obj->window = wdata; // Dialog UI - ui_grid(obj, .margin = 10, .columnspacing = 10, .rowspacing = 10, .def_vfill = TRUE, .fill = UI_ON) { + ui_grid(obj, .margin = 10, .columnspacing = 10, .rowspacing = 10, .def_vfill = TRUE, .fill = TRUE) { ui_rlabel(obj, .label = "Group"); ui_combobox(obj, .list = wdata->groups, .getvalue = nnd_group_value, .hfill = TRUE, .hexpand = TRUE); ui_newline(obj); diff --git a/application/window.h b/application/window.h index 4a134fb..63fc9bb 100644 --- a/application/window.h +++ b/application/window.h @@ -53,7 +53,7 @@ void window_create(); MainWindow* window_init_data(UiObject *obj); -void window_sidebar_getvalue(void *sublist_userdata, void *rowdata, int index, UiSubListItem *item, void *userdata); +void window_sidebar_getvalue(UiList *list, void *sublist_userdata, void *rowdata, int index, UiSubListItem *item, void *userdata); void window_notelist_setvisible(MainWindow *window, UiBool visible); diff --git a/ucx/mempool.c b/ucx/mempool.c index 8711439..b7b2e81 100644 --- a/ucx/mempool.c +++ b/ucx/mempool.c @@ -638,7 +638,7 @@ int cxMempoolTransfer( // transfer all registered memory memcpy(&dest->registered[dest->registered_size], source->registered, - sizeof(struct cx_mempool_foreign_memory_s) * source->size); + sizeof(struct cx_mempool_foreign_memory_s) * source->registered_size); dest->registered_size += source->registered_size; // register the old allocator with the new pool diff --git a/ui/cocoa/container.h b/ui/cocoa/container.h index b1796b5..d969fa8 100644 --- a/ui/cocoa/container.h +++ b/ui/cocoa/container.h @@ -43,7 +43,7 @@ enum UiLayoutBool { }; struct UiLayout { - UiTri fill; + UiBool fill; //UiBool newline; //char *label; UiBool hexpand; diff --git a/ui/common/args.c b/ui/common/args.c index c99ce0c..e799889 100644 --- a/ui/common/args.c +++ b/ui/common/args.c @@ -608,6 +608,242 @@ void ui_splitpane_args_free(UiSplitPaneArgs *args) { } +/* ------------------------- UiLabelArgs ----------------------------*/ + + +UiLabelArgs* ui_label_args_new(void) { + UiLabelArgs *args = malloc(sizeof(UiLabelArgs)); + memset(args, 0, sizeof(UiLabelArgs)); + return args; +} + + +void ui_label_args_set_fill(UiLabelArgs *args, UiBool fill) { + args->fill = fill ? UI_ON : UI_OFF; +} + + +void ui_label_args_set_hexpand(UiLabelArgs *args, UiBool value) { + args->hexpand = value; +} + + +void ui_label_args_set_vexpand(UiLabelArgs *args, UiBool value) { + args->vexpand = value; +} + + +void ui_label_args_set_hfill(UiLabelArgs *args, UiBool value) { + args->hfill = value; +} + + +void ui_label_args_set_vfill(UiLabelArgs *args, UiBool value) { + args->vfill = value; +} + + +void ui_label_args_set_override_defaults(UiLabelArgs *args, UiBool value) { + args->override_defaults = value; +} + + +void ui_label_args_set_colspan(UiLabelArgs *args, int colspan) { + args->colspan = colspan; +} + + +void ui_label_args_set_rowspan(UiLabelArgs *args, int rowspan) { + args->rowspan = rowspan; +} + + +void ui_label_args_set_name(UiLabelArgs *args, const char *name) { + args->name = strdup(name); +} + + +void ui_label_args_set_style_class(UiLabelArgs *args, const char *classname) { + args->style_class = strdup(classname); +} + +void ui_label_args_set_label(UiLabelArgs *args, const char *label){ + args->label = strdup(label); +} + + +void ui_label_args_set_align(UiLabelArgs *args, UiAlignment align) { + args->align = align; +} + +void ui_label_args_set_style(UiLabelArgs *args, UiLabelStyle style) { + args->style = style; +} + +void ui_label_args_set_varname(UiLabelArgs *args, const char *varname) { + args->varname = strdup(varname); +} + +void ui_label_args_set_value(UiLabelArgs *args, UiString *value) { + args->value = value; +} + +void ui_label_args_free(UiLabelArgs *args) { + free((void*)args->name); + free((void*)args->style_class); + free((void*)args->label); + free((void*)args->varname); + free(args); +} + + +/* ------------------------- UiProgressbarArgs ----------------------------*/ + + +UiProgressbarArgs* ui_progressbar_args_new(void) { + UiProgressbarArgs *args = malloc(sizeof(UiProgressbarArgs)); + memset(args, 0, sizeof(UiProgressbarArgs)); + return args; +} + + +void ui_progressbar_args_set_fill(UiProgressbarArgs *args, UiBool fill) { + args->fill = fill ? UI_ON : UI_OFF; +} + + +void ui_progressbar_args_set_hexpand(UiProgressbarArgs *args, UiBool value) { + args->hexpand = value; +} + + +void ui_progressbar_args_set_vexpand(UiProgressbarArgs *args, UiBool value) { + args->vexpand = value; +} + + +void ui_progressbar_args_set_hfill(UiProgressbarArgs *args, UiBool value) { + args->hfill = value; +} + + +void ui_progressbar_args_set_vfill(UiProgressbarArgs *args, UiBool value) { + args->vfill = value; +} + + +void ui_progressbar_args_set_override_defaults(UiProgressbarArgs *args, UiBool value) { + args->override_defaults = value; +} + + +void ui_progressbar_args_set_colspan(UiProgressbarArgs *args, int colspan) { + args->colspan = colspan; +} + + +void ui_progressbar_args_set_rowspan(UiProgressbarArgs *args, int rowspan) { + args->rowspan = rowspan; +} + + +void ui_progressbar_args_set_name(UiProgressbarArgs *args, const char *name) { + args->name = strdup(name); +} + + +void ui_progressbar_args_set_style_class(UiProgressbarArgs *args, const char *classname) { + args->style_class = strdup(classname); +} + +void ui_progressbar_args_set_min(UiProgressbarArgs *args, double min) { + args->min = min; +} + +void ui_progressbar_args_set_max(UiProgressbarArgs *args, double max) { + args->max = max; +} + +void ui_progressbar_args_set_varname(UiProgressbarArgs *args, const char *varname) { + args->varname = strdup(varname); +} + +void ui_progressbar_args_set_value(UiProgressbarArgs *args, UiDouble *value) { + args->value = value; +} + +void ui_progressbar_args_free(UiProgressbarArgs *args) { + free((void*)args->name); + free((void*)args->style_class); + free((void*)args->varname); + free(args); +} + + +/* ------------------------- UiProgressbarSpinnerArgs ----------------------------*/ + +UiProgressbarSpinnerArgs* ui_progress_spinner_args_new(void) { + UiProgressbarSpinnerArgs *args = malloc(sizeof(UiProgressbarSpinnerArgs)); + memset(args, 0, sizeof(UiProgressbarSpinnerArgs)); + return args; +} + +void ui_progress_spinner_args_set_fill(UiProgressbarSpinnerArgs *args, UiBool fill) { + args->fill = fill ? UI_ON : UI_OFF; +} + +void ui_progress_spinner_args_set_hexpand(UiProgressbarSpinnerArgs *args, UiBool value) { + args->hexpand = value; +} + +void ui_progress_spinner_args_set_vexpand(UiProgressbarSpinnerArgs *args, UiBool value) { + args->vexpand = value; +} + +void ui_progress_spinner_args_set_hfill(UiProgressbarSpinnerArgs *args, UiBool value) { + args->hfill = value; +} + +void ui_progress_spinner_args_set_vfill(UiProgressbarSpinnerArgs *args, UiBool value) { + args->vfill = value; +} + +void ui_progress_spinner_args_set_override_defaults(UiProgressbarSpinnerArgs *args, UiBool value) { + args->override_defaults = value; +} + +void ui_progress_spinner_args_set_colspan(UiProgressbarSpinnerArgs *args, int colspan) { + args->colspan = colspan; +} + +void ui_progress_spinner_args_set_rowspan(UiProgressbarSpinnerArgs *args, int rowspan) { + args->rowspan = rowspan; +} + +void ui_progress_spinner_args_set_name(UiProgressbarSpinnerArgs *args, const char *name) { + args->name = strdup(name); +} + +void ui_progress_spinner_args_set_style_class(UiProgressbarSpinnerArgs *args, const char *classname) { + args->style_class = strdup(classname); +} + +void ui_progress_spinner_args_set_varname(UiProgressbarSpinnerArgs *args, const char *varname) { + args->varname = strdup(varname); +} + +void ui_progress_spinner_args_set_value(UiProgressbarSpinnerArgs *args, UiInteger *value) { + args->value = value; +} + +void ui_progress_spinner_args_free(UiProgressbarSpinnerArgs *args) { + free((void*)args->name); + free((void*)args->style_class); + free((void*)args->varname); + free(args); +} + + /* ---------------------------- UiButtonArgs -------------------------------*/ UiButtonArgs* ui_button_args_new(void) { @@ -1084,3 +1320,267 @@ void ui_sourcelist_args_free(UiSourceListArgs *args) { } +/* ------------------------- UiTextAreaArgs ----------------------------*/ + +UiTextAreaArgs* ui_textarea_args_new(void) { + UiTextAreaArgs *args = malloc(sizeof(UiTextAreaArgs)); + memset(args, 0, sizeof(UiTextAreaArgs)); + return args; +} + + +void ui_textarea_args_set_fill(UiTextAreaArgs *args, UiBool fill) { + args->fill = fill ? UI_ON : UI_OFF; +} + + +void ui_textarea_args_set_hexpand(UiTextAreaArgs *args, UiBool value) { + args->hexpand = value; +} + + +void ui_textarea_args_set_vexpand(UiTextAreaArgs *args, UiBool value) { + args->vexpand = value; +} + + +void ui_textarea_args_set_hfill(UiTextAreaArgs *args, UiBool value) { + args->hfill = value; +} + + +void ui_textarea_args_set_vfill(UiTextAreaArgs *args, UiBool value) { + args->vfill = value; +} + + +void ui_textarea_args_set_override_defaults(UiTextAreaArgs *args, UiBool value) { + args->override_defaults = value; +} + + +void ui_textarea_args_set_colspan(UiTextAreaArgs *args, int colspan) { + args->colspan = colspan; +} + + +void ui_textarea_args_set_rowspan(UiTextAreaArgs *args, int rowspan) { + args->rowspan = rowspan; +} + + +void ui_textarea_args_set_name(UiTextAreaArgs *args, const char *name) { + args->name = strdup(name); +} + + +void ui_textarea_args_set_style_class(UiTextAreaArgs *args, const char *classname) { + args->style_class = strdup(classname); +} + +void ui_textarea_args_set_onchange(UiTextAreaArgs *args, ui_callback callback){ + args->onchange = callback; +} + + +void ui_textarea_args_set_onchangedata(UiTextAreaArgs *args, void *onchangedata){ + args->onchangedata = onchangedata; +} + +void ui_textarea_args_set_varname(UiTextAreaArgs *args, const char *varname) { + args->varname = strdup(varname); +} + +void ui_textarea_args_set_value(UiTextAreaArgs *args, UiText *value) { + args->value = value; +} + +void ui_textarea_args_set_groups(UiTextAreaArgs *args, int *groups){ + // TODO +} + +void ui_textarea_args_free(UiTextAreaArgs *args) { + free((void*)args->name); + free((void*)args->style_class); + free((void*)args->varname); + free((void*)args->groups); + free(args); +} + + + +/* ------------------------- UiTextFieldArgs ----------------------------*/ + +UiTextFieldArgs* ui_textfield_args_new(void) { + UiTextFieldArgs *args = malloc(sizeof(UiTextFieldArgs)); + memset(args, 0, sizeof(UiTextFieldArgs)); + return args; +} + + +void ui_textfield_args_set_fill(UiTextFieldArgs *args, UiBool fill) { + args->fill = fill ? UI_ON : UI_OFF; +} + + +void ui_textfield_args_set_hexpand(UiTextFieldArgs *args, UiBool value) { + args->hexpand = value; +} + + +void ui_textfield_args_set_vexpand(UiTextFieldArgs *args, UiBool value) { + args->vexpand = value; +} + + +void ui_textfield_args_set_hfill(UiTextFieldArgs *args, UiBool value) { + args->hfill = value; +} + + +void ui_textfield_args_set_vfill(UiTextFieldArgs *args, UiBool value) { + args->vfill = value; +} + + +void ui_textfield_args_set_override_defaults(UiTextFieldArgs *args, UiBool value) { + args->override_defaults = value; +} + + +void ui_textfield_args_set_colspan(UiTextFieldArgs *args, int colspan) { + args->colspan = colspan; +} + + +void ui_textfield_args_set_rowspan(UiTextFieldArgs *args, int rowspan) { + args->rowspan = rowspan; +} + + +void ui_textfield_args_set_name(UiTextFieldArgs *args, const char *name) { + args->name = strdup(name); +} + + +void ui_textfield_args_set_style_class(UiTextFieldArgs *args, const char *classname) { + args->style_class = strdup(classname); +} + +void ui_textfield_args_set_onchange(UiTextFieldArgs *args, ui_callback callback){ + args->onchange = callback; +} + + +void ui_textfield_args_set_onchangedata(UiTextFieldArgs *args, void *onchangedata){ + args->onchangedata = onchangedata; +} + +void ui_textfield_args_set_onactivate(UiTextFieldArgs *args, ui_callback callback){ + args->onactivate = callback; +} + + +void ui_textfield_args_set_onactivatedata(UiTextFieldArgs *args, void *onactivatedata){ + args->onactivatedata = onactivatedata; +} + +void ui_textfield_args_set_varname(UiTextFieldArgs *args, const char *varname) { + args->varname = strdup(varname); +} + +void ui_textfield_args_set_value(UiTextFieldArgs *args, UiString *value) { + args->value = value; +} + +void ui_textfield_args_set_groups(UiTextFieldArgs *args, int *groups){ + // TODO +} + +void ui_textfield_args_free(UiTextFieldArgs *args) { + free((void*)args->name); + free((void*)args->style_class); + free((void*)args->varname); + free((void*)args->groups); + free(args); +} + + +/* ------------------------- UiWebviewArgs ----------------------------*/ + +UiWebviewArgs* ui_webview_args_new(void) { + UiWebviewArgs *args = malloc(sizeof(UiWebviewArgs)); + memset(args, 0, sizeof(UiWebviewArgs)); + return args; +} + + +void ui_webview_args_set_fill(UiWebviewArgs *args, UiBool fill) { + args->fill = fill ? UI_ON : UI_OFF; +} + + +void ui_webview_args_set_hexpand(UiWebviewArgs *args, UiBool value) { + args->hexpand = value; +} + + +void ui_webview_args_set_vexpand(UiWebviewArgs *args, UiBool value) { + args->vexpand = value; +} + + +void ui_webview_args_set_hfill(UiWebviewArgs *args, UiBool value) { + args->hfill = value; +} + + +void ui_webview_args_set_vfill(UiWebviewArgs *args, UiBool value) { + args->vfill = value; +} + + +void ui_webview_args_set_override_defaults(UiWebviewArgs *args, UiBool value) { + args->override_defaults = value; +} + + +void ui_webview_args_set_colspan(UiWebviewArgs *args, int colspan) { + args->colspan = colspan; +} + + +void ui_webview_args_set_rowspan(UiWebviewArgs *args, int rowspan) { + args->rowspan = rowspan; +} + + +void ui_webview_args_set_name(UiWebviewArgs *args, const char *name) { + args->name = strdup(name); +} + + +void ui_webview_args_set_style_class(UiWebviewArgs *args, const char *classname) { + args->style_class = strdup(classname); +} + +void ui_webview_args_set_varname(UiWebviewArgs *args, const char *varname) { + args->varname = strdup(varname); +} + +void ui_webview_args_set_value(UiWebviewArgs *args, UiGeneric *value) { + args->value = value; +} + +void ui_webview_args_set_groups(UiWebviewArgs *args, int *groups){ + // TODO +} + +void ui_webview_args_free(UiWebviewArgs *args) { + free((void*)args->name); + free((void*)args->style_class); + free((void*)args->varname); + free((void*)args->groups); + free(args); +} + diff --git a/ui/common/args.h b/ui/common/args.h index 6499594..04e7063 100644 --- a/ui/common/args.h +++ b/ui/common/args.h @@ -30,10 +30,13 @@ #define UIC_ARGS_H #include "../ui/container.h" +#include "../ui/display.h" #include "../ui/button.h" #include "../ui/menu.h" #include "../ui/toolbar.h" #include "../ui/tree.h" +#include "../ui/text.h" +#include "../ui/webview.h" #ifdef __cplusplus extern "C" { @@ -159,6 +162,56 @@ UIEXPORT void ui_splitpane_args_set_value(UiSplitPaneArgs *args, UiInteger *valu UIEXPORT void ui_splitpane_args_set_max_panes(UiSplitPaneArgs *args, int max); UIEXPORT void ui_splitpane_args_free(UiSplitPaneArgs *args); +UIEXPORT UiLabelArgs* ui_label_args_new(void); +UIEXPORT void ui_label_args_set_fill(UiLabelArgs *args, UiBool fill); +UIEXPORT void ui_label_args_set_hexpand(UiLabelArgs *args, UiBool value); +UIEXPORT void ui_label_args_set_vexpand(UiLabelArgs *args, UiBool value); +UIEXPORT void ui_label_args_set_hfill(UiLabelArgs *args, UiBool value); +UIEXPORT void ui_label_args_set_vfill(UiLabelArgs *args, UiBool value); +UIEXPORT void ui_label_args_set_override_defaults(UiLabelArgs *args, UiBool value); +UIEXPORT void ui_label_args_set_colspan(UiLabelArgs *args, int colspan); +UIEXPORT void ui_label_args_set_rowspan(UiLabelArgs *args, int rowspan); +UIEXPORT void ui_label_args_set_name(UiLabelArgs *args, const char *name); +UIEXPORT void ui_label_args_set_style_class(UiLabelArgs *args, const char *classname); +UIEXPORT void ui_label_args_set_label(UiLabelArgs *args, const char *label); +UIEXPORT void ui_label_args_set_align(UiLabelArgs *args, UiAlignment align); +UIEXPORT void ui_label_args_set_style(UiLabelArgs *args, UiLabelStyle style); +UIEXPORT void ui_label_args_set_value(UiLabelArgs *args, UiString *value); +UIEXPORT void ui_label_args_set_varname(UiLabelArgs *args, const char *varname); +UIEXPORT void ui_label_args_free(UiLabelArgs *args); + +UIEXPORT UiProgressbarArgs* ui_progressbar_args_new(void); +UIEXPORT void ui_progressbar_args_set_fill(UiProgressbarArgs *args, UiBool fill); +UIEXPORT void ui_progressbar_args_set_hexpand(UiProgressbarArgs *args, UiBool value); +UIEXPORT void ui_progressbar_args_set_vexpand(UiProgressbarArgs *args, UiBool value); +UIEXPORT void ui_progressbar_args_set_hfill(UiProgressbarArgs *args, UiBool value); +UIEXPORT void ui_progressbar_args_set_vfill(UiProgressbarArgs *args, UiBool value); +UIEXPORT void ui_progressbar_args_set_override_defaults(UiProgressbarArgs *args, UiBool value); +UIEXPORT void ui_progressbar_args_set_colspan(UiProgressbarArgs *args, int colspan); +UIEXPORT void ui_progressbar_args_set_rowspan(UiProgressbarArgs *args, int rowspan); +UIEXPORT void ui_progressbar_args_set_name(UiProgressbarArgs *args, const char *name); +UIEXPORT void ui_progressbar_args_set_style_class(UiProgressbarArgs *args, const char *classname); +UIEXPORT void ui_progressbar_args_set_min(UiProgressbarArgs *args, double min); +UIEXPORT void ui_progressbar_args_set_max(UiProgressbarArgs *args, double max); +UIEXPORT void ui_progressbar_args_set_value(UiProgressbarArgs *args, UiDouble *value); +UIEXPORT void ui_progressbar_args_set_varname(UiProgressbarArgs *args, const char *varname); +UIEXPORT void ui_progressbar_args_free(UiProgressbarArgs *args); + +UIEXPORT UiProgressbarSpinnerArgs* ui_progress_spinner_args_new(void); +UIEXPORT void ui_progress_spinner_args_set_fill(UiProgressbarSpinnerArgs *args, UiBool fill); +UIEXPORT void ui_progress_spinner_args_set_hexpand(UiProgressbarSpinnerArgs *args, UiBool value); +UIEXPORT void ui_progress_spinner_args_set_vexpand(UiProgressbarSpinnerArgs *args, UiBool value); +UIEXPORT void ui_progress_spinner_args_set_hfill(UiProgressbarSpinnerArgs *args, UiBool value); +UIEXPORT void ui_progress_spinner_args_set_vfill(UiProgressbarSpinnerArgs *args, UiBool value); +UIEXPORT void ui_progress_spinner_args_set_override_defaults(UiProgressbarSpinnerArgs *args, UiBool value); +UIEXPORT void ui_progress_spinner_args_set_colspan(UiProgressbarSpinnerArgs *args, int colspan); +UIEXPORT void ui_progress_spinner_args_set_rowspan(UiProgressbarSpinnerArgs *args, int rowspan); +UIEXPORT void ui_progress_spinner_args_set_name(UiProgressbarSpinnerArgs *args, const char *name); +UIEXPORT void ui_progress_spinner_args_set_style_class(UiProgressbarSpinnerArgs *args, const char *classname); +UIEXPORT void ui_progress_spinner_args_set_value(UiProgressbarSpinnerArgs *args, UiInteger *value); +UIEXPORT void ui_progress_spinner_args_set_varname(UiProgressbarSpinnerArgs *args, const char *varname); +UIEXPORT void ui_progress_spinner_args_free(UiProgressbarSpinnerArgs *args); + UIEXPORT UiButtonArgs* ui_button_args_new(void); UIEXPORT void ui_button_args_set_fill(UiButtonArgs *args, UiBool fill); UIEXPORT void ui_button_args_set_hexpand(UiButtonArgs *args, UiBool value); @@ -257,6 +310,60 @@ UIEXPORT void ui_sourcelist_args_set_onbuttonclick(UiSourceListArgs *args, ui_ca UIEXPORT void ui_sourcelist_args_set_onbuttonclickdata(UiSourceListArgs *args, void *userdata); UIEXPORT void ui_sourcelist_args_free(UiSourceListArgs *args); +UIEXPORT UiTextAreaArgs* ui_textarea_args_new(void); +UIEXPORT void ui_textarea_args_set_fill(UiTextAreaArgs *args, UiBool fill); +UIEXPORT void ui_textarea_args_set_hexpand(UiTextAreaArgs *args, UiBool value); +UIEXPORT void ui_textarea_args_set_vexpand(UiTextAreaArgs *args, UiBool value); +UIEXPORT void ui_textarea_args_set_hfill(UiTextAreaArgs *args, UiBool value); +UIEXPORT void ui_textarea_args_set_vfill(UiTextAreaArgs *args, UiBool value); +UIEXPORT void ui_textarea_args_set_override_defaults(UiTextAreaArgs *args, UiBool value); +UIEXPORT void ui_textarea_args_set_colspan(UiTextAreaArgs *args, int colspan); +UIEXPORT void ui_textarea_args_set_rowspan(UiTextAreaArgs *args, int rowspan); +UIEXPORT void ui_textarea_args_set_name(UiTextAreaArgs *args, const char *name); +UIEXPORT void ui_textarea_args_set_style_class(UiTextAreaArgs *args, const char *classname); +UIEXPORT void ui_textarea_args_set_onchange(UiTextAreaArgs *args, ui_callback callback); +UIEXPORT void ui_textarea_args_set_onchangedata(UiTextAreaArgs *args, void *onchangedata); +UIEXPORT void ui_textarea_args_set_varname(UiTextAreaArgs *args, const char *varname); +UIEXPORT void ui_textarea_args_set_value(UiTextAreaArgs *args, UiText *value); +UIEXPORT void ui_textarea_args_set_groups(UiTextAreaArgs *args, int *groups); +UIEXPORT void ui_textarea_args_free(UiTextAreaArgs *args); + +UIEXPORT UiTextFieldArgs* ui_textfield_args_new(void); +UIEXPORT void ui_textfield_args_set_fill(UiTextFieldArgs *args, UiBool fill); +UIEXPORT void ui_textfield_args_set_hexpand(UiTextFieldArgs *args, UiBool value); +UIEXPORT void ui_textfield_args_set_vexpand(UiTextFieldArgs *args, UiBool value); +UIEXPORT void ui_textfield_args_set_hfill(UiTextFieldArgs *args, UiBool value); +UIEXPORT void ui_textfield_args_set_vfill(UiTextFieldArgs *args, UiBool value); +UIEXPORT void ui_textfield_args_set_override_defaults(UiTextFieldArgs *args, UiBool value); +UIEXPORT void ui_textfield_args_set_colspan(UiTextFieldArgs *args, int colspan); +UIEXPORT void ui_textfield_args_set_rowspan(UiTextFieldArgs *args, int rowspan); +UIEXPORT void ui_textfield_args_set_name(UiTextFieldArgs *args, const char *name); +UIEXPORT void ui_textfield_args_set_style_class(UiTextFieldArgs *args, const char *classname); +UIEXPORT void ui_textfield_args_set_onchange(UiTextFieldArgs *args, ui_callback callback); +UIEXPORT void ui_textfield_args_set_onchangedata(UiTextFieldArgs *args, void *onchangedata); +UIEXPORT void ui_textfield_args_set_onactivate(UiTextFieldArgs *args, ui_callback callback); +UIEXPORT void ui_textfield_args_set_onactivatedata(UiTextFieldArgs *args, void *onactivatedata); +UIEXPORT void ui_textfield_args_set_varname(UiTextFieldArgs *args, const char *varname); +UIEXPORT void ui_textfield_args_set_value(UiTextFieldArgs *args, UiString *value); +UIEXPORT void ui_textfield_args_set_groups(UiTextFieldArgs *args, int *groups); +UIEXPORT void ui_textfield_args_free(UiTextFieldArgs *args); + +UIEXPORT UiWebviewArgs* ui_webview_args_new(void); +UIEXPORT void ui_webview_args_set_fill(UiWebviewArgs *args, UiBool fill); +UIEXPORT void ui_webview_args_set_hexpand(UiWebviewArgs *args, UiBool value); +UIEXPORT void ui_webview_args_set_vexpand(UiWebviewArgs *args, UiBool value); +UIEXPORT void ui_webview_args_set_hfill(UiWebviewArgs *args, UiBool value); +UIEXPORT void ui_webview_args_set_vfill(UiWebviewArgs *args, UiBool value); +UIEXPORT void ui_webview_args_set_override_defaults(UiWebviewArgs *args, UiBool value); +UIEXPORT void ui_webview_args_set_colspan(UiWebviewArgs *args, int colspan); +UIEXPORT void ui_webview_args_set_rowspan(UiWebviewArgs *args, int rowspan); +UIEXPORT void ui_webview_args_set_name(UiWebviewArgs *args, const char *name); +UIEXPORT void ui_webview_args_set_style_class(UiWebviewArgs *args, const char *classname); +UIEXPORT void ui_webview_args_set_varname(UiWebviewArgs *args, const char *varname); +UIEXPORT void ui_webview_args_set_value(UiWebviewArgs *args, UiGeneric *value); +UIEXPORT void ui_webview_args_set_groups(UiWebviewArgs *args, int *groups); +UIEXPORT void ui_webview_args_free(UiWebviewArgs *args); + #ifdef __cplusplus } #endif diff --git a/ui/common/document.c b/ui/common/document.c index b2b2fba..bd69073 100644 --- a/ui/common/document.c +++ b/ui/common/document.c @@ -62,6 +62,7 @@ void ui_document_destroy(void *doc) { ev.document = doc; ev.obj = NULL; ev.eventdata = NULL; + ev.eventdatatype = 0; ev.intval = 0; if(ctx->close_callback) { diff --git a/ui/common/object.c b/ui/common/object.c index 9a42ce4..e7981c4 100644 --- a/ui/common/object.c +++ b/ui/common/object.c @@ -124,6 +124,7 @@ void uic_object_destroy(UiObject *obj) { ev.document = obj->ctx->document; ev.obj = obj; ev.eventdata = NULL; + ev.eventdatatype = 0; ev.intval = 0; obj->ctx->close_callback(&ev, obj->ctx->close_data); } diff --git a/ui/common/threadpool.c b/ui/common/threadpool.c index 7a37407..7988eab 100644 --- a/ui/common/threadpool.c +++ b/ui/common/threadpool.c @@ -165,6 +165,7 @@ static int ui_threadpool_job_finish(void *data) { event.document = job->obj->ctx->document; event.intval = 0; event.eventdata = NULL; + event.eventdatatype = 0; job->finish_callback(&event, job->finish_data); free(job); return 0; diff --git a/ui/common/types.c b/ui/common/types.c index 024ec0b..b3f55d1 100644 --- a/ui/common/types.c +++ b/ui/common/types.c @@ -77,6 +77,7 @@ void ui_notify_except(UiObserver *observer, UiObserver *exc, void *data) { evt.window = NULL; evt.document = NULL; evt.eventdata = data; + evt.eventdatatype = UI_EVENT_DATA_POINTER; evt.intval = 0; while(observer) { diff --git a/ui/common/wrapper.c b/ui/common/wrapper.c index 04b7430..ea88553 100644 --- a/ui/common/wrapper.c +++ b/ui/common/wrapper.c @@ -29,6 +29,7 @@ #include "wrapper.h" #include "types.h" #include +#include /* ---------------------------- UiObject ---------------------------- */ @@ -134,6 +135,33 @@ int ui_srclist_size(UiList *list) { } +/* ---------------------------- UiSubListEventData ---------------------------- */ + +UiList* ui_sublist_event_get_list(UiSubListEventData *event) { + return event->list; +} + +int ui_sublist_event_get_sublist_index(UiSubListEventData *event) { + return event->sublist_index; +} + +int ui_sublist_event_get_row_index(UiSubListEventData *event) { + return event->row_index; +} + +void* ui_sublist_event_get_row_data(UiSubListEventData *event) { + return event->row_data; +} + +void* ui_sublist_event_get_sublist_userdata(UiSubListEventData *event) { + return event->sublist_userdata; +} + +void* ui_sublist_event_get_event_data(UiSubListEventData *event) { + return event->event_data; +} + + /* ---------------------------- UiEvent ---------------------------- */ UiObject* ui_event_get_obj(UiEvent *event) { @@ -152,6 +180,10 @@ void* ui_event_get_eventdata(UiEvent *event) { return event->eventdata; } +int ui_event_get_eventdatatype(UiEvent *event) { + return event->eventdatatype; +} + int ui_event_get_int(UiEvent *event) { return event->intval; } diff --git a/ui/common/wrapper.h b/ui/common/wrapper.h index 02794b1..d190fc8 100644 --- a/ui/common/wrapper.h +++ b/ui/common/wrapper.h @@ -58,11 +58,19 @@ UIEXPORT void ui_srclist_insert(UiList *list, int index, UiSubList *item); UIEXPORT void ui_srclist_remove(UiList *list, int index); UIEXPORT void ui_srclist_clear(UiList *list); UIEXPORT int ui_srclist_size(UiList *list); + +UIEXPORT UiList* ui_sublist_event_get_list(UiSubListEventData *event); +UIEXPORT int ui_sublist_event_get_sublist_index(UiSubListEventData *event); +UIEXPORT int ui_sublist_event_get_row_index(UiSubListEventData *event); +UIEXPORT void* ui_sublist_event_get_row_data(UiSubListEventData *event); +UIEXPORT void* ui_sublist_event_get_sublist_userdata(UiSubListEventData *event); +UIEXPORT void* ui_sublist_event_get_event_data(UiSubListEventData *event); UIEXPORT UiObject* ui_event_get_obj(UiEvent *event); UIEXPORT void* ui_event_get_document(UiEvent *event); UIEXPORT void* ui_event_get_windowdata(UiEvent *event); UIEXPORT void* ui_event_get_eventdata(UiEvent *event); +UIEXPORT int ui_event_get_eventdatatype(UiEvent *event); UIEXPORT int ui_event_get_int(UiEvent *event); UIEXPORT int ui_event_get_set(UiEvent *event); diff --git a/ui/gtk/button.c b/ui/gtk/button.c index 6a95150..6f6ad0b 100644 --- a/ui/gtk/button.c +++ b/ui/gtk/button.c @@ -73,6 +73,7 @@ GtkWidget* ui_create_button( event->callback = onclick; event->value = event_value; event->customdata = NULL; + event->customint = 0; g_signal_connect( button, @@ -102,7 +103,7 @@ UIWIDGET ui_button_create(UiObject *obj, UiButtonArgs *args) { ui_set_name_and_style(button, args->name, args->style_class); ui_set_widget_groups(obj->ctx, button, args->groups); UI_APPLY_LAYOUT2(current, args); - current->container->add(current->container, button, FALSE); + current->container->add(current->container, button); return button; } @@ -113,6 +114,7 @@ void ui_button_clicked(GtkWidget *widget, UiEventData *event) { e.window = event->obj->window; e.document = event->obj->ctx->document; e.eventdata = NULL; + e.eventdatatype = 0; e.intval = event->value; e.set = ui_get_setop(); event->callback(&e, event->userdata); @@ -137,6 +139,7 @@ void ui_toggled_obs(void *widget, UiVarEventData *event) { e.window = event->obj->window; e.document = event->obj->ctx->document; e.eventdata = event->var->value; + e.eventdatatype = UI_EVENT_DATA_INTEGER_VALUE; e.intval = i->get(i); e.set = ui_get_setop(); @@ -149,6 +152,7 @@ static void ui_toggled_callback(GtkToggleButton *widget, UiEventData *event) { e.window = event->obj->window; e.document = event->obj->ctx->document; e.eventdata = NULL; + e.eventdatatype = 0; e.intval = gtk_toggle_button_get_active(widget); e.set = ui_get_setop(); event->callback(&e, event->userdata); @@ -240,6 +244,7 @@ void ui_bind_togglebutton( event->callback = onchange; event->value = 0; event->customdata = NULL; + event->customint = 0; g_signal_connect( widget, @@ -260,6 +265,7 @@ void ui_bind_togglebutton( event->callback = NULL; event->value = enable_state; event->customdata = NULL; + event->customint = 0; g_signal_connect( widget, @@ -291,7 +297,7 @@ static UIWIDGET togglebutton_create(UiObject *obj, GtkWidget *widget, UiToggleAr ui_set_widget_groups(obj->ctx, widget, args->groups); UI_APPLY_LAYOUT2(current, args); - current->container->add(current->container, widget, FALSE); + current->container->add(current->container, widget); return widget; } @@ -320,6 +326,7 @@ static void ui_checkbox_callback(GtkCheckButton *widget, UiEventData *event) { e.window = event->obj->window; e.document = event->obj->ctx->document; e.eventdata = NULL; + e.eventdatatype = 0; e.intval = gtk_check_button_get_active(widget); e.set = ui_get_setop(); event->callback(&e, event->userdata); @@ -354,7 +361,7 @@ UIWIDGET ui_checkbox_create(UiObject* obj, UiToggleArgs *args) { ui_set_widget_groups(obj->ctx, widget, args->groups); UI_APPLY_LAYOUT2(current, args); - current->container->add(current->container, widget, FALSE); + current->container->add(current->container, widget); return widget; } @@ -391,6 +398,7 @@ static void radiobutton_toggled(void *widget, UiEventData *event) { e.window = event->obj->window; e.document = event->obj->ctx->document; e.eventdata = NULL; + e.eventdatatype = 0; e.intval = RADIOBUTTON_GET_ACTIVE(widget); e.set = ui_get_setop(); event->callback(&e, event->userdata); @@ -483,6 +491,7 @@ UIWIDGET ui_radiobutton_create(UiObject *obj, UiToggleArgs *args) { event->callback = args->onchange; event->value = 0; event->customdata = NULL; + event->customint = 0; g_signal_connect( rbutton, @@ -497,7 +506,7 @@ UIWIDGET ui_radiobutton_create(UiObject *obj, UiToggleArgs *args) { } UI_APPLY_LAYOUT2(current, args); - current->container->add(current->container, rbutton, FALSE); + current->container->add(current->container, rbutton); return rbutton; } @@ -510,6 +519,7 @@ void ui_radio_obs(GtkToggleButton *widget, UiVarEventData *event) { e.window = event->obj->window; e.document = event->obj->ctx->document; e.eventdata = NULL; + e.eventdatatype = 0; e.intval = i->get(i); ui_notify_evt(i->observers, &e); diff --git a/ui/gtk/container.c b/ui/gtk/container.c index 8ee7ee5..7a98bf4 100644 --- a/ui/gtk/container.c +++ b/ui/gtk/container.c @@ -120,12 +120,9 @@ UiContainer* ui_box_container(UiObject *obj, GtkWidget *box, UiSubContainerType return (UiContainer*)ct; } -void ui_box_container_add(UiContainer *ct, GtkWidget *widget, UiBool fill) { +void ui_box_container_add(UiContainer *ct, GtkWidget *widget) { UiBoxContainer *bc = (UiBoxContainer*)ct; - if(ct->layout.fill != UI_LAYOUT_UNDEFINED) { - fill = ui_lb2bool(ct->layout.fill); - } - + UiBool fill = ct->layout.fill; if(bc->has_fill && fill) { fprintf(stderr, "UiError: container has 2 filled widgets"); fill = FALSE; @@ -180,7 +177,7 @@ UiContainer* ui_grid_container( } #if GTK_MAJOR_VERSION >= 3 -void ui_grid_container_add(UiContainer *ct, GtkWidget *widget, UiBool fill) { +void ui_grid_container_add(UiContainer *ct, GtkWidget *widget) { UiGridContainer *grid = (UiGridContainer*)ct; if(ct->layout.newline) { @@ -208,9 +205,7 @@ void ui_grid_container_add(UiContainer *ct, GtkWidget *widget, UiBool fill) { } } - if(ct->layout.fill != UI_LAYOUT_UNDEFINED) { - fill = ui_lb2bool(ct->layout.fill); - } + UiBool fill = ct->layout.fill; if(ct->layout.hexpand) { hexpand = TRUE; hfill = TRUE; @@ -249,7 +244,7 @@ void ui_grid_container_add(UiContainer *ct, GtkWidget *widget, UiBool fill) { } #endif #ifdef UI_GTK2 -void ui_grid_container_add(UiContainer *ct, GtkWidget *widget, UiBool fill) { +void ui_grid_container_add(UiContainer *ct, GtkWidget *widget) { UiGridContainer *grid = (UiGridContainer*)ct; if(ct->layout.newline) { @@ -277,9 +272,7 @@ void ui_grid_container_add(UiContainer *ct, GtkWidget *widget, UiBool fill) { } } - if(ct->layout.fill != UI_LAYOUT_UNDEFINED) { - fill = ui_lb2bool(ct->layout.fill); - } + UiBool fill = ct->layout.fill; if(ct->layout.hexpand) { hexpand = TRUE; hfill = TRUE; @@ -340,7 +333,7 @@ UiContainer* ui_frame_container(UiObject *obj, GtkWidget *frame) { return ct; } -void ui_frame_container_add(UiContainer *ct, GtkWidget *widget, UiBool fill) { +void ui_frame_container_add(UiContainer *ct, GtkWidget *widget) { FRAME_SET_CHILD(ct->widget, widget); } @@ -354,11 +347,11 @@ UiContainer* ui_expander_container(UiObject *obj, GtkWidget *expander) { return ct; } -void ui_expander_container_add(UiContainer *ct, GtkWidget *widget, UiBool fill) { +void ui_expander_container_add(UiContainer *ct, GtkWidget *widget) { EXPANDER_SET_CHILD(ct->widget, widget); } -void ui_scrolledwindow_container_add(UiContainer *ct, GtkWidget *widget, UiBool fill) { +void ui_scrolledwindow_container_add(UiContainer *ct, GtkWidget *widget) { // TODO: check if the widget implements GtkScrollable SCROLLEDWINDOW_SET_CHILD(ct->widget, widget); ui_reset_layout(ct->layout); @@ -385,7 +378,7 @@ UiContainer* ui_tabview_container(UiObject *obj, GtkWidget *tabview) { return (UiContainer*)ct; } -void ui_tabview_container_add(UiContainer *ct, GtkWidget *widget, UiBool fill) { +void ui_tabview_container_add(UiContainer *ct, GtkWidget *widget) { UiGtkTabView *data = ui_widget_get_tabview_data(ct->widget); if(!data) { fprintf(stderr, "UI Error: widget is not a tabview"); @@ -428,7 +421,7 @@ UIWIDGET ui_box_create(UiObject *obj, UiContainerArgs *args, UiSubContainerType GtkWidget *box = type == UI_CONTAINER_VBOX ? ui_gtk_vbox_new(args->spacing) : ui_gtk_hbox_new(args->spacing); ui_set_name_and_style(box, args->name, args->style_class); GtkWidget *widget = args->margin > 0 ? ui_box_set_margin(box, args->margin) : box; - ct->add(ct, widget, TRUE); + ct->add(ct, widget); UiObject *newobj = uic_object_new(obj, box); newobj->container = ui_box_container(obj, box, type); @@ -466,7 +459,7 @@ UIWIDGET ui_grid_create(UiObject *obj, UiContainerArgs *args) { GtkWidget *grid = ui_create_grid_widget(args->columnspacing, args->rowspacing); ui_set_name_and_style(grid, args->name, args->style_class); widget = ui_box_set_margin(grid, args->margin); - current->container->add(current->container, widget, TRUE); + current->container->add(current->container, widget); UiObject *newobj = uic_object_new(obj, grid); newobj->container = ui_grid_container(obj, grid, args->def_hexpand, args->def_vexpand, args->def_hfill, args->def_vfill); @@ -488,7 +481,7 @@ UIWIDGET ui_frame_create(UiObject *obj, UiFrameArgs *args) { newobj->widget = frame; newobj->container = ui_frame_container(obj, frame); } - current->container->add(current->container, frame, FALSE); + current->container->add(current->container, frame); uic_obj_add(obj, newobj); return frame; @@ -508,7 +501,7 @@ UIEXPORT UIWIDGET ui_expander_create(UiObject *obj, UiFrameArgs *args) { newobj->widget = expander; newobj->container = ui_expander_container(obj, expander); } - current->container->add(current->container, expander, FALSE); + current->container->add(current->container, expander); uic_obj_add(obj, newobj); return expander; @@ -522,7 +515,7 @@ UIWIDGET ui_scrolledwindow_create(UiObject* obj, UiFrameArgs *args) { GtkWidget *sw = SCROLLEDWINDOW_NEW(); ui_set_name_and_style(sw, args->name, args->style_class); GtkWidget *widget = ui_box_set_margin(sw, args->margin); - current->container->add(current->container, widget, TRUE); + current->container->add(current->container, widget); UiObject *newobj = uic_object_new(obj, sw); GtkWidget *sub = ui_subcontainer_create(args->subcontainer, newobj, args->spacing, args->columnspacing, args->rowspacing, args->margin); @@ -706,6 +699,7 @@ static void tabview_switch_page( event.document = event.obj->ctx->document; event.set = ui_get_setop(); event.eventdata = NULL; + event.eventdatatype = 0; event.intval = page_num; tabview->onchange(&event, tabview->onchange); @@ -728,6 +722,7 @@ static void tabview_stack_changed( event.document = event.obj->ctx->document; event.set = ui_get_setop(); event.eventdata = NULL; + event.eventdatatype = 0; event.intval = 0; tabview->onchange(&event, tabview->onchange); @@ -815,7 +810,7 @@ UIWIDGET ui_tabview_create(UiObject* obj, UiTabViewArgs *args) { data->subcontainer = args->subcontainer; UI_APPLY_LAYOUT2(current, args); - current->container->add(current->container, widget, TRUE); + current->container->add(current->container, widget); UiObject *newobj = uic_object_new(obj, widget); newobj->container = ui_tabview_container(obj, widget); @@ -932,7 +927,7 @@ UIWIDGET ui_headerbar_fallback_create(UiObject *obj, UiHeaderbarArgs *args) { GtkWidget *box = ui_gtk_hbox_new(args->alt_spacing); ui_set_name_and_style(box, args->name, args->style_class); - ct->add(ct, box, FALSE); + ct->add(ct, box); UiObject *newobj = uic_object_new(obj, box); newobj->container = ui_headerbar_fallback_container(obj, box); @@ -963,7 +958,7 @@ UiContainer* ui_headerbar_fallback_container(UiObject *obj, GtkWidget *headerbar return (UiContainer*)ct; } -void ui_headerbar_fallback_container_add(UiContainer *ct, GtkWidget *widget, UiBool fill) { +void ui_headerbar_fallback_container_add(UiContainer *ct, GtkWidget *widget) { UiHeaderbarContainer *hb = (UiHeaderbarContainer*)ct; BOX_ADD(ct->widget, widget); } @@ -993,7 +988,7 @@ UiContainer* ui_headerbar_container(UiObject *obj, GtkWidget *headerbar) { return (UiContainer*)ct; } -void ui_headerbar_container_add(UiContainer *ct, GtkWidget *widget, UiBool fill) { +void ui_headerbar_container_add(UiContainer *ct, GtkWidget *widget) { UiHeaderbarContainer *hb = (UiHeaderbarContainer*)ct; if(hb->part == 0) { UI_HEADERBAR_PACK_START(ct->widget, widget); @@ -1078,7 +1073,7 @@ static UIWIDGET splitpane_create(UiObject *obj, UiOrientation orientation, UiSpl GtkWidget *pane0 = create_paned(orientation); UI_APPLY_LAYOUT2(current, args); - current->container->add(current->container, pane0, TRUE); + current->container->add(current->container, pane0); int max = args->max_panes == 0 ? 2 : args->max_panes; @@ -1111,7 +1106,7 @@ UiContainer* ui_splitpane_container(UiObject *obj, GtkWidget *pane, UiOrientatio return (UiContainer*)ct; } -void ui_splitpane_container_add(UiContainer *ct, GtkWidget *widget, UiBool fill) { +void ui_splitpane_container_add(UiContainer *ct, GtkWidget *widget) { UiSplitPaneContainer *s = (UiSplitPaneContainer*)ct; if(s->nchildren >= s->max) { @@ -1204,7 +1199,7 @@ static void update_itemlist(UiList *list, int c) { UiObject *item_obj = cxMapGet(ct->current_items, key); if(item_obj) { // re-add previously created widget - ui_box_container_add(ct->container, item_obj->widget, FALSE); + ui_box_container_add(ct->container, item_obj->widget); } else { // create new widget and object for this list element CxMempool *mp = cxMempoolCreateSimple(256); @@ -1219,7 +1214,7 @@ static void update_itemlist(UiList *list, int c) { ct->columnspacing, ct->rowspacing, ct->margin); - ui_box_container_add(ct->container, obj->widget, FALSE); + ui_box_container_add(ct->container, obj->widget); if(ct->create_ui) { ct->create_ui(obj, index, elm, ct->userdata); } @@ -1248,7 +1243,7 @@ UIWIDGET ui_itemlist_create(UiObject *obj, UiItemListContainerArgs *args) { GtkWidget *box = args->container == UI_CONTAINER_VBOX ? ui_gtk_vbox_new(args->spacing) : ui_gtk_hbox_new(args->spacing); ui_set_name_and_style(box, args->name, args->style_class); GtkWidget *widget = args->margin > 0 ? ui_box_set_margin(box, args->margin) : box; - ct->add(ct, widget, TRUE); + ct->add(ct, widget); UiGtkItemListContainer *container = malloc(sizeof(UiGtkItemListContainer)); container->parent = obj; @@ -1293,7 +1288,7 @@ UIWIDGET ui_itemlist_create(UiObject *obj, UiItemListContainerArgs *args) { void ui_layout_fill(UiObject *obj, UiBool fill) { UiContainer *ct = uic_get_current_container(obj); - ct->layout.fill = ui_bool2lb(fill); + ct->layout.fill = fill; } void ui_layout_hexpand(UiObject *obj, UiBool expand) { diff --git a/ui/gtk/container.h b/ui/gtk/container.h index 6c254a4..5f44766 100644 --- a/ui/gtk/container.h +++ b/ui/gtk/container.h @@ -44,23 +44,15 @@ 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 void (*ui_container_add_f)(UiContainer*, GtkWidget*); typedef struct UiDocumentView UiDocumentView; -typedef enum UiLayoutBool { - UI_LAYOUT_UNDEFINED = 0, - UI_LAYOUT_TRUE, - UI_LAYOUT_FALSE, -} UiLayoutBool; - typedef struct UiLayout UiLayout; struct UiLayout { - UiLayoutBool fill; + UiBool fill; UiBool newline; char *label; UiBool hexpand; @@ -78,7 +70,7 @@ struct UiContainer { UIMENU menu; GtkWidget *current; - void (*add)(UiContainer*, GtkWidget*, UiBool); + void (*add)(UiContainer*, GtkWidget*); UiLayout layout; int close; @@ -172,13 +164,13 @@ GtkWidget* ui_subcontainer_create( int margin); UiContainer* ui_frame_container(UiObject *obj, GtkWidget *frame); -void ui_frame_container_add(UiContainer *ct, GtkWidget *widget, UiBool fill); +void ui_frame_container_add(UiContainer *ct, GtkWidget *widget); 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); +void ui_box_container_add(UiContainer *ct, GtkWidget *widget); GtkWidget* ui_create_grid_widget(int colspacing, int rowspacing); UiContainer* ui_grid_container( @@ -188,22 +180,22 @@ UiContainer* ui_grid_container( UiBool def_vexpand, UiBool def_hfill, UiBool def_vfill); -void ui_grid_container_add(UiContainer *ct, GtkWidget *widget, UiBool fill); +void ui_grid_container_add(UiContainer *ct, GtkWidget *widget); UiContainer* ui_frame_container(UiObject *obj, GtkWidget *frame); -void ui_frame_container_add(UiContainer *ct, GtkWidget *widget, UiBool fill); +void ui_frame_container_add(UiContainer *ct, GtkWidget *widget); UiContainer* ui_expander_container(UiObject *obj, GtkWidget *expander); -void ui_expander_container_add(UiContainer *ct, GtkWidget *widget, UiBool fill); +void ui_expander_container_add(UiContainer *ct, GtkWidget *widget); UiContainer* ui_scrolledwindow_container(UiObject *obj, GtkWidget *scrolledwindow); -void ui_scrolledwindow_container_add(UiContainer *ct, GtkWidget *widget, UiBool fill); +void ui_scrolledwindow_container_add(UiContainer *ct, GtkWidget *widget); UiContainer* ui_tabview_container(UiObject *obj, GtkWidget *tabview); -void ui_tabview_container_add(UiContainer *ct, GtkWidget *widget, UiBool fill); +void ui_tabview_container_add(UiContainer *ct, GtkWidget *widget); UiContainer* ui_splitpane_container(UiObject *obj, GtkWidget *pane, UiOrientation orientation, int max, int init); -void ui_splitpane_container_add(UiContainer *ct, GtkWidget *widget, UiBool fill); +void ui_splitpane_container_add(UiContainer *ct, GtkWidget *widget); UiGtkTabView* ui_widget_get_tabview_data(UIWIDGET tabview); @@ -212,11 +204,11 @@ 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); +void ui_headerbar_container_add(UiContainer *ct, GtkWidget *widget); #endif UiContainer* ui_headerbar_fallback_container(UiObject *obj, GtkWidget *headerbar); -void ui_headerbar_fallback_container_add(UiContainer *ct, GtkWidget *widget, UiBool fill); +void ui_headerbar_fallback_container_add(UiContainer *ct, GtkWidget *widget); #ifdef __cplusplus } diff --git a/ui/gtk/display.c b/ui/gtk/display.c index 617273a..40fcde1 100644 --- a/ui/gtk/display.c +++ b/ui/gtk/display.c @@ -114,7 +114,7 @@ UIWIDGET ui_label_create(UiObject *obj, UiLabelArgs *args) { } UI_APPLY_LAYOUT2(current, args); - current->container->add(current->container, widget, FALSE); + current->container->add(current->container, widget); return widget; } @@ -150,7 +150,7 @@ void ui_label_set(UiString *s, const char *value) { UIWIDGET ui_space_deprecated(UiObject *obj) { GtkWidget *widget = gtk_label_new(""); UiContainer *ct = uic_get_current_container(obj); - ct->add(ct, widget, TRUE); + ct->add(ct, widget); return widget; } @@ -162,7 +162,7 @@ UIWIDGET ui_separator_deprecated(UiObject *obj) { GtkWidget *widget = gtk_hseparator_new(); #endif UiContainer *ct = uic_get_current_container(obj); - ct->add(ct, widget, FALSE); + ct->add(ct, widget); return widget; } @@ -201,7 +201,7 @@ UIWIDGET ui_progressbar_create(UiObject *obj, UiProgressbarArgs *args) { } UI_APPLY_LAYOUT2(current, args); - current->container->add(current->container, progressbar, FALSE); + current->container->add(current->container, progressbar); return progressbar; } @@ -243,7 +243,7 @@ UIWIDGET ui_progressspinner_create(UiObject* obj, UiProgressbarSpinnerArgs *args } UI_APPLY_LAYOUT2(current, args); - current->container->add(current->container, spinner, FALSE); + current->container->add(current->container, spinner); return spinner; } diff --git a/ui/gtk/entry.c b/ui/gtk/entry.c index ea02755..3c83f11 100644 --- a/ui/gtk/entry.c +++ b/ui/gtk/entry.c @@ -130,7 +130,7 @@ UIWIDGET ui_spinner_create(UiObject *obj, UiSpinnerArgs *args) { event); UI_APPLY_LAYOUT2(current, args); - current->container->add(current->container, spin, FALSE); + current->container->add(current->container, spin); return spin; } @@ -150,7 +150,8 @@ void ui_spinner_changed(GtkSpinButton *spinner, UiVarEventData *event) { e.obj = event->obj; e.window = event->obj->window; e.document = event->obj->ctx->document; - e.eventdata = &value; + e.eventdata = NULL; + e.eventdatatype = 0; e.intval = (int64_t)value; if(event->callback) { diff --git a/ui/gtk/graphics.c b/ui/gtk/graphics.c index dcaff88..6883575 100644 --- a/ui/gtk/graphics.c +++ b/ui/gtk/graphics.c @@ -45,7 +45,7 @@ UIWIDGET ui_drawingarea(UiObject *obj, ui_drawfunc f, void *userdata) { } UiContainer *ct = uic_get_current_container(obj); - ct->add(ct, widget, TRUE); + ct->add(ct, widget); return widget; } diff --git a/ui/gtk/image.c b/ui/gtk/image.c index 3a2550d..425af82 100644 --- a/ui/gtk/image.c +++ b/ui/gtk/image.c @@ -188,7 +188,7 @@ UIWIDGET ui_imageviewer_create(UiObject *obj, UiImageViewerArgs *args) { } UI_APPLY_LAYOUT2(current, args); - current->container->add(current->container, toplevel, TRUE); + current->container->add(current->container, toplevel); return toplevel; } @@ -438,6 +438,7 @@ static void imgviewer_button_event( event.window = event.obj->window; event.document = event.obj->ctx->document; event.eventdata = NULL; + event.eventdatatype = 0; event.intval = gtk_gesture_single_get_current_button(GTK_GESTURE_SINGLE(gesture)); event.set = 0; callback(&event, userdata); diff --git a/ui/gtk/list.c b/ui/gtk/list.c index ea96fb0..be9c00a 100644 --- a/ui/gtk/list.c +++ b/ui/gtk/list.c @@ -133,7 +133,7 @@ static void column_factory_setup(GtkListItemFactory *factory, GtkListItem *item, static void column_factory_bind( GtkListItemFactory *factory, GtkListItem *item, gpointer userdata) { UiColData *col = userdata; - UiList *list = col->listview->var->value; + UiList *list = col->listview->var ? col->listview->var->value : NULL; ObjWrapper *obj = gtk_list_item_get_item(item); UiModel *model = col->listview->model; @@ -305,7 +305,7 @@ UIWIDGET ui_listview_create(UiObject *obj, UiListArgs *args) { SCROLLEDWINDOW_SET_CHILD(scroll_area, view); UI_APPLY_LAYOUT2(current, args); - current->container->add(current->container, scroll_area, FALSE); + current->container->add(current->container, scroll_area); // ct->current should point to view, not scroll_area, to make it possible // to add a context menu @@ -381,7 +381,7 @@ UIWIDGET ui_combobox_create(UiObject *obj, UiListArgs *args) { // add widget to parent UI_APPLY_LAYOUT2(current, args); - current->container->add(current->container, view, FALSE); + current->container->add(current->container, view); return view; } @@ -485,7 +485,7 @@ UIWIDGET ui_table_create(UiObject *obj, UiListArgs *args) { SCROLLEDWINDOW_SET_CHILD(scroll_area, view); UI_APPLY_LAYOUT2(current, args); - current->container->add(current->container, scroll_area, FALSE); + current->container->add(current->container, scroll_area); // ct->current should point to view, not scroll_area, to make it possible // to add a context menu @@ -511,6 +511,7 @@ static void listview_event(ui_callback cb, void *cbdata, UiListView *view) { event.window = event.obj->window; event.intval = view->selection.count; event.eventdata = &view->selection; + event.eventdatatype = UI_EVENT_DATA_LIST_SELECTION; event.set = ui_get_setop(); if(cb) { cb(&event, cbdata); @@ -554,6 +555,7 @@ void ui_dropdown_notify(GtkWidget *dropdown, GObject *pspec, gpointer userdata) event.window = event.obj->window; event.intval = index; event.eventdata = eventdata->data; + event.eventdatatype = UI_EVENT_DATA_LIST_ELM; event.set = ui_get_setop(); view->onactivate(&event, view->onactivatedata); } @@ -591,6 +593,7 @@ void ui_dropdown_activate(GtkDropDown* self, gpointer userdata) { event.window = event.obj->window; event.intval = view->selection.count; event.eventdata = &view->selection; + event.eventdatatype = UI_EVENT_DATA_LIST_SELECTION; event.set = ui_get_setop(); view->onactivate(&event, view->onactivatedata); } @@ -1385,6 +1388,7 @@ static GdkContentProvider *ui_listview_dnd_prepare(GtkDragSource *source, double event.window = event.obj->window; event.document = event.obj->ctx->document; event.eventdata = dnd; + event.eventdatatype = UI_EVENT_DATA_DND; event.intval = 0; event.set = ui_get_setop(); listview->ondragstart(&event, listview->ondragstartdata); @@ -1421,6 +1425,7 @@ static void ui_listview_drag_end(GtkDragSource *self, GdkDrag *drag, gboolean de event.window = event.obj->window; event.document = event.obj->ctx->document; event.eventdata = &dnd; + event.eventdatatype = UI_EVENT_DATA_DND; event.intval = 0; event.set = ui_get_setop(); listview->ondragcomplete(&event, listview->ondragcompletedata); @@ -1450,6 +1455,7 @@ static gboolean ui_listview_drop( event.window = event.obj->window; event.document = event.obj->ctx->document; event.eventdata = &dnd; + event.eventdatatype = UI_EVENT_DATA_DND; event.intval = 0; event.set = ui_get_setop(); listview->ondrop(&event, listview->ondropdata); @@ -1829,7 +1835,7 @@ UIEXPORT UIWIDGET ui_sourcelist_create(UiObject *obj, UiSourceListArgs *args) { ui_set_name_and_style(listbox, args->name, args->style_class); ui_set_widget_groups(obj->ctx, listbox, args->groups); UI_APPLY_LAYOUT2(current, args); - current->container->add(current->container, scroll_area, TRUE); + current->container->add(current->container, scroll_area); UiListBox *uilistbox = malloc(sizeof(UiListBox)); uilistbox->obj = obj; @@ -2008,7 +2014,11 @@ void ui_listbox_update_sublist(UiListBox *listbox, UiListBoxSubList *sublist, si void *elm = list->first(list); while(elm) { UiSubListItem item = { NULL, NULL, NULL, NULL, NULL, NULL }; - listbox->getvalue(sublist->userdata, elm, index, &item, listbox->getvaluedata); + if(listbox->getvalue) { + listbox->getvalue(list, sublist->userdata, elm, index, &item, listbox->getvaluedata); + } else { + item.label = strdup(elm); + } // create listbox item GtkWidget *row = create_listbox_row(listbox, sublist, &item, (int)index); @@ -2059,7 +2069,7 @@ void ui_listbox_row_activate(GtkListBox *self, GtkListBoxRow *row, gpointer user eventdata.sublist_index = sublist->index; eventdata.row_index = data->value0; eventdata.sublist_userdata = sublist->userdata; - eventdata.row_data = ui_list_get(eventdata.list, eventdata.row_index); + eventdata.row_data = eventdata.list->get(eventdata.list, eventdata.row_index); eventdata.event_data = data->customdata2; UiEvent event; @@ -2067,6 +2077,7 @@ void ui_listbox_row_activate(GtkListBox *self, GtkListBoxRow *row, gpointer user event.window = event.obj->window; event.document = event.obj->ctx->document; event.eventdata = &eventdata; + event.eventdatatype = UI_EVENT_DATA_SUBLIST; event.intval = data->value0; event.set = ui_get_setop(); diff --git a/ui/gtk/menu.c b/ui/gtk/menu.c index a54a34b..521bf91 100644 --- a/ui/gtk/menu.c +++ b/ui/gtk/menu.c @@ -514,6 +514,7 @@ void ui_gmenu_add_menuitem(GMenu *parent, int index, UiMenuItemI *item, UiObject event->callback = i->callback; event->value = 0; event->customdata = NULL; + event->customint = 0; g_signal_connect( action, @@ -613,6 +614,7 @@ void ui_gmenu_add_menuitem_list(GMenu *p, int index, UiMenuItemI *item, UiObject event->userdata = il->userdata; event->callback = il->callback; event->customdata = var; + event->customint = 0; event->value = 0; g_signal_connect( @@ -638,6 +640,7 @@ void ui_activate_event_wrapper(GSimpleAction* self, GVariant* parameter, UiEvent evt.window = event->obj->window; evt.document = event->obj->ctx->document; evt.eventdata = event->customdata; + evt.eventdatatype = event->customint; evt.intval = intval; event->callback(&evt, event->userdata); } @@ -652,6 +655,7 @@ void ui_menu_list_item_activate_event_wrapper(GSimpleAction* self, GVariant* par evt.window = event->obj->window; evt.document = event->obj->ctx->document; evt.eventdata = ui_list_get(list, index); + evt.eventdatatype = UI_EVENT_DATA_LIST_ELM; evt.intval = index; event->callback(&evt, event->userdata); diff --git a/ui/gtk/range.c b/ui/gtk/range.c index c992159..45c5bfc 100644 --- a/ui/gtk/range.c +++ b/ui/gtk/range.c @@ -62,6 +62,7 @@ static UIWIDGET ui_scrollbar(UiObject *obj, UiOrientation orientation, UiRange * event->callback = f; event->value = 0; event->customdata = NULL; + event->customint = 0; g_signal_connect( G_OBJECT(scrollbar), @@ -76,7 +77,7 @@ static UIWIDGET ui_scrollbar(UiObject *obj, UiOrientation orientation, UiRange * } UiContainer *ct = uic_get_current_container(obj); - ct->add(ct, scrollbar, FALSE); + ct->add(ct, scrollbar); return scrollbar; } @@ -95,6 +96,7 @@ gboolean ui_scrollbar_value_changed(GtkRange *range, UiEventData *event) { e.window = event->obj->window; e.document = event->obj->ctx->document; e.eventdata = NULL; + e.eventdatatype = 0; e.intval = event->value; event->callback(&e, event->userdata); return TRUE; diff --git a/ui/gtk/text.c b/ui/gtk/text.c index 3e81342..9ea0c4c 100644 --- a/ui/gtk/text.c +++ b/ui/gtk/text.c @@ -156,7 +156,7 @@ UIWIDGET ui_textarea_create(UiObject *obj, UiTextAreaArgs *args) { // add UI_APPLY_LAYOUT2(current, args); - current->container->add(current->container, scroll_area, TRUE); + current->container->add(current->container, scroll_area); // bind value if(var) { @@ -330,6 +330,7 @@ void ui_textbuf_changed(GtkTextBuffer *textbuffer, UiTextArea *textarea) { e.window = e.obj->window; e.document = textarea->ctx->document; e.eventdata = value; + e.eventdatatype = UI_EVENT_DATA_TEXT_VALUE; e.intval = 0; e.set = ui_get_setop(); @@ -629,7 +630,7 @@ static UIWIDGET create_textfield(UiObject *obj, UiBool frameless, UiBool passwor } UI_APPLY_LAYOUT2(current, args); - current->container->add(current->container, textfield, FALSE); + current->container->add(current->container, textfield); if(var) { UiString *value = var->value; @@ -691,6 +692,7 @@ void ui_textfield_changed(GtkEditable *editable, UiTextField *textfield) { e.window = e.obj->window; e.document = textfield->obj->ctx->document; e.eventdata = value; + e.eventdatatype = UI_EVENT_DATA_TEXT_VALUE; e.intval = 0; e.set = ui_get_setop(); @@ -710,6 +712,7 @@ void ui_textfield_activate(GtkEntry* self, UiTextField *textfield) { e.window = e.obj->window; e.document = textfield->obj->ctx->document; e.eventdata = NULL; + e.eventdatatype = 0; e.intval = 0; e.set = ui_get_setop(); textfield->onactivate(&e, textfield->onactivatedata); @@ -807,6 +810,7 @@ void ui_path_button_clicked(GtkWidget *widget, UiEventDataExt *event) { evt.window = evt.obj->window; evt.document = evt.obj->ctx->document; evt.eventdata = elm->path; + evt.eventdatatype = UI_EVENT_DATA_STRING; evt.intval = event->value0; evt.set = ui_get_setop(); event->callback(&evt, event->userdata); @@ -888,6 +892,7 @@ static void ui_path_textfield_activate(GtkWidget *entry, UiPathTextField *pathtf evt.window = obj->window; evt.document = obj->ctx->document; evt.eventdata = (char*)text; + evt.eventdatatype = UI_EVENT_DATA_STRING; evt.intval = -1; pathtf->onactivate(&evt, pathtf->onactivatedata); } @@ -941,7 +946,7 @@ UIWIDGET ui_path_textfield_create(UiObject* obj, UiPathTextFieldArgs *args) { gtk_widget_set_name(pathtf->stack, "path-textfield-box"); UI_APPLY_LAYOUT2(current, args); - current->container->add(current->container, pathtf->stack, FALSE); + current->container->add(current->container, pathtf->stack); pathtf->entry_box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); pathtf->entry = gtk_entry_new(); diff --git a/ui/gtk/toolbar.c b/ui/gtk/toolbar.c index 60c4bac..0409be9 100644 --- a/ui/gtk/toolbar.c +++ b/ui/gtk/toolbar.c @@ -155,6 +155,7 @@ void add_toolitem_widget(GtkToolbar *tb, UiToolbarItem *item, UiObject *obj) { event->callback = item->args.onclick; event->userdata = item->args.onclickdata; event->customdata = NULL; + event->customint = 0; event->value = 0; g_signal_connect( @@ -237,6 +238,7 @@ void ui_tool_button_toggled(GtkToggleToolButton *widget, UiVarEventData *event) e.window = event->obj->window; e.document = event->obj->ctx->document; e.eventdata = NULL; + e.eventdatatype = 0; e.intval = gtk_toggle_tool_button_get_active(widget); if(event->callback) { diff --git a/ui/gtk/toolkit.c b/ui/gtk/toolkit.c index 7e8e3a5..7a26a70 100644 --- a/ui/gtk/toolkit.c +++ b/ui/gtk/toolkit.c @@ -191,6 +191,7 @@ static gboolean ui_job_finished(void *data) { event.document = job->obj->ctx->document; event.intval = 0; event.eventdata = NULL; + event.eventdatatype = 0; job->finish_callback(&event, job->finish_data); free(job); diff --git a/ui/gtk/toolkit.h b/ui/gtk/toolkit.h index b98bb25..b66c695 100644 --- a/ui/gtk/toolkit.h +++ b/ui/gtk/toolkit.h @@ -131,6 +131,7 @@ typedef struct UiEventData { ui_callback callback; void *userdata; int value; + int customint; void *customdata; } UiEventData; diff --git a/ui/gtk/webview.c b/ui/gtk/webview.c index 1cd09aa..3b9a946 100644 --- a/ui/gtk/webview.c +++ b/ui/gtk/webview.c @@ -61,7 +61,7 @@ UIWIDGET ui_webview_create(UiObject *obj, UiWebviewArgs *args) { ui_set_widget_groups(obj->ctx, webview, args->groups); UI_APPLY_LAYOUT2(current, args); - current->container->add(current->container, webview, FALSE); + current->container->add(current->container, webview); return webview; } diff --git a/ui/gtk/widget.c b/ui/gtk/widget.c index 633b0f9..36f4465 100644 --- a/ui/gtk/widget.c +++ b/ui/gtk/widget.c @@ -37,7 +37,7 @@ UIEXPORT UIWIDGET ui_customwidget_create(UiObject *obj, ui_createwidget_func cre UIWIDGET widget = create_widget(obj, args, userdata); UI_APPLY_LAYOUT2(current, args); - current->container->add(current->container, widget, FALSE); + current->container->add(current->container, widget); return widget; } @@ -47,7 +47,7 @@ UIWIDGET ui_separator_create(UiObject *obj, UiWidgetArgs *args) { GtkWidget *widget = gtk_separator_new(GTK_ORIENTATION_HORIZONTAL); ui_set_name_and_style(widget, args->name, args->style_class); UI_APPLY_LAYOUT1(current, (*args)); - current->container->add(current->container, widget, FALSE); + current->container->add(current->container, widget); return widget; } diff --git a/ui/gtk/window.c b/ui/gtk/window.c index 1d03948..cdafae3 100644 --- a/ui/gtk/window.c +++ b/ui/gtk/window.c @@ -312,6 +312,8 @@ static void dialog_response(AdwAlertDialog *self, gchar *response, UiEventData * evt.document = evt.obj->ctx->document; evt.window = evt.obj->window; evt.eventdata = NULL; + evt.eventdatatype = 0; + evt.eventdatatype = 0; evt.intval = 0; if(!strcmp(response, "btn1")) { @@ -323,6 +325,7 @@ static void dialog_response(AdwAlertDialog *self, gchar *response, UiEventData * if(data->customdata) { GtkWidget *entry = data->customdata; evt.eventdata = (void*)ENTRY_GET_TEXT(GTK_ENTRY(entry)); + evt.eventdatatype = UI_EVENT_DATA_STRING; } if(data->callback) { @@ -336,6 +339,7 @@ void ui_dialog_create(UiObject *parent, UiDialogArgs args) { event->callback = args.result; event->userdata = args.resultdata; event->customdata = NULL; + event->customint = 0; event->value = 0; event->obj = parent; @@ -361,6 +365,7 @@ void ui_dialog_create(UiObject *parent, UiDialogArgs args) { } adw_alert_dialog_set_extra_child(ADW_ALERT_DIALOG(dialog), entry); event->customdata = entry; + event->customint = 0; } g_signal_connect( @@ -517,6 +522,7 @@ static void filechooser_opened(GObject *source, GAsyncResult *result, void *data flist.files = NULL; flist.nfiles = 0; evt.eventdata = &flist; + evt.eventdatatype = UI_EVENT_DATA_FILE_LIST; if(selection) { flist = listmodel2filelist(selection); @@ -551,6 +557,7 @@ static void ui_gtkfilechooser(UiObject *obj, GtkFileChooserAction action, unsign event->callback = file_selected_callback; event->userdata = cbdata; event->customdata = NULL; + event->customint = 0; event->value = mode; event->obj = obj; diff --git a/ui/motif/button.c b/ui/motif/button.c index b8ede8b..b421a8a 100644 --- a/ui/motif/button.c +++ b/ui/motif/button.c @@ -173,6 +173,7 @@ static void togglebutton_changed(Widget w, UiVarEventData *event, XmToggleButton e.window = e.obj->window; e.document = e.obj->ctx->document; e.eventdata = NULL; + e.eventdatatype = 0; e.intval = XmToggleButtonGetState(w); e.set = ui_get_setop(); @@ -282,6 +283,7 @@ static void radiobutton_changed(Widget w, UiVarEventData *event, XmToggleButtonC e.window = e.obj->window; e.document = e.obj->ctx->document; e.eventdata = value; + e.eventdatatype = UI_EVENT_DATA_INTEGER_VALUE; e.intval = v; e.set = ui_get_setop(); diff --git a/ui/motif/container.h b/ui/motif/container.h index 596e372..4f36550 100644 --- a/ui/motif/container.h +++ b/ui/motif/container.h @@ -65,7 +65,7 @@ typedef enum UiContainerType UiContainerType; typedef struct UiLayout UiLayout; struct UiLayout { - UiTri fill; + UiBool fill; UiBool newline; char *label; UiBool hexpand; diff --git a/ui/motif/list.c b/ui/motif/list.c index aa65be9..ffb915b 100644 --- a/ui/motif/list.c +++ b/ui/motif/list.c @@ -134,6 +134,7 @@ static void list_callback(UiObject *obj, UiListSelection sel, ui_callback callba event.window = obj->window; event.document = obj->ctx->document; event.eventdata = &sel; + event.eventdatatype = UI_EVENT_DATA_LIST_SELECTION; event.intval = sel.count > 0 ? sel.rows[0] : -1; callback(&event, userdata); } @@ -248,6 +249,7 @@ static void ui_dropdown_selection( event.window = event.obj->window; event.document = event.obj->ctx->document; event.eventdata = elm; + event.eventdatatype = UI_EVENT_DATA_LIST_ELM; event.intval = index; if(listview->onactivate) { listview->onactivate(&event, listview->onactivatedata); diff --git a/ui/motif/text.c b/ui/motif/text.c index 08ade21..ae9bbb0 100644 --- a/ui/motif/text.c +++ b/ui/motif/text.c @@ -961,6 +961,7 @@ static void pathbar_activate(void *data, char *path, int index) { evt.window = evt.obj->window; evt.document = evt.obj->ctx->document; evt.eventdata = path; + evt.eventdatatype = UI_EVENT_DATA_STRING; evt.intval = index; event->callback(&evt, event->userdata); } diff --git a/ui/motif/toolkit.c b/ui/motif/toolkit.c index 8131fad..25ea546 100644 --- a/ui/motif/toolkit.c +++ b/ui/motif/toolkit.c @@ -202,6 +202,7 @@ static Boolean ui_job_finished(void *data) { event.document = job->obj->ctx->document; event.intval = 0; event.eventdata = NULL; + event.eventdatatype = 0; job->finish_callback(&event, job->finish_data); } free(job); diff --git a/ui/qt/button.cpp b/ui/qt/button.cpp index f563d21..5e04f27 100644 --- a/ui/qt/button.cpp +++ b/ui/qt/button.cpp @@ -43,7 +43,7 @@ UIWIDGET ui_button_create(UiObject* obj, UiButtonArgs *args) { button->connect(button, SIGNAL(destroyed()), event, SLOT(destroy())); } - ctn->add(button, false); + ctn->add(button); return button; } @@ -53,6 +53,7 @@ static void togglebutton_event(UiEvent *event, UiEventWrapper *wrapper) { event->intval = button->isChecked(); if(wrapper->var) { event->eventdata = wrapper->var->value; + event->eventdatatype = UI_EVENT_DATA_INTEGER_VALUE; } } @@ -87,7 +88,7 @@ UIWIDGET ui_togglebutton_create(UiObject* obj, UiToggleArgs *args) { i->set = ui_togglebutton_set; } - ctn->add(button, false); + ctn->add(button); return button; } @@ -111,6 +112,7 @@ static void checkbox_event(UiEvent *event, UiEventWrapper *wrapper) { event->intval = button->isChecked(); if(wrapper->var) { event->eventdata = wrapper->var->value; + event->eventdatatype = UI_EVENT_DATA_INTEGER_VALUE; } } @@ -145,7 +147,7 @@ UIWIDGET ui_checkbox_create(UiObject* obj, UiToggleArgs *args) { i->set = ui_checkbox_set; } - ctn->add(checkbox, false); + ctn->add(checkbox); return checkbox; } @@ -169,6 +171,7 @@ static void radiobutton_event(UiEvent *event, UiEventWrapper *wrapper) { if(wrapper->var) { UiInteger *value = (UiInteger*)wrapper->var->value; event->eventdata = value; + event->eventdatatype = UI_EVENT_DATA_INTEGER_VALUE; event->intval = value->get(value); } } @@ -205,7 +208,7 @@ UIWIDGET ui_radiobutton_create(UiObject *obj, UiToggleArgs *args) { button->connect(button, SIGNAL(clicked()), event, SLOT(slot())); button->connect(button, SIGNAL(destroyed()), event, SLOT(destroy())); - ctn->add(button, false); + ctn->add(button); return button; } diff --git a/ui/qt/container.cpp b/ui/qt/container.cpp index b4392ff..07ac46a 100644 --- a/ui/qt/container.cpp +++ b/ui/qt/container.cpp @@ -60,17 +60,14 @@ UiBoxContainer::UiBoxContainer(QBoxLayout* box) { ui_reset_layout(layout); } -void UiBoxContainer::add(QWidget* widget, bool fill) { - if(layout.fill != UI_LAYOUT_UNDEFINED) { - fill = ui_lb2bool(layout.fill); - } - +void UiBoxContainer::add(QWidget* widget) { + bool fill = layout.fill; if(hasStretchedWidget && fill) { fill = false; fprintf(stderr, "UiError: container has 2 filled widgets"); } - box->addWidget(widget, fill); + box->addWidget(widget); if(!hasStretchedWidget) { QSpacerItem *newspace = new QSpacerItem(0, 0, QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding); @@ -93,7 +90,7 @@ UIWIDGET ui_box(UiObject *obj, UiContainerArgs *args, QBoxLayout::Direction dir) QWidget *widget = new QWidget(); QBoxLayout *box = new QBoxLayout(dir); widget->setLayout(box); - ctn->add(widget, true); + ctn->add(widget); ui_container_add(obj, new UiBoxContainer(box)); @@ -133,16 +130,17 @@ UiGridContainer::UiGridContainer( ui_reset_layout(layout); } -void UiGridContainer::add(QWidget* widget, bool fill) { +void UiGridContainer::add(QWidget* widget) { if(layout.newline) { x = 0; y++; } - int hexpand = false; - int vexpand = false; - int hfill = false; - int vfill = false; + bool fill = layout.fill; + bool hexpand = false; + bool vexpand = false; + bool hfill = false; + bool vfill = false; if(!layout.override_defaults) { if(def_hexpand) { hexpand = true; @@ -158,9 +156,6 @@ void UiGridContainer::add(QWidget* widget, bool fill) { } } - if(layout.fill != UI_LAYOUT_UNDEFINED) { - fill = ui_lb2bool(layout.fill); - } if(layout.hexpand) { hexpand = true; //hfill = true; @@ -240,7 +235,7 @@ UIEXPORT UIWIDGET ui_grid_create(UiObject *obj, UiContainerArgs *args) { QWidget *widget = new QWidget(); QGridLayout *grid = new QGridLayout(); widget->setLayout(grid); - ctn->add(widget, true); + ctn->add(widget); ui_container_add(obj, new UiGridContainer( grid, diff --git a/ui/qt/container.h b/ui/qt/container.h index bb51908..0d166cd 100644 --- a/ui/qt/container.h +++ b/ui/qt/container.h @@ -64,7 +64,7 @@ typedef enum UiLayoutBool { typedef struct UiLayout UiLayout; struct UiLayout { - UiTri fill; + UiBool fill; UiBool newline; char *label; UiBool hexpand; @@ -81,7 +81,7 @@ struct UiContainerPrivate { UiLayout layout; UIWIDGET current; - virtual void add(QWidget *widget, bool fill) = 0; + virtual void add(QWidget *widget) = 0; virtual void end() {} }; @@ -93,7 +93,7 @@ public: UiBoxContainer(QBoxLayout *box); - virtual void add(QWidget *widget, bool fill); + virtual void add(QWidget *widget); }; class UiGridContainer : public UiContainerPrivate { @@ -120,7 +120,7 @@ public: bool def_hfill, bool def_vfill); - virtual void add(QWidget *widget, bool fill); + virtual void add(QWidget *widget); virtual void end(); }; diff --git a/ui/qt/entry.cpp b/ui/qt/entry.cpp index 69d7552..af60ff7 100644 --- a/ui/qt/entry.cpp +++ b/ui/qt/entry.cpp @@ -126,7 +126,7 @@ UIWIDGET ui_spinner_create(UiObject *obj, UiSpinnerArgs *args) { } - ctn->add(widget, false); + ctn->add(widget); return widget; } diff --git a/ui/qt/label.cpp b/ui/qt/label.cpp index b813064..0101b6a 100644 --- a/ui/qt/label.cpp +++ b/ui/qt/label.cpp @@ -47,7 +47,7 @@ UIWIDGET ui_label_create(UiObject* obj, UiLabelArgs *args) { } widget->setAlignment(align); - ctn->add(widget, false); + ctn->add(widget); return widget; } diff --git a/ui/qt/list.cpp b/ui/qt/list.cpp index 51d9528..a44a93d 100644 --- a/ui/qt/list.cpp +++ b/ui/qt/list.cpp @@ -84,7 +84,7 @@ UIWIDGET ui_listview_create(UiObject* obj, UiListArgs *args) { SLOT(selectionChanged(const QItemSelection &, const QItemSelection &))); - ctn->add(view, false); + ctn->add(view); return view; } @@ -124,7 +124,7 @@ UIWIDGET ui_table_create(UiObject* obj, UiListArgs *args) { SLOT(selectionChanged(const QItemSelection &, const QItemSelection &))); - ctn->add(view, false); + ctn->add(view); return view; } diff --git a/ui/qt/menu.cpp b/ui/qt/menu.cpp index 86bf75f..4dbb7e1 100644 --- a/ui/qt/menu.cpp +++ b/ui/qt/menu.cpp @@ -157,6 +157,7 @@ void ui_actiongroup_prepare_event(UiEvent *event, UiAction *action) { if(action->var) { UiInteger *value = (UiInteger*)action->var->value; event->eventdata = value; + event->eventdatatype = UI_EVENT_DATA_INTEGER_VALUE; event->intval = value->get(value); } } @@ -217,6 +218,7 @@ void ui_add_menus(UiObject *obj, QMainWindow *window) { void ui_checkableaction_prepare_event(UiEvent *event, UiAction *action) { if(action->var) { event->eventdata = action->var->value; + event->eventdatatype = UI_EVENT_DATA_INTEGER_VALUE; } event->intval = action->isChecked(); } diff --git a/ui/qt/model.cpp b/ui/qt/model.cpp index c9fc7bc..e4846b8 100644 --- a/ui/qt/model.cpp +++ b/ui/qt/model.cpp @@ -100,6 +100,7 @@ void ListModel::selectionChanged(const QItemSelection& selected, const QItemSele event.window = obj->window; event.document = obj->ctx->document; event.eventdata = &sel; + event.eventdatatype = UI_EVENT_DATA_LIST_SELECTION; event.intval = sel.count; event.set = ui_get_setop(); @@ -213,6 +214,7 @@ void TableModel::selectionChanged(const QItemSelection& selected, const QItemSel event.window = obj->window; event.document = obj->ctx->document; event.eventdata = &sel; + event.eventdatatype = UI_EVENT_DATA_LIST_SELECTION; event.intval = sel.count; event.set = ui_get_setop(); diff --git a/ui/qt/text.cpp b/ui/qt/text.cpp index 5ef157c..31c3fa8 100644 --- a/ui/qt/text.cpp +++ b/ui/qt/text.cpp @@ -62,7 +62,7 @@ UIWIDGET ui_textarea_create(UiObject *obj, UiTextAreaArgs *args) { UI_APPLY_LAYOUT(ctn->layout, args); QTextEdit *textarea = new QTextEdit(); - ctn->add(textarea, true); + ctn->add(textarea); QTextDocument *document = nullptr; @@ -215,7 +215,7 @@ static UIWIDGET create_textfield(UiObject *obj, UiTextFieldArgs *args, bool pass UI_APPLY_LAYOUT(ctn->layout, args); QLineEdit *textfield = new QLineEdit(); - ctn->add(textfield, false); + ctn->add(textfield); if(password) { textfield->setEchoMode(QLineEdit::Password); diff --git a/ui/qt/toolbar.cpp b/ui/qt/toolbar.cpp index 22e81de..2cb1589 100644 --- a/ui/qt/toolbar.cpp +++ b/ui/qt/toolbar.cpp @@ -104,6 +104,7 @@ static void toolbar_togglebutton_event(UiEvent *event, UiEventWrapper *wrapper) event->intval = action->isChecked(); if(wrapper->var) { event->eventdata = wrapper->var->value; + event->eventdatatype = UI_EVENT_DATA_INTEGER_VALUE; } } diff --git a/ui/qt/toolkit.cpp b/ui/qt/toolkit.cpp index 7f915c8..1d1a15e 100644 --- a/ui/qt/toolkit.cpp +++ b/ui/qt/toolkit.cpp @@ -137,6 +137,7 @@ void UiEventWrapper::slot() { e.window = obj->window; e.document = obj->ctx->document; e.eventdata = NULL; + e.eventdatatype = 0; e.intval = 0; e.set = ui_get_setop(); if(prepare_event) { @@ -174,6 +175,7 @@ void UiAction::trigger() { e.window = obj->window; e.document = obj->ctx->document; e.eventdata = NULL; + e.eventdatatype = 0; e.intval = 0; e.set = ui_get_setop(); if(prepare_event) { diff --git a/ui/qt/widget.cpp b/ui/qt/widget.cpp index f275efd..2a3cbd2 100644 --- a/ui/qt/widget.cpp +++ b/ui/qt/widget.cpp @@ -35,7 +35,7 @@ UIWIDGET ui_customwidget_create(UiObject *obj, ui_createwidget_func create_widge UIWIDGET widget = create_widget(obj, args, userdata); UiContainerPrivate *ctn = ui_obj_container(obj); UI_APPLY_LAYOUT(ctn->layout, args); - ctn->add(widget, false); + ctn->add(widget); return widget; } @@ -47,7 +47,7 @@ UIWIDGET ui_separator_create(UiObject *obj, UiWidgetArgs *args) { UiContainerPrivate *ctn = ui_obj_container(obj); UI_APPLY_LAYOUT(ctn->layout, args); - ctn->add(separator, false); + ctn->add(separator); return separator; } diff --git a/ui/ui/button.h b/ui/ui/button.h index 57144b9..fb578f7 100644 --- a/ui/ui/button.h +++ b/ui/ui/button.h @@ -36,7 +36,7 @@ extern "C" { #endif typedef struct UiButtonArgs { - UiTri fill; + UiBool fill; UiBool hexpand; UiBool vexpand; UiBool hfill; @@ -58,7 +58,7 @@ typedef struct UiButtonArgs { } UiButtonArgs; typedef struct UiToggleArgs { - UiTri fill; + UiBool fill; UiBool hexpand; UiBool vexpand; UiBool hfill; diff --git a/ui/ui/container.h b/ui/ui/container.h index 51c15bd..75c78b0 100644 --- a/ui/ui/container.h +++ b/ui/ui/container.h @@ -59,7 +59,7 @@ typedef enum UiHeaderbarAlternative { typedef struct UiContainerArgs { - UiTri fill; + UiBool fill; UiBool hexpand; UiBool vexpand; UiBool hfill; @@ -81,7 +81,7 @@ typedef struct UiContainerArgs { } UiContainerArgs; typedef struct UiFrameArgs { - UiTri fill; + UiBool fill; UiBool hexpand; UiBool vexpand; UiBool hfill; @@ -104,7 +104,7 @@ typedef struct UiFrameArgs { } UiFrameArgs; typedef struct UiTabViewArgs { - UiTri fill; + UiBool fill; UiBool hexpand; UiBool vexpand; UiBool hfill; @@ -134,7 +134,7 @@ typedef struct UiTabViewArgs { } UiTabViewArgs; typedef struct UiHeaderbarArgs { - UiTri fill; + UiBool fill; UiBool hexpand; UiBool vexpand; UiBool hfill; @@ -160,7 +160,7 @@ typedef struct UiSidebarArgs { } UiSidebarArgs; typedef struct UiSplitPaneArgs { - UiTri fill; + UiBool fill; UiBool hexpand; UiBool vexpand; UiBool hfill; @@ -183,7 +183,7 @@ typedef struct UiSplitPaneArgs { } UiSplitPaneArgs; typedef struct UiItemListContainerArgs { - UiTri fill; + UiBool fill; UiBool hexpand; UiBool vexpand; UiBool hfill; diff --git a/ui/ui/display.h b/ui/ui/display.h index 6e2b579..3cb3d65 100644 --- a/ui/ui/display.h +++ b/ui/ui/display.h @@ -58,7 +58,7 @@ enum UiLabelStyle { typedef enum UiLabelStyle UiLabelStyle; typedef struct UiLabelArgs { - UiTri fill; + UiBool fill; UiBool hexpand; UiBool vexpand; UiBool hfill; @@ -77,7 +77,7 @@ typedef struct UiLabelArgs { } UiLabelArgs; typedef struct UiProgressbarArgs { - UiTri fill; + UiBool fill; UiBool hexpand; UiBool vexpand; UiBool hfill; @@ -96,7 +96,7 @@ typedef struct UiProgressbarArgs { } UiProgressbarArgs; typedef struct UiProgressbarSpinnerArgs { - UiTri fill; + UiBool fill; UiBool hexpand; UiBool vexpand; UiBool hfill; diff --git a/ui/ui/entry.h b/ui/ui/entry.h index 3e0a99f..cb1b7f7 100644 --- a/ui/ui/entry.h +++ b/ui/ui/entry.h @@ -37,7 +37,7 @@ extern "C" { typedef struct UiSpinnerArgs { - UiTri fill; + UiBool fill; UiBool hexpand; UiBool vexpand; UiBool hfill; diff --git a/ui/ui/image.h b/ui/ui/image.h index 49e57ab..405b509 100644 --- a/ui/ui/image.h +++ b/ui/ui/image.h @@ -45,7 +45,7 @@ extern "C" { typedef struct UiImageViewerArgs { - UiTri fill; + UiBool fill; UiBool hexpand; UiBool vexpand; UiBool hfill; diff --git a/ui/ui/text.h b/ui/ui/text.h index 2200235..0daf925 100644 --- a/ui/ui/text.h +++ b/ui/ui/text.h @@ -36,7 +36,7 @@ extern "C" { #endif typedef struct UiTextAreaArgs { - UiTri fill; + UiBool fill; UiBool hexpand; UiBool vexpand; UiBool hfill; @@ -57,7 +57,7 @@ typedef struct UiTextAreaArgs { } UiTextAreaArgs; typedef struct UiTextFieldArgs { - UiTri fill; + UiBool fill; UiBool hexpand; UiBool vexpand; UiBool hfill; @@ -91,7 +91,7 @@ typedef UiPathElm*(*ui_pathelm_func)(const char *full_path, size_t len, size_t * typedef struct UiPathTextFieldArgs { - UiTri fill; + UiBool fill; UiBool hexpand; UiBool vexpand; UiBool hfill; diff --git a/ui/ui/toolkit.h b/ui/ui/toolkit.h index ff23a53..7b54742 100644 --- a/ui/ui/toolkit.h +++ b/ui/ui/toolkit.h @@ -92,7 +92,11 @@ typedef void* UIMENU; // NSMenu* #define UIEXPORT __declspec(dllexport) -#define UIWIDGET void* +typedef struct W32Widget { + HWND hwnd; +} W32Widget; + +#define UIWIDGET W32Widget* #define UIWINDOW void* #define UIMENU void* @@ -217,7 +221,6 @@ typedef enum UiTri { UI_OFF } UiTri; - enum UiMouseEventType { UI_PRESS = 0, UI_PRESS2 }; typedef enum UiLabelType { @@ -319,6 +322,7 @@ struct UiEvent { void *document; void *window; void *eventdata; + int eventdatatype; int intval; int set; }; @@ -473,6 +477,22 @@ typedef struct UiCondVar { int intdata; } UiCondVar; +enum UiEventType { + UI_EVENT_DATA_NULL = 0, + UI_EVENT_DATA_POINTER, + UI_EVENT_DATA_STRING, + UI_EVENT_DATA_INTEGER_VALUE, + UI_EVENT_DATA_STRING_VALUE, + UI_EVENT_DATA_TEXT_VALUE, + UI_EVENT_DATA_DOUBLE_VALUE, + UI_EVENT_DATA_RANGE_VALUE, + UI_EVENT_DATA_LIST_SELECTION, + UI_EVENT_DATA_LIST_ELM, + UI_EVENT_DATA_DND, + UI_EVENT_DATA_SUBLIST, + UI_EVENT_DATA_FILE_LIST +}; + UIEXPORT void ui_init(const char *appname, int argc, char **argv); UIEXPORT const char* ui_appname(); diff --git a/ui/ui/tree.h b/ui/ui/tree.h index b9f8672..af51d08 100644 --- a/ui/ui/tree.h +++ b/ui/ui/tree.h @@ -115,7 +115,7 @@ struct UiListCallbacks { }; struct UiListArgs { - UiTri fill; + UiBool fill; UiBool hexpand; UiBool vexpand; UiBool hfill; @@ -150,7 +150,7 @@ struct UiListArgs { const int *groups; }; -typedef void (*ui_sublist_getvalue_func)(void *sublist_userdata, void *rowdata, int index, UiSubListItem *item, void *userdata); +typedef void (*ui_sublist_getvalue_func)(UiList *list, void *sublist_userdata, void *rowdata, int index, UiSubListItem *item, void *userdata); struct UiSubList { UiList *value; @@ -184,7 +184,7 @@ struct UiSubListItem { }; struct UiSourceListArgs { - UiTri fill; + UiBool fill; UiBool hexpand; UiBool vexpand; UiBool hfill; diff --git a/ui/ui/widget.h b/ui/ui/widget.h index 7e96ab6..fee08d9 100644 --- a/ui/ui/widget.h +++ b/ui/ui/widget.h @@ -35,7 +35,7 @@ extern "C" { #endif typedef struct UiWidgetArgs { - UiTri fill; + UiBool fill; UiBool hexpand; UiBool vexpand; UiBool hfill; diff --git a/ui/win32/Makefile b/ui/win32/Makefile index f31efac..563a6fd 100644 --- a/ui/win32/Makefile +++ b/ui/win32/Makefile @@ -33,4 +33,4 @@ $(UI_LIB): $(OBJ) $(AR) $(ARFLAGS) $(UI_LIB) $(OBJ) $(UI_SHLIB): $(OBJ) - $(CC) -o $(UI_SHLIB) $(LDFLAGS) $(SHLIB_LDFLAGS) $(TK_LDFLAGS) $(OBJ) -L../build/lib -lucx + $(CC) -o $(UI_SHLIB) $(LDFLAGS) $(SHLIB_LDFLAGS) $(TK_LDFLAGS) $(OBJ) -L../build/$(BUILD_LIB_DIR) -lucx diff --git a/ui/win32/button.c b/ui/win32/button.c new file mode 100644 index 0000000..2cb2e17 --- /dev/null +++ b/ui/win32/button.c @@ -0,0 +1,33 @@ +/* + * 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 "button.h" + +UIWIDGET ui_button_create(UiObject *obj, UiButtonArgs *args) { + return NULL; +} diff --git a/ui/win32/button.h b/ui/win32/button.h new file mode 100644 index 0000000..6a79f7b --- /dev/null +++ b/ui/win32/button.h @@ -0,0 +1,35 @@ +/* + * 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 BUTTON_H +#define BUTTON_H + +#include "../ui/button.h" +#include "container.h" + +#endif //BUTTON_H diff --git a/ui/win32/container.c b/ui/win32/container.c new file mode 100644 index 0000000..251be4a --- /dev/null +++ b/ui/win32/container.c @@ -0,0 +1,48 @@ +/* + * 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 "container.h" + + +/* ---------------------------- Box Container ---------------------------- */ + +static UIWIDGET box_create(UiObject *obj, UiContainerArgs *args, UiBoxOrientation orientation) { + return NULL; +} + +// public +UIWIDGET ui_vbox_create(UiObject *obj, UiContainerArgs *args) { + return box_create(obj, args, UI_BOX_VERTICAL); +} + +// public +UIWIDGET ui_hbox_create(UiObject *obj, UiContainerArgs *args) { + return box_create(obj, args, UI_BOX_HORIZONTAL); +} + + diff --git a/ui/win32/container.h b/ui/win32/container.h new file mode 100644 index 0000000..f1d517e --- /dev/null +++ b/ui/win32/container.h @@ -0,0 +1,91 @@ +/* +* 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 CONTAINER_H + +#include "../ui/container.h" + +#define CONTAINER_H + +#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.override_defaults = args->override_defaults; \ + layout.colspan = args->colspan; \ + layout.rowspan = args->rowspan + +typedef struct UiLayout UiLayout; + +struct UiLayout { + UiBool fill; + UiBool newline; + char *label; + UiBool hexpand; + UiBool vexpand; + UiBool hfill; + UiBool vfill; + UiBool override_defaults; + int width; + int colspan; + int rowspan; +}; + +enum UiBoxOrientation { + UI_BOX_VERTICAL = 0, + UI_BOX_HORIZONTAL +}; +typedef enum UiBoxOrientation UiBoxOrientation; + +enum UiContainerType { + UI_CONTAINER_GENERIC = 0, + UI_CONTAINER_TABVIEW +}; +typedef enum UiContainerType UiContainerType; + +typedef struct UiContainerPrivate UiContainerPrivate; + +typedef struct UiRect { + int x; + int y; + int width; + int height; +} UiRect; + + +struct UiContainerPrivate { + UiContainerX container; + void (*prepare)(UiContainerPrivate*, UiRect*); + void (*add)(UiContainerPrivate*, UiRect*, W32Widget*); + UiContainerType type; + UiLayout layout; +}; + +#endif //CONTAINER_H diff --git a/ui/win32/grid.c b/ui/win32/grid.c new file mode 100644 index 0000000..b37986f --- /dev/null +++ b/ui/win32/grid.c @@ -0,0 +1,61 @@ +/* +* 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 "grid.h" + +#include "../../ucx/cx/array_list.h" +#include "../common/context.h" + +UiGridLayout* ui_grid_container(UiObject *obj, HWND control, short padding, short columnspacing, short rowspacing) { + UiGridLayout *grid = cxZalloc(obj->ctx->allocator, sizeof(UiGridLayout)); + grid->hwnd = control; + grid->widgets = cxArrayListCreate(obj->ctx->allocator, NULL, sizeof(GridElm), 32); + grid->padding = padding; + grid->columnspacing = columnspacing; + grid->rowspacing = rowspacing; + return grid; +} + +void ui_grid_add_widget( + UiGridLayout *grid, + short x, + short y, + W32Widget *widget, + GridLayoutInfo *layout) +{ + GridElm elm; + elm.widget = widget; + elm.x = x; + elm.y = y; + elm.layout = *layout; + cxListAdd(grid->widgets, elm); +} + +void ui_grid_layout(UiGridLayout *grid) { + // TODO +} diff --git a/ui/win32/grid.h b/ui/win32/grid.h new file mode 100644 index 0000000..6cbb6b7 --- /dev/null +++ b/ui/win32/grid.h @@ -0,0 +1,82 @@ +/* +* 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 GRID_H +#define GRID_H + +#include "container.h" +#include +#include + +typedef struct GridElm { + W32Widget *widget; + short x; + short y; + GridLayoutInfo layout; +} GridElm; + +typedef struct GridLayoutInfo { + short margin_left; + short margin_right; + short margin_top; + short margin_bottom; + short colspan; + short rowspan; + short preferred_width; + short preferred_height; + bool hexpand; + bool vexpand; + bool hfill; + bool vfill; +} GridLayoutInfo; + +typedef struct UiGridLayout { + HWND hwnd; + + short padding; + short columnspacing; + short rowspacing; + + /* + * list element type: GridElm + */ + CxList *widgets; + +} UiGridLayout; + +UiGridLayout* ui_grid_container(UiObject *obj, HWND control, short padding, short columnspacing, short rowspacing); + +void ui_grid_add_widget( + UiGridLayout *grid, + short x, + short y, + W32Widget *widget, + GridLayoutInfo *layout); + +void ui_grid_layout(UiGridLayout *grid); + +#endif //GRID_H diff --git a/ui/win32/objs.mk b/ui/win32/objs.mk index d861b9f..37e9366 100644 --- a/ui/win32/objs.mk +++ b/ui/win32/objs.mk @@ -32,6 +32,8 @@ WIN32_OBJPRE = $(OBJ_DIR)$(WIN32_SRC_DIR) WIN32OBJ = toolkit.obj WIN32OBJ += window.obj WIN32OBJ += image.obj +WIN32OBJ += container.obj +WIN32OBJ += button.obj TOOLKITOBJS += $(WIN32OBJ:%=$(WIN32_OBJPRE)%) TOOLKITSOURCE += $(WIN32OBJ:%.obj=win32/%.c) diff --git a/ui/win32/window.c b/ui/win32/window.c index 8ee0cbb..b121565 100644 --- a/ui/win32/window.c +++ b/ui/win32/window.c @@ -39,7 +39,7 @@ static HINSTANCE hInstance; -static const wchar_t *mainWindowClass = L"UiMainWindow"; +static const char *mainWindowClass = "UiMainWindow"; LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { switch(uMsg) { @@ -62,7 +62,7 @@ void ui_window_init(void) { wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1); - if(!RegisterClassEx(&wc)) { + if(!RegisterClassExA(&wc)) { MessageBox(NULL, "RegisterClassEx failed", "Error", MB_ICONERROR); exit(-1); } @@ -72,10 +72,10 @@ static UiObject* create_window(const char *title, void *window_data, bool simple UiObject *obj = uic_object_new_toplevel(); obj->window = window_data; - HWND hwnd = CreateWindowEx( + HWND hwnd = CreateWindowExA( 0, - L"UiMainWindow", - "Test", + "UiMainWindow", + title, WS_OVERLAPPEDWINDOW | WS_VISIBLE, CW_USEDEFAULT, CW_USEDEFAULT,