TGUI  v0.6.10
Classes | Public Types | Public Member Functions | List of all members
tgui::Grid Class Reference
Inheritance diagram for tgui::Grid:
tgui::Container tgui::Widget tgui::Transformable tgui::CallbackManager

Classes

struct  Layout
 The layout of the widget. More...
 

Public Types

- Public Types inherited from tgui::Widget

Public Member Functions

 Grid ()
 Default constructor. More...
 
 Grid (const Grid &copy)
 Copy constructor. More...
 
virtual ~Grid ()
 Destructor. More...
 
Gridoperator= (const Grid &right)
 Overload of assignment operator. More...
 
virtual void setSize (float width, float height)
 Changes the size of the grid. More...
 
virtual sf::Vector2f getSize () const
 Returns the size of the grid. More...
 
virtual void remove (const Widget::Ptr &widget)
 Removes a single widget that was added to the container. More...
 
virtual void remove (Widget *widget)
 Removes a single widget that was added to the container. More...
 
virtual void removeAllWidgets ()
 Removes all widgets that were added to the container. More...
 
void addWidget (const Widget::Ptr &widget, unsigned int row, unsigned int column, const Borders &borders=Borders(0, 0, 0, 0), Layout::Layouts layout=Layout::Center)
 Add a widget to the grid. More...
 
Widget::Ptr getWidget (unsigned int row, unsigned int column)
 Returns the widget in a specific square of the grid. More...
 
void updateWidgets ()
 Updates the position and size of the widget. More...
 
void changeWidgetBorders (const Widget::Ptr &widget, const Borders &borders=Borders(0, 0, 0, 0))
 Changes borders of a given widget. More...
 
void changeWidgetLayout (const Widget::Ptr &widget, Layout::Layouts layout=Layout::Center)
 Changes the layout of a given widget. More...
 
- Public Member Functions inherited from tgui::Container
 Container ()
 Default constructor. More...
 
 Container (const Container &copy)
 Copy constructor. More...
 
virtual ~Container ()
 Destructor. More...
 
Containeroperator= (const Container &right)
 Overload of assignment operator. More...
 
bool setGlobalFont (const std::string &filename)
 Changes the global font. More...
 
void setGlobalFont (const sf::Font &font)
 Changes the global font. More...
 
const sf::Font & getGlobalFont () const
 Returns the global font. More...
 
const std::vector< Widget::Ptr > & getWidgets ()
 Returns a list of all the widgets. More...
 
const std::vector< sf::String > & getWidgetNames ()
 Returns a list of the names of all the widgets. More...
 
virtual void add (const Widget::Ptr &widgetPtr, const sf::String &widgetName="")
 Adds a widget to the container. More...
 
Widget::Ptr get (const sf::String &widgetName, bool recursive=false) const
 Returns a pointer to an earlier created widget. More...
 
template<class T >
T::Ptr get (const sf::String &widgetName, bool recursive=false) const
 Returns a pointer to an earlier created widget. More...
 
Widget::Ptr copy (const Widget::Ptr &oldWidget, const sf::String &newWidgetName="")
 Makes a copy of any existing widget and returns the pointer to the new widget. More...
 
bool setWidgetName (const Widget::Ptr &widget, const std::string &name)
 Changes the name of a widget. More...
 
bool getWidgetName (const Widget::Ptr &widget, std::string &name) const
 Returns the name of a widget. More...
 
void focusWidget (const Widget::Ptr &widget)
 Focuses a widget. More...
 
void focusWidget (Widget *const widget)
 Focuses a widget. More...
 
void focusNextWidget ()
 Focuses the next widget. More...
 
void focusPreviousWidget ()
 Focuses the previous widget. More...
 
void unfocusWidgets ()
 Unfocus all the widgets. More...
 
void uncheckRadioButtons ()
 Uncheck all the radio buttons. More...
 
void moveWidgetToFront (Widget *const widget)
 Places a widget before all other widgets. More...
 
void moveWidgetToBack (Widget *const widget)
 Places a widget behind all other widgets. More...
 
