TGUI  v0.6.10
Canvas.hpp
1 //
3 // TGUI - Texus's Graphical User Interface
4 // Copyright (C) 2012-2015 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_CANVAS_HPP
27 #define TGUI_CANVAS_HPP
28 
29 
30 #include <TGUI/ClickableWidget.hpp>
31 
33 
34 namespace tgui
35 {
37 
38  class TGUI_API Canvas : public ClickableWidget
39  {
40  public:
41 
43 
44 
49  Canvas();
50 
51 
58  Canvas(const Canvas& copy);
59 
60 
65  virtual ~Canvas();
66 
67 
76  Canvas& operator= (const Canvas& right);
77 
78 
80  // Makes a copy of the widget by calling the copy constructor.
81  // This function calls new and if you use this function then you are responsible for calling delete.
83  virtual Canvas* clone();
84 
85 
99  virtual void setPosition(float x, float y);
101 
102 
110  virtual void setSize(float width, float height);
111 
112 
119  virtual sf::Vector2f getSize() const;
120 
121 
130  void clear(const sf::Color& color = sf::Color(0, 0, 0, 255));
131 
132 
140  void draw(const sf::Drawable& drawable, const sf::RenderStates& states = sf::RenderStates::Default);
141 
142 
152  void draw(const sf::Vertex* vertices, unsigned int vertexCount,
153  sf::PrimitiveType type, const sf::RenderStates& states = sf::RenderStates::Default);
154 
155 
164  void display();
165 
166 
168  protected:
169 
171  // Draws the widget on the render target.
173  virtual void draw(sf::RenderTarget& target, sf::RenderStates states) const;
174 
175 
177  public:
178 
183  {
184  AllCanvasCallbacks = ClickableWidgetCallbacksCount - 1,
185  CanvasCallbacksCount = ClickableWidgetCallbacksCount
186  };
187 
188 
190  protected:
191 
192  sf::RenderTexture m_renderTexture;
193  sf::Sprite m_sprite;
194  };
195 
197 }
198 
200 
201 #endif // TGUI_CANVAS_HPP
Namespace that contains all TGUI functions and classes.
Definition: AnimatedPicture.hpp:33
virtual void setPosition(float x, float y)
Set the position of the widget.
CanvasCallbacks
Defines specific triggers to Canvas.
Definition: Canvas.hpp:182
Definition: ClickableWidget.hpp:38
Definition: Canvas.hpp:38
Definition: SharedWidgetPtr.hpp:44