1 #include <cppconsui/Button.h>
2 #include <cppconsui/CoreManager.h>
3 #include <cppconsui/Label.h>
4 #include <cppconsui/KeyConfig.h>
5 #include <cppconsui/TreeView.h>
6 #include <cppconsui/Window.h>
12 : public CppConsUI::Window
16 virtual ~TestWindow() {}
21 TestWindow(const TestWindow
&);
22 TestWindow
& operator=(const TestWindow
&);
25 TestWindow::TestWindow()
26 : Window(0, 0, AUTOSIZE
, AUTOSIZE
)
30 CppConsUI::TreeView
*tree
;
31 CppConsUI::TreeView::NodeReference node
;
32 CppConsUI::TreeView::NodeReference node2
;
34 addWidget(*(new CppConsUI::Label(20, 1, "Press F10 to quit.")), 1, 1);
36 tree
= new CppConsUI::TreeView(30, 12);
37 addWidget(*tree
, 1, 3);
40 node
= tree
->appendNode(tree
->getRootNode(),
41 *(new CppConsUI::Button("Button node A")));
42 node2
= tree
->appendNode(node
, *(new CppConsUI::Button("Button node A-1")));
43 tree
->appendNode(node2
, *(new CppConsUI::Button("Button node A-1-a")));
44 tree
->appendNode(node2
, *(new CppConsUI::Button("Button node A-1-b")));
45 tree
->appendNode(node2
, *(new CppConsUI::Button("Button node A-1-c")));
46 tree
->appendNode(node
, *(new CppConsUI::Button("Button node A-2")));
47 tree
->appendNode(node
, *(new CppConsUI::Button("Button node A-3")));
49 node
= tree
->appendNode(tree
->getRootNode(),
50 *(new CppConsUI::Label("Label node B")));
51 tree
->appendNode(node
, *(new CppConsUI::Label("Label node B-1")));
52 tree
->appendNode(node
, *(new CppConsUI::Label("Label node B-2")));
53 tree
->appendNode(node
, *(new CppConsUI::Label("Label node B-3")));
55 node
= tree
->appendNode(tree
->getRootNode(),
56 *(new CppConsUI::Button("Button node C")));
57 tree
->appendNode(node
, *(new CppConsUI::Button("Button node C-1")));
58 tree
->appendNode(node
, *(new CppConsUI::Button("Button node C-2")));
59 tree
->appendNode(node
, *(new CppConsUI::Button("Button node C-3")));
64 : public CppConsUI::InputProcessor
72 // ignore every message
73 static void g_log_func_(const gchar
* /*log_domain*/,
74 GLogLevelFlags
/*log_level*/, const gchar
* /*message*/,
75 gpointer
/*user_data*/)
81 TestApp(const TestApp
&);
82 TestApp
& operator=(const TestApp
&);
87 KEYCONFIG
->loadDefaultKeyConfig();
88 KEYCONFIG
->bindKey("testapp", "quit", "F10");
90 g_log_set_default_handler(g_log_func_
, this);
92 declareBindable("testapp", "quit", sigc::mem_fun(COREMANAGER
,
93 &CppConsUI::CoreManager::quitMainLoop
),
94 InputProcessor::BINDABLE_OVERRIDE
);
99 TestWindow
*win
= new TestWindow
;
102 COREMANAGER
->setTopInputProcessor(*this);
103 COREMANAGER
->enableResizing();
104 COREMANAGER
->startMainLoop();
110 setlocale(LC_ALL
, "");
112 // initialize CppConsUI
113 int consui_res
= CppConsUI::initializeConsUI();
115 fprintf(stderr
, "CppConsUI initialization failed.\n");
119 TestApp
*app
= new TestApp
;
123 // finalize CppConsUI
124 consui_res
= CppConsUI::finalizeConsUI();
126 fprintf(stderr
, "CppConsUI deinitialization failed.\n");
133 /* vim: set tabstop=2 shiftwidth=2 textwidth=78 expandtab : */