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

Movable Panel with title bar. More...

#include <ChildWindow.hpp>

Inheritance diagram for tgui::ChildWindow:
tgui::Container tgui::WidgetBorders tgui::Widget tgui::Transformable tgui::CallbackManager tgui::MessageBox

Public Types

- Public Types inherited from tgui::Widget

Public Member Functions

 ChildWindow ()
 Default constructor. More...
 
 ChildWindow (const ChildWindow &copy)
 Copy constructor. More...
 
virtual ~ChildWindow ()
 Destructor. More...
 
ChildWindowoperator= (const ChildWindow &right)
 Overload of assignment operator. More...
 
virtual bool load (const std::string &configFileFilename, const std::string &sectionName="ChildWindow")
 Loads the widget. More...
 
const std::string & getLoadedConfigFile () const
 Returns the filename of the config file that was used to load the widget. More...
 
void setSize (float width, float height)
 Changes the size of the child window. More...
 
virtual sf::Vector2f getSize () const
 Returns the size of the drawable area of the child window. More...
 
virtual sf::Vector2f getFullSize () const
 Returns the size of the full child window. More...
 
void setBackgroundTexture (sf::Texture *const texture=nullptr)
 Changes the background texture of the child window. More...
 
sf::Texture * getBackgroundTexture ()
 Returns the background texture of the child window. More...
 
void setTitleBarHeight (unsigned int height)
 Change the height of the title bar. More...
 
unsigned int getTitleBarHeight () const
 Returns the height of the title bar. More...
 
void setBackgroundColor (const sf::Color &backgroundColor)
 Changes the background color of the child window. More...
 
const sf::Color & getBackgroundColor () const
 Returns the background color of the child window. More...
 
virtual void setTransparency (unsigned char transparency)
 Changes the transparency of the widget. More...
 
void setTitle (const sf::String &title)
 Changes the title that is displayed in the title bar of the child window. More...
 
const sf::String & getTitle () const
 Returns the title that is displayed in the title bar of the child window. More...
 
void setTitleColor (const sf::Color &color)
 Changes the color of the title that is displayed in the title bar of the child window. More...
 
const sf::Color & getTitleColor () const
 Returns the color of the title that is displayed in the title bar of the child window. More...
 
void setBorderColor (const sf::Color &borderColor)
 Set the border color. More...
 
const sf::Color & getBorderColor () const
 Returns the borde color. More...
 
virtual void setBorders (unsigned int leftBorder=0, unsigned int topBorder=0, unsigned int rightBorder=0, unsigned int bottomBorder=0)
 Changes the size of the borders. More...
 
void setDistanceToSide (unsigned int distanceToSide)
 Changes the distance between the title and the side of the title bar. More...
 
unsigned int getDistanceToSide () const
 Returns the distance between the title and the side of the title bar. More...
 
void setTitleAlignment (TitleAlignment alignment)
 Changes the title alignment. More...
 
TitleAlignment getTitleAlignment () const
 Returns the title alignment. More...
 
void setIcon (const std::string &filename)
 Changes the icon in the top left corner of the child window. More...
 
void removeIcon ()
 Removes the icon in the top left corner of the child window. More...
 
void destroy ()
 Destroys the window. More...
 
void keepInParent (bool enabled)
 Set the child window to be kept inside its parent. More...
 
bool isKeptInParent () const
 Tells whether the child window is kept inside its parent. 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...
 
void setPosition (float x, float y)
 Set the position of the 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...
 
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...
 
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...
 
- 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...
 
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...
 
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...
 
- Public Member Functions inherited from tgui::WidgetBorders
 WidgetBorders ()
 Default constructor. More...
 
virtual ~WidgetBorders ()
 Destructor. More...
 
virtual Borders getBorders () const
 Returns the size of the borders as a tgui::Borders. More...
 

Detailed Description

Movable Panel with title bar.

Member Enumeration Documentation

Defines specific triggers to ChildWindow.

Enumerator
LeftMousePressed 

The left mouse button was pressed (child window was thus brough to front)

Closed 

Child window was closed.

Moved 

Child window was moved.

AllChildWindowCallbacks 

All triggers defined in ChildWindow and its base classes.

Title alignments, possible options for the setTitleAlignment function.

Enumerator
TitleAlignmentLeft 

Places the title on the left side of the title bar.

TitleAlignmentCentered 

Places the title in the middle of the title bar.

TitleAlignmentRight 

Places the title on the right side of the title bar.

Constructor & Destructor Documentation

tgui::ChildWindow::ChildWindow ( )

Default constructor.

tgui::ChildWindow::ChildWindow ( const ChildWindow copy)

Copy constructor.

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

Destructor.

Member Function Documentation

void tgui::ChildWindow::destroy ( )

Destroys the window.

When no callback is requested when closing the window, this function will be called automatically.

When you requested a callback then you get the opportunity to cancel the closure of the window. If you want to keep it open then don't do anything, if you want to close it then just call this function.

const sf::Color& tgui::ChildWindow::getBackgroundColor ( ) const

Returns the background color of the child window.

Returns
The current background color
sf::Texture* tgui::ChildWindow::getBackgroundTexture ( )

Returns the background texture of the child window.

Returns
Pointer to the texture that is being used as background of the child window. This pointer is nullptr when no background texture was set.
const sf::Color& tgui::ChildWindow::getBorderColor ( ) const

Returns the borde color.

Returns
The color of the borders
unsigned int tgui::ChildWindow::getDistanceToSide ( ) const

Returns the distance between the title and the side of the title bar.

