TGUI  v0.5.2
 All Classes Namespaces Functions Variables Enumerations Enumerator Pages
Picture.hpp
1 //
3 // TGUI - Texus's Graphical User Interface
4 // Copyright (C) 2012 Bruno Van de Velde (VDV_B@hotmail.com)
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_INCLUDED_
27 #define _TGUI_PICTURE_INCLUDED_
28 
30 
31 namespace tgui
32 {
34 
35  struct TGUI_API Picture : public OBJECT
36  {
40  Picture();
41 
42 
46  Picture(const Picture& copy);
47 
48 
52  virtual ~Picture();
53 
54 
58  Picture& operator= (const Picture& right);
59 
60 
64  virtual Picture* clone();
65 
66 
77  virtual bool load(const std::string& filename);
78 
79 
87  virtual void setSize(float width, float height);
88 
89 
93  virtual Vector2u getSize() const;
94 
95 
99  virtual Vector2f getScaledSize() const;
100 
101 
107  virtual std::string getLoadedFilename() const;
108 
109 
111  // These functions are used to receive callback from the EventManager.
112  // You normally don't need them, but you can use them to simulate an event.
114  virtual bool mouseOnObject(float x, float y);
115  virtual void leftMousePressed(float x, float y);
116  virtual void leftMouseReleased(float x, float y);
117 
118 
120  protected:
121 
123  // Because this struct is derived from sf::Drawable, you can just call the draw function from your sf::RenderTarget.
124  // This function will be called and it will draw the picture on the render target.
126  virtual void draw(sf::RenderTarget& target, sf::RenderStates states) const;
127 
128 
130  protected:
131 
132  sf::Texture* m_Texture;
133  sf::Sprite m_Sprite;
134 
135  // The size of the picture
136  Vector2f m_Size;
137 
138  // The filename used to load the picture
139  std::string m_LoadedFilename;
140  };
141 
143 }
144 
146 
147 #endif //_TGUI_PICTURE_INCLUDED_
Definition: Picture.hpp:35
The parent struct for every object.
Definition: Objects.hpp:36