63 UiWindow::UiWindow(winrt::Microsoft::UI::Xaml::Window& win) : window(win) {} |
63 UiWindow::UiWindow(winrt::Microsoft::UI::Xaml::Window& win) : window(win) {} |
64 |
64 |
65 UiObject* ui_window(const char* title, void* window_data) { |
65 UiObject* ui_window(const char* title, void* window_data) { |
66 UiObject* obj = ui_simple_window(title, window_data); |
66 UiObject* obj = ui_simple_window(title, window_data); |
67 |
67 |
|
68 /* |
68 if (uic_get_menu_list()) { |
69 if (uic_get_menu_list()) { |
69 // create/add menubar |
70 // create/add menubar |
70 MenuBar mb = ui_create_menubar(obj); |
71 MenuBar mb = ui_create_menubar(obj); |
71 mb.VerticalAlignment(VerticalAlignment::Top); |
72 mb.VerticalAlignment(VerticalAlignment::Top); |
72 obj->container->Add(mb, false); |
73 obj->container->Add(mb, false); |
73 } |
74 } |
|
75 */ |
74 |
76 |
75 if (uic_toolbar_isenabled()) { |
77 if (uic_toolbar_isenabled()) { |
76 // create a grid for the toolbar: ColumnDefinitions="Auto, *, Auto" |
78 // create a grid for the toolbar: ColumnDefinitions="Auto, *, Auto" |
77 Grid toolbar_grid = Grid(); |
79 Grid toolbar_grid = Grid(); |
78 GridLength gl; |
80 GridLength gl; |
107 CxList* def_l = uic_get_toolbar_defaults(UI_TOOLBAR_LEFT); |
109 CxList* def_l = uic_get_toolbar_defaults(UI_TOOLBAR_LEFT); |
108 CxList* def_c = uic_get_toolbar_defaults(UI_TOOLBAR_CENTER); |
110 CxList* def_c = uic_get_toolbar_defaults(UI_TOOLBAR_CENTER); |
109 CxList* def_r = uic_get_toolbar_defaults(UI_TOOLBAR_RIGHT); |
111 CxList* def_r = uic_get_toolbar_defaults(UI_TOOLBAR_RIGHT); |
110 |
112 |
111 bool addappmenu = true; |
113 bool addappmenu = true; |
112 if (def_r->size > 0) { |
114 if (cxListSize(def_r) > 0) { |
113 CommandBar toolbar_r = ui_create_toolbar(obj, def_r, addappmenu); |
115 CommandBar toolbar_r = ui_create_toolbar(obj, def_r, addappmenu); |
114 toolbar_grid.SetColumn(toolbar_r, 2); |
116 toolbar_grid.SetColumn(toolbar_r, 2); |
115 toolbar_grid.SetRow(toolbar_r, 0); |
117 toolbar_grid.SetRow(toolbar_r, 0); |
116 toolbar_grid.Children().Append(toolbar_r); |
118 toolbar_grid.Children().Append(toolbar_r); |
117 addappmenu = false; |
119 addappmenu = false; |
118 } |
120 } |
119 if (def_c->size > 0) { |
121 if (cxListSize(def_c) > 0) { |
120 CommandBar toolbar_c = ui_create_toolbar(obj, def_c, addappmenu); |
122 CommandBar toolbar_c = ui_create_toolbar(obj, def_c, addappmenu); |
121 toolbar_c.HorizontalAlignment(HorizontalAlignment::Center); |
123 toolbar_c.HorizontalAlignment(HorizontalAlignment::Center); |
122 toolbar_grid.SetColumn(toolbar_c, 1); |
124 toolbar_grid.SetColumn(toolbar_c, 1); |
123 toolbar_grid.SetRow(toolbar_c, 0); |
125 toolbar_grid.SetRow(toolbar_c, 0); |
124 toolbar_grid.Children().Append(toolbar_c); |
126 toolbar_grid.Children().Append(toolbar_c); |
125 addappmenu = false; |
127 addappmenu = false; |
126 } |
128 } |
127 if (def_l->size > 0) { |
129 if (cxListSize(def_l) > 0) { |
128 CommandBar toolbar_l = ui_create_toolbar(obj, def_l, addappmenu); |
130 CommandBar toolbar_l = ui_create_toolbar(obj, def_l, addappmenu); |
129 toolbar_grid.SetColumn(toolbar_l, 0); |
131 toolbar_grid.SetColumn(toolbar_l, 0); |
130 toolbar_grid.SetRow(toolbar_l, 0); |
132 toolbar_grid.SetRow(toolbar_l, 0); |
131 toolbar_grid.Children().Append(toolbar_l); |
133 toolbar_grid.Children().Append(toolbar_l); |
132 } |
134 } |
197 obj->window = window_data; |
199 obj->window = window_data; |
198 |
200 |
199 return obj; |
201 return obj; |
200 } |
202 } |
201 |
203 |
|
204 UIEXPORT UiObject* ui_dialog_window_create(UiObject *parent, UiDialogWindowArgs args) { |
|
205 return NULL; |
|
206 } |
|
207 |
202 void ui_window_size(UiObject *obj, int width, int height) { |
208 void ui_window_size(UiObject *obj, int width, int height) { |
203 UIWINDOW win = obj->wobj; |
209 UIWINDOW win = obj->wobj; |
204 if (win) { |
210 if (win) { |
205 winrt::Windows::Graphics::SizeInt32 wsize; |
211 winrt::Windows::Graphics::SizeInt32 wsize; |
206 wsize.Width = width; |
212 wsize.Width = width; |
224 dialog.Title(winrt::box_value(str)); |
230 dialog.Title(winrt::box_value(str)); |
225 free(str); |
231 free(str); |
226 } |
232 } |
227 |
233 |
228 TextBox textfield{ nullptr }; |
234 TextBox textfield{ nullptr }; |
229 if (args.input) { |
235 PasswordBox password{ nullptr }; |
|
236 if(args.input || args.password) { |
230 StackPanel panel = StackPanel(); |
237 StackPanel panel = StackPanel(); |
231 panel.Orientation(Orientation::Vertical); |
238 panel.Orientation(Orientation::Vertical); |
232 if (args.content) { |
239 if (args.content) { |
233 wchar_t *str = str2wstr(args.content, nullptr); |
240 wchar_t *str = str2wstr(args.content, nullptr); |
234 TextBlock label = TextBlock(); |
241 TextBlock label = TextBlock(); |
235 label.Text(str); |
242 label.Text(str); |
236 panel.Children().Append(label); |
243 panel.Children().Append(label); |
237 free(str); |
244 free(str); |
238 } |
245 } |
239 |
246 |
240 textfield = TextBox(); |
|
241 Thickness margin = { 0, 5, 0, 0 }; |
247 Thickness margin = { 0, 5, 0, 0 }; |
242 textfield.Margin(margin); |
248 if (args.password) { |
|
249 password = PasswordBox(); |
|
250 password.Margin(margin); |
|
251 panel.Children().Append(password); |
|
252 } else { |
|
253 textfield = TextBox(); |
|
254 textfield.Margin(margin); |
|
255 panel.Children().Append(textfield); |
|
256 } |
|
257 |
243 panel.Margin(margin); |
258 panel.Margin(margin); |
244 |
|
245 panel.Children().Append(textfield); |
|
246 |
259 |
247 dialog.Content(panel); |
260 dialog.Content(panel); |
248 |
261 |
249 } else { |
262 } else { |
250 if (args.content) { |
263 if (args.content) { |
284 evt.intval = 1; |
297 evt.intval = 1; |
285 } else if (result == ContentDialogResult::Secondary) { |
298 } else if (result == ContentDialogResult::Secondary) { |
286 evt.intval = 2; |
299 evt.intval = 2; |
287 } |
300 } |
288 |
301 |
289 if (args.input) { |
302 if (args.password) { |
|
303 std::wstring wstr(password.Password()); |
|
304 char *text = wchar2utf8(wstr.c_str(), wstr.length()); |
|
305 evt.eventdata = text; |
|
306 } else if (args.input) { |
290 std::wstring wstr(textfield.Text()); |
307 std::wstring wstr(textfield.Text()); |
291 char *text = wchar2utf8(wstr.c_str(), wstr.length()); |
308 char *text = wchar2utf8(wstr.c_str(), wstr.length()); |
292 evt.eventdata = text; |
309 evt.eventdata = text; |
293 } |
310 } |
294 |
311 |