1 /* ToggleButton.hpp
2  * Copyright (C) 2018  Sven Jähnichen
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
16  */
17 
18 #ifndef BWIDGETS_TOGGLEBUTTON_HPP_
19 #define BWIDGETS_TOGGLEBUTTON_HPP_
20 
21 #include "Button.hpp"
22 
23 namespace BWidgets
24 {
25 /**
26  * Class BWidgets::ToggleButton
27  *
28  * Basic toggle button widget. Is is a BWidgets::Button and thus a
29  * BWidgets::ValueWidget having two conditions: on (value != 0) or off
30  * (value == 0)
31  */
32 class ToggleButton : public Button
33 {
34 public:
35 	ToggleButton ();
36 	ToggleButton (const double x, const double y, const double width, const double height, const std::string& name, double defaultValue = 0.0);
37 
38 	/**
39 	 * Pattern cloning. Creates a new instance of the widget and copies all
40 	 * its properties.
41 	 */
42 	virtual Widget* clone () const override;
43 
44 	/**
45 	 * Handles the BEvents::BUTTON_PRESS_EVENT.
46 	 * @param event Pointer to a pointer event emitted by the same widget.
47 	 */
48 	virtual void onButtonPressed (BEvents::PointerEvent* event) override;
49 
50 	/**
51 	 * Overrides the BEvents::BUTTON_RELEASED_EVENT handled by
52 	 * BWidgets::Button.
53 	 * @param event Pointer to a pointer event emitted by the same widget.
54 	 */
55 	virtual void onButtonReleased (BEvents::PointerEvent* event) override;
56 };
57 
58 }
59 
60 
61 
62 
63 #endif /* BWIDGETS_TOGGLEBUTTON_HPP_ */
64