TGUI  v0.5.2
 All Classes Namespaces Functions Variables Enumerations Enumerator Pages
Public Member Functions | List of all members
tgui::ListBox Struct Reference
Inheritance diagram for tgui::ListBox:
tgui::OBJECT tgui::OBJECT_BORDERS

Public Member Functions

 ListBox ()
 Default constructor. More...
 
 ListBox (const ListBox &copy)
 Copy constructor. More...
 
virtual ~ListBox ()
 Destructor. More...
 
ListBoxoperator= (const ListBox &right)
 Overload of assignment operator. More...
 
virtual bool load (unsigned int width, unsigned int height, const std::string &scrollbarPathname="", unsigned int itemHeight=0)
 Creates the list box. More...
 
virtual void setSize (float width, float height)
 Changes the size of the list box. More...
 
virtual Vector2u getSize () const
 Returns the size of the list box, unaffected by scaling. More...
 
virtual Vector2f getScaledSize () const
 Returns the size of the list box, after the scaling transformation. More...
 
virtual std::string getLoadedScrollbarPathname () const
 Returns the pathname that was used to load the scrollbar. More...
 
virtual void changeColors (const sf::Color &backgroundColor=sf::Color::White, const sf::Color &textColor=sf::Color::Black, const sf::Color &selectedBackgroundColor=sf::Color(50, 100, 200), const sf::Color &selectedTextColor=sf::Color::White, const sf::Color &borderColor=sf::Color::Black)
 Changes the colors used in the list box. More...
 
virtual void setBackgroundColor (const sf::Color &backgroundColor)
 Set the background color that will be used inside the list box. More...
 
virtual void setTextColor (const sf::Color &textColor)
 Set the text color that will be used inside the list box. More...
 
virtual void setSelectedBackgroundColor (const sf::Color &selectedBackgroundColor)
 Set the background color of the selected text that will be used inside the list box. More...
 
virtual void setSelectedTextColor (const sf::Color &selectedTextColor)
 Set the text color of the selected text that will be used inside the list box. More...
 
virtual void setBorderColor (const sf::Color &borderColor)
 Set the border color text that will be used inside the list box. More...
 
virtual const sf::Color & getBackgroundColor () const
 Get the background color that is currently being used inside the list box. More...
 
virtual const sf::Color & getTextColor () const
 Get the text color that is currently being used inside the list box. More...
 
virtual const sf::Color & getSelectedBackgroundColor () const
 Get the background color of the selected text that is currently being used inside the list box. More...
 
virtual const sf::Color & getSelectedTextColor () const
 Get the text color of the selected text that is currently being used inside the list box. More...
 
virtual const sf::Color & getBorderColor () const
 Get the border color that is currently being used inside the list box. More...
 
virtual void setTextFont (const sf::Font &font)
 Changes the font of the items. More...
 
virtual const sf::Font * getTextFont () const
 Returns the font of the items. More...
 
virtual unsigned int addItem (const sf::String &itemName)
 Adds an item to the list. More...
 
virtual bool setSelectedItem (const sf::String &itemName)
 Selects an item in the list box. More...
 
virtual bool setSelectedItem (unsigned int id)
 Selects an item in the list box. More...
 
virtual void removeItem (unsigned int id)
 Removes an item from the list with a given id. More...
 
virtual void removeItem (const sf::String &itemName)
 Removes all items from the list with a given name. More...
 
virtual void removeAllItems ()
 Removes all items from the list. More...
 
virtual sf::String getItem (unsigned int id) const
 Returns the item name of the given id. More...
 
virtual unsigned int getItemID (const sf::String &itemName) const
 Returns the id of the first item with the given name. More...
 
virtual std::vector< sf::String > & getItems ()
 Returns the list that constains all the items. More...
 
virtual sf::String getSelectedItem () const
 Returns the currently selected item. More...
 
virtual unsigned int getSelectedItemID () const
 Get the id of the selected item. More...
 
virtual bool setScrollbar (const std::string &scrollbarPathname)
 Changes the scrollbar of the list box. More...
 
virtual void removeScrollbar ()
 Removes the scrollbar from the list box (if there is one). More...
 
virtual void setItemHeight (unsigned int itemHeight)
 Changes the height of the items in the list box. More...
 
virtual unsigned int getItemHeight () const
 Returns the height of the items in the list box. More...
 
virtual void setMaximumItems (unsigned int maximumItems=0)
 Changes the maximum items that the list box can contain. More...
 
virtual unsigned int getMaximumItems () const
 Returns the maximum items that the list box can contain. If 0 then there is no limit. 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...
 
- Public Member Functions inherited from tgui::OBJECT
 OBJECT ()
 Default constructor. More...
 
 OBJECT (const OBJECT &copy)
 Copy constructor. More...
 
virtual ~OBJECT ()
 Destructor. More...
 
