GUIFramework 1.1.0
Framework for desktop GUI applications in C++.
Loading...
Searching...
No Matches
BaseButton.h
Go to the documentation of this file.
1#pragma once
2
7
8namespace gui_framework
9{
13 public BaseComponent,
15 {
16 public:
17 inline static constexpr uint16_t buttonWidth = 200;
18 inline static constexpr uint16_t buttonHeight = 20;
19
20 protected:
21 std::function<void()> onClick;
22 std::string functionName;
23 std::string moduleName;
24
25 protected:
26 virtual LRESULT windowMessagesHandle(HWND handle, UINT message, WPARAM wparam, LPARAM lparam, bool& isUsed) override;
27
28 virtual void updateLocalization(std::wstring_view localizedText) override;
29
30 public:
31 BaseButton(const std::wstring& buttonName, const std::wstring& buttonText, const utility::ComponentSettings& settings, const styles::ButtonStyles& styles, BaseComposite* parent, const std::function<void()>& onClick = nullptr);
32
36 BaseButton(const std::wstring& buttonName, const std::wstring& buttonText, const utility::ComponentSettings& settings, const styles::ButtonStyles& styles, BaseComposite* parent, const std::string& functionName, const std::string& moduleName);
37
40 void setOnClick(const std::function<void()>& onClick);
41
47 virtual void setOnClick(const std::string& functionName, const std::string& moduleName);
48
49 const std::function<void()>& getOnClick() const;
50
53 const std::string& getFunctionName() const;
54
57 const std::string& getModuleName() const;
58
64 virtual void setTextColor(uint8_t red, uint8_t green, uint8_t blue) final override;
65
68 virtual size_t getHash() const override = 0;
69
70 virtual json::JSONBuilder getStructure() const override;
71
72 virtual void setText(std::string_view localizationKey) final override;
73
74 virtual ~BaseButton() = default;
75
76 using interfaces::ITextOperations::setText;
77 };
78}
#define GUI_FRAMEWORK_API
Base class for all buttons.
Definition BaseButton.h:15
virtual void setOnClick(const std::string &functionName, const std::string &moduleName)
Load function from module. Can be seriazlied.
void setOnClick(const std::function< void()> &onClick)
Can't serialize.
virtual ~BaseButton()=default
BaseButton(const std::wstring &buttonName, const std::wstring &buttonText, const utility::ComponentSettings &settings, const styles::ButtonStyles &styles, BaseComposite *parent, const std::function< void()> &onClick=nullptr)
virtual size_t getHash() const override=0
Used as key in creators.
BaseButton(const std::wstring &buttonName, const std::wstring &buttonText, const utility::ComponentSettings &settings, const styles::ButtonStyles &styles, BaseComposite *parent, const std::string &functionName, const std::string &moduleName)
std::function< void()> onClick
Definition BaseButton.h:21
Base class for all windows, controls, etc.
Base class for all windows that has children windows.
Change localization of buttons, edit controls, etc.
Provides setText and getText methods.
Base class for button styles.