TGUI  v0.6.10
Public Types | Public Member Functions | List of all members
tgui::Widget Class Referenceabstract

The parent class for every widget. More...

#include <Widget.hpp>

Inheritance diagram for tgui::Widget:
tgui::Transformable tgui::CallbackManager tgui::ChatBox tgui::ClickableWidget tgui::ComboBox tgui::Container tgui::Knob tgui::ListBox tgui::MenuBar tgui::Scrollbar tgui::Slider tgui::Tab tgui::TextBox

Public Types

Public Member Functions

 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...
 
virtual void setTransparency (unsigned char transparency)
 Changes the transparency of the 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...
 

Detailed Description

The parent class for every widget.

Member Enumeration Documentation

Defines specific triggers to Widget.

Enumerator
None 

No trigger.

Focused 

Widget gained focus.

Unfocused 

Widget lost focus.

MouseEntered 

Mouse cursor entered in the Widget area.

MouseLeft 

Mouse cursor left the Widget area.

Constructor & Destructor Documentation

tgui::Widget::Widget ( )

Default constructor.

tgui::Widget::Widget ( const Widget copy)

Copy constructor.

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

Destructor.

Member Function Documentation

virtual void tgui::Widget::disable ( )
virtual

Disables the widget.

The widget will no longer receive events and it will thus no longer send callbacks. All widgets are enabled by default.

virtual void tgui::Widget::enable ( )
virtual

Enables the widget.

The widget will receive events and send callbacks again. All widgets are enabled by default.

virtual void tgui::Widget::focus ( )
virtual

Focus the widget.

The previously focused widget will be unfocused.

See also
unfocus
focusNextWidget
virtual sf::Vector2f tgui::Widget::getAbsolutePosition ( ) const
virtual

Get the absolute position of the widget on the screen.

Returns
Position of the widget
unsigned int tgui::Widget::getCallbackId ( )

Returns the callback id of the widget.

Returns
Callback id
See also
setCallbackId
Container* tgui::Widget::getParent ( ) const

Returns a pointer to the parent widget.

Returns
Pointer to the parent.
unsigned char tgui::Widget::getTransparency ( ) const

Returns the transparency of the widget.

Returns
The transparency of the widget. 0 is completely transparent, while 255 (default) means fully opaque.
WidgetTypes tgui::Widget::getWidgetType ( ) const

Returns the type of the widget.

Returns
Type of the widget
virtual void tgui::Widget::hide ( )
virtual

Hides the widget.

The widget won't receive events nor will it be drawn when hidden. The widget is visible by default.

bool tgui::Widget::isDisabled ( ) const

Returns true when the widget is disabled.

Returns
Is the widget disabled?

This means that the widget will longer receive events and it will thus no longer send callbacks. All widgets are enabled by default.

bool tgui::Widget::isEnabled ( ) const

Returns true when the widget is enabled.

Returns
Is the widget enabled?

If this function returns false then the widget is disabled and will longer receive events and it will thus no longer send callbacks. All widgets are enabled by default.

bool tgui::Widget::isFocused ( ) const

Returns true when the widget is focused and false otherwise.

Returns
Is the widget focused?
bool tgui::Widget::isLoaded ( ) const

Returns true when the widget is loaded successfully.

Returns
Is the widget loaded?

When a widget is not loaded correctly then it will not be drawn.

bool tgui::Widget::isVisible ( ) const

Returns true when the widget is visible.

Returns
Is the widget visible?

If this function returns false then the widget is hidden, which means that it won't receive events and it won't be drawn. All widgets are visible by default.

virtual void tgui::Widget::moveToBack ( )
virtual

Places the widget behind all other widgets.

virtual void tgui::Widget::moveToFront ( )
virtual

Places the widget before all other widgets.

Widget& tgui::Widget::operator= ( const Widget right)

Overload of assignment operator.

Parameters
rightInstance to assign
Returns
Reference to itself
void tgui::Widget::setCallbackId ( unsigned int  callbackId)

Changes the callback id of the widget.

Parameters
callbackIdThe new callback id

When receiving callback in a function which takes a Callback as parameter (or when polling the callbacks), you can find a callbackId in this Callback struct which can identify the widget. This function changes the id that this widget sends on a callback.

By default, the callback id will be 0.

virtual void tgui::Widget::setTransparency ( unsigned char  transparency)
virtual

Changes the transparency of the widget.

Parameters
transparencyThe 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 in tgui::ComboBox, tgui::ListBox, tgui::TextBox, tgui::EditBox, tgui::ChatBox, tgui::Tab, tgui::Container, tgui::Knob, tgui::LoadingBar, tgui::RadioButton, tgui::AnimatedPicture, tgui::Scrollbar, tgui::Slider, tgui::Slider2d, tgui::ChildWindow, tgui::Button, tgui::SpinButton, tgui::Picture, and tgui::Panel.

virtual void tgui::Widget::show ( )
virtual

Shows the widget.

The widget won't receive events nor will it be drawn when hidden. The widget is visible by default.

virtual void tgui::Widget::unfocus ( )
virtual

Unfocus the widget.

See also
focus
focusNextWidget

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