TGUI  v0.6.10
Picture.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_PICTURE_HPP
27 #define TGUI_PICTURE_HPP
28 
29 
30 #include <TGUI/ClickableWidget.hpp>
31 
33 
34 namespace tgui
35 {
37 
38  class TGUI_API Picture : public ClickableWidget
39  {
40  public:
41 
43 
44 
49  Picture();
50 
51 
58  Picture(const Picture& copy);
59 
60 
65  virtual ~Picture();
66 
67 
76  Picture& operator= (const Picture& 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 Picture* clone();
84 
85 
97  bool load(const std::string& filename);
98 
99 
108  void loadFromTexture(const sf::Texture& texture);
109 
110 
118  const std::string& getLoadedFilename() const;
119 
120 
134  virtual void setPosition(float x, float y);
136 
137 
145  virtual void setSize(float width, float height);
146 
147 
160  void setSmooth(bool smooth);
161 
162 
171  bool isSmooth() const;
172 
173 
184  virtual void setTransparency(unsigned char transparency);
185 
186 
190  virtual bool mouseOnWidget(float x, float y);
191 
192 
195  // This function is a (slow) way to set properties on the widget, no matter what type it is.
196  // When the requested property doesn't exist in the widget then the functions will return false.
198  virtual bool setProperty(std::string property, const std::string& value);
199 
202  // This function is a (slow) way to get properties of the widget, no matter what type it is.
203  // When the requested property doesn't exist in the widget then the functions will return false.
205  virtual bool getProperty(std::string property, std::string& value) const;
206 
207 
210  // Returns a list of all properties that can be used in setProperty and getProperty.
211  // The second value in the pair is the type of the property (e.g. int, uint, string, ...).
213  virtual std::list< std::pair<std::string, std::string> > getPropertyList() const;
214 
215 
217  protected:
218 
220  // Draws the widget on the render target.
222  virtual void draw(sf::RenderTarget& target, sf::RenderStates states) const;
223 
224 
226  public:
227 
232  {
233  AllPictureCallbacks = ClickableWidgetCallbacksCount - 1,
234  PictureCallbacksCount = ClickableWidgetCallbacksCount
235  };
236 
237 
239  protected:
240 
241  std::string m_LoadedFilename;
242 
243  Texture m_Texture;
244  };
245 
247 }
248 
250 
251 #endif // TGUI_PICTURE_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.
Definition: TextureManager.hpp:52
PictureCallbacks
Defines specific triggers to Picture.
Definition: Picture.hpp:231
Definition: ClickableWidget.hpp:38
Definition: SharedWidgetPtr.hpp:44
Definition: Picture.hpp:38