ui/winui/text.cpp

Thu, 14 Nov 2024 23:22:35 +0100

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Thu, 14 Nov 2024 23:22:35 +0100
changeset 85
44ebbb4c8a13
parent 83
a612adaee43d
permissions
-rw-r--r--

add support for secret store credentials when connecting to repositories, resolves #496

0
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1 /*
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
3 *
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
4 * Copyright 2023 Olaf Wintermann. All rights reserved.
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
5 *
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
6 * Redistribution and use in source and binary forms, with or without
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
7 * modification, are permitted provided that the following conditions are met:
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
8 *
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
9 * 1. Redistributions of source code must retain the above copyright
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
10 * notice, this list of conditions and the following disclaimer.
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
11 *
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
12 * 2. Redistributions in binary form must reproduce the above copyright
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
13 * notice, this list of conditions and the following disclaimer in the
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
14 * documentation and/or other materials provided with the distribution.
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
15 *
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
26 * POSSIBILITY OF SUCH DAMAGE.
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
27 */
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
28
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
29 #include "pch.h"
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
30
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
31 #include "text.h"
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
32
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
33 #include "../common/context.h"
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
34 #include "../common/object.h"
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
35
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
36 #include <cx/string.h>
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
37 #include <cx/allocator.h>
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
38
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
39 #include "util.h"
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
40 #include "container.h"
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
41
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
42
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
43
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
44 using namespace winrt;
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
45 using namespace Microsoft::UI::Xaml;
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
46 using namespace Microsoft::UI::Xaml::Controls;
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
47 using namespace Windows::UI::Xaml::Interop;
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
48 using namespace winrt::Windows::Foundation;
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
49 using namespace Microsoft::UI::Xaml::Markup;
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
50 using namespace Microsoft::UI::Xaml::Media;
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
51 using namespace winrt::Microsoft::UI::Xaml::Controls::Primitives;
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
52 using namespace winrt::Windows::UI::Xaml::Input;
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
53
76
641dcc79e0ef update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 13
diff changeset
54
641dcc79e0ef update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 13
diff changeset
55 UIEXPORT UIWIDGET ui_textarea_create(UiObject *obj, UiTextAreaArgs args) {
641dcc79e0ef update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 13
diff changeset
56 UiObject* current = uic_current_obj(obj);
641dcc79e0ef update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 13
diff changeset
57
641dcc79e0ef update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 13
diff changeset
58 // create textarea and toolkit wrapper
77
5de33c2d94c6 fix text/image preview loading
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 76
diff changeset
59 TextBox textarea = TextBox();
5de33c2d94c6 fix text/image preview loading
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 76
diff changeset
60 textarea.AcceptsReturn(true);
5de33c2d94c6 fix text/image preview loading
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 76
diff changeset
61 ScrollViewer::SetVerticalScrollBarVisibility(textarea, ScrollBarVisibility::Auto);
76
641dcc79e0ef update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 13
diff changeset
62 UIElement elm = textarea;
641dcc79e0ef update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 13
diff changeset
63 UiWidget* widget = new UiWidget(elm);
641dcc79e0ef update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 13
diff changeset
64 ui_context_add_widget_destructor(current->ctx, widget);
83
a612adaee43d fix pathbar elmfunc creating an element for an empty string
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 77
diff changeset
65 ui_set_widget_groups(current->ctx, widget, args.groups);
76
641dcc79e0ef update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 13
diff changeset
66
641dcc79e0ef update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 13
diff changeset
67 UiVar* var = uic_widget_var(obj->ctx, current->ctx, args.value, args.varname, UI_VAR_TEXT);
641dcc79e0ef update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 13
diff changeset
68 if (var) {
641dcc79e0ef update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 13
diff changeset
69 UiText* value = (UiText*)var->value;
641dcc79e0ef update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 13
diff changeset
70 value->obj = widget;
641dcc79e0ef update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 13
diff changeset
71 value->undomgr = NULL;
641dcc79e0ef update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 13
diff changeset
72 value->set = ui_textarea_set;
641dcc79e0ef update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 13
diff changeset
73 value->get = ui_textarea_get;
641dcc79e0ef update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 13
diff changeset
74 value->getsubstr = ui_textarea_getsubstr;
641dcc79e0ef update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 13
diff changeset
75 value->insert = ui_textarea_insert;
641dcc79e0ef update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 13
diff changeset
76 value->setposition = ui_textarea_setposition;
641dcc79e0ef update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 13
diff changeset
77 value->position = ui_textarea_position;
641dcc79e0ef update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 13
diff changeset
78 value->selection = ui_textarea_selection;
641dcc79e0ef update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 13
diff changeset
79 value->length = ui_textarea_length;
641dcc79e0ef update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 13
diff changeset
80 value->remove = ui_textarea_remove;
641dcc79e0ef update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 13
diff changeset
81 }
641dcc79e0ef update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 13
diff changeset
82
641dcc79e0ef update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 13
diff changeset
83 // add textarea to current container
641dcc79e0ef update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 13
diff changeset
84 UI_APPLY_LAYOUT1(current, args);
641dcc79e0ef update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 13
diff changeset
85
641dcc79e0ef update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 13
diff changeset
86 current->container->Add(textarea, true);
641dcc79e0ef update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 13
diff changeset
87
641dcc79e0ef update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 13
diff changeset
88 return widget;
641dcc79e0ef update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 13
diff changeset
89 }
641dcc79e0ef update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 13
diff changeset
90
641dcc79e0ef update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 13
diff changeset
91 UIEXPORT UIWIDGET ui_textarea_gettextwidget(UIWIDGET textarea) {
641dcc79e0ef update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 13
diff changeset
92 return textarea;
641dcc79e0ef update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 13
diff changeset
93 }
641dcc79e0ef update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 13
diff changeset
94
641dcc79e0ef update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 13
diff changeset
95 UIEXPORT void ui_text_undo(UiText *value) {
641dcc79e0ef update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 13
diff changeset
96
641dcc79e0ef update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 13
diff changeset
97 }
641dcc79e0ef update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 13
diff changeset
98
641dcc79e0ef update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 13
diff changeset
99 UIEXPORT void ui_text_redo(UiText *value) {
641dcc79e0ef update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 13
diff changeset
100
641dcc79e0ef update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 13
diff changeset
101 }
641dcc79e0ef update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 13
diff changeset
102
77
5de33c2d94c6 fix text/image preview loading
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 76
diff changeset
103 // -------------------------- getter/setter for textarea UiText --------------------------
76
641dcc79e0ef update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 13
diff changeset
104
77
5de33c2d94c6 fix text/image preview loading
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 76
diff changeset
105 char* ui_wtext_get(UiText *text, std::wstring &value) {
5de33c2d94c6 fix text/image preview loading
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 76
diff changeset
106 if (text->value.ptr) {
5de33c2d94c6 fix text/image preview loading
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 76
diff changeset
107 text->value.free(text->value.ptr);
5de33c2d94c6 fix text/image preview loading
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 76
diff changeset
108 }
5de33c2d94c6 fix text/image preview loading
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 76
diff changeset
109
5de33c2d94c6 fix text/image preview loading
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 76
diff changeset
110 text->value.ptr = wchar2utf8(value.c_str(), value.length());
5de33c2d94c6 fix text/image preview loading
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 76
diff changeset
111 text->value.free = free;
5de33c2d94c6 fix text/image preview loading
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 76
diff changeset
112
5de33c2d94c6 fix text/image preview loading
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 76
diff changeset
113 return text->value.ptr;
5de33c2d94c6 fix text/image preview loading
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 76
diff changeset
114 }
5de33c2d94c6 fix text/image preview loading
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 76
diff changeset
115
5de33c2d94c6 fix text/image preview loading
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 76
diff changeset
116 std::wstring ui_wtext_set(UiText *text, const char* value) {
5de33c2d94c6 fix text/image preview loading
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 76
diff changeset
117 if (text->value.ptr) {
5de33c2d94c6 fix text/image preview loading
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 76
diff changeset
118 text->value.free(text->value.ptr);
5de33c2d94c6 fix text/image preview loading
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 76
diff changeset
119 }
5de33c2d94c6 fix text/image preview loading
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 76
diff changeset
120
5de33c2d94c6 fix text/image preview loading
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 76
diff changeset
121 text->value.ptr = _strdup(value);
5de33c2d94c6 fix text/image preview loading
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 76
diff changeset
122 text->value.free = free;
5de33c2d94c6 fix text/image preview loading
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 76
diff changeset
123
5de33c2d94c6 fix text/image preview loading
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 76
diff changeset
124 int len;
5de33c2d94c6 fix text/image preview loading
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 76
diff changeset
125 wchar_t* wstr = str2wstr(value, &len);
5de33c2d94c6 fix text/image preview loading
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 76
diff changeset
126 std::wstring s(wstr);
5de33c2d94c6 fix text/image preview loading
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 76
diff changeset
127 free(wstr);
5de33c2d94c6 fix text/image preview loading
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 76
diff changeset
128
5de33c2d94c6 fix text/image preview loading
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 76
diff changeset
129 return s;
5de33c2d94c6 fix text/image preview loading
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 76
diff changeset
130 }
76
641dcc79e0ef update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 13
diff changeset
131
641dcc79e0ef update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 13
diff changeset
132 extern "C" char* ui_textarea_get(UiText *text) {
77
5de33c2d94c6 fix text/image preview loading
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 76
diff changeset
133 UiWidget* widget = (UiWidget*)text->obj;
5de33c2d94c6 fix text/image preview loading
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 76
diff changeset
134 TextBox box = widget->uielement.as<TextBox>();
5de33c2d94c6 fix text/image preview loading
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 76
diff changeset
135 std::wstring wstr(box.Text());
5de33c2d94c6 fix text/image preview loading
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 76
diff changeset
136 return ui_wtext_get(text, wstr);
76
641dcc79e0ef update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 13
diff changeset
137 }
641dcc79e0ef update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 13
diff changeset
138
641dcc79e0ef update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 13
diff changeset
139 extern "C" void ui_textarea_set(UiText *text, const char *newvalue) {
77
5de33c2d94c6 fix text/image preview loading
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 76
diff changeset
140 UiWidget* widget = (UiWidget*)text->obj;
5de33c2d94c6 fix text/image preview loading
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 76
diff changeset
141 TextBox box = widget->uielement.as<TextBox>();
5de33c2d94c6 fix text/image preview loading
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 76
diff changeset
142 box.Text(ui_wtext_set(text, newvalue));
76
641dcc79e0ef update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 13
diff changeset
143 }
641dcc79e0ef update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 13
diff changeset
144
641dcc79e0ef update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 13
diff changeset
145 extern "C" char* ui_textarea_getsubstr(UiText *text, int begin, int end) {
641dcc79e0ef update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 13
diff changeset
146 return NULL;
641dcc79e0ef update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 13
diff changeset
147 }
641dcc79e0ef update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 13
diff changeset
148
641dcc79e0ef update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 13
diff changeset
149 extern "C" void ui_textarea_insert(UiText *text, int pos, char *str) {
641dcc79e0ef update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 13
diff changeset
150
641dcc79e0ef update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 13
diff changeset
151 }
641dcc79e0ef update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 13
diff changeset
152
641dcc79e0ef update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 13
diff changeset
153 extern "C" void ui_textarea_setposition(UiText *text, int pos) {
641dcc79e0ef update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 13
diff changeset
154
641dcc79e0ef update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 13
diff changeset
155 }
641dcc79e0ef update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 13
diff changeset
156
641dcc79e0ef update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 13
diff changeset
157 extern "C" int ui_textarea_position(UiText *text) {
641dcc79e0ef update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 13
diff changeset
158 return 0;
641dcc79e0ef update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 13
diff changeset
159 }
641dcc79e0ef update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 13
diff changeset
160
641dcc79e0ef update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 13
diff changeset
161 extern "C" void ui_textarea_selection(UiText *text, int *begin, int *end) {
641dcc79e0ef update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 13
diff changeset
162
641dcc79e0ef update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 13
diff changeset
163 }
641dcc79e0ef update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 13
diff changeset
164
641dcc79e0ef update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 13
diff changeset
165 extern "C" int ui_textarea_length(UiText *text) {
641dcc79e0ef update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 13
diff changeset
166 return 0;
641dcc79e0ef update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 13
diff changeset
167 }
641dcc79e0ef update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 13
diff changeset
168
641dcc79e0ef update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 13
diff changeset
169 extern "C" void ui_textarea_remove(UiText *text, int begin, int end) {
641dcc79e0ef update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 13
diff changeset
170
641dcc79e0ef update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 13
diff changeset
171 }
641dcc79e0ef update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 13
diff changeset
172
641dcc79e0ef update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 13
diff changeset
173
641dcc79e0ef update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 13
diff changeset
174
641dcc79e0ef update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 13
diff changeset
175
0
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
176 UIWIDGET ui_textfield_create(UiObject* obj, UiTextFieldArgs args) {
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
177 UiObject* current = uic_current_obj(obj);
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
178
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
179 // create textbox and toolkit wrapper
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
180 TextBox textfield = TextBox();
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
181 UIElement elm = textfield;
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
182 UiWidget* widget = new UiWidget(elm);
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
183 ui_context_add_widget_destructor(current->ctx, widget);
83
a612adaee43d fix pathbar elmfunc creating an element for an empty string
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 77
diff changeset
184 ui_set_widget_groups(current->ctx, widget, args.groups);
0
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
185
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
186 UiVar* var = uic_widget_var(obj->ctx, current->ctx, args.value, args.varname, UI_VAR_STRING);
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
187 if (var) {
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
188 UiString* value = (UiString*)var->value;
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
189 value->obj = widget;
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
190 value->get = ui_textfield_get;
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
191 value->set = ui_textfield_set;
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
192
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
193 // listener for notifying observers
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
194 // TODO:
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
195 }
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
196
76
641dcc79e0ef update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 13
diff changeset
197 // add textfield to current container
0
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
198 UI_APPLY_LAYOUT1(current, args);
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
199
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
200 current->container->Add(textfield, false);
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
201
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
202 return widget;
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
203 }
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
204
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
205 UIWIDGET ui_frameless_textfield_create(UiObject* obj, UiTextFieldArgs args) {
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
206 return ui_textfield_create(obj, args);
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
207 }
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
208
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
209 UIWIDGET ui_passwordfield_create(UiObject* obj, UiTextFieldArgs args) {
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
210 UiObject* current = uic_current_obj(obj);
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
211
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
212 // create textbox and toolkit wrapper
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
213 PasswordBox textfield = PasswordBox();
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
214 UIElement elm = textfield;
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
215 UiWidget* widget = new UiWidget(elm);
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
216 ui_context_add_widget_destructor(current->ctx, widget);
83
a612adaee43d fix pathbar elmfunc creating an element for an empty string
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 77
diff changeset
217 ui_set_widget_groups(current->ctx, widget, args.groups);
0
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
218
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
219 UiVar* var = uic_widget_var(obj->ctx, current->ctx, args.value, args.varname, UI_VAR_STRING);
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
220 if (var) {
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
221 UiString* value = (UiString*)var->value;
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
222 value->obj = widget;
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
223 value->get = ui_passwordfield_get;
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
224 value->set = ui_passwordfield_set;
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
225
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
226 // listener for notifying observers
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
227 // TODO:
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
228 }
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
229
76
641dcc79e0ef update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 13
diff changeset
230 // add textfield to current container
0
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
231 UI_APPLY_LAYOUT1(current, args);
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
232
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
233 current->container->Add(textfield, false);
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
234
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
235 return widget;
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
236 }
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
237
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
238
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
239 // -------------------------- getter/setter for textfield UiString --------------------------
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
240
3
f154867f54dc add nav buttons, update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
241 char* ui_wstring_get(UiString* str, std::wstring &value) {
0
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
242 if (str->value.ptr) {
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
243 str->value.free(str->value.ptr);
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
244 }
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
245
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
246 str->value.ptr = wchar2utf8(value.c_str(), value.length());
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
247 str->value.free = free;
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
248
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
249 return str->value.ptr;
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
250 }
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
251
3
f154867f54dc add nav buttons, update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
252 std::wstring ui_wstring_set(UiString* str, const char* value) {
0
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
253 if (str->value.ptr) {
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
254 str->value.free(str->value.ptr);
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
255 }
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
256
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
257 str->value.ptr = _strdup(value);
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
258 str->value.free = free;
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
259
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
260 int len;
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
261 wchar_t* wstr = str2wstr(value, &len);
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
262 std::wstring s(wstr);
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
263 free(wstr);
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
264
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
265 return s;
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
266 }
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
267
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
268 char* ui_textfield_get(UiString * str) {
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
269 UiWidget* widget = (UiWidget*)str->obj;
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
270 TextBox box = widget->uielement.as<TextBox>();
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
271 std::wstring wstr(box.Text());
3
f154867f54dc add nav buttons, update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
272 return ui_wstring_get(str, wstr);
0
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
273 }
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
274
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
275 void ui_textfield_set(UiString * str, const char* newvalue) {
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
276 UiWidget* widget = (UiWidget*)str->obj;
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
277 TextBox box = widget->uielement.as<TextBox>();
3
f154867f54dc add nav buttons, update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
278 box.Text(ui_wstring_set(str, newvalue));
0
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
279 }
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
280
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
281
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
282 char* ui_passwordfield_get(UiString * str) {
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
283 UiWidget* widget = (UiWidget*)str->obj;
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
284 PasswordBox box = widget->uielement.as<PasswordBox>();
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
285 std::wstring wstr(box.Password());
3
f154867f54dc add nav buttons, update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
286 return ui_wstring_get(str, wstr);
0
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
287 }
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
288
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
289 void ui_passwordfield_set(UiString * str, const char* newvalue) {
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
290 UiWidget* widget = (UiWidget*)str->obj;
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
291 PasswordBox box = widget->uielement.as<PasswordBox>();
3
f154867f54dc add nav buttons, update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
292 box.Password(ui_wstring_set(str, newvalue));
0
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
293 }
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
294
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
295
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
296 // ------------------------ path textfield --------------------------------------
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
297
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
298 extern "C" static void destroy_ui_pathtextfield(void* ptr) {
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
299 UiPathTextField* pb = (UiPathTextField*)ptr;
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
300 delete pb;
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
301 }
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
302
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
303 static void ui_context_add_pathtextfield_destructor(UiContext* ctx, UiPathTextField* pb) {
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
304 cxMempoolRegister(ctx->mp, pb, destroy_ui_pathtextfield);
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
305 }
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
306
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
307 static void ui_pathtextfield_clear(StackPanel& buttons) {
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
308 for (int i = buttons.Children().Size() - 1; i >= 0; i--) {
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
309 buttons.Children().RemoveAt(i);
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
310 }
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
311 }
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
312
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
313 static void ui_pathfield_free_pathelms(UiPathElm* elms, size_t nelm) {
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
314 if (!elms) {
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
315 return;
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
316 }
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
317 for (int i = 0; i < nelm; i++) {
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
318 UiPathElm e = elms[i];
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
319 free(e.name);
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
320 free(e.path);
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
321 }
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
322 free(elms);
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
323 }
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
324
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
325 UiPathTextField::~UiPathTextField() {
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
326 ui_pathfield_free_pathelms(this->current_path, this->current_path_nelms);
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
327 }
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
328
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
329 static UiPathElm* default_pathelm_func(const char* full_path, size_t len, size_t* ret_nelm, void* data) {
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
330 cxstring *pathelms;
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
331 size_t nelm = cx_strsplit_a(cxDefaultAllocator, cx_strn(full_path, len), CX_STR("/"), 4096, &pathelms);
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
332
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
333 if (nelm == 0) {
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
334 *ret_nelm = 0;
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
335 return nullptr;
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
336 }
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
337
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
338 UiPathElm* elms = (UiPathElm*)calloc(nelm, sizeof(UiPathElm));
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
339 size_t n = nelm;
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
340 int j = 0;
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
341 for (int i = 0; i < nelm; i++) {
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
342 cxstring c = pathelms[i];
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
343 if (c.length == 0) {
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
344 if (i == 0) {
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
345 c.length = 1;
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
346 }
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
347 else {
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
348 n--;
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
349 continue;
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
350 }
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
351 }
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
352
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
353 cxmutstr m = cx_strdup(c);
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
354 elms[j].name = m.ptr;
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
355 elms[j].name_len = m.length;
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
356
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
357 size_t elm_path_len = c.ptr + c.length - full_path;
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
358 cxmutstr elm_path = cx_strdup(cx_strn(full_path, elm_path_len));
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
359 elms[j].path = elm_path.ptr;
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
360 elms[j].path_len = elm_path.length;
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
361
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
362 j++;
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
363 }
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
364 *ret_nelm = n;
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
365
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
366 return elms;
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
367 }
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
368
13
5a8762fcfecc update toolkit / set window size
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 8
diff changeset
369 int ui_pathtextfield_update(UiPathTextField* pb, const char *full_path) {
0
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
370 Grid grid = pb->grid;
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
371
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
372 ui_pathelm_func getpathelm = pb->getpathelm;
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
373 void* getpathelmdata = pb->getpathelmdata;
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
374
13
5a8762fcfecc update toolkit / set window size
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 8
diff changeset
375 size_t full_path_len = full_path ? strlen(full_path) : 0;
5a8762fcfecc update toolkit / set window size
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 8
diff changeset
376
5a8762fcfecc update toolkit / set window size
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 8
diff changeset
377 size_t nelm = 0;
5a8762fcfecc update toolkit / set window size
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 8
diff changeset
378 UiPathElm* path_elm = getpathelm(full_path, full_path_len, &nelm, getpathelmdata);
5a8762fcfecc update toolkit / set window size
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 8
diff changeset
379 if (!path_elm) {
5a8762fcfecc update toolkit / set window size
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 8
diff changeset
380 return 1;
5a8762fcfecc update toolkit / set window size
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 8
diff changeset
381 }
5a8762fcfecc update toolkit / set window size
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 8
diff changeset
382
0
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
383 // hide textbox, show button panel
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
384 pb->textbox.Visibility(Visibility::Collapsed);
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
385 pb->buttons.Visibility(Visibility::Visible);
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
386
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
387 // clear old buttons
13
5a8762fcfecc update toolkit / set window size
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 8
diff changeset
388 ui_pathtextfield_clear(pb->buttons);
0
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
389
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
390 ui_pathfield_free_pathelms(pb->current_path, pb->current_path_nelms);
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
391 pb->current_path = path_elm;
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
392 pb->current_path_nelms = nelm;
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
393
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
394 // add new buttons
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
395 int j = 0;
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
396 for (int i = 0; i < nelm;i++) {
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
397 UiPathElm elm = path_elm[i];
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
398 wchar_t* wstr = str2wstr_len(elm.name, elm.name_len, nullptr);
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
399 Button button = Button();
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
400 button.Content(box_value(wstr));
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
401 free(wstr);
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
402
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
403 if (pb->onactivate) {
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
404 button.Click([pb, j, elm](IInspectable const& sender, RoutedEventArgs) {
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
405 // copy elm.path because it could be a non-terminated string
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
406 cxmutstr elmpath = cx_strdup(cx_strn(elm.path, elm.path_len));
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
407
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
408 UiEvent evt;
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
409 evt.obj = pb->obj;
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
410 evt.window = evt.obj->window;
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
411 evt.document = evt.obj->ctx->document;
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
412 evt.eventdata = elmpath.ptr;
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
413 evt.intval = j;
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
414 pb->onactivate(&evt, pb->onactivatedata);
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
415
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
416 free(elmpath.ptr);
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
417 });
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
418 }
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
419
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
420 Thickness t = { 0, 0, 1, 0 };
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
421 CornerRadius c = { 0 ,0, 0, 0 };
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
422 button.BorderThickness(t);
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
423 button.CornerRadius(c);
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
424
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
425 pb->buttons.Children().Append(button);
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
426
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
427 j++;
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
428 }
13
5a8762fcfecc update toolkit / set window size
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 8
diff changeset
429
5a8762fcfecc update toolkit / set window size
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 8
diff changeset
430 return 0;
0
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
431 }
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
432
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
433 char* ui_path_textfield_get(UiString * str) {
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
434 UiPathTextField* widget = (UiPathTextField*)str->obj;
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
435 TextBox box = widget->textbox;
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
436 std::wstring wstr(box.Text());
3
f154867f54dc add nav buttons, update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
437 return ui_wstring_get(str, wstr);
0
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
438 }
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
439
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
440 void ui_path_textfield_set(UiString* str, const char* newvalue) {
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
441 UiPathTextField* widget = (UiPathTextField*)str->obj;
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
442 TextBox box = widget->textbox;
3
f154867f54dc add nav buttons, update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
443 box.Text(ui_wstring_set(str, newvalue));
0
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
444 ui_pathtextfield_update(widget, newvalue);
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
445 }
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
446
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
447 UIEXPORT UIWIDGET ui_path_textfield_create(UiObject* obj, UiPathTextFieldArgs args) {
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
448 UiObject* current = uic_current_obj(obj);
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
449
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
450 // create view and toolkit wrapper
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
451 Border pathbar = Border();
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
452
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
453 IInspectable bgRes = Application::Current().Resources().Lookup(box_value(L"TextControlBackground"));
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
454 IInspectable borderThicknessRes = Application::Current().Resources().Lookup(box_value(L"TextControlBorderThemeThickness"));
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
455 IInspectable borderBrushRes = Application::Current().Resources().Lookup(box_value(L"TextControlBorderBrush"));
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
456 // IInspectable cornerRes = Application::Current().Resources().Lookup(box_value(L"TextControlCornerRadius"));
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
457
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
458 Brush bgBrush = unbox_value<Brush>(bgRes);
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
459 Thickness border = unbox_value<Thickness>(borderThicknessRes);
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
460 Brush borderBrush = unbox_value<Brush>(borderBrushRes);
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
461 CornerRadius cornerRadius = { 4, 4, 4, 4 }; //unbox_value<CornerRadius>(cornerRes);
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
462
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
463 pathbar.Background(bgBrush);
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
464 pathbar.BorderBrush(borderBrush);
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
465 pathbar.BorderThickness(border);
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
466 pathbar.CornerRadius(cornerRadius);
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
467
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
468 Grid content = Grid();
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
469 pathbar.Child(content);
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
470
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
471 GridLength gl;
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
472 gl.Value = 0;
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
473 gl.GridUnitType = GridUnitType::Auto;
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
474
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
475 ColumnDefinition coldef = ColumnDefinition();
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
476 coldef.Width(gl);
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
477 content.ColumnDefinitions().Append(coldef);
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
478
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
479 gl.Value = 1;
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
480 gl.GridUnitType = GridUnitType::Star;
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
481
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
482 ColumnDefinition coldef2 = ColumnDefinition();
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
483 coldef2.Width(gl);
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
484 content.ColumnDefinitions().Append(coldef2);
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
485
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
486 TextBox pathTextBox = TextBox();
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
487 Thickness t = { 0, 0, 0, 0 };
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
488 CornerRadius c = { 0 ,0, 0, 0 };
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
489 pathTextBox.BorderThickness(t);
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
490 //pathTextBox.CornerRadius(c);
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
491
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
492
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
493 pathTextBox.HorizontalAlignment(HorizontalAlignment::Stretch);
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
494 content.SetColumn(pathTextBox, 0);
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
495 content.SetColumnSpan(pathTextBox, 2);
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
496
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
497 content.Children().Append(pathTextBox);
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
498
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
499 // stackpanel for buttons
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
500 StackPanel buttons = StackPanel();
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
501 buttons.Orientation(Orientation::Horizontal);
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
502 buttons.Visibility(Visibility::Collapsed);
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
503 content.SetColumn(buttons, 0);
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
504 content.Children().Append(buttons);
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
505
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
506 TextBlock filler = TextBlock();
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
507 filler.VerticalAlignment(VerticalAlignment::Stretch);
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
508 //filler.Text(winrt::hstring(L"hello filler"));
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
509
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
510 filler.HorizontalAlignment(HorizontalAlignment::Stretch);
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
511 filler.VerticalAlignment(VerticalAlignment::Stretch);
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
512 content.SetColumn(filler, 1);
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
513 content.Children().Append(filler);
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
514
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
515 filler.PointerPressed(
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
516 winrt::Microsoft::UI::Xaml::Input::PointerEventHandler(
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
517 [=](IInspectable const& sender, winrt::Microsoft::UI::Xaml::Input::PointerRoutedEventArgs const& args) {
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
518 pathTextBox.Visibility(Visibility::Visible);
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
519 buttons.Visibility(Visibility::Collapsed);
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
520 filler.Visibility(Visibility::Collapsed);
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
521 pathTextBox.SelectionStart(pathTextBox.Text().size());
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
522 pathTextBox.SelectionLength(0);
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
523 pathTextBox.Focus(FocusState::Keyboard);
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
524 })
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
525 );
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
526
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
527 //pathTextBox.Visibility(Visibility::Collapsed);
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
528
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
529 UiPathTextField* uipathbar = new UiPathTextField;
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
530 ui_context_add_pathtextfield_destructor(current->ctx, uipathbar);
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
531 uipathbar->grid = content;
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
532 uipathbar->buttons = buttons;
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
533 uipathbar->textbox = pathTextBox;
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
534 uipathbar->filler = filler;
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
535 uipathbar->obj = obj;
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
536 uipathbar->getpathelm = args.getpathelm ? args.getpathelm : default_pathelm_func;
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
537 uipathbar->getpathelmdata = args.getpathelmdata;
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
538 uipathbar->onactivate = args.onactivate;
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
539 uipathbar->onactivatedata = args.onactivatedata;
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
540 uipathbar->ondragstart = args.ondragstart;
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
541 uipathbar->ondragstartdata = args.ondragstartdata;
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
542 uipathbar->ondragcomplete = args.ondragcomplete;
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
543 uipathbar->ondragcompletedata = args.ondragcompletedata;
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
544 uipathbar->ondrop = args.ondrop;
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
545 uipathbar->ondropdata = args.ondropsdata;
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
546
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
547
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
548 pathTextBox.KeyDown(
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
549 winrt::Microsoft::UI::Xaml::Input::KeyEventHandler(
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
550 [=](winrt::Windows::Foundation::IInspectable const& sender, winrt::Microsoft::UI::Xaml::Input::KeyRoutedEventArgs const& e) {
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
551 auto key = e.Key();
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
552 bool showButtons = false;
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
553 bool update = false;
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
554 if (key == Windows::System::VirtualKey::Escape) {
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
555 showButtons = true;
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
556 }
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
557 else if (key == Windows::System::VirtualKey::Enter) {
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
558 showButtons = true;
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
559 update = true;
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
560 }
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
561
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
562 if (showButtons) {
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
563 pathTextBox.Visibility(Visibility::Collapsed);
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
564 buttons.Visibility(Visibility::Visible);
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
565 filler.Visibility(Visibility::Visible);
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
566 if (update) {
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
567 std::wstring value(pathTextBox.Text());
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
568 char* full_path = wchar2utf8(value.c_str(), value.length());
13
5a8762fcfecc update toolkit / set window size
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 8
diff changeset
569
5a8762fcfecc update toolkit / set window size
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 8
diff changeset
570 if (!ui_pathtextfield_update(uipathbar, full_path)) {
5a8762fcfecc update toolkit / set window size
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 8
diff changeset
571 UiEvent evt;
5a8762fcfecc update toolkit / set window size
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 8
diff changeset
572 evt.obj = obj;
5a8762fcfecc update toolkit / set window size
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 8
diff changeset
573 evt.window = obj->window;
5a8762fcfecc update toolkit / set window size
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 8
diff changeset
574 evt.document = obj->ctx->document;
5a8762fcfecc update toolkit / set window size
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 8
diff changeset
575 evt.eventdata = full_path;
5a8762fcfecc update toolkit / set window size
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 8
diff changeset
576 evt.intval = -1;
5a8762fcfecc update toolkit / set window size
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 8
diff changeset
577 args.onactivate(&evt, args.onactivatedata);
5a8762fcfecc update toolkit / set window size
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 8
diff changeset
578 }
5a8762fcfecc update toolkit / set window size
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 8
diff changeset
579
0
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
580 free(full_path);
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
581 }
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
582
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
583 //buttons.Focus(FocusState::Keyboard);
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
584 }
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
585 })
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
586 );
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
587
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
588
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
589 UIElement elm = pathbar;
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
590 UiWidget* widget = new UiWidget(elm);
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
591 widget->data1 = uipathbar;
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
592 ui_context_add_widget_destructor(current->ctx, widget);
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
593
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
594 // bind var
8
726b24766437 implement connecting to repositories
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 3
diff changeset
595 UiVar* var = uic_widget_var(obj->ctx, current->ctx, args.value, args.varname, UI_VAR_STRING);
0
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
596 if (var) {
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
597 UiString* value = (UiString*)var->value;
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
598 value->obj = uipathbar;
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
599 value->get = ui_path_textfield_get;
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
600 value->set = ui_path_textfield_set;
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
601 }
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
602
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
603 // add listview to current container
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
604 UI_APPLY_LAYOUT1(current, args);
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
605
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
606 current->container->Add(pathbar, false);
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
607
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
608 return widget;
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
609 }

mercurial