module app; import dlangui; mixin APP_ENTRY_POINT; /// entry point for dlangui based application extern (C) int UIAppMain(string[] args) { // create window Log.d("Creating window"); if (!Platform.instance) { Log.e("Platform.instance is null!!!"); } Window window = Platform.instance.createWindow("DlangUI example - HelloWorld", null); Log.d("Window created"); // create some widget to show in window //window.mainWidget = (new Button()).text("Hello, world!"d).margins(Rect(20,20,20,20)); window.mainWidget = parseML(q{ VerticalLayout { margins: 10 padding: 10 layoutWidth: fill backgroundColor: "#C0E0E070" // semitransparent yellow background // red bold text with size = 150% of base style size and font face Arial TextWidget { text: "Hello World example for DlangUI"; textColor: "red"; fontSize: 150%; fontWeight: 800; fontFace: "Arial" } // arrange controls as form - table with two columns TableLayout { colCount: 2 layoutWidth: fill TextWidget { text: "param 1" } EditLine { id: edit1; text: "some text"; layoutWidth: fill; margins: 3pt } TextWidget { text: "param 2" } EditLine { id: edit2; text: "some text for param2"; layoutWidth: fill; margins: 3pt } TextWidget { text: "Radio buttons" } // arrange some radio buttons vertically VerticalLayout { layoutWidth: fill RadioButton { id: rb1; text: "Item 1" } RadioButton { id: rb2; text: "Item 2" } RadioButton { id: rb3; text: "Item 3" } } TextWidget { text: "Switches:" } VerticalLayout { SwitchWidget { checked: true } SwitchWidget { checked: false } SwitchWidget { checked: true; enabled: false } } TextWidget { text: "Checkboxes:" } // arrange some checkboxes horizontally VerticalLayout { layoutWidth: fill CheckBox { id: cb1; text: "checkbox 1" } CheckBox { id: cb2; text: "checkbox 2" } } } HorizontalLayout { Button { id: btnOk; text: "Ok" } Button { id: btnCancel; text: "Cancel" } } } }); // you can access loaded items by id - e.g. to assign signal listeners auto edit1 = window.mainWidget.childById!EditLine("edit1"); auto edit2 = window.mainWidget.childById!EditLine("edit2"); // close window on Cancel button click window.mainWidget.childById!Button("btnCancel").click = delegate(Widget w) { window.close(); return true; }; // show message box with content of editors window.mainWidget.childById!Button("btnOk").click = delegate(Widget w) { window.showMessageBox(UIString("Ok button pressed"d), UIString("Editors content\nEdit1: "d ~ edit1.text ~ "\nEdit2: "d ~ edit2.text)); return true; }; // show window window.show(); // run message loop return Platform.instance.enterMessageLoop(); }