TGUI  v0.6.10
Tab.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_TAB_HPP
27 #define TGUI_TAB_HPP
28 
29 
30 #include <TGUI/Widget.hpp>
31 
33 
34 namespace tgui
35 {
37 
38  class TGUI_API Tab : public Widget
39  {
40  public:
41 
42  typedef SharedWidgetPtr<Tab> Ptr;
43 
44 
49  Tab();
50 
51 
58  Tab(const Tab& copy);
59 
60 
65  virtual ~Tab();
66 
67 
76  Tab& operator= (const Tab& 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 Tab* clone();
84 
85 
95  bool load(const std::string& configFileFilename, const std::string& sectionName = "Tab");
96 
97 
105  const std::string& getLoadedConfigFile() const;
106 
107 
121  virtual void setSize(float width, float height);
122 
123 
130  virtual sf::Vector2f getSize() const;
131 
132 
144  unsigned int add(const sf::String& name, bool select = true);
145 
146 
158  void select(const sf::String& name);
159 
160 
171  void select(unsigned int index);
172 
173 
178  void deselect();
179 
180 
191  void remove(const sf::String& name);
192 
193 
204  void remove(unsigned int index);
205 
206 
211  void removeAll();
212 
213 
221  sf::String getSelected() const;
222 
223 
233  int getSelectedIndex() const;
234 
235 
245  void setTextFont(const sf::Font& font);
246 
247 
254  const sf::Font* getTextFont() const;
255 
256 
263  void setTextColor(const sf::Color& color);
264 
265 
272  const sf::Color& getTextColor() const;
273 
274 
281  void setSelectedTextColor(const sf::Color& color);
282 
283 
290  const sf::Color& getSelectedTextColor() const;
291 
292 
300  void setTextSize(unsigned int size);
301 
302 
309  unsigned int getTextSize() const;
310 
311 
320  void setTabHeight(unsigned int height);
321 
322 
329  unsigned int getTabHeight() const;
330 
331 
341  void setMaximumTabWidth(unsigned int maximumWidth);
342 
343 
353  unsigned int getMaximumTabWidth() const;
354 
355 
362  void setDistanceToSide(unsigned int distanceToSide);
363 
364 
371  unsigned int getDistanceToSide() const;
372 
373 
384  virtual void setTransparency(unsigned char transparency);
385 
386 
390  virtual bool mouseOnWidget(float x, float y);
391 
395  virtual void leftMousePressed(float x, float y);
396 
397 
400  // This function is a (slow) way to set properties on the widget, no matter what type it is.
401  // When the requested property doesn't exist in the widget then the functions will return false.
403  virtual bool setProperty(std::string property, const std::string& value);
404 
407  // This function is a (slow) way to get properties of the widget, no matter what type it is.
408  // When the requested property doesn't exist in the widget then the functions will return false.
410  virtual bool getProperty(std::string property, std::string& value) const;
411 
412 
415  // Returns a list of all properties that can be used in setProperty and getProperty.
416  // The second value in the pair is the type of the property (e.g. int, uint, string, ...).
418  virtual std::list< std::pair<std::string, std::string> > getPropertyList() const;
419 
420 
422  protected:
423 
425  // This function is called when the widget is added to a container.
427  virtual void initialize(Container *const container);
428 
429 
431  // Draws the widget on the render target.
433  virtual void draw(sf::RenderTarget& target, sf::RenderStates states) const;
434 
435 
437  public:
438 
443  {
444  TabChanged = WidgetCallbacksCount * 1,
445  AllTabCallbacks = WidgetCallbacksCount * 2 - 1,
446  TabCallbacksCount = WidgetCallbacksCount * 2
447  };
448 
449 
451  protected:
452 
453  std::string m_LoadedConfigFile;
454 
455  bool m_SplitImage;
456  bool m_SeparateSelectedImage;
457 
458  unsigned int m_TabHeight;
459  unsigned int m_TextSize;
460 
461  sf::Color m_TextColor;
462  sf::Color m_SelectedTextColor;
463 
464  unsigned int m_MaximumTabWidth;
465 
466  // The distance between the side of the tab and the text that is drawn on top of the tab.
467  unsigned int m_DistanceToSide;
468 
469  int m_SelectedTab;
470 
471  std::vector<sf::String> m_TabNames;
472  std::vector<float> m_NameWidth;
473 
474  Texture m_TextureNormal_L;
475  Texture m_TextureNormal_M;
476  Texture m_TextureNormal_R;
477  Texture m_TextureSelected_L;
478  Texture m_TextureSelected_M;
479  Texture m_TextureSelected_R;
480 
481  sf::Text m_Text;
482 
483 
485  };
486 
488 }
489 
490 
492 
493 #endif // TGUI_TAB_HPP
Namespace that contains all TGUI functions and classes.
Definition: AnimatedPicture.hpp:33
The parent class for every widget.
Definition: Widget.hpp:45
Definition: TextureManager.hpp:52
Parent class for widgets that store multiple widgets.
Definition: Container.hpp:43
Definition: Tab.hpp:38
TabCallbacks
Defines specific triggers to Tab.
Definition: Tab.hpp:442
Definition: SharedWidgetPtr.hpp:44