virtual void setTransparency (unsigned char transparency)
 Changes the transparency of the widget. More...
 
void bindGlobalCallback (std::function< void(const Callback &)> func)
 Bind a function to the callbacks of all child widgets. More...
 
template<typename T >
void bindGlobalCallback (void(T::*func)(const Callback &), T *const classPtr)
 Bind a function to the callbacks of all child widgets. More...
 
virtual void unbindGlobalCallback ()
 Unbind the global callback function(s). More...
 
bool loadWidgetsFromFile (const std::string &filename)
 Loads a form from a file. More...
 
bool saveWidgetsToFile (const std::string &filename)
 Save the widgets to a file. More...
 
virtual sf::Vector2f getWidgetsOffset () const
 Returns the distance between the position of the container and a widget that would be drawn inside this container on relative position (0,0). More...
 
- Public Member Functions inherited from tgui::Widget
 Widget ()
 Default constructor. More...
 
 Widget (const Widget &copy)
 Copy constructor. More...
 
virtual ~Widget ()
 Destructor. More...
 
Widgetoperator= (const Widget &right)
 Overload of assignment operator. More...
 
virtual sf::Vector2f getAbsolutePosition () const
 Get the absolute position of the widget on the screen. More...
 
virtual void show ()
 Shows the widget. More...
 
virtual void hide ()
 Hides the widget. More...
 
bool isVisible () const
 Returns true when the widget is visible. More...
 
virtual void enable ()
 Enables the widget. More...
 
virtual void disable ()
 Disables the widget. More...
 
bool isEnabled () const
 Returns true when the widget is enabled. More...
 
bool isDisabled () const
 Returns true when the widget is disabled. More...
 
bool isLoaded () const
 Returns true when the widget is loaded successfully. More...
 
virtual void focus ()
 Focus the widget. More...
 
virtual void unfocus ()
 Unfocus the widget. More...
 
bool isFocused () const
 Returns true when the widget is focused and false otherwise. More...
 
WidgetTypes getWidgetType () const
 Returns the type of the widget. More...
 
ContainergetParent () const
 Returns a pointer to the parent widget. More...
 
unsigned char getTransparency () const
 Returns the transparency of the widget. More...
 
virtual void moveToFront ()
 Places the widget before all other widgets. More...
 
virtual void moveToBack ()
 Places the widget behind all other widgets. More...
 
void setCallbackId (unsigned int callbackId)
 Changes the callback id of the widget. More...
 
unsigned int getCallbackId ()
 Returns the callback id of the widget. More...
 
- Public Member Functions inherited from tgui::Transformable
 Transformable ()
 Default constructor. More...
 
virtual ~Transformable ()
 Destructor. More...
 
virtual void setPosition (float x, float y)
 Set the position of the widget. More...
 
void setPosition (const sf::Vector2f &position)
 set the position of the widget More...
 
const sf::Vector2f & getPosition () const
 get the position of the widget More...
 
void move (float offsetX, float offsetY)
 Move the widget by a given offset. More...
 
void move (const sf::Vector2f &offset)
 Move the widget by a given offset. More...
 
virtual sf::Vector2f getFullSize () const
 Returns the entire size that the widget is using. More...
 
void scale (float factorX, float factorY)
 Scale the widget. More...
 
void scale (const sf::Vector2f &factors)
 Scale the widget. More...
 
- Public Member Functions inherited from tgui::CallbackManager
void bindCallback (std::function< void()> func, unsigned int trigger)
 Bind a function to one or more specific callback trigger(s). More...
 
template<typename T >
void bindCallback (void(T::*func)(), T *const classPtr, unsigned int trigger)
 Bind a function to one or more specific callback trigger(s). More...
 
void bindCallbackEx (std::function< void(const Callback &)> func, unsigned int trigger)
 Bind a function to one or more specific callback trigger(s). More...
 
template<typename T >
void bindCallbackEx (void(T::*func)(const Callback &), T *const classPtr, unsigned int trigger)
 Bind a function to one or more specific callback trigger(s). More...
 
