Update list of wide characters
[centerim5.git] / cppconsui / CheckBox.h
blob736531cdb39998d9da50723231aaec64a7f98d0d
1 // Copyright (C) 2010-2015 Petr Pavlu <setup@dagobah.cz>
2 //
3 // This file is part of CenterIM.
4 //
5 // CenterIM is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; either version 2 of the License, or
8 // (at your option) any later version.
9 //
10 // CenterIM is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with CenterIM. If not, see <http://www.gnu.org/licenses/>.
18 /// @file
19 /// CheckBox class.
20 ///
21 /// @ingroup cppconsui
23 #ifndef CHECKBOX_H
24 #define CHECKBOX_H
26 #include "Widget.h"
28 namespace CppConsUI {
30 /// CheckBox.
31 class CheckBox : public Widget {
32 public:
33 CheckBox(int w, int h, const char *text = nullptr, bool checked = false);
34 explicit CheckBox(const char *text = nullptr, bool checked = false);
35 virtual ~CheckBox() override;
37 // Widget
38 virtual int draw(Curses::ViewPort area, Error &error) override;
40 /// Sets new text label.
41 virtual void setText(const char *new_text);
43 /// Returns current text label.
44 virtual const char *getText() const { return text_; }
46 virtual void setChecked(bool new_checked);
47 virtual bool isChecked() const { return checked_; }
49 /// Signal emitted when the checkbox is pressed/activated.
50 sigc::signal<void, CheckBox &, bool> signal_toggle;
52 protected:
53 char *text_;
54 int text_width_;
55 int text_height_;
57 bool checked_;
59 private:
60 CONSUI_DISABLE_COPY(CheckBox);
62 void actionToggle();
64 void declareBindables();
67 } // namespace CppConsUI
69 #endif // CHECKBOX_H
71 // vim: set tabstop=2 shiftwidth=2 textwidth=80 expandtab: