Fix build on systems that have a separate iconv library
[centerim5.git] / tests / submenu.cpp
blob3a013fb374c12df32fb4f8a46d62977b55e3fe8f
1 #include <cppconsui/Button.h>
2 #include <cppconsui/Label.h>
3 #include <cppconsui/MenuWindow.h>
4 #include <cppconsui/Window.h>
6 #include <string>
8 // TestWindow class
9 class TestWindow : public CppConsUI::Window {
10 public:
11 TestWindow();
12 virtual ~TestWindow() override;
14 private:
15 CppConsUI::MenuWindow *menu;
17 CONSUI_DISABLE_COPY(TestWindow);
20 TestWindow::TestWindow() : CppConsUI::Window(0, 0, AUTOSIZE, AUTOSIZE)
22 setClosable(false);
24 addWidget(*(new CppConsUI::Label("Press F10 to quit.")), 1, 1);
26 CppConsUI::Button *button = new CppConsUI::Button("Open Menu...");
27 addWidget(*button, 1, 3);
29 menu = new CppConsUI::MenuWindow(*button, AUTOSIZE, AUTOSIZE);
30 menu->setHideOnClose(true);
32 button->signal_activate.connect(
33 sigc::hide(sigc::mem_fun(menu, &CppConsUI::MenuWindow::show)));
35 menu->appendItem(
36 "Item 1", sigc::hide(sigc::mem_fun(menu, &CppConsUI::MenuWindow::hide)));
37 menu->appendItem(
38 "Item 2", sigc::hide(sigc::mem_fun(menu, &CppConsUI::MenuWindow::hide)));
39 menu->appendItem(
40 "Item 3", sigc::hide(sigc::mem_fun(menu, &CppConsUI::MenuWindow::hide)));
41 menu->appendItem(
42 "Item 4", sigc::hide(sigc::mem_fun(menu, &CppConsUI::MenuWindow::hide)));
43 menu->appendSeparator();
45 auto submenu = new CppConsUI::MenuWindow(*button, AUTOSIZE, AUTOSIZE);
46 submenu->appendItem(
47 "Item 1", sigc::hide(sigc::mem_fun(submenu, &CppConsUI::MenuWindow::hide)));
48 submenu->appendItem(
49 "Item 2", sigc::hide(sigc::mem_fun(submenu, &CppConsUI::MenuWindow::hide)));
50 submenu->appendItem(
51 "Item 3", sigc::hide(sigc::mem_fun(submenu, &CppConsUI::MenuWindow::hide)));
52 submenu->appendItem(
53 "Item 3", sigc::hide(sigc::mem_fun(submenu, &CppConsUI::MenuWindow::hide)));
54 menu->appendSubMenu("First submenu", *submenu);
56 submenu = new CppConsUI::MenuWindow(*button, AUTOSIZE, AUTOSIZE);
57 submenu->appendItem(
58 "Item 1", sigc::hide(sigc::mem_fun(menu, &CppConsUI::MenuWindow::hide)));
59 submenu->appendItem(
60 "Item 2", sigc::hide(sigc::mem_fun(menu, &CppConsUI::MenuWindow::hide)));
61 submenu->appendItem(
62 "Item 3", sigc::hide(sigc::mem_fun(menu, &CppConsUI::MenuWindow::hide)));
63 submenu->appendItem(
64 "Item 4", sigc::hide(sigc::mem_fun(menu, &CppConsUI::MenuWindow::hide)));
65 menu->appendSubMenu("Second submenu", *submenu);
68 TestWindow::~TestWindow()
70 delete menu;
73 void setupTest()
75 // Create the main window.
76 auto win = new TestWindow;
77 win->show();
80 // vim: set tabstop=2 shiftwidth=2 textwidth=80 expandtab