Update git-version-gen from gnulib to version 2017-01-09.19
[centerim5.git] / tests / treeview.cpp
blobdd29bf3f3f7cdbb2c4f48af9cb3712b5d69bec93
1 #include <cppconsui/Button.h>
2 #include <cppconsui/Label.h>
3 #include <cppconsui/TreeView.h>
4 #include <cppconsui/Window.h>
6 // TestWindow class
7 class TestWindow : public CppConsUI::Window {
8 public:
9 TestWindow();
10 virtual ~TestWindow() override {}
12 private:
13 CONSUI_DISABLE_COPY(TestWindow);
16 TestWindow::TestWindow() : Window(0, 0, AUTOSIZE, AUTOSIZE)
18 setClosable(false);
20 addWidget(*(new CppConsUI::Label(20, 1, "Press F10 to quit.")), 1, 1);
22 auto tree = new CppConsUI::TreeView(30, 12);
23 addWidget(*tree, 1, 3);
24 setInputChild(*tree);
26 CppConsUI::TreeView::NodeReference node, node2;
28 node = tree->appendNode(
29 tree->getRootNode(), *(new CppConsUI::Button("Button node A")));
30 node2 = tree->appendNode(node, *(new CppConsUI::Button("Button node A-1")));
31 tree->appendNode(node2, *(new CppConsUI::Button("Button node A-1-a")));
32 tree->appendNode(node2, *(new CppConsUI::Button("Button node A-1-b")));
33 tree->appendNode(node2, *(new CppConsUI::Button("Button node A-1-c")));
34 tree->appendNode(node, *(new CppConsUI::Button("Button node A-2")));
35 tree->appendNode(node, *(new CppConsUI::Button("Button node A-3")));
37 node = tree->appendNode(
38 tree->getRootNode(), *(new CppConsUI::Label("Label node B")));
39 tree->appendNode(node, *(new CppConsUI::Label("Label node B-1")));
40 tree->appendNode(node, *(new CppConsUI::Label("Label node B-2")));
41 tree->appendNode(node, *(new CppConsUI::Label("Label node B-3")));
43 node = tree->appendNode(
44 tree->getRootNode(), *(new CppConsUI::Button("Button node C")));
45 tree->appendNode(node, *(new CppConsUI::Button("Button node C-1")));
46 tree->appendNode(node, *(new CppConsUI::Button("Button node C-2")));
47 tree->appendNode(node, *(new CppConsUI::Button("Button node C-3")));
50 void setupTest()
52 // Create the main window.
53 auto win = new TestWindow;
54 win->show();
57 // vim: set tabstop=2 shiftwidth=2 textwidth=80 expandtab