TGUI  v0.5.2
 All Classes Namespaces Functions Variables Enumerations Enumerator Pages
Tab.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_TAB_INCLUDED_
27 #define _TGUI_TAB_INCLUDED_
28 
29 
32 
34 
35 namespace tgui
36 {
38 
39  struct TGUI_API Tab : public OBJECT
40  {
45  Tab();
46 
47 
54  Tab(const Tab& copy);
55 
56 
61  virtual ~Tab();
62 
63 
72  Tab& operator= (const Tab& right);
73 
74 
76  // This function is called when the object is created (when it is added to a group).
78  virtual void initialize();
79 
80 
82  // Makes a copy of the tab by calling the copy constructor.
83  // This function calls new and if you use this function then you are responsible for calling delete.
85  virtual Tab* clone();
86 
87 
101  virtual bool load(const std::string& pathname);
102 
103 
117  virtual void setSize(float width, float height);
118 
119 
126  virtual Vector2u getSize() const;
127 
128 
135  virtual Vector2f getScaledSize() const;
136 
137 
145  virtual std::string getLoadedPathname() const;
146 
147 
159  virtual unsigned int add(const sf::String& name, bool select = true);
160 
161 
173  virtual void select(const sf::String& name);
174 
175 
186  virtual void select(unsigned int index);
187 
188 
193  virtual void deselect();
194 
195 
206  virtual void remove(const sf::String& name);
207 
208 
219  virtual void remove(unsigned int index);
220 
221 
226  virtual void removeAll();
227 
228 
236  virtual sf::String getSelected() const;
237 
238 
248  virtual int getSelectedIndex() const;
249 
250 
260  virtual void setTextFont(const sf::Font& font);
261 
262 
269  virtual const sf::Font* getTextFont() const;
270 
271 
278  virtual void setTextColor(const sf::Color& color);
279 
280 
287  virtual const sf::Color& getTextColor() const;
288 
289 
297  virtual void setTextSize(unsigned int size);
298 
299 
306  virtual unsigned int getTextSize() const;
307 
308 
317  virtual void setTabHeight(unsigned int height);
318 
319 
326  virtual unsigned int getTabHeight() const;
327 
328 
330  // These functions are used to receive callback from EventManager.
331  // You normally don't need them, but you can use these functions to simulate an event.
333  virtual bool mouseOnObject(float x, float y);
334  virtual void leftMousePressed(float x, float y);
335 
336 
338  protected:
339 
340 
342  // Because this struct is derived from sf::Drawable, you can just call the draw function from your sf::RenderTarget.
343  // This function will be called and it will draw the tab object on the render target.
345  virtual void draw(sf::RenderTarget& target, sf::RenderStates states) const;
346 
347 
349  public:
350 
352  unsigned int distanceToSide;
353 
356  unsigned int maximumTabWidth;
357 
358 
360  protected:
361 
362  std::string m_LoadedPathname;
363  bool m_SplitImage;
364  bool m_SeparateSelectedImage;
365 
366  unsigned int m_TabHeight;
367  unsigned int m_TextSize;
368 
369  int m_SelectedTab;
370 
371  std::vector<sf::String> m_TabNames;
372  std::vector<float> m_NameWidth;
373 
374  sf::Texture* m_TextureNormal_L;
375  sf::Texture* m_TextureNormal_M;
376  sf::Texture* m_TextureNormal_R;
377  sf::Texture* m_TextureSelected_L;
378  sf::Texture* m_TextureSelected_M;
379  sf::Texture* m_TextureSelected_R;
380 
381  sf::Sprite m_SpriteNormal_L;
382  sf::Sprite m_SpriteNormal_M;
383  sf::Sprite m_SpriteNormal_R;
384  sf::Sprite m_SpriteSelected_L;
385  sf::Sprite m_SpriteSelected_M;
386  sf::Sprite m_SpriteSelected_R;
387 
388  sf::Text m_Text;
389 
390 
392  };
393 
395 }
396 
397 
399 
400 #endif //_TGUI_TAB_INCLUDED_
The parent struct for every object.
Definition: Objects.hpp:36
Definition: Tab.hpp:39
unsigned int maximumTabWidth
Definition: Tab.hpp:356
unsigned int distanceToSide
The distance between the side of the tab and the text that is drawn on top of the tab...
Definition: Tab.hpp:352