OBJECToperator= (const OBJECT &right)
 Overload of assignment operator. More...
 
virtual void show ()
 Shows the object. More...
 
virtual void hide ()
 Hides the object. More...
 
virtual bool isVisible () const
 Returns true when the object is visible. More...
 
virtual void enable ()
 Enables the object. More...
 
virtual void disable ()
 Disables the object. More...
 
virtual bool isEnabled () const
 Returns true when the object is enabled. More...
 
virtual bool isDisabled () const
 Returns true when the object is disabled. More...
 
virtual bool isLoaded () const
 Returns true when the object is loaded successfully. More...
 
void focus ()
 Focus the object. More...
 
void unfocus ()
 Unfocus the object. More...
 
void focusNextObject ()
 Focuses the next object. More...
 
virtual bool isFocused () const
 Returns true when the object is focused and false otherwise. More...
 
virtual ObjectTypes getObjectType () const
 Returns the type of the object. More...
 
virtual void moveToFront ()
 Places the object before all other objects. More...
 
virtual void moveToBack ()
 Places the object behind all other objects. More...
 
- Public Member Functions inherited from tgui::OBJECT_BORDERS
 OBJECT_BORDERS ()
 Default constructor. More...
 
virtual Vector4u getBorders () const
 Returns the size of the borders as a tgui::Vector4u. More...
 

Constructor & Destructor Documentation

tgui::ListBox::ListBox ( )

Default constructor.

tgui::ListBox::ListBox ( const ListBox copy)

Copy constructor.

virtual tgui::ListBox::~ListBox ( )
virtual

Destructor.

Member Function Documentation

virtual unsigned int tgui::ListBox::addItem ( const sf::String &  itemName)
virtual

Adds an item to the list.

Parameters
itemNameThe name of the item you want to add (this is the text that will be displayed inside the list box)
Returns
  • 0 when the list box is full (you have set a maximum item limit and you are trying to add more items)
  • 0 when there is no scrollbar and you try to have more items than fit inside the list box
  • The id of the item when it was successfully added.
Warning
The id returned by this function is no longer correct when an item is removed. Use it immediately or don't use it at all.
See Also
setMaximumItems
virtual void tgui::ListBox::changeColors ( const sf::Color &  backgroundColor = sf::Color::White,
const sf::Color &  textColor = sf::Color::Black,
const sf::Color &  selectedBackgroundColor = sf::Color(50, 100, 200),
const sf::Color &  selectedTextColor = sf::Color::White,
const sf::Color &  borderColor = sf::Color::Black 
)
virtual

Changes the colors used in the list box.

Parameters
backgroundColorThe color of the background of the list box
textColorThe color of the text
selectedBackgroundColorThe color of the background of the selected item
selectedTextColorThe color of the text when it is selected
borderColorThe color of the borders
virtual const sf::Color& tgui::ListBox::getBackgroundColor ( ) const
virtual

Get the background color that is currently being used inside the list box.

virtual const sf::Color& tgui::ListBox::getBorderColor ( ) const
virtual

Get the border color that is currently being used inside the list box.

virtual sf::String tgui::ListBox::getItem ( unsigned int  id) const
virtual

Returns the item name of the given id.

The string will be empty when the id was too high or when it was 0.

See Also
getItemID
virtual unsigned int tgui::ListBox::getItemHeight ( ) const
virtual

Returns the height of the items in the list box.

virtual unsigned int tgui::ListBox::getItemID ( const sf::String &  itemName) const
virtual

Returns the id of the first item with the given name.

If none of the items matches then the id will be 0.

Warning
This id will become wrong when an item is removed from the list. Use it immediately or don't use it at all.
See Also
getItem
virtual std::vector<sf::String>& tgui::ListBox::getItems ( )
virtual

Returns the list that constains all the items.

virtual std::string tgui::ListBox::getLoadedScrollbarPathname ( ) const
virtual

Returns the pathname that was used to load the scrollbar.

When no scrollbar was loaded then this function will return an empty string.

virtual unsigned int tgui::ListBox::getMaximumItems ( ) const
virtual

Returns the maximum items that the list box can contain. If 0 then there is no limit.

virtual Vector2f tgui::ListBox::getScaledSize ( ) const
virtual

Returns the size of the list box, after the scaling transformation.

Implements tgui::OBJECT.

virtual const sf::Color& tgui::ListBox::getSelectedBackgroundColor ( ) const
virtual

Get the background color of the selected text that is currently being used inside the list box.

virtual sf::String tgui::ListBox::getSelectedItem ( ) const
virtual

Returns the currently selected item.

When no item was selected then this function will return an empty string.

See Also
getSelectedItemID
virtual unsigned int tgui::ListBox::getSelectedItemID ( ) const
virtual

Get the id of the selected item.

When no item was selected then this function returns 0.

