# HG changeset patch # User Olaf Wintermann # Date 1423916760 -3600 # Node ID 04c81be1c5a02b4de0000a5ab2dd93c7ad9d4ace # Parent e624b6fa4c78ead9e117e4d9b10a5fd428071fde added textarea (WPF) diff -r e624b6fa4c78 -r 04c81be1c5a0 application/main.c --- a/application/main.c Sat Feb 14 10:30:45 2015 +0100 +++ b/application/main.c Sat Feb 14 13:26:00 2015 +0100 @@ -33,6 +33,7 @@ #include #include +/* typedef struct Person { char *name; char *mail; @@ -90,23 +91,39 @@ void action_test(UiEvent *event, void *data) { //ui_select_tab(tabview, 0); } +*/ void action_menu(UiEvent *event, void *data) { printf("action_menu test: {%s}\n", data); + printf("text: {%s}\n", ui_gettext(event->obj, "text")); + fflush(stdout); +} + +void action_button(UiEvent *event, void *data) { + printf("button clicked\n"); fflush(stdout); } -void action_combobox_select(UiEvent *event, void *data) { - UiList *list = data; - int i = event->intval; - printf("selection{%s}[%d]\n", ui_list_get(list, i), i); -} - - int main(int argc, char** argv) { - ui_locales_dir("/opt/app1/locales"); + ui_init("app1", argc, argv); + + ui_menu("File"); + ui_menuitem("Hello", action_menu, "hello"); + ui_submenu("Submenu1"); + ui_submenu("Submenu2"); + ui_menuitem("item2", NULL, NULL); + ui_submenu_end(); + ui_menuitem("item3", NULL, NULL); + ui_submenu_end(); + ui_menuitem("item4", NULL, NULL); + + UiObject *obj = ui_window("Test", NULL); + ui_textarea_nv(obj, "text"); + ui_show(obj); + ui_main(); + /* + ui_locales_dir("/opt/app1/locales"); ui_load_lang_def(NULL, "en_EN"); - ui_init("app1", argc, argv); //ui_openfilefunc(action_new, NULL); @@ -117,17 +134,7 @@ //ui_checkitem("Check", action_button, NULL); ui_toolitem_st("button", UI_STOCK_GO_BACK, action_button, NULL); - - UiList *cb = ui_list_new(); - ui_list_append(cb, "Hello World"); - ui_list_append(cb, "2"); - ui_list_append(cb, "3"); - ui_list_append(cb, "4"); - ui_list_append(cb, "5"); - ui_toolbar_combobox_str("combobox", cb, action_combobox_select, cb); - ui_toolbar_add_default("button"); - ui_toolbar_add_default("combobox"); printf("create window\n"); UiObject *window = ui_window("Mod0", NULL); @@ -174,5 +181,6 @@ ui_show(window); ui_main(); + */ return (EXIT_SUCCESS); } diff -r e624b6fa4c78 -r 04c81be1c5a0 ui/common/context.c --- a/ui/common/context.c Sat Feb 14 10:30:45 2015 +0100 +++ b/ui/common/context.c Sat Feb 14 13:26:00 2015 +0100 @@ -395,7 +395,7 @@ } else { fprintf( stderr, - "UI Error: requested variable %s is not an string.\n", + "UI Error: requested variable %s is not a text.\n", name); } } else { diff -r e624b6fa4c78 -r 04c81be1c5a0 ui/wpf/UIcore/TextArea.cs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ui/wpf/UIcore/TextArea.cs Sat Feb 14 13:26:00 2015 +0100 @@ -0,0 +1,73 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace UI +{ + public class TextArea : System.Windows.Controls.TextBox + { + public TextArea(Container container, String text) : base() + { + AcceptsReturn = true; + IsUndoEnabled = false; // we need our own undo stack + if (text != null) + { + Text = text; + } + VerticalScrollBarVisibility = System.Windows.Controls.ScrollBarVisibility.Auto; + HorizontalScrollBarVisibility = System.Windows.Controls.ScrollBarVisibility.Auto; + + container.Add(this, true); + } + + public static TextArea CreateTextArea(Container container, String text) + { + return Application.GetInstance().Exec