ui/winui/window.cpp

changeset 76
641dcc79e0ef
parent 29
3fc287f06305
child 79
483d7342b439
--- a/ui/winui/window.cpp	Sun Nov 10 09:12:30 2024 +0100
+++ b/ui/winui/window.cpp	Sun Nov 10 15:30:46 2024 +0100
@@ -65,12 +65,14 @@
 UiObject* ui_window(const char* title, void* window_data) {
 	UiObject* obj = ui_simple_window(title, window_data);
 
+	/*
 	if (uic_get_menu_list()) {
 		// create/add menubar
 		MenuBar mb = ui_create_menubar(obj);
 		mb.VerticalAlignment(VerticalAlignment::Top);
 		obj->container->Add(mb, false);
 	}
+	*/
 
 	if (uic_toolbar_isenabled()) {
 		// create a grid for the toolbar: ColumnDefinitions="Auto, *, Auto"
@@ -109,14 +111,14 @@
 		CxList* def_r = uic_get_toolbar_defaults(UI_TOOLBAR_RIGHT);
 
 		bool addappmenu = true;
-		if (def_r->size > 0) {
+		if (cxListSize(def_r) > 0) {
 			CommandBar toolbar_r = ui_create_toolbar(obj, def_r, addappmenu);
 			toolbar_grid.SetColumn(toolbar_r, 2);
 			toolbar_grid.SetRow(toolbar_r, 0);
 			toolbar_grid.Children().Append(toolbar_r);
 			addappmenu = false;
 		}
-		if (def_c->size > 0) {
+		if (cxListSize(def_c) > 0) {
 			CommandBar toolbar_c = ui_create_toolbar(obj, def_c, addappmenu);
 			toolbar_c.HorizontalAlignment(HorizontalAlignment::Center);
 			toolbar_grid.SetColumn(toolbar_c, 1);
@@ -124,7 +126,7 @@
 			toolbar_grid.Children().Append(toolbar_c);
 			addappmenu = false;
 		}
-		if (def_l->size > 0) {
+		if (cxListSize(def_l) > 0) {
 			CommandBar toolbar_l = ui_create_toolbar(obj, def_l, addappmenu);
 			toolbar_grid.SetColumn(toolbar_l, 0);
 			toolbar_grid.SetRow(toolbar_l, 0);
@@ -199,6 +201,10 @@
 	return obj;
 }
 
+UIEXPORT UiObject* ui_dialog_window_create(UiObject *parent, UiDialogWindowArgs args) {
+	return NULL;
+}
+
 void ui_window_size(UiObject *obj, int width, int height) {
 	UIWINDOW win = obj->wobj;
 	if (win) {
@@ -226,7 +232,8 @@
 	}
 
 	TextBox textfield{ nullptr };
-	if (args.input) {
+	PasswordBox password{ nullptr };
+	if(args.input || args.password) {
 		StackPanel panel = StackPanel();
 		panel.Orientation(Orientation::Vertical);
 		if (args.content) {
@@ -237,13 +244,19 @@
 			free(str);
 		}
 
-		textfield = TextBox();
 		Thickness margin = { 0, 5, 0, 0 };
-		textfield.Margin(margin);
+		if (args.password) {
+			password = PasswordBox();
+			password.Margin(margin);
+			panel.Children().Append(password);
+		} else {
+			textfield = TextBox();
+			textfield.Margin(margin);
+			panel.Children().Append(textfield);
+		}
+		
 		panel.Margin(margin);
 
-		panel.Children().Append(textfield);
-
 		dialog.Content(panel);
 
 	} else {
@@ -286,7 +299,11 @@
 			evt.intval = 2;
 		}
 
-		if (args.input) {
+		if (args.password) {
+			std::wstring wstr(password.Password());
+			char *text = wchar2utf8(wstr.c_str(), wstr.length());
+			evt.eventdata = text;
+		} else if (args.input) {
 			std::wstring wstr(textfield.Text());
 			char *text = wchar2utf8(wstr.c_str(), wstr.length());
 			evt.eventdata = text;

mercurial