1 // Copyright (C) 2007 Mark Pustjens <pustjens@dds.nl>
2 // Copyright (C) 2010-2015 Petr Pavlu <setup@dagobah.cz>
4 // This file is part of CenterIM.
6 // CenterIM is free software; you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation; either version 2 of the License, or
9 // (at your option) any later version.
11 // CenterIM is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with CenterIM. If not, see <http://www.gnu.org/licenses/>.
22 /// @ingroup cppconsui
31 /// This class implements a simple button behaviour.
33 /// The button does not keep states like pressed or not and it can call back one
34 /// (or more) functions when pressed.
35 class Button
: public Widget
{
43 Button(int w
, int h
, const char *text
= nullptr, int flags
= 0,
46 const char *text
= nullptr, int flags
= 0, bool masked
= false);
47 Button(int w
, int h
, int flags
= 0, const char *text
= nullptr,
48 const char *value
= nullptr, const char *unit
= nullptr,
49 const char *right
= nullptr, bool masked
= false);
50 Button(int flags
, const char *text
= nullptr, const char *value
= nullptr,
51 const char *unit
= nullptr, const char *right
= nullptr,
53 virtual ~Button() override
;
56 virtual int draw(Curses::ViewPort area
, Error
&error
) override
;
58 virtual void setFlags(int new_flags
);
59 virtual int getFlags() const { return flags_
; }
61 /// Sets a new text and redraws itself.
62 virtual void setText(const char *new_text
);
64 /// Returns previously set text.
65 virtual const char *getText() const { return text_
; }
67 virtual void setValue(const char *new_value
);
68 virtual void setValue(int new_value
);
69 virtual const char *getValue() const { return value_
; }
71 virtual void setUnit(const char *new_unit
);
72 virtual const char *getUnit() const { return unit_
; }
74 virtual void setRight(const char *new_right
);
75 virtual const char *getRight() const { return right_
; }
77 virtual void setMasked(bool new_masked
);
78 virtual bool isMasked() const { return masked_
; }
80 /// Signal emitted when the button is pressed/activated.
81 sigc::signal
<void, Button
&> signal_activate
;
102 CONSUI_DISABLE_COPY(Button
);
104 void actionActivate();
106 void declareBindables();
109 } // namespace CppConsUI
113 // vim: set tabstop=2 shiftwidth=2 textwidth=80 expandtab: