#include <button.hpp>
Inheritance diagram for gcn::Button:
Add an ActionListener to it to know when it has been clicked.
NOTE: You can only have text (a caption) on the button. If you want it to handle, for instance images, you can implement an ImageButton of your own and overload member functions from Button.
Definition at line 73 of file button.hpp.
Public Member Functions | |
Button () | |
Constructor. | |
Button (const std::string &caption) | |
Constructor. | |
virtual void | setCaption (const std::string &caption) |
Sets the Button caption. | |
virtual const std::string & | getCaption () const |
Gets the Button caption. | |
virtual void | setAlignment (unsigned int alignment) |
Sets the alignment for the caption. | |
virtual unsigned int | getAlignment () const |
Gets the alignment for the caption. | |
virtual void | adjustSize () |
Adjusts the buttons size to fit the content. | |
virtual bool | isPressed () const |
Checks if the button is pressed down. | |
virtual void | draw (Graphics *graphics) |
Draws the Widget. | |
virtual void | drawBorder (Graphics *graphics) |
Draws a the Widget border. | |
virtual void | lostFocus () |
Called if the Widget looses focus. | |
virtual void | mouseClick (int x, int y, int button, int count) |
Called when a mouse button is pressed and released (clicked) when the mouse is in the Widget area or if the Widget has focus. | |
virtual void | mousePress (int x, int y, int button) |
Called when a mouse button is pressed when the mouse is in the Widget area or if the Widget has focus. | |
virtual void | mouseRelease (int x, int y, int button) |
Called when a mouse button is released when the mouse is in the Widget area or if the Widget has focus. | |
virtual void | keyPress (const Key &key) |
Called if a key is pressed when the widget has keyboard focus. | |
virtual void | keyRelease (const Key &key) |
Called if a key is released when the widget has keyboard focus. | |
Protected Attributes | |
std::string | mCaption |
bool | mMouseDown |
bool | mKeyDown |
unsigned int | mAlignment |
|
Constructor.
Definition at line 74 of file button.cpp. References gcn::Widget::addKeyListener(), gcn::Widget::addMouseListener(), adjustSize(), gcn::Widget::setBorderSize(), and gcn::Widget::setFocusable(). |
|
Draws the Widget. It is called by the parent widget when it is time for the Widget to draw itself. The graphics object is set up so that all drawing is relative to the Widget, i.e coordinate (0,0) is the top-left corner of the Widget. It is not possible to draw outside of a Widgets dimension.
Implements gcn::Widget. Definition at line 109 of file button.cpp. References gcn::Color::a, getAlignment(), gcn::Widget::getBaseColor(), getCaption(), gcn::Widget::getDimension(), gcn::Widget::getFont(), gcn::Widget::getForegroundColor(), gcn::Font::getHeight(), gcn::Widget::getHeight(), gcn::Widget::getWidth(), gcn::Widget::hasFocus(), and isPressed(). |
|
Draws a the Widget border. A border is drawn around a Widget. The width and height of the border is therefore the Widgets height+2*bordersize. Think of a painting that has a certain size, the border surrounds the painting.
Reimplemented from gcn::Widget. Definition at line 181 of file button.cpp. References gcn::Color::a, gcn::Widget::getBaseColor(), gcn::Widget::getBorderSize(), gcn::Widget::getHeight(), and gcn::Widget::getWidth(). |
|
Gets the alignment for the caption.
Definition at line 104 of file button.cpp. Referenced by draw(). |
|
Gets the Button caption.
Definition at line 94 of file button.cpp. Referenced by draw(). |
|
Checks if the button is pressed down. Useful when drawing.
Definition at line 211 of file button.cpp. References gcn::Widget::hasMouse(). Referenced by draw(). |
|
Called if a key is pressed when the widget has keyboard focus. If a key is held down the widget will generate multiple key presses.
Reimplemented from gcn::KeyListener. Definition at line 240 of file button.cpp. |
|
Called if a key is released when the widget has keyboard focus.
Reimplemented from gcn::KeyListener. Definition at line 250 of file button.cpp. References gcn::Widget::generateAction(). |
|
Called when a mouse button is pressed and released (clicked) when the mouse is in the Widget area or if the Widget has focus.
Reimplemented from gcn::MouseListener. Definition at line 216 of file button.cpp. References gcn::Widget::generateAction(). |
|
Called when a mouse button is pressed when the mouse is in the Widget area or if the Widget has focus. NOTE: A mouse press is NOT equal to a mouse click. Use mouseClickMessage to check for mouse clicks.
Reimplemented from gcn::MouseListener. Definition at line 224 of file button.cpp. References gcn::Widget::hasMouse(). |
|
Called when a mouse button is released when the mouse is in the Widget area or if the Widget has focus.
Reimplemented from gcn::MouseListener. Definition at line 232 of file button.cpp. |
|
Sets the alignment for the caption.
Definition at line 99 of file button.cpp. |
|
Sets the Button caption.
Definition at line 89 of file button.cpp. |