1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- //module app;
- import dlangui;
- mixin APP_ENTRY_POINT;
- /// entry point for dlangui based application
- extern (C) int UIAppMain(string[] args) {
- // load theme from file "theme_default.xml"
- //Platform.instance.uiTheme = "theme_default";
- // create window
- Log.d("Creating window");
- //Window window = Platform.instance.createWindow("DlangUI example - HelloWorld", null);
- Window window = Platform.instance.createWindow("local git for GPT - git4GPT", null, 1, 1200, 900);
- 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: 4pt
- padding: 3pt
- layoutWidth: fill
- // 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" }
- //TextWidget { text: "______________________________ localhost RepoGPT ______________________________"; fontSize: 90%; fontFace: "Arial" }
-
- // arrange controls as form - table with two columns
- TableLayout {
- colCount: 2
- layoutWidth: fill
- TextWidget { text: "path to git repo" }
- EditLine { id: edit1; text: "todo read default path from toml file"; layoutWidth: fill }
- //ComboEdit { id: type1; text: ""; minWidth: 100pt; items: ["Exclude", "Include"] }
- //ComboEdit { id: type1; text: ""; items: ["Exclude", "Include"] }
- ComboBox { id: type1; text: ""; items: ["Exclude", "Include"] }
- //TextWidget { text: "param 2" }
- EditLine { id: edit2; text: "*.md, *.MD"; layoutWidth: fill }
- Button { id: btnRun; text: "Run" }
- Button { id: btnCopy; text: "Copy" }
-
- //TextWidget { text: "some 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: "and checkboxes" }
- // arrange some checkboxes horizontally
- //HorizontalLayout {
- // layoutWidth: fill
- // CheckBox { id: cb1; text: "checkbox 1" }
- // CheckBox { id: cb2; text: "checkbox 2" }
- // ComboEdit { id: ce1; text: "some text"; minWidth: 20pt; items: ["Item 1", "Item 2", "Additional item"] }
- //}
- }
- //EditBox { layoutWidth: 20pt; layoutHeight: 10pt }
- EditBox { layoutWidth: FILL_PARENT; layoutHeight: FILL_PARENT; minWidth: 1000; minHeight: 750 }
- //EditBox { minWidth: 1000; minHeight: 200 }
- //HorizontalLayout {
- // Button { id: btnOk; text: "Ok" }
- // Button { id: btnCancel; text: "Cancel" }
- //}
- }
- });
-
- //window.mainWidget.minWidth(900);
- //window.mainWidget.minHeight(500);
-
- // 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("btnRun").click = delegate(Widget w) {
- window.showMessageBox(UIString.fromRaw("Run button pressed"d),
- UIString.fromRaw("Editors content\nEdit1: "d ~ edit1.text ~ "\nEdit2: "d ~ edit2.text));
- return true;
- };
- // show window
- window.show();
- // run message loop
- return Platform.instance.enterMessageLoop();
- }
|