1 #include <cppconsui/CoreManager.h>
2 #include <cppconsui/KeyConfig.h>
3 #include <cppconsui/Label.h>
4 #include <cppconsui/Window.h>
10 : public CppConsUI::Window
14 virtual ~TestWindow() {}
19 TestWindow(const TestWindow
&);
20 TestWindow
& operator=(const TestWindow
&);
23 TestWindow::TestWindow()
24 : CppConsUI::Window(0, 0, AUTOSIZE
, AUTOSIZE
)
28 CppConsUI::Label
*label
;
30 label
= new CppConsUI::Label(
33 "Press F10 to quit."); // text
34 /* Add label to container, container takes widget ownership and deletes it
36 addWidget(*label
, 1, 1);
38 label
= new CppConsUI::Label(20, 1,
39 "Too wide string, too wide string, too wide string");
40 addWidget(*label
, 1, 3);
42 label
= new CppConsUI::Label(20, 3,
43 "Multiline label, multiline label, multiline label");
44 addWidget(*label
, 1, 5);
46 label
= new CppConsUI::Label(
47 "Auto multiline label,\nauto multiline label,\nauto multiline label");
48 addWidget(*label
, 1, 9);
51 label
= new CppConsUI::Label(30, 3,
52 "\x56\xc5\x99\x65\xc5\xa1\x74\xc3\xad\x63\xc3\xad\x20\x70\xc5\x99"
53 "\xc3\xad\xc5\xa1\x65\x72\x79\x20\x73\x65\x20\x64\x6f\xc5\xbe\x61"
54 "\x64\x6f\x76\x61\x6c\x79\x20\xc3\xba\x70\x6c\x6e\xc4\x9b\x20\xc4"
55 "\x8d\x65\x72\x73\x74\x76\xc3\xbd\x63\x68\x20\xc5\x99\xc3\xad\x7a"
56 "\x65\xc4\x8d\x6b\xc5\xaf\x2e\x0a");
57 addWidget(*label
, 1, 13);
59 label
= new CppConsUI::Label("Autosize");
60 addWidget(*label
, 1, 17);
62 const gchar
*long_text
= "Lorem ipsum dolor sit amet, consectetur"
63 "adipiscing elit. Duis dui dui, interdum eget tempor auctor, viverra"
64 "suscipit velit. Phasellus vel magna odio. Duis rutrum tortor at nisi"
65 "auctor tincidunt. Mauris libero neque, faucibus sit amet semper in, "
66 "dictum ut tortor. Duis lacinia justo non lorem blandit ultrices."
67 "Nullam vel purus erat, eget aliquam massa. Aenean eget mi a nunc"
68 "lacinia consectetur sed a neque. Cras varius, dolor nec rhoncus"
69 "ultricies, leo ipsum adipiscing mi, vel feugiat ipsum urna id "
70 "metus. Cras non pulvinar nisi. Vivamus nisi lorem, tempor tristique"
71 "cursus sit amet, ultricies interdum metus. Nullam tortor tortor, "
72 "iaculis sed tempor non, tincidunt ac mi. Quisque id diam vitae diam"
73 "dictum facilisis eget ac lacus. Vivamus at gravida felis. Curabitur"
74 "fermentum mattis eros, ut auctor urna tincidunt vitae. Praesent"
75 "tincidunt laoreet lobortis.";
77 label
= new CppConsUI::Label(AUTOSIZE
, 10, long_text
);
78 addWidget(*label
, 42, 17);
80 label
= new CppConsUI::Label(40, AUTOSIZE
, long_text
);
81 addWidget(*label
, 1, 28);
83 label
= new CppConsUI::Label(AUTOSIZE
, AUTOSIZE
, long_text
);
84 addWidget(*label
, 42, 28);
89 : public CppConsUI::InputProcessor
97 // ignore every message
98 static void g_log_func_(const gchar
* /*log_domain*/,
99 GLogLevelFlags
/*log_level*/, const gchar
* /*message*/,
100 gpointer
/*user_data*/)
106 TestApp(const TestApp
&);
107 TestApp
& operator=(const TestApp
&);
112 KEYCONFIG
->loadDefaultKeyConfig();
113 KEYCONFIG
->bindKey("testapp", "quit", "F10");
115 g_log_set_default_handler(g_log_func_
, this);
117 declareBindable("testapp", "quit", sigc::mem_fun(COREMANAGER
,
118 &CppConsUI::CoreManager::quitMainLoop
),
119 InputProcessor::BINDABLE_OVERRIDE
);
124 TestWindow
*win
= new TestWindow
;
127 COREMANAGER
->setTopInputProcessor(*this);
128 COREMANAGER
->enableResizing();
129 COREMANAGER
->startMainLoop();
135 setlocale(LC_ALL
, "");
137 // initialize CppConsUI
138 int consui_res
= CppConsUI::initializeConsUI();
140 fprintf(stderr
, "CppConsUI initialization failed.\n");
144 TestApp
*app
= new TestApp
;
148 // finalize CppConsUI
149 consui_res
= CppConsUI::finalizeConsUI();
151 fprintf(stderr
, "CppConsUI deinitialization failed.\n");
158 /* vim: set tabstop=2 shiftwidth=2 textwidth=78 expandtab : */