--- a/ui/winui/text.cpp Wed Oct 30 11:07:52 2024 +0100 +++ b/ui/winui/text.cpp Wed Oct 30 12:23:52 2024 +0100 @@ -51,6 +51,93 @@ using namespace winrt::Microsoft::UI::Xaml::Controls::Primitives; using namespace winrt::Windows::UI::Xaml::Input; + +UIEXPORT UIWIDGET ui_textarea_create(UiObject *obj, UiTextAreaArgs args) { + UiObject* current = uic_current_obj(obj); + + // create textarea and toolkit wrapper + RichEditBox textarea = RichEditBox(); + UIElement elm = textarea; + UiWidget* widget = new UiWidget(elm); + ui_context_add_widget_destructor(current->ctx, widget); + + UiVar* var = uic_widget_var(obj->ctx, current->ctx, args.value, args.varname, UI_VAR_TEXT); + if (var) { + UiText* value = (UiText*)var->value; + value->obj = widget; + value->undomgr = NULL; + value->set = ui_textarea_set; + value->get = ui_textarea_get; + value->getsubstr = ui_textarea_getsubstr; + value->insert = ui_textarea_insert; + value->setposition = ui_textarea_setposition; + value->position = ui_textarea_position; + value->selection = ui_textarea_selection; + value->length = ui_textarea_length; + value->remove = ui_textarea_remove; + } + + // add textarea to current container + UI_APPLY_LAYOUT1(current, args); + + current->container->Add(textarea, true); + + return widget; +} + +UIEXPORT UIWIDGET ui_textarea_gettextwidget(UIWIDGET textarea) { + return textarea; +} + +UIEXPORT void ui_text_undo(UiText *value) { + +} + +UIEXPORT void ui_text_redo(UiText *value) { + +} + + + +extern "C" char* ui_textarea_get(UiText *text) { + return NULL; +} + +extern "C" void ui_textarea_set(UiText *text, const char *newvalue) { + +} + +extern "C" char* ui_textarea_getsubstr(UiText *text, int begin, int end) { + return NULL; +} + +extern "C" void ui_textarea_insert(UiText *text, int pos, char *str) { + +} + +extern "C" void ui_textarea_setposition(UiText *text, int pos) { + +} + +extern "C" int ui_textarea_position(UiText *text) { + return 0; +} + +extern "C" void ui_textarea_selection(UiText *text, int *begin, int *end) { + +} + +extern "C" int ui_textarea_length(UiText *text) { + return 0; +} + +extern "C" void ui_textarea_remove(UiText *text, int begin, int end) { + +} + + + + UIWIDGET ui_textfield_create(UiObject* obj, UiTextFieldArgs args) { UiObject* current = uic_current_obj(obj); @@ -71,7 +158,7 @@ // TODO: } - // add button to current container + // add textfield to current container UI_APPLY_LAYOUT1(current, args); current->container->Add(textfield, false); @@ -103,7 +190,7 @@ // TODO: } - // add button to current container + // add textfield to current container UI_APPLY_LAYOUT1(current, args); current->container->Add(textfield, false);