ui/winui/text.cpp

changeset 3
f154867f54dc
parent 0
2483f517c562
child 8
726b24766437
equal deleted inserted replaced
2:fbdfaacc4182 3:f154867f54dc
112 } 112 }
113 113
114 114
115 // -------------------------- getter/setter for textfield UiString -------------------------- 115 // -------------------------- getter/setter for textfield UiString --------------------------
116 116
117 char* ui_string_get(UiString* str, std::wstring &value) { 117 char* ui_wstring_get(UiString* str, std::wstring &value) {
118 if (str->value.ptr) { 118 if (str->value.ptr) {
119 str->value.free(str->value.ptr); 119 str->value.free(str->value.ptr);
120 } 120 }
121 121
122 str->value.ptr = wchar2utf8(value.c_str(), value.length()); 122 str->value.ptr = wchar2utf8(value.c_str(), value.length());
123 str->value.free = free; 123 str->value.free = free;
124 124
125 return str->value.ptr; 125 return str->value.ptr;
126 } 126 }
127 127
128 std::wstring ui_string_set(UiString* str, const char* value) { 128 std::wstring ui_wstring_set(UiString* str, const char* value) {
129 if (str->value.ptr) { 129 if (str->value.ptr) {
130 str->value.free(str->value.ptr); 130 str->value.free(str->value.ptr);
131 } 131 }
132 132
133 str->value.ptr = _strdup(value); 133 str->value.ptr = _strdup(value);
143 143
144 char* ui_textfield_get(UiString * str) { 144 char* ui_textfield_get(UiString * str) {
145 UiWidget* widget = (UiWidget*)str->obj; 145 UiWidget* widget = (UiWidget*)str->obj;
146 TextBox box = widget->uielement.as<TextBox>(); 146 TextBox box = widget->uielement.as<TextBox>();
147 std::wstring wstr(box.Text()); 147 std::wstring wstr(box.Text());
148 return ui_string_get(str, wstr); 148 return ui_wstring_get(str, wstr);
149 } 149 }
150 150
151 void ui_textfield_set(UiString * str, const char* newvalue) { 151 void ui_textfield_set(UiString * str, const char* newvalue) {
152 UiWidget* widget = (UiWidget*)str->obj; 152 UiWidget* widget = (UiWidget*)str->obj;
153 TextBox box = widget->uielement.as<TextBox>(); 153 TextBox box = widget->uielement.as<TextBox>();
154 box.Text(ui_string_set(str, newvalue)); 154 box.Text(ui_wstring_set(str, newvalue));
155 } 155 }
156 156
157 157
158 char* ui_passwordfield_get(UiString * str) { 158 char* ui_passwordfield_get(UiString * str) {
159 UiWidget* widget = (UiWidget*)str->obj; 159 UiWidget* widget = (UiWidget*)str->obj;
160 PasswordBox box = widget->uielement.as<PasswordBox>(); 160 PasswordBox box = widget->uielement.as<PasswordBox>();
161 std::wstring wstr(box.Password()); 161 std::wstring wstr(box.Password());
162 return ui_string_get(str, wstr); 162 return ui_wstring_get(str, wstr);
163 } 163 }
164 164
165 void ui_passwordfield_set(UiString * str, const char* newvalue) { 165 void ui_passwordfield_set(UiString * str, const char* newvalue) {
166 UiWidget* widget = (UiWidget*)str->obj; 166 UiWidget* widget = (UiWidget*)str->obj;
167 PasswordBox box = widget->uielement.as<PasswordBox>(); 167 PasswordBox box = widget->uielement.as<PasswordBox>();
168 box.Password(ui_string_set(str, newvalue)); 168 box.Password(ui_wstring_set(str, newvalue));
169 } 169 }
170 170
171 171
172 // ------------------------ path textfield -------------------------------------- 172 // ------------------------ path textfield --------------------------------------
173 173
302 302
303 char* ui_path_textfield_get(UiString * str) { 303 char* ui_path_textfield_get(UiString * str) {
304 UiPathTextField* widget = (UiPathTextField*)str->obj; 304 UiPathTextField* widget = (UiPathTextField*)str->obj;
305 TextBox box = widget->textbox; 305 TextBox box = widget->textbox;
306 std::wstring wstr(box.Text()); 306 std::wstring wstr(box.Text());
307 return ui_string_get(str, wstr); 307 return ui_wstring_get(str, wstr);
308 } 308 }
309 309
310 void ui_path_textfield_set(UiString* str, const char* newvalue) { 310 void ui_path_textfield_set(UiString* str, const char* newvalue) {
311 UiPathTextField* widget = (UiPathTextField*)str->obj; 311 UiPathTextField* widget = (UiPathTextField*)str->obj;
312 TextBox box = widget->textbox; 312 TextBox box = widget->textbox;
313 box.Text(ui_string_set(str, newvalue)); 313 box.Text(ui_wstring_set(str, newvalue));
314 ui_pathtextfield_update(widget, newvalue); 314 ui_pathtextfield_update(widget, newvalue);
315 } 315 }
316 316
317 UIEXPORT UIWIDGET ui_path_textfield_create(UiObject* obj, UiPathTextFieldArgs args) { 317 UIEXPORT UIWIDGET ui_path_textfield_create(UiObject* obj, UiPathTextFieldArgs args) {
318 UiObject* current = uic_current_obj(obj); 318 UiObject* current = uic_current_obj(obj);

mercurial