1 module splitter;
2 
3 import std..string;
4 import dguihub;
5 import dguihub.layout.splitpanel;
6 
7 class MainForm : Form {
8    private SplitPanel _spVPanel;
9    private SplitPanel _spHPanel;
10    private RichTextBox _rtbText;
11    private RichTextBox _rtbText2;
12    private TreeView _tvwTree;
13 
14    public this() {
15       this.text = "DGui SplitPanel Example";
16       this.size = Size(500, 500);
17       this.startPosition = FormStartPosition.centerScreen;
18 
19       this._spVPanel = new SplitPanel();
20       this._spVPanel.dock = DockStyle.fill;
21       this._spVPanel.splitPosition = 200;
22       this._spVPanel.splitOrientation = SplitOrientation.vertical; // Split Window vertically (this is the default option)
23       this._spVPanel.parent = this;
24 
25       // Add another Splitter Panel in Panel1 of the Vertical Splitter Panel (aka. Right Panel)
26       this._spHPanel = new SplitPanel();
27       this._spHPanel.dock = DockStyle.fill;
28       this._spHPanel.splitPosition = 300;
29       this._spHPanel.splitOrientation = SplitOrientation.horizontal; // Split Window horizontally (this is the default option)
30       this._spHPanel.parent = this._spVPanel.panel2; // The parent of the Horizontal Splitter Panel is the left panel of the Vertical Splitter Panel
31 
32       // Add a TreeView in Panel1 of the Vertical Splitter Panel (aka. Left Panel)
33       this._tvwTree = new TreeView();
34       this._tvwTree.dock = DockStyle.fill;
35       this._tvwTree.parent = this._spVPanel.panel1;
36 
37       for (int i = 0; i < 4; i++) {
38          TreeNode node1 = this._tvwTree.addNode(format("Node %d", i));
39 
40          for (int j = 0; j < 5; j++) {
41             node1.addNode(format("Node %d -> %d", i, j));
42          }
43       }
44 
45       // Add a RichTextBox in Panel1 of the Horizontal Splitter Panel (aka. Top Panel)
46       this._rtbText = new RichTextBox();
47       this._rtbText.dock = DockStyle.fill;
48       this._rtbText.readOnly = true;
49       this._rtbText.text = "This is a RichTextBox inside a Horizontal Splitter Panel (Top Panel)!";
50       this._rtbText.parent = this._spHPanel.panel1; // The parent of the RichTextBox is the Top Panel of the Horizontal Splitter Panel
51 
52       // Add a RichTextBox in Panel2 of the Horizontal (aka. Bottom Panel)
53       this._rtbText = new RichTextBox();
54       this._rtbText.dock = DockStyle.fill;
55       this._rtbText.readOnly = true;
56       this._rtbText.text
57          = "This is a RichTextBox inside a Horizontal Splitter Panel (Bottom Panel)!";
58       this._rtbText.parent = this._spHPanel.panel2; // The parent of the RichTextBox is the Bottom Panel of the Horizontal Splitter Panel
59 
60    }
61 }
62 
63 int main(string[] args) {
64    return Application.run(new MainForm());
65 }