TGUI  0.9.5
Loading...
Searching...
No Matches
CheckBox.hpp
1
2//
3// TGUI - Texus' Graphical User Interface
4// Copyright (C) 2012-2022 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_CHECK_BOX_HPP
27#define TGUI_CHECK_BOX_HPP
28
29
30#include <TGUI/Renderers/CheckBoxRenderer.hpp>
31#include <TGUI/Widgets/RadioButton.hpp>
32
34
35namespace tgui
36{
40 class TGUI_API CheckBox : public RadioButton
41 {
42 public:
43
44 typedef std::shared_ptr<CheckBox> Ptr;
45 typedef std::shared_ptr<const CheckBox> ConstPtr;
46
47
55 CheckBox(const char* typeName = "CheckBox", bool initRenderer = true);
56
57
66 static CheckBox::Ptr create(String text = "");
67
68
78
79
85 const CheckBoxRenderer* getSharedRenderer() const;
86
93 const CheckBoxRenderer* getRenderer() const;
94
95
105 Vector2f getFullSize() const override;
106
107
117 Vector2f getWidgetOffset() const override;
118
119
126 void setChecked(bool checked) override;
127
128
132 void leftMouseReleased(Vector2f pos) override;
133
137 void keyPressed(const Event::KeyEvent& event) override;
138
139
147 void draw(BackendRenderTargetBase& target, RenderStates states) const override;
148
149
151 protected:
152
159 void rendererChanged(const String& property) override;
160
161
163 // Resets the sizes of the textures if they are used
165 void updateTextureSizes() override;
166
167
169 // Makes a copy of the widget
171 Widget::Ptr clone() const override
172 {
173 return std::make_shared<CheckBox>(*this);
174 }
175
176
178 private:
179
180 Texture m_textureUncheckedCached;
181 Texture m_textureCheckedCached;
182
183
185 };
186
188}
189
191
192#endif // TGUI_CHECK_BOX_HPP
Base class for render targets.
Definition BackendRenderTarget.hpp:48
Definition CheckBoxRenderer.hpp:37
CheckBox widget.
Definition CheckBox.hpp:41
Vector2f getWidgetOffset() const override
Returns the distance between the position where the widget is drawn and where the widget is placed.
std::shared_ptr< CheckBox > Ptr
Shared widget pointer.
Definition CheckBox.hpp:44
void setChecked(bool checked) override
Checks or unchecks the check box.
std::shared_ptr< const CheckBox > ConstPtr
Shared constant widget pointer.
Definition CheckBox.hpp:45
void draw(BackendRenderTargetBase &target, RenderStates states) const override
Draw the widget to a render target.
static CheckBox::Ptr copy(CheckBox::ConstPtr checkbox)
Makes a copy of another checkbox.
void rendererChanged(const String &property) override
Function called when one of the properties of the renderer is changed.
CheckBoxRenderer * getRenderer()
Returns the renderer, which gives access to functions that determine how the widget is displayed.
static CheckBox::Ptr create(String text="")
Creates a new check box widget.
Vector2f getFullSize() const override
Returns the full size of the radio button.
CheckBoxRenderer * getSharedRenderer()
Returns the renderer, which gives access to functions that determine how the widget is displayed.
Widget::Ptr clone() const override
Makes a copy of the widget if you don't know its exact type.
Definition CheckBox.hpp:171
Radio button widget.
Definition RadioButton.hpp:42
Wrapper class to store strings.
Definition String.hpp:79
Definition Texture.hpp:49
std::shared_ptr< Widget > Ptr
Shared widget pointer.
Definition Widget.hpp:73
Namespace that contains all TGUI functions and classes.
Definition AbsoluteOrRelativeValue.hpp:36
KeyPressed event parameters.
Definition Event.hpp:167
States used for drawing.
Definition RenderStates.hpp:39