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

Public Member Functions

 ComboBox ()
 Default constructor. More...
 
 ComboBox (const ComboBox &copy)
 Copy constructor. More...
 
virtual ~ComboBox ()
 Destructor. More...
 
ComboBoxoperator= (const ComboBox &right)
 Overload of assignment operator. More...
 
virtual bool load (const std::string &comboBoxPathname, float width, float height, unsigned int nrOfItemsInListToDisplay=10, const std::string &scrollbarPathname="")
 Loads the combo box. More...
 
virtual void setSize (float width, float height)
 Changes the size of the combo box. More...
 
virtual Vector2u getSize () const
 Returns the size of the combo box, unaffected by scaling. More...
 
virtual Vector2f getScaledSize () const
 Returns the size of the combo box, after the scaling transformation. More...
 
virtual std::string getLoadedPathname () const
 Returns the pathname that was used to load the combo box. More...
 
virtual std::string getLoadedScrollbarPathname () const
 Returns the pathname that was used to load the scrollbar. More...
 
virtual void setItemsToDisplay (unsigned int nrOfItemsInListToDisplay)
 Changes the number of items that are displayed in the list. More...
 
virtual unsigned int getItemsToDisplay () const
 Returns the number of items that are displayed in the list. 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 that are used in the combo box. More...
 
virtual void setBackgroundColor (const sf::Color &backgroundColor)
 Set the background color that will be used inside the combo box. More...
 
virtual void setTextColor (const sf::Color &textColor)
 Set the text color that will be used inside the combo box. More...
 
virtual void setSelectedBackgroundColor (const sf::Color &selectedBackgroundColor)
 Set the background color of the selected text that will be used inside the combo box. More...
 
virtual void setSelectedTextColor (const sf::Color &selectedTextColor)
 Set the text color of the selected text that will be used inside the combo box. More...
 
virtual void setBorderColor (const sf::Color &borderColor)
 Set the border color text that will be used inside the combo box. More...
 
virtual const sf::Color & getBackgroundColor () const
 Get the background color that is currently being used inside the combo box. More...
 
virtual const sf::Color & getTextColor () const
 Get the text color that is currently being used inside the combo box. More...
 
virtual const sf::Color & getSelectedBackgroundColor () const
 Get the background color of the selected text that is currently being used inside the combo box. More...
 
virtual const sf::Color & getSelectedTextColor () const
 Get the text color of the selected text that is currently being used inside the combo box. More...
 
virtual const sf::Color & getBorderColor () const
 Get the border color that is currently being used inside the combo box. More...
 
virtual void setTextFont (const sf::Font &font)
 Changes the text font. More...
 
virtual const sf::Font * getTextFont () const
 Returns the text font. 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...
 
virtual unsigned int addItem (const sf::String &itemName)
 Adds an item to the list, so that it can be selected later. More...
 
virtual bool setSelectedItem (const sf::String &itemName)
 Selects an item from the list. More...
 
virtual bool setSelectedItem (unsigned int id)
 Selects an item from the list. 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 () const
 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 that is displayed next to the list. More...
 
virtual void removeScrollbar ()
 Removes the scrollbar. More...
 
virtual void setMaximumItems (unsigned int maximumItems=0)
 Changes the maximum items that the combo box can contain. More...
 
virtual unsigned int getMaximumItems () const
 Returns the maximum items that the combo box can contain. 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::ComboBox::ComboBox ( )

Default constructor.

tgui::ComboBox::ComboBox ( const ComboBox copy)

Copy constructor.

virtual tgui::ComboBox::~ComboBox ( )
virtual

Destructor.

Member Function Documentation

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

Adds an item to the list, so that it can be selected later.

Parameters
itemNameThe name of the item you want to add (this is the text that will be displayed inside the combo box)
Returns
  • 0 when the combo box wasn't loaded correctly
  • 0 when the list 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 the number of items to display
  • 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
setItemsToDisplay
virtual void tgui::ComboBox::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 that are used in the combo box.

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

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

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

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

virtual sf::String tgui::ComboBox::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::ComboBox::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 is no longer correct when an item is removed. Use it immediately or don't use it at all.
See Also
getItem
virtual std::vector<sf::String>& tgui::ComboBox::getItems ( ) const
virtual

Returns the list that constains all the items.

virtual unsigned int tgui::ComboBox::getItemsToDisplay ( ) const
virtual

Returns the number of items that are displayed in the list.

When there is no scrollbar then this is the maximum number of items. If there is one, then it will only become visible when there are more items than this number.

virtual std::string tgui::ComboBox::getLoadedPathname ( ) const
virtual

Returns the pathname that was used to load the combo box.

When the combo box has not been loaded yet then this function will return an empty string.

virtual std::string tgui::ComboBox::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::ComboBox::getMaximumItems ( ) const
virtual

Returns the maximum items that the combo box can contain.

If this function returns 0 then there is no limit. If no scrollbar was loaded then the amount of items that are displayed will still be a limit.

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

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

Implements tgui::OBJECT.

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

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

virtual sf::String tgui::ComboBox::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::ComboBox::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::ComboBox::getSelectedTextColor ( ) const
virtual

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

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

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

Implements tgui::OBJECT.

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

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

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

Returns the text font.

virtual bool tgui::ComboBox::load ( const std::string &  comboBoxPathname,
float  width,
float  height,
unsigned int  nrOfItemsInListToDisplay = 10,
const std::string &  scrollbarPathname = "" 
)
virtual

Loads the combo box.

Parameters
comboBoxPathnameThe path to the folder that contains the arrow image(s). The folder must also contain an info.txt file, which will give more information about the comb box.
widthThe width of the combo box (borders included).
heightThe height of the combo box (borders included).
nrOfItemsToDisplayThe amount of items that are displayed when you click on the arrow. If there is no scrollbar then this will also be the maximum amount of items that the combo box can contain.
scrollbarPathnameThe ScrollbarPathname is the 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 combo box is full.
Returns
  • true on success
  • false when the pathname is empty
  • false when the info.txt file was not found
  • false when the images couldn't be loaded
  • false when scrollbar couldn't be loaded (only if scrollbarPathname isn't empty)
ComboBox& tgui::ComboBox::operator= ( const ComboBox right)

Overload of assignment operator.

virtual void tgui::ComboBox::removeAllItems ( )
virtual

Removes all items from the list.

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

Removes an item from the list with a given id.

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

Removes all items from the list with a given name.

virtual void tgui::ComboBox::removeScrollbar ( )
virtual

Removes the scrollbar.

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

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

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

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

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

See Also
changeColors
virtual void tgui::ComboBox::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::ComboBox::setItemsToDisplay ( unsigned int  nrOfItemsInListToDisplay)
virtual

Changes the number of items that are displayed in the list.

When there is no scrollbar then this is the maximum number of items. If there is one, then it will only become visible when there are more items than this number.

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

Changes the maximum items that the combo box can contain.

If maximumItems is 0 then there is no limit. If no scrollbar was loaded then the amount of items that are displayed is already a limit.

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

Changes the scrollbar that is displayed next to the list.

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

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

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

Selects an item from the list.

When adding items to the combo box with the addItem function, none of them will be selected. If you don't want the combo box to stay empty until the user selects something, but you want a default item instead, then you can use this function to select an item. 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::ComboBox::setSelectedItem ( unsigned int  id)
virtual

Selects an item from the list.

When adding items to the combo box with the addItem function, none of them will be selected. If you don't want the combo box to stay empty until the user selects something, but you want a default item instead, then you can use this function to select an item.

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::ComboBox::setSelectedTextColor ( const sf::Color &  selectedTextColor)
virtual

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

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

Changes the size of the combo box.

Parameters
widthThe new width of the combo box (borders included)
heightThe new height of the combo box (borders included)

Implements tgui::OBJECT.

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

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

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

Changes the text font.


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