54 |
54 |
55 UIEXPORT UIWIDGET ui_textarea_create(UiObject *obj, UiTextAreaArgs args) { |
55 UIEXPORT UIWIDGET ui_textarea_create(UiObject *obj, UiTextAreaArgs args) { |
56 UiObject* current = uic_current_obj(obj); |
56 UiObject* current = uic_current_obj(obj); |
57 |
57 |
58 // create textarea and toolkit wrapper |
58 // create textarea and toolkit wrapper |
59 RichEditBox textarea = RichEditBox(); |
59 TextBox textarea = TextBox(); |
|
60 textarea.AcceptsReturn(true); |
|
61 ScrollViewer::SetVerticalScrollBarVisibility(textarea, ScrollBarVisibility::Auto); |
60 UIElement elm = textarea; |
62 UIElement elm = textarea; |
61 UiWidget* widget = new UiWidget(elm); |
63 UiWidget* widget = new UiWidget(elm); |
62 ui_context_add_widget_destructor(current->ctx, widget); |
64 ui_context_add_widget_destructor(current->ctx, widget); |
63 |
65 |
64 UiVar* var = uic_widget_var(obj->ctx, current->ctx, args.value, args.varname, UI_VAR_TEXT); |
66 UiVar* var = uic_widget_var(obj->ctx, current->ctx, args.value, args.varname, UI_VAR_TEXT); |
95 |
97 |
96 UIEXPORT void ui_text_redo(UiText *value) { |
98 UIEXPORT void ui_text_redo(UiText *value) { |
97 |
99 |
98 } |
100 } |
99 |
101 |
100 |
102 // -------------------------- getter/setter for textarea UiText -------------------------- |
|
103 |
|
104 char* ui_wtext_get(UiText *text, std::wstring &value) { |
|
105 if (text->value.ptr) { |
|
106 text->value.free(text->value.ptr); |
|
107 } |
|
108 |
|
109 text->value.ptr = wchar2utf8(value.c_str(), value.length()); |
|
110 text->value.free = free; |
|
111 |
|
112 return text->value.ptr; |
|
113 } |
|
114 |
|
115 std::wstring ui_wtext_set(UiText *text, const char* value) { |
|
116 if (text->value.ptr) { |
|
117 text->value.free(text->value.ptr); |
|
118 } |
|
119 |
|
120 text->value.ptr = _strdup(value); |
|
121 text->value.free = free; |
|
122 |
|
123 int len; |
|
124 wchar_t* wstr = str2wstr(value, &len); |
|
125 std::wstring s(wstr); |
|
126 free(wstr); |
|
127 |
|
128 return s; |
|
129 } |
101 |
130 |
102 extern "C" char* ui_textarea_get(UiText *text) { |
131 extern "C" char* ui_textarea_get(UiText *text) { |
103 return NULL; |
132 UiWidget* widget = (UiWidget*)text->obj; |
|
133 TextBox box = widget->uielement.as<TextBox>(); |
|
134 std::wstring wstr(box.Text()); |
|
135 return ui_wtext_get(text, wstr); |
104 } |
136 } |
105 |
137 |
106 extern "C" void ui_textarea_set(UiText *text, const char *newvalue) { |
138 extern "C" void ui_textarea_set(UiText *text, const char *newvalue) { |
107 |
139 UiWidget* widget = (UiWidget*)text->obj; |
|
140 TextBox box = widget->uielement.as<TextBox>(); |
|
141 box.Text(ui_wtext_set(text, newvalue)); |
108 } |
142 } |
109 |
143 |
110 extern "C" char* ui_textarea_getsubstr(UiText *text, int begin, int end) { |
144 extern "C" char* ui_textarea_getsubstr(UiText *text, int begin, int end) { |
111 return NULL; |
145 return NULL; |
112 } |
146 } |