TGUI  v0.6.10
Classes | Public Types | Public Member Functions | List of all members
tgui::MenuBar Class Reference
Inheritance diagram for tgui::MenuBar:
tgui::Widget tgui::Transformable tgui::CallbackManager

Classes

struct  Menu
 

Public Types

- Public Types inherited from tgui::Widget

Public Member Functions

 MenuBar ()
 Default constructor. More...
 
bool load (const std::string &configFileFilename, const std::string &sectionName="MenuBar")
 Loads the widget. More...
 
const std::string & getLoadedConfigFile () const
 Returns the filename of the config file that was used to load the widget. More...
 
virtual void setSize (float width, float height)
 Changes the size of the menu bar. More...
 
virtual sf::Vector2f getSize () const
 Returns the size of the menu bar. More...
 
void addMenu (const sf::String &text)
 Adds a new menu. More...
 
bool addMenuItem (const sf::String &menu, const sf::String &text)
 Adds a new menu item. More...
 
bool removeMenu (const sf::String &menu)
 Removes a menu. More...
 
void removeAllMenus ()
 Removes all menus. More...
 
bool removeMenuItem (const sf::String &menu, const sf::String &menuItem)
 Removes a menu item. More...
 
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)
 Changes the colors used in the menu bar. More...
 
void setBackgroundColor (const sf::Color &backgroundColor)
 Set the background color that will be used inside the menu bar. More...
 
void setTextColor (const sf::Color &textColor)
 Set the text color that will be used inside the menu bar. More...
 
void setSelectedBackgroundColor (const sf::Color &selectedBackgroundColor)
 Set the background color of the selected text that will be used inside the menu bar. More...
 
void setSelectedTextColor (const sf::Color &selectedTextColor)
 Set the text color of the selected text that will be used inside the menu bar. More...
 
const sf::Color & getBackgroundColor () const
 Get the background color that is currently being used inside the menu bar. More...
 
const sf::Color & getTextColor () const
 Get the text color that is currently being used inside the menu bar. More...
 
const sf::Color & getSelectedBackgroundColor () const
 Get the background color of the selected text that is currently being used inside the menu bar. More...
 
const sf::Color & getSelectedTextColor () const
 Get the text color of the selected text that is currently being used inside the menu bar. More...
 
void setTextFont (const sf::Font &font)
 Changes the font used in the menu bar. More...
 
const sf::Font * getTextFont () const
 Returns the font that is used in the menu bar. More...
 
void setTextSize (unsigned int size)
 Changes the character size of the text. More...
 
unsigned int getTextSize () const
 Returns the character size of the text. More...
 
void setDistanceToSide (unsigned int distanceToSide)
 Changes the distance between the text and the side of the menu item. More...
 
unsigned int getDistanceToSide () const
 Returns the distance between the text and the side of the menu item. More...
 
void setMinimumSubMenuWidth (unsigned int minimumWidth)
 Changes the minimum width of the submenus. More...
 
unsigned int getMinimumSubMenuWidth () const
 Returns the distance between the text and the side of the menu item. 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...
 
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 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...
 

Member Enumeration Documentation

Defines specific triggers to MenuBar.

Enumerator
MenuItemClicked 

A menu item was clicked.

AllMenuBarCallbacks 

All triggers defined in MenuBar and its base classes.

Constructor & Destructor Documentation

tgui::MenuBar::MenuBar ( )

Default constructor.

Member Function Documentation

void tgui::MenuBar::addMenu ( const sf::String &  text)

Adds a new menu.

Parameters
textThe text written on the menu
bool tgui::MenuBar::addMenuItem ( const sf::String &  menu,
const sf::String &  text 
)

Adds a new menu item.

Parameters
menuThe name of the menu to which the menu item will be added
textThe text written on this menu item
Returns
True when the item was added, false when menu was not found.
menuBar->addMenu("File");
menuBar->addMenuItem("File", "Load");
menuBar->addMenuItem("File", "Save");
void tgui::MenuBar::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 
)

Changes the colors used in the menu bar.

Parameters
backgroundColorThe color of the background of the menu bar
textColorThe color of the text
selectedBackgroundColorThe color of the background of the selected item
selectedTextColorThe color of the text when it is selected
const sf::Color& tgui::MenuBar::getBackgroundColor ( ) const

