Use pkg-config to find ncursesw
[centerim5.git] / tests / label.cpp
blob29898793cc0ba1650e732200f8ec99f53d3bb2a3
1 #include <cppconsui/Label.h>
2 #include <cppconsui/Window.h>
4 // TestWindow class
5 class TestWindow : public CppConsUI::Window {
6 public:
7 TestWindow();
8 virtual ~TestWindow() override {}
10 private:
11 CONSUI_DISABLE_COPY(TestWindow);
14 TestWindow::TestWindow() : CppConsUI::Window(0, 0, AUTOSIZE, AUTOSIZE)
16 setClosable(false);
18 CppConsUI::Label *label;
20 label = new CppConsUI::Label(20, // width
21 1, // height
22 "Press F10 to quit."); // text
23 // Add the label to the container. It will take ownership of the widget and
24 // delete it when no longer needed.
25 addWidget(*label, 1, 1);
27 label = new CppConsUI::Label(
28 20, 1, "Too wide string, too wide string, too wide string");
29 addWidget(*label, 1, 3);
31 label = new CppConsUI::Label(
32 20, 3, "Multiline label, multiline label, multiline label");
33 addWidget(*label, 1, 5);
35 label = new CppConsUI::Label(
36 "Auto multiline label,\nauto multiline label,\nauto multiline label");
37 addWidget(*label, 1, 9);
39 // Unicode test.
40 label = new CppConsUI::Label(30, 3,
41 "\x56\xc5\x99\x65\xc5\xa1\x74\xc3\xad\x63\xc3\xad\x20\x70\xc5\x99"
42 "\xc3\xad\xc5\xa1\x65\x72\x79\x20\x73\x65\x20\x64\x6f\xc5\xbe\x61"
43 "\x64\x6f\x76\x61\x6c\x79\x20\xc3\xba\x70\x6c\x6e\xc4\x9b\x20\xc4"
44 "\x8d\x65\x72\x73\x74\x76\xc3\xbd\x63\x68\x20\xc5\x99\xc3\xad\x7a"
45 "\x65\xc4\x8d\x6b\xc5\xaf\x2e\x0a");
46 addWidget(*label, 1, 13);
48 label = new CppConsUI::Label("Autosize");
49 addWidget(*label, 1, 17);
51 const char *long_text =
52 "Lorem ipsum dolor sit amet, consectetur"
53 "adipiscing elit. Duis dui dui, interdum eget tempor auctor, viverra"
54 "suscipit velit. Phasellus vel magna odio. Duis rutrum tortor at nisi"
55 "auctor tincidunt. Mauris libero neque, faucibus sit amet semper in, "
56 "dictum ut tortor. Duis lacinia justo non lorem blandit ultrices."
57 "Nullam vel purus erat, eget aliquam massa. Aenean eget mi a nunc"
58 "lacinia consectetur sed a neque. Cras varius, dolor nec rhoncus"
59 "ultricies, leo ipsum adipiscing mi, vel feugiat ipsum urna id "
60 "metus. Cras non pulvinar nisi. Vivamus nisi lorem, tempor tristique"
61 "cursus sit amet, ultricies interdum metus. Nullam tortor tortor, "
62 "iaculis sed tempor non, tincidunt ac mi. Quisque id diam vitae diam"
63 "dictum facilisis eget ac lacus. Vivamus at gravida felis. Curabitur"
64 "fermentum mattis eros, ut auctor urna tincidunt vitae. Praesent"
65 "tincidunt laoreet lobortis.";
67 label = new CppConsUI::Label(AUTOSIZE, 10, long_text);
68 addWidget(*label, 42, 17);
70 label = new CppConsUI::Label(40, AUTOSIZE, long_text);
71 addWidget(*label, 1, 28);
73 label = new CppConsUI::Label(AUTOSIZE, AUTOSIZE, long_text);
74 addWidget(*label, 42, 28);
77 void setupTest()
79 // Create the main window.
80 auto win = new TestWindow;
81 win->show();
84 // vim: set tabstop=2 shiftwidth=2 textwidth=80 expandtab