Returns
distance between the title and the side of the title bar
virtual sf::Vector2f tgui::ChildWindow::getFullSize ( ) const
virtual

Returns the size of the full child window.

Returns
Size of the child window

The size returned by this function is the size of the child window, including the title bar and the borders.

Reimplemented from tgui::Transformable.

const std::string& tgui::ChildWindow::getLoadedConfigFile ( ) const

Returns the filename of the config file that was used to load the widget.

Returns
Filename of loaded config file. Empty string when no config file was loaded yet.
virtual sf::Vector2f tgui::ChildWindow::getSize ( ) const
virtual

Returns the size of the drawable area of the child window.

Returns
Size of the child window

The size returned by this function is the size of the child window, without the title bar nor the borders.

Implements tgui::Transformable.

const sf::String& tgui::ChildWindow::getTitle ( ) const

Returns the title that is displayed in the title bar of the child window.

Returns
Title of the child window
TitleAlignment tgui::ChildWindow::getTitleAlignment ( ) const

Returns the title alignment.

Returns
How the title is aligned in the title bar
unsigned int tgui::ChildWindow::getTitleBarHeight ( ) const

Returns the height of the title bar.

Returns
Height of the title bar
const sf::Color& tgui::ChildWindow::getTitleColor ( ) const

Returns the color of the title that is displayed in the title bar of the child window.

Returns
Title color of the child window
virtual sf::Vector2f tgui::ChildWindow::getWidgetsOffset ( ) const
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).

Returns
Offset of the widgets in the container

Reimplemented from tgui::Container.

bool tgui::ChildWindow::isKeptInParent ( ) const

Tells whether the child window is kept inside its parent.

Returns
When it's set to true, the child window will always be kept automatically inside its parent. It will be fully kept on left, right and top. At the bottom of the parent only the title bar will be kept inside. It's set to false by default.
void tgui::ChildWindow::keepInParent ( bool  enabled)

Set the child window to be kept inside its parent.

Parameters
enabledWhen it's set to true, the child window will always be kept automatically inside its parent. It will be fully kept on left, right and top. At the bottom of the parent only the title bar will be kept inside. It's set to false by default.
virtual bool tgui::ChildWindow::load ( const std::string &  configFileFilename,
const std::string &  sectionName = "ChildWindow" 
)
virtual

Loads the widget.

Parameters
configFileFilenameFilename of the config file.
sectionNameName of the section in the file to load

The config file must contain a ChildWindow section with the needed information.

Reimplemented in tgui::MessageBox.

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

Overload of assignment operator.

Parameters
rightInstance to assign
Returns
Reference to itself
void tgui::ChildWindow::removeIcon ( )

Removes the icon in the top left corner of the child window.

void tgui::ChildWindow::setBackgroundColor ( const sf::Color &  backgroundColor)

Changes the background color of the child window.

Parameters
backgroundColorNew background color
void tgui::ChildWindow::setBackgroundTexture ( sf::Texture *const  texture = nullptr)

Changes the background texture of the child window.

Parameters
texturePointer to the texture that should be used as background of the child window
Warning
You should make sure that the texture stays alive.

If the texture has a different size than the child window then it will be scaled to fill the whole window. Pass nullptr to this function to remove the background texture.

void tgui::ChildWindow::setBorderColor ( const sf::Color &  borderColor)

Set the border color.

Parameters
borderColorThe color of the borders
virtual void tgui::ChildWindow::setBorders ( unsigned int  leftBorder = 0,
unsigned int  topBorder = 0,
unsigned int  rightBorder = 0,
unsigned int  bottomBorder = 0 
)
virtual

Changes the size of the borders.

Parameters
leftBorderThe width of the left border
topBorderThe height of the top border
rightBorderThe width of the right border
bottomBorderThe height of the bottom border

Implements tgui::WidgetBorders.

void tgui::ChildWindow::setDistanceToSide ( unsigned int  distanceToSide)

Changes the distance between the title and the side of the title bar.

Parameters
distanceToSidedistance between the title and the side of the title bar
void tgui::ChildWindow::setIcon ( const std::string &  filename)

Changes the icon in the top left corner of the child window.

Parameters
filenameFilename of the icon image

There is no icon by default.

void tgui::ChildWindow::setPosition ( float  x,
float  y 
)
virtual

Set the position of the widget.

This function completely overwrites the previous position. See the move function to apply an offset based on the previous position instead. The default position of a transformable widget is (0, 0).

Parameters
xX coordinate of the new position
yY coordinate of the new position
See also
move, getPosition

Reimplemented from tgui::Transformable.

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

Changes the size of the child window.

Parameters
widthSets the new width of the child window
heightSets the new height of the child window

The width and height are the size of the child window, without the title bar nor the borders.

Implements tgui::Transformable.

void tgui::ChildWindow::setTitle ( const sf::String &  title)

Changes the title that is displayed in the title bar of the child window.

Parameters
titleNew title for the child window
void tgui::ChildWindow::setTitleAlignment ( TitleAlignment  alignment)

Changes the title alignment.

Parameters
alignmentHow should the title be aligned in the title bar?
void tgui::ChildWindow::setTitleBarHeight ( unsigned int  height)

Change the height of the title bar.

Parameters
heightNew height of the title bar

The default height is the height of the title bar image that is loaded with the load function.

void tgui::ChildWindow::setTitleColor ( const sf::Color &  color)

Changes the color of the title that is displayed in the title bar of the child window.

Parameters
colorNew title color for the child window
virtual void tgui::ChildWindow::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 from tgui::Container.


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