TGUI  0.8-dev
CheckBox.hpp
1 //
3 // TGUI - Texus' 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_CHECK_BOX_HPP
27 #define TGUI_CHECK_BOX_HPP
28 
29 
30 #include <TGUI/Widgets/RadioButton.hpp>
31 
33 
34 namespace tgui
35 {
43  class TGUI_API CheckBox : public RadioButton
44  {
45  public:
46 
47  typedef std::shared_ptr<CheckBox> Ptr;
48  typedef std::shared_ptr<const CheckBox> ConstPtr;
49 
50 
52  // Default constructor
54  CheckBox();
55 
56 
65  static CheckBox::Ptr create(sf::String text = "");
66 
67 
76  static CheckBox::Ptr copy(CheckBox::ConstPtr checkbox);
77 
78 
86  {
87  return aurora::downcast<RadioButtonRenderer*>(m_renderer.get());
88  }
89 
90 
100  virtual sf::Vector2f getFullSize() const override;
101 
102 
112  virtual sf::Vector2f getWidgetOffset() const override;
113 
114 
121  void check() override;
122 
123 
127  virtual void leftMouseReleased(sf::Vector2f pos) override;
128 
132  virtual void keyPressed(const sf::Event::KeyEvent& event) override;
133 
134 
142  virtual void draw(sf::RenderTarget& target, sf::RenderStates states) const override;
143 
144 
146  protected:
147 
154  virtual void rendererChanged(const std::string& property) override;
155 
156 
158  // Resets the sizes of the textures if they are used
160  virtual void updateTextureSizes() override;
161 
162 
164  // Makes a copy of the widget
166  virtual Widget::Ptr clone() const override
167  {
168  return std::make_shared<CheckBox>(*this);
169  }
170 
171 
173  private:
174 
175  Texture m_textureUncheckedCached;
176  Texture m_textureCheckedCached;
177 
178 
180  };
181 
183 }
184 
186 
187 #endif // TGUI_CHECK_BOX_HPP
Namespace that contains all TGUI functions and classes.
Definition: Animation.hpp:33
virtual Widget::Ptr clone() const override
Makes a copy of the widget if you don&#39;t know its exact type.
Definition: CheckBox.hpp:166
Radio button widget.
Definition: RadioButton.hpp:53
CheckBox widget.
Definition: CheckBox.hpp:43
Definition: RadioButtonRenderer.hpp:36
std::shared_ptr< Widget > Ptr
Shared widget pointer.
Definition: Widget.hpp:76
Definition: Texture.hpp:39
std::shared_ptr< const CheckBox > ConstPtr
Shared constant widget pointer.
Definition: CheckBox.hpp:48
std::shared_ptr< CheckBox > Ptr
Shared widget pointer.
Definition: CheckBox.hpp:47
RadioButtonRenderer * getRenderer() const
Returns the renderer, which gives access to functions that determine how the widget is displayed...
Definition: CheckBox.hpp:85