TGUI
v0.6.10
|
Parent class for widgets that store multiple widgets. More...
#include <Container.hpp>
Public Member Functions | |
Container () | |
Default constructor. More... | |
Container (const Container ©) | |
Copy constructor. More... | |
virtual | ~Container () |
Destructor. More... | |
Container & | operator= (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... | |
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... | |
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 constructor. More... | |
virtual | ~Widget () |
Destructor. More... | |
Widget & | operator= (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... | |
Container * | getParent () 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 void | setSize (float width, float height)=0 |
Changes the size of the widget. More... | |
virtual sf::Vector2f | getSize () const =0 |
Returns the size of the widget. 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... | |
Additional Inherited Members | |
Public Types inherited from tgui::Widget |
Parent class for widgets that store multiple widgets.
tgui::Container::Container | ( | ) |
Default constructor.
tgui::Container::Container | ( | const Container & | copy | ) |
Copy constructor.
copy | Instance to copy |
|
virtual |
Destructor.
|
virtual |
Adds a widget to the container.
widgetPtr | Pointer to the widget you would like to add |
widgetName | If you want to access the widget later then you must do this with this name |
Usage example:
void tgui::Container::bindGlobalCallback | ( | std::function< void(const Callback &)> | func | ) |
Bind a function to the callbacks of all child widgets.
When a child widget tells this widget about the callback then the global callback function(s) will be called. If no global callback function has been bound then the callback is passed to the parent of this widget.
func | Pointer to a free function with a reference to a Callback widget as parameter. |
|
inline |
Bind a function to the callbacks of all child widgets.
When a child widget tells this widget about the callback then the global callback function(s) will be called. If no global callback function has been bound then the callback is passed to the parent of this widget.
func | Pointer to a member function with a reference to a Callback widget as parameter. |
classPtr | Pointer to the widget of the class. |
Widget::Ptr tgui::Container::copy | ( | const Widget::Ptr & | oldWidget, |
const sf::String & | newWidgetName = "" |
||
) |
Makes a copy of any existing widget and returns the pointer to the new widget.
oldWidget | A pointer to the old widget. |
newWidgetName | If you want to access the widget later then you must do this with this name |
Usage example:
void tgui::Container::focusNextWidget | ( | ) |
Focuses the next widget.
The currently focused widget will be unfocused, even if it was the only widget. When no widget was focused, the first widget in the container will be focused.
void tgui::Container::focusPreviousWidget | ( | ) |
Focuses the previous widget.
The currently focused widget will be unfocused, even if it was the only widget. When no widget was focused, the last widget in the container will be focused.
void tgui::Container::focusWidget | ( | const Widget::Ptr & | widget | ) |
Focuses a widget.
The previously focused widget will be unfocused.
widget | The widget that has to be focused. |
void tgui::Container::focusWidget | ( | Widget *const | widget | ) |
Focuses a widget.
The previously focused widget will be unfocused.
widget | The widget that has to be focused. |
Widget::Ptr tgui::Container::get | ( | const sf::String & | widgetName, |
bool | recursive = false |
||
) | const |
Returns a pointer to an earlier created widget.
widgetName | The name that was given to the widget when it was added to the container. |
recursive | Should the function also search for widgets inside containers that are inside this container? |
Usage example:
|
inline |
Returns a pointer to an earlier created widget.
widgetName | The name that was given to the widget when it was added to the container. |
recursive | Should the function also search for widgets inside containers that are inside this container? |
Usage example:
const sf::Font& tgui::Container::getGlobalFont | ( | ) | const |
Returns the global font.
This is the font that is used for newly created widget by default.
bool tgui::Container::getWidgetName | ( | const Widget::Ptr & | widget, |
std::string & | name | ||
) | const |
Returns the name of a widget.
widget | Widget of which the name should be retrieved |
name | Name for the widget |
const std::vector<sf::String>& tgui::Container::getWidgetNames | ( | ) |
Returns a list of the names of all the widgets.
const std::vector<Widget::Ptr>& tgui::Container::getWidgets | ( | ) |
Returns a list of all the widgets.
|
virtual |
Returns the distance between the position of the container and a widget that would be drawn inside this container on relative position (0,0).
Reimplemented in tgui::ChildWindow.
bool tgui::Container::loadWidgetsFromFile | ( | const std::string & | filename | ) |
Loads a form from a file.
The widgets will be loaded and added to the container. Note that even when this function fails, some widgets might have been loaded already.
filename | Filename of the widget file that is to be loaded |
void tgui::Container::moveWidgetToBack | ( | Widget *const | widget | ) |
Places a widget behind all other widgets.
widget | The widget that should be moved to the back |
void tgui::Container::moveWidgetToFront | ( | Widget *const | widget | ) |
Places a widget before all other widgets.
widget | The widget that should be moved to the front |
Overload of assignment operator.
right | Instance to assign |
|
virtual |
Removes a single widget that was added to the container.
widget | Pointer to the widget to remove |
Usage example:
Reimplemented in tgui::Grid.
|
virtual |
Removes a single widget that was added to the container.
widget | Pointer to the widget to remove |
Reimplemented in tgui::Grid.
|
virtual |
Removes all widgets that were added to the container.
Reimplemented in tgui::Grid.
bool tgui::Container::saveWidgetsToFile | ( | const std::string & | filename | ) |
Save the widgets to a file.
filename | Filename of the widget file that is to be created |
bool tgui::Container::setGlobalFont | ( | const std::string & | filename | ) |
Changes the global font.
This font will be used by all widgets that are created after calling this function.
filename | Path of the font file to load |
void tgui::Container::setGlobalFont | ( | const sf::Font & | font | ) |
Changes the global font.
This font will be used by all widgets that are created after calling this function.
font | Font to copy |
|
virtual |
Changes the transparency of the widget.
transparency | The transparency of the widget. 0 is completely transparent, while 255 (default) means fully opaque. |
Note that this will only change the transparency of the images. The parts of the widgets that use a color will not be changed. You must change them yourself by setting the alpha channel of the color.
Reimplemented from tgui::Widget.
Reimplemented in tgui::ChildWindow, and tgui::Panel.
bool tgui::Container::setWidgetName | ( | const Widget::Ptr & | widget, |
const std::string & | name | ||
) |
Changes the name of a widget.
widget | Widget of which the name should be changed |
name | New name for the widget |
|
virtual |
Unbind the global callback function(s).
Reimplemented in tgui::GuiContainer.
void tgui::Container::uncheckRadioButtons | ( | ) |
Uncheck all the radio buttons.
void tgui::Container::unfocusWidgets | ( | ) |
Unfocus all the widgets.