#include <Pt/Gui/Button.h>

Public Member Functions | |
| Button (Widget &parent, const Math::Point &at=Math::Point(0, 0), const Math::Size &size=Math::Size(0, 0), const Pt::String &text=Pt::String()) | |
| Constructor for the Button widget. | |
| ~Button () | |
| Empty destructor for the button widget. | |
| void | setText (const Pt::String &text) |
| Sets the button's text which is displayed centered inside the button. | |
| const Pt::String & | text () const |
| Returns the current text of this button. | |
| virtual void | update () |
| Updates the presentation of this button. | |
| virtual Math::Size | minimumSize () |
| Calculates and returns the minimum size of this widget. | |
| virtual Math::Size | preferredSize () |
| Calculates and returns the preferred size of this widget. | |
Public Attributes | |
| Signal | clicked |
| A signal that notifies the registered slots when this button was clicked by the user. | |
Protected Member Functions | |
| virtual void | _resizeEvent (const ResizeEvent &event) |
| Internal resize event handle method. | |
| virtual void | _mouseEvent (const MouseEvent &event) |
| Internal mouse event handle method. | |
| virtual void | _paintEvent (const PaintEvent &event) |
| Internal repaint event handle method. | |
| virtual void | _mouseMoveEvent (const MouseMoveEvent &event) |
| Internal move event handle method. | |
Protected Attributes | |
| bool | _pressed |
This Button class provides the 'clicked'-Signal for that matter. A Slot can be connected to this Signal and will be executed whenever the button was clicked.
A typical button's presentation is a rectangle, wider than it is tall, with a descriptive text in its center. This text can be set using the constructor of this class or by calling setTex().
A button usually has three visual states: pressed, not pressed and disabled.
A foreground and a background color can be set for a button. The foreground color is used as color for the label's text. The background color is used for the button's interior except for the border drawing. The default background color is a gray shade.
A default cancel button
| Button | ( | Widget & | parent, | |
| const Math::Point & | at = Math::Point(0, 0), |
|||
| const Math::Size & | size = Math::Size(0, 0), |
|||
| const Pt::String & | text = Pt::String() | |||
| ) |
A button widget is created. The given parent is set as parent of this button and the button is added to the parent's children list. The button is positioned at the given location using the given size. An optional text can be passed as an argument. This text will be shown as button text. If no text is given, no text is shown.
| parent | The parent widget for this button. The button will become the child of this parent and be shown inside of it. To create a top-level widget 0 can be passed as an argument. | |
| at | The position of this button inside its parent relative to the parent's top-left corner. | |
| size | The size of this button. The size must be >0 for width and height. | |
| text | The (optional) text of this button. |
| void setText | ( | const Pt::String & | text | ) |
When calling this method, the presentation of the button is updated automatically. No re-layout is done, though.
| text | The new text for this button. |
| const Pt::String& text | ( | ) | const |
| virtual void update | ( | ) | [virtual] |
It does a complete repaint including the background, the border and the text of the button.
Reimplemented from Widget.
| virtual Math::Size minimumSize | ( | ) | [virtual] |
When resizing a widget the new size should not be smaller than the minimum size returned by this method. The minimum size specifies the size at which the widget can still be shown normally without major graphical glitches.
A call to resize() does no check against the minimum size. The widget can be resized to a smaller size than is returned by minimumSize().
Reimplemented from Widget.
| virtual Math::Size preferredSize | ( | ) | [virtual] |
The preferred size specifies the size at which the presentation of the widget is optimal. The preferred size depends on the widget, on its content, its insets and its presentation. The preferred size of the Button, for example, depends on the length of the button's text, its font size, the spacing of the text to the border (=insets) and the border width itself.
The optimal presentation concerning all those attributes contribute to the preferred size.
Reimplemented from Widget.