SimpleButton class reference
Basic interactive widget - displays a button that reacts to mouse clicks. It has two forms - it can
be displayed as a rectangular area of a given color or as a picture.
SimpleButton button(window, {{0,0}, {100, 30}}, theme, "Btn", &image);
...or...
SimpleButton button(window, {{0,0}, {100, 30}}, theme, "Btn");
Functions
Functions documentation
SimpleButton
(
Window
* window, const
Widget2DProps
& props =
Widget2DProps
({ 0,0 }, { 0,0 },
Anchor
::Left |
Anchor
::Bottom |
ResizePolicy
::AutoFill), const
SimpleButtonTheme
& buttonTheme =
SimpleButtonTheme
(), std::wstring btnText = L"",
Texture
* imageTex = nullptr );
Default constructor.
SimpleButton
(
Window
* window, const
Widget2DProps
& props =
Widget2DProps
({ 0,0 }, { 0,0 },
Anchor
::Left |
Anchor
::Bottom |
ResizePolicy
::AutoFill), const
Theme
& theme =
Theme
(), std::wstring btnText = L"",
Texture
* imageTex = nullptr );
Delegating constructor with theme application.
SimpleButton
(const
SimpleButton
& copy);
Copy constructor.
virtual ~
SimpleButton
();
Destructor.
SimpleButton
& operator=(
SimpleButton
rhs);
Assignment operator.
friend void swap<>(
SimpleButton
<T>& first,
SimpleButton
<T>& second) noexcept;
Swap function.
SimpleButton
* Clone() const override;
Clones the object (usefull while making copy of object that is casted to its base).
void SetCallback(Callback function);
Sets a callback that is executed every time an event is processed (inside button object).
void ResetCallback();
Resets the callback to nullptr.
WidgetMouseState
GetState();
Returns the current status of the widget (useful when using the pooling technique).
bool GetDragInfo();
Returns information whether the user drags the mouse over the button.
void SetColor(
WidgetMouseState
forState,
Color
color);
Sets the background color for a given widget state.
Sets the background color for all widget states.
void SetBorderColor(
WidgetMouseState
forState,
Color
color);
Sets the border color for a given widget state.
Sets the border color for all widget states.
void SetBoderSize(
Dimension
<int> newBorderSize);
Sets the widget border size.
void SetFontSize(int newSize);
Sets the font size for the button.
void SetText(std::wstring newText);
Sets the button text.
void SetFont(
Font
* newFont);
Sets the new font for the button.
void SetFontColor(
Color
newColor);
Sets the font color for all widget states.
void SetState(
WidgetMouseState
state);
Sets new button state (WidgetMouseState).
void SetFlags(int newFlags) override;
Sets the widget flags.
void Resize(
Dimension
<size_t> newDim);
Changes the size of the button.
void SetBypassEventReturn(bool mode);
Sets whether to delete events that have been handled by the widget or not.
void SetBypassMoveEvWhileDrag(bool mode);
Sets whether to callback MouseMove events when dragging or not. Usefull when implementing dragging mechanics.
void UnregisterEvent(
EventType
eventType) override;
Allows to unregister the widget from a specific event in the parent window.
Color
GetColor(
WidgetMouseState
forState) const;
Returns the background color for a given widget state.
Color
GetBorderColor(
WidgetMouseState
forState) const;
Returns the border color for a given widget state.
Dimension
<int> GetBoderSize() const;
Returns the border size of the widget.
int GetFontSize() const;
Returns font size used by widget to render text.
std::wstring GetText() const;
Returns the text displayed by the widget.
Color
GetFontColor() const;
Returns font color used by widget to render text.
Font
* GetUsedFont() const;
Returns pointer to the font object used by widget to render text.
void CalcAnchorOffsets();
Converts the location of the widget depending on the flags set (Anchor).
Variables documentation
int m_iTicks;
Internal widget counter.
bool m_bDrag;
Stores information whether the user drags the mouse over the button.
Point<int> m_AnchorOffsets;
Stores precalculated (depending on Anchor flags) offsets.
T* m_FrontWidget;
Stores pointer to the base/template widget object.
SimpleButtonTheme
m_BtnTheme;
Stores widget theme.
bool m_bBypassEventsReturn;
Stores information whether delete the processed event or not.
bool m_bEnableMoveEv;
Stores information whether callback on MouseMove event when dragging or not.
WidgetMouseState
m_State;
Stores widet state. (depends on mouse actions)
std::list<BindListIterator> m_Bindings;
Stores additional internal bindings to the parent window.
Callback m_Callback;
Stores callback function.