void bindCallback (unsigned int trigger)
 Bind one or more specific callback trigger(s) to the parent widget. More...
 
void unbindCallback (unsigned int trigger)
 Unbind all callback function bound to the given trigger. More...
 
void unbindAllCallback ()
 Unbind all callback functions bound to any callback. More...
 

Member Enumeration Documentation

Defines specific triggers to Grid.

Enumerator
AllGridCallbacks 

All Callbacks defined in Grid and its base classes.

Constructor & Destructor Documentation

tgui::Grid::Grid ( )

Default constructor.

tgui::Grid::Grid ( const Grid copy)

Copy constructor.

Parameters
copyInstance to copy
virtual tgui::Grid::~Grid ( )
virtual

Destructor.

Member Function Documentation

void tgui::Grid::addWidget ( const Widget::Ptr widget,
unsigned int  row,
unsigned int  column,
const Borders borders = Borders(0, 0, 0, 0),
Layout::Layouts  layout = Layout::Center 
)

Add a widget to the grid.

Parameters
widgetPointer to a fully created widget that will be added to the grid
rowThe row in which the widget should be placed
columnThe column in which the widget should be placed
bordersDistance from the grid square to the widget (left, top, right, bottom)
layoutWhere the widget is located in the square
void tgui::Grid::changeWidgetBorders ( const Widget::Ptr widget,
const Borders borders = Borders(0, 0, 0, 0) 
)

Changes borders of a given widget.

Parameters
widgetThe widget to which borders should be added
bordersThe new borders around the widget
void tgui::Grid::changeWidgetLayout ( const Widget::Ptr widget,
Layout::Layouts  layout = Layout::Center 
)

Changes the layout of a given widget.

Parameters
widgetThe widget for which the layout should be changed
layoutThe new layout
virtual sf::Vector2f tgui::Grid::getSize ( ) const
virtual

Returns the size of the grid.

Returns
Size of the grid

Implements tgui::Transformable.

Widget::Ptr tgui::Grid::getWidget ( unsigned int  row,
unsigned int  column 
)

Returns the widget in a specific square of the grid.

Parameters
rowThe row that the widget is in
columnThe column that the widget is in
Returns
The widget inside the given square, or nullptr when the square doesn't contain a widget
Grid& tgui::Grid::operator= ( const Grid right)

Overload of assignment operator.

Parameters
rightInstance to assign
Returns
Reference to itself
virtual void tgui::Grid::remove ( const Widget::Ptr widget)
virtual

Removes a single widget that was added to the container.

Parameters
widgetPointer to the widget to remove
See also
remove(sf::String)

Usage example:

tgui::Picture::Ptr pic(grid, "picName");
tgui::Picture::Ptr pic2(grid, "picName2");
grid.remove(pic);
grid.remove(grid.get("picName2"));

Reimplemented from tgui::Container.

virtual void tgui::Grid::remove ( Widget widget)
virtual

Removes a single widget that was added to the container.

Parameters
widgetPointer to the widget to remove

This function is provided for internal use. The other remove function will probably be easier to use, but in the end they do exactly the same.

See also
remove(Widget::Ptr)

Reimplemented from tgui::Container.

virtual void tgui::Grid::removeAllWidgets ( )
virtual

Removes all widgets that were added to the container.

Reimplemented from tgui::Container.

virtual void tgui::Grid::setSize ( float  width,
float  height 
)
virtual

Changes the size of the grid.

Parameters
widthWidth of the grid
heightHeight of the grid

Widgets in the grid will be repositionned to fill in the best way the available space of the grid. If the size is too small to have all Widgets correctly placed, the size will be ignored and the grid auto-sized until some Widgets are removed of the grid and the size was become valid again.

Implements tgui::Transformable.

void tgui::Grid::updateWidgets ( )

Updates the position and size of the widget.

Once a widget has been added to the grid, you will have to call this function every time you change the size of the widget.


The documentation for this class was generated from the following file: