1 #include <cppconsui/CoreManager.h>
2 #include <cppconsui/KeyConfig.h>
3 #include <cppconsui/Label.h>
4 #include <cppconsui/Window.h>
10 : public CppConsUI::Window
13 TestWindow(int number
, int x
, int y
, int w
, int h
);
14 virtual ~TestWindow() {}
19 TestWindow(const TestWindow
&);
20 TestWindow
& operator=(const TestWindow
&);
23 TestWindow::TestWindow(int number
, int x
, int y
, int w
, int h
)
24 : CppConsUI::Window(x
, y
, w
, h
)
26 CppConsUI::Label
*label
;
28 gchar
*t
= g_strdup_printf("Win %d", number
);
29 label
= new CppConsUI::Label(w
- 4, 1, t
);
31 addWidget(*label
, 2, 1);
34 label
= new CppConsUI::Label("Press F10 to quit.");
35 addWidget(*label
, 2, 2);
37 label
= new CppConsUI::Label("Press ESC to close a focused window.");
38 addWidget(*label
, 2, 3);
44 : public CppConsUI::InputProcessor
52 // ignore every message
53 static void g_log_func_(const gchar
* /*log_domain*/,
54 GLogLevelFlags
/*log_level*/, const gchar
* /*message*/,
55 gpointer
/*user_data*/)
61 TestApp(const TestApp
&);
62 TestApp
& operator=(const TestApp
&);
67 KEYCONFIG
->loadDefaultKeyConfig();
68 KEYCONFIG
->bindKey("testapp", "quit", "F10");
70 g_log_set_default_handler(g_log_func_
, this);
72 declareBindable("testapp", "quit", sigc::mem_fun(COREMANAGER
,
73 &CppConsUI::CoreManager::quitMainLoop
),
74 InputProcessor::BINDABLE_OVERRIDE
);
79 for (int i
= 1; i
<= 4; i
++) {
80 TestWindow
*win
= new TestWindow(i
, (i
- 1) % 2 * 40, (i
- 1) / 2 * 10,
85 COREMANAGER
->setTopInputProcessor(*this);
86 COREMANAGER
->enableResizing();
87 COREMANAGER
->startMainLoop();
93 setlocale(LC_ALL
, "");
95 // initialize CppConsUI
96 int consui_res
= CppConsUI::initializeConsUI();
98 fprintf(stderr
, "CppConsUI initialization failed.\n");
102 TestApp
*app
= new TestApp
;
106 // finalize CppConsUI
107 consui_res
= CppConsUI::finalizeConsUI();
109 fprintf(stderr
, "CppConsUI deinitialization failed.\n");
116 /* vim: set tabstop=2 shiftwidth=2 textwidth=78 expandtab : */