TGUI  0.7.8
CheckBox.hpp
1
2//
3// TGUI - Texus's Graphical User Interface
4// Copyright (C) 2012-2017 Bruno Van de Velde (vdv_b@tgui.eu)
5//
6// This software is provided 'as-is', without any express or implied warranty.
7// In no event will the authors be held liable for any damages arising from the use of this software.
8//
9// Permission is granted to anyone to use this software for any purpose,
10// including commercial applications, and to alter it and redistribute it freely,
11// subject to the following restrictions:
12//
13// 1. The origin of this software must not be misrepresented;
14// you must not claim that you wrote the original software.
15// If you use this software in a product, an acknowledgment
16// in the product documentation would be appreciated but is not required.
17//
18// 2. Altered source versions must be plainly marked as such,
19// and must not be misrepresented as being the original software.
20//
21// 3. This notice may not be removed or altered from any source distribution.
22//
24
25
26#ifndef TGUI_CHECKBOX_HPP
27#define TGUI_CHECKBOX_HPP
28
29
30#include <TGUI/Widgets/RadioButton.hpp>
31
33
34namespace tgui
35{
36 class CheckBoxRenderer;
37
45 class TGUI_API CheckBox : public RadioButton
46 {
47 public:
48
49 typedef std::shared_ptr<CheckBox> Ptr;
50 typedef std::shared_ptr<const CheckBox> ConstPtr;
51
52
54 // Default constructor
56 CheckBox();
57
58
67 static CheckBox::Ptr create(sf::String text = "");
68
69
79
80
87 std::shared_ptr<CheckBoxRenderer> getRenderer() const
88 {
89 return std::static_pointer_cast<CheckBoxRenderer>(m_renderer);
90 }
91
92
97 void check() override;
98
99
104 void uncheck() override;
105
106
110 virtual void leftMouseReleased(float x, float y) override;
111
115 virtual void keyPressed(const sf::Event::KeyEvent& event) override;
116
117
119 protected:
120
122 // Makes a copy of the widget
124 virtual Widget::Ptr clone() const override
125 {
126 return std::make_shared<CheckBox>(*this);
127 }
128
129
131 };
132
133
135
136 class TGUI_API CheckBoxRenderer : public RadioButtonRenderer
137 {
138 public:
139
147
148
150 // Draws the widget on the render target.
152 void draw(sf::RenderTarget& target, sf::RenderStates states) const override;
153
154
156 private:
157
159 // Makes a copy of the renderer
161 virtual std::shared_ptr<WidgetRenderer> clone(Widget* widget) override;
162
163
164 friend class CheckBox;
165
167 };
168
170
171}
172
174
175#endif // TGUI_CHECKBOX_HPP
Definition: CheckBox.hpp:137
CheckBoxRenderer(CheckBox *checkbox)
Constructor.
Definition: CheckBox.hpp:146
CheckBox widget.
Definition: CheckBox.hpp:46
void uncheck() override
Unchecks the checkbox.
std::shared_ptr< CheckBox > Ptr
Shared widget pointer.
Definition: CheckBox.hpp:49
std::shared_ptr< const CheckBox > ConstPtr
Shared constant widget pointer.
Definition: CheckBox.hpp:50
static CheckBox::Ptr copy(CheckBox::ConstPtr checkbox)
Makes a copy of another checkbox.
virtual Widget::Ptr clone() const override
Makes a copy of the widget if you don't know its exact type.
Definition: CheckBox.hpp:124
static CheckBox::Ptr create(sf::String text="")
Creates a new check box widget.
std::shared_ptr< CheckBoxRenderer > getRenderer() const
Returns the renderer, which gives access to functions that determine how the widget is displayed.
Definition: CheckBox.hpp:87
void check() override
Checks the checkbox.
Definition: RadioButton.hpp:327
Radio button widget.
Definition: RadioButton.hpp:54
The parent class for every widget.
Definition: Widget.hpp:72
std::shared_ptr< Widget > Ptr
Shared widget pointer.
Definition: Widget.hpp:75
Namespace that contains all TGUI functions and classes.
Definition: Animation.hpp:34