Public Member Functions | Public Attributes | List of all members
pButton Class Reference

Button class. More...

#include <primitiveGui.h>

Inheritance diagram for pButton:
pWidget

Public Member Functions

 pButton (float x, float y, float width, float height)
 
void setColors (sf::Color borderColor, sf::Color fillColor, sf::Color hoverColor, sf::Color clickedColor)
 
void setText (sf::String &text)
 
sf::String getText ()
 
virtual void updateWidget ()
 
- Public Member Functions inherited from pWidget
 pWidget (float x, float y, float width, float height)
 
void setGeometry (float x, float y, float width, float height)
 
void setVisiblity (bool visiblity)
 

Public Attributes

sf::Color borderColor
 Color of button border - default ( 117, 119, 114, 255 )
 
sf::Color fillColor
 Color of default button background - default ( 85, 87, 82, 255 )
 
sf::Color hoverColor
 Color of button when it's hovered - default ( 136, 127, 131, 255 )
 
sf::Color clickedColor
 Color of button when it's clicked - default ( 81, 78, 45, 255 )
 
sf::Color colorToDraw
 Color which is actually draw.
 
pText buttonLabel
 Text on button.
 
- Public Attributes inherited from pWidget
int widgetId
 Widget unique index.
 
int widgetOnWindowId
 If widget is on some window this is a unique index of this window ( it's widgetId of this window ) else it is -1.
 
bool visiblity
 visibility of widget
 
widgetTypeEnum widgetType
 Type of the widget.
 
widgetEventType widgetEvent
 Type of the event.
 
sf::Vector2f widgetPosition
 Position of widget.
 
sf::Vector2f widgetSize
 Size of widget.
 

Additional Inherited Members

- Public Types inherited from pWidget
enum  widgetTypeEnum {
  Button =0, TextEdit, CheckBox, Slider,
  ProgressBar, Window
}
 Enumeration of the different types of widgets. More...
 
enum  widgetEventType { NoEvent =0, WidgetClicked }
 Enumeration of the different types of widgets. More...
 

Detailed Description

Button class.

This class inherits of pWidget class. Button recive click events.

Usage example:

pButton button(5, 5, 150, 50);
gui.addWidget( &button );
// In event loop
if( button.widgetEvent == pWidget::WidgetClicked )
// button was clicked -> put your code here :)

Constructor & Destructor Documentation

pButton::pButton ( float  x,
float  y,
float  width,
float  height 
)

Default constructor.

Parameters
x
y
width
height

Member Function Documentation

sf::String pButton::getText ( )

Get the text of buttonLabel.

Returns
sf::String : fullString from buttonLabel
See Also
pText
void pButton::setColors ( sf::Color  borderColor,
sf::Color  fillColor,
sf::Color  hoverColor,
sf::Color  clickedColor 
)

Set button colors.

Parameters
borderColor
fillColor
hoverColor
clickedColor
void pButton::setText ( sf::String &  text)

Set new string on buttonLabel.

Parameters
text
void pButton::updateWidget ( )
virtual

Update widget. Every widget have own impementation of this function, because some widgets have more elements to draw.

Implements pWidget.


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