Warning
This id will become wrong when an item is removed from the list. Use it immediately or don't use it at all.
See Also
getSelectedItem
virtual const sf::Color& tgui::ListBox::getSelectedTextColor ( ) const
virtual

Get the text color of the selected text that is currently being used inside the list box.

virtual Vector2u tgui::ListBox::getSize ( ) const
virtual

Returns the size of the list box, unaffected by scaling.

Implements tgui::OBJECT.

virtual const sf::Color& tgui::ListBox::getTextColor ( ) const
virtual

Get the text color that is currently being used inside the list box.

virtual const sf::Font* tgui::ListBox::getTextFont ( ) const
virtual

Returns the font of the items.

virtual bool tgui::ListBox::load ( unsigned int  width,
unsigned int  height,
const std::string &  scrollbarPathname = "",
unsigned int  itemHeight = 0 
)
virtual

Creates the list box.

The list box may resize a little bit. It might be a little bit bigger or smaller than the size passed to this function.

Parameters
widthThe width of the list box (borders included).
heightThe height of the list box (borders included).
scrollbarPathnameThe pathname needed to load the scrollbar. If not provided then there will be no possibility to scroll, thus no items will be added when the list box is full.
itemHeightThe height of a single item in the list box. The text size will be based on this, but will be a little smaller. If ItemHeight is 0 then it will become a tenth of the height of the list box.
Returns
  • true on success
  • false when scrollbar couldn't be loaded (only if scrollbarPathname isn't empty)
ListBox& tgui::ListBox::operator= ( const ListBox right)

Overload of assignment operator.

virtual void tgui::ListBox::removeAllItems ( )
virtual

Removes all items from the list.

virtual void tgui::ListBox::removeItem ( unsigned int  id)
virtual

Removes an item from the list with a given id.

virtual void tgui::ListBox::removeItem ( const sf::String &  itemName)
virtual

Removes all items from the list with a given name.

virtual void tgui::ListBox::removeScrollbar ( )
virtual

Removes the scrollbar from the list box (if there is one).

When there are too many items to fit in the list box then the items will be removed.

virtual void tgui::ListBox::setBackgroundColor ( const sf::Color &  backgroundColor)
virtual

Set the background color that will be used inside the list box.

See Also
changeColors
virtual void tgui::ListBox::setBorderColor ( const sf::Color &  borderColor)
virtual

Set the border color text that will be used inside the list box.

See Also
changeColors
virtual void tgui::ListBox::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::OBJECT_BORDERS.

virtual void tgui::ListBox::setItemHeight ( unsigned int  itemHeight)
virtual

Changes the height of the items in the list box.

This size is always a little big greater than the text size. When there is no scrollbar then the items will be removed when they no longer fit inside the list box.

virtual void tgui::ListBox::setMaximumItems ( unsigned int  maximumItems = 0)
virtual

Changes the maximum items that the list box can contain.

If this function returns 0 then there is no limit. If no scrollbar was loaded then there is always a limitation because the text can't go outside the list box.

virtual bool tgui::ListBox::setScrollbar ( const std::string &  scrollbarPathname)
virtual

Changes the scrollbar of the list box.

virtual void tgui::ListBox::setSelectedBackgroundColor ( const sf::Color &  selectedBackgroundColor)
virtual

Set the background color of the selected text that will be used inside the list box.

See Also
changeColors
virtual bool tgui::ListBox::setSelectedItem ( const sf::String &  itemName)
virtual

Selects an item in the list box.

When adding items to the list box with the addItem function, none of them will be selected. If you want a default item selected then you can use this function to select it. The first item that matches the name will be selected.

Returns
  • true on success
  • false when none of the items matches the name
See Also
setSelectedItem(unsigned int)
virtual bool tgui::ListBox::setSelectedItem ( unsigned int  id)
virtual

Selects an item in the list box.

When adding items to the list box with the addItem function, none of them will be selected. If you want a default item selected then you can use this function to select it.

The id starts counting from 1. If you pass 0 to this function then none of the items will be selected.

Returns
  • true on success
  • false when the id was too high
See Also
setSelectedItem(sf::String)
virtual void tgui::ListBox::setSelectedTextColor ( const sf::Color &  selectedTextColor)
virtual

Set the text color of the selected text that will be used inside the list box.

See Also
changeColors
virtual void tgui::ListBox::setSize ( float  width,
float  height 
)
virtual

Changes the size of the list box.

Parameters
widthThe new width of the list box
heightThe new height of the list box

Implements tgui::OBJECT.

virtual void tgui::ListBox::setTextColor ( const sf::Color &  textColor)
virtual

Set the text color that will be used inside the list box.

See Also
changeColors
virtual void tgui::ListBox::setTextFont ( const sf::Font &  font)
virtual

Changes the font of the items.

When you don't call this function then the global font will be use. This global font can be changed by changing gloabalFont from the parent.


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