SavvyUI C++ UI Library
Loading...
Searching...
No Matches
Button.h
Go to the documentation of this file.
1#pragma once
2
3#include "Component.h"
4
12class Button : public Component
13{
14 wstring _text;
15 ButtonType _buttonType;
16 BOOL _isLink;
17 BOOL _showShadow;
18 COLORREF _bkColor;
19 COLORREF _fgColor;
20 BOOL _isClicked;
21 IconSource _iconSource;
22 Direction _iconPosition;
23
24protected:
34 BOOL getCreateWindowOptions(wstring& title, UINT& widownStyles, wstring& wndClassName, BOOL& isCustomWndProc);
35
40
41public:
46
50 virtual ~Button();
51
57 void setText(const wstring& text);
58
59 void setHasShadow(BOOL hasShadow);
60
67 void setImage(const IconSource& iconSource, const Direction& imagePosition = Direction::LEFT);
68
74 void setButtonType(const ButtonType& buttonType,
75 COLORREF bkColor = Theme::ButtonBackgroundStartColor, /* Will only be used is btnType is set to ButtonType::CUSTOM */
76 COLORREF fgColor = Theme::ButtonForegroundColor /* Will only be used is btnType is set to ButtonType::CUSTOM */);
77
79
85 void onPaint(Graphics *g);
86
97 void onMousePressed(WinHandle hWnd, int x, int y, int clickCount, BOOL shiftPressed, BOOL ctrlPressed);
98
108 void onMouseReleased(WinHandle hWnd, int x, int y, BOOL shiftPressed, BOOL ctrlPressed);
109
119 void onMouseMoved(WinHandle hWnd, int x, int y, BOOL shiftPressed, BOOL ctrlPressed);
120
127};
Direction
Definition Common.h:114
@ LEFT
Definition Common.h:115
HWND WinHandle
Definition Common.h:16
ButtonType
Definition Common.h:151
Definition EventListeners.h:46
BOOL getCreateWindowOptions(wstring &title, UINT &widownStyles, wstring &wndClassName, BOOL &isCustomWndProc)
Prepares window creation options such as title, styles, and class name.
void onMouseReleased(WinHandle hWnd, int x, int y, BOOL shiftPressed, BOOL ctrlPressed)
Handles mouse release events on the button.
Button()
Constructs a Button object.
void onMouseMoved(WinHandle hWnd, int x, int y, BOOL shiftPressed, BOOL ctrlPressed)
Handles mouse move events over the button.
void setHasShadow(BOOL hasShadow)
void onPaint(Graphics *g)
Handles the painting of the button.
void windowCreated()
Called after the window has been created to perform any initialization.
void setLinkStyle()
virtual ~Button()
Destructs the Button object and cleans up resources.
void setButtonType(const ButtonType &buttonType, COLORREF bkColor=Theme::ButtonBackgroundStartColor, COLORREF fgColor=Theme::ButtonForegroundColor)
Sets the button type/style.
void addActionListener(ActionListener *l)
Adds an action listener to the button to handle action events.
void setText(const wstring &text)
Sets the text displayed on the button.
void onMousePressed(WinHandle hWnd, int x, int y, int clickCount, BOOL shiftPressed, BOOL ctrlPressed)
Handles mouse press events on the button.
void setImage(const IconSource &iconSource, const Direction &imagePosition=Direction::LEFT)
Sets the image file displayed on the button and the image position.
Component()
Constructs a new Component instance.
Definition Graphics.h:161
Definition Graphics.h:115
static COLORREF ButtonForegroundColor
Definition Theme.h:115
static COLORREF ButtonBackgroundStartColor
Definition Theme.h:113