Get the background color that is currently being used inside the menu bar.

Returns
The color of the background of the menu bar
unsigned int tgui::MenuBar::getDistanceToSide ( ) const

Returns the distance between the text and the side of the menu item.

Returns
distance between the text and the side of the menu item
const std::string& tgui::MenuBar::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.
unsigned int tgui::MenuBar::getMinimumSubMenuWidth ( ) const

Returns the distance between the text and the side of the menu item.

Returns
minimum width of the submenus
See also
setMinimumSubMenuWidth
const sf::Color& tgui::MenuBar::getSelectedBackgroundColor ( ) const

Get the background color of the selected text that is currently being used inside the menu bar.

Returns
The color of the background of the selected item
const sf::Color& tgui::MenuBar::getSelectedTextColor ( ) const

Get the text color of the selected text that is currently being used inside the menu bar.

Returns
The color of the text when it is selected
virtual sf::Vector2f tgui::MenuBar::getSize ( ) const
virtual

Returns the size of the menu bar.

Returns
Size of the menu bar

By default, the menu bar has the same width as the window. The height used by default is the height of the background image(s).

Implements tgui::Transformable.

const sf::Color& tgui::MenuBar::getTextColor ( ) const

Get the text color that is currently being used inside the menu bar.

Returns
The color of the text
const sf::Font* tgui::MenuBar::getTextFont ( ) const

Returns the font that is used in the menu bar.

Returns
Pointer to the font that is currently being used.
unsigned int tgui::MenuBar::getTextSize ( ) const

Returns the character size of the text.

Returns
The text size.
bool tgui::MenuBar::load ( const std::string &  configFileFilename,
const std::string &  sectionName = "MenuBar" 
)

Loads the widget.

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

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

void tgui::MenuBar::removeAllMenus ( )

Removes all menus.

bool tgui::MenuBar::removeMenu ( const sf::String &  menu)

Removes a menu.

Any menu items that belong to this menu will be removed as well.

Parameters
menuThe name of the menu to remove
Returns
True when the menu was removed, false when menu was not found.
bool tgui::MenuBar::removeMenuItem ( const sf::String &  menu,
const sf::String &  menuItem 
)

Removes a menu item.

Parameters
menuThe name of the menu in which the menu item is located
menuItemThe name of the menu item to remove
Returns
True when the item was removed, false when menu or menuItem was not found.
void tgui::MenuBar::setBackgroundColor ( const sf::Color &  backgroundColor)

Set the background color that will be used inside the menu bar.

Parameters
backgroundColorThe color of the background of the menu bar
void tgui::MenuBar::setDistanceToSide ( unsigned int  distanceToSide)

Changes the distance between the text and the side of the menu item.

Parameters
distanceToSidedistance between the text and the side of the menu item
void tgui::MenuBar::setMinimumSubMenuWidth ( unsigned int  minimumWidth)

Changes the minimum width of the submenus.

When a submenu is displayed, the width will be either this or the width of the longest text in the submenu. The default minimum width is 125 pixels.

Parameters
minimumWidthminimum width of the submenus
void tgui::MenuBar::setSelectedBackgroundColor ( const sf::Color &  selectedBackgroundColor)

Set the background color of the selected text that will be used inside the menu bar.

Parameters
selectedBackgroundColorThe color of the background of the selected item
void tgui::MenuBar::setSelectedTextColor ( const sf::Color &  selectedTextColor)

Set the text color of the selected text that will be used inside the menu bar.

Parameters
selectedTextColorThe color of the text when it is selected
virtual void tgui::MenuBar::setSize ( float  width,
float  height 
)
virtual

Changes the size of the menu bar.

Parameters
widthThe width of the menu bar.
heightThe height of the menu bar.

By default the height is 20 pixels.

Implements tgui::Transformable.

void tgui::MenuBar::setTextColor ( const sf::Color &  textColor)

Set the text color that will be used inside the menu bar.

Parameters
textColorThe color of the text
void tgui::MenuBar::setTextFont ( const sf::Font &  font)

Changes the font used in the menu bar.

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

Parameters
fontThe new font.
void tgui::MenuBar::setTextSize ( unsigned int  size)

Changes the character size of the text.

Parameters
sizeThe new size of the text. If the size is 0 (default) then the text will be scaled to fit in the menu bar.

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