Update list of wide characters
[centerim5.git] / tests / button.cpp
blob78dd8af4fcfa1063698688d7756612a033c4f8b4
1 #include <cppconsui/Button.h>
2 #include <cppconsui/Label.h>
3 #include <cppconsui/Window.h>
5 // TestWindow class
6 class TestWindow : public CppConsUI::Window {
7 public:
8 TestWindow();
9 virtual ~TestWindow() override {}
11 private:
12 CppConsUI::Label *label;
14 CONSUI_DISABLE_COPY(TestWindow);
16 void onButtonActivate(CppConsUI::Button &activator);
19 TestWindow::TestWindow() : CppConsUI::Window(0, 0, AUTOSIZE, AUTOSIZE)
21 setClosable(false);
23 addWidget(*(new CppConsUI::Label("Press F10 to quit.")), 1, 1);
24 label = new CppConsUI::Label;
25 addWidget(*label, 1, 2);
27 CppConsUI::Button *button;
29 button = new CppConsUI::Button(20, 1, "Normal button");
30 button->signal_activate.connect(
31 sigc::mem_fun(this, &TestWindow::onButtonActivate));
32 addWidget(*button, 1, 8);
34 button = new CppConsUI::Button("Simple autosize");
35 button->signal_activate.connect(
36 sigc::mem_fun(this, &TestWindow::onButtonActivate));
37 addWidget(*button, 1, 10);
39 button = new CppConsUI::Button(
40 CppConsUI::Button::FLAG_VALUE, "Text+value button", "value");
41 button->signal_activate.connect(
42 sigc::mem_fun(this, &TestWindow::onButtonActivate));
43 addWidget(*button, 1, 12);
45 button = new CppConsUI::Button(
46 CppConsUI::Button::FLAG_VALUE | CppConsUI::Button::FLAG_UNIT,
47 "Text+value+unit button", "value", "unit");
48 button->signal_activate.connect(
49 sigc::mem_fun(this, &TestWindow::onButtonActivate));
50 addWidget(*button, 1, 14);
52 button = new CppConsUI::Button(
53 CppConsUI::Button::FLAG_VALUE | CppConsUI::Button::FLAG_UNIT,
54 "Text+value+unit\n2-line button", "value", "unit");
55 button->signal_activate.connect(
56 sigc::mem_fun(this, &TestWindow::onButtonActivate));
57 addWidget(*button, 1, 16);
59 button = new CppConsUI::Button(
60 CppConsUI::Button::FLAG_VALUE | CppConsUI::Button::FLAG_UNIT,
61 "Text+value+unit\n3-line\nbutton", "value", "unit");
62 button->signal_activate.connect(
63 sigc::mem_fun(this, &TestWindow::onButtonActivate));
64 addWidget(*button, 1, 19);
66 button = new CppConsUI::Button(
67 CppConsUI::Button::FLAG_VALUE | CppConsUI::Button::FLAG_UNIT,
68 "Text+value+unit\n4-line\n\nbutton", "value", "unit");
69 button->signal_activate.connect(
70 sigc::mem_fun(this, &TestWindow::onButtonActivate));
71 addWidget(*button, 1, 23);
73 button = new CppConsUI::Button(30, 1, CppConsUI::Button::FLAG_RIGHT,
74 "Text+right button", nullptr, nullptr, "right");
75 button->signal_activate.connect(
76 sigc::mem_fun(this, &TestWindow::onButtonActivate));
77 addWidget(*button, 1, 28);
80 void TestWindow::onButtonActivate(CppConsUI::Button &activator)
82 std::string text = std::string(activator.getText()) + " activated.";
83 label->setText(text.c_str());
86 void setupTest()
88 // Create the main window.
89 auto win = new TestWindow;
90 win->show();
93 // vim: set tabstop=2 shiftwidth=2 textwidth=80 expandtab