GUIFramework 1.1.0
Framework for desktop GUI applications in C++.
Loading...
Searching...
No Matches
BaseComponent.h
Go to the documentation of this file.
1#pragma once
2
3#include "Core.h"
4#include "Utility/Utility.h"
10
11namespace gui_framework
12{
13 class BaseComposite;
14
17 {
18 public:
22 static void runFunctionAsync(const std::function<void()>& callable, const std::function<void()>& callback = nullptr) noexcept;
23
27 static void runFunctionAsync(std::function<void()>&& callable, const std::function<void()>& callback = nullptr) noexcept;
28
29 protected:
31 const std::wstring className;
32 const std::wstring windowName;
33 HWND handle;
34 uint16_t desiredWidth;
35 uint16_t desiredHeight;
36 int desiredX;
37 int desiredY;
38 uint32_t id;
39 COLORREF backgroundColor;
40 COLORREF textColor;
41 smartPointerType<interfaces::IStyles> styles;
42
43 protected:
44 virtual LRESULT preWindowMessagesHandle(HWND handle, UINT message, WPARAM wparam, LPARAM lparam, bool& isUsed);
45
46 virtual LRESULT windowMessagesHandle(HWND handle, UINT message, WPARAM wparam, LPARAM lparam, bool& isUsed);
47
48 protected:
53 virtual void setLocalizationKeys(interfaces::ITextLocalized* localized, const std::vector<std::string>& localizationKeys);
54
55 public:
61 BaseComponent(std::wstring_view className, std::wstring_view windowName, const utility::ComponentSettings& settings, const interfaces::IStyles& styles, BaseComposite* parent = nullptr, std::string_view windowFunctionName = "", std::string_view moduleName = "", uint16_t smallIconResource = NULL, uint16_t largeIconResource = NULL);
62
63 LRESULT handleMessages(HWND handle, UINT message, WPARAM wparam, LPARAM lparam, bool& isUsed);
64
65 bool destroyComponent();
66
67 bool asyncDestroyComponent();
68
69 void enable();
70
71 void disable();
72
73 bool isEnabled() const;
74
75 bool isDisabled() const;
76
84 LRESULT sendRawMessage(UINT message, WPARAM wparam, LPARAM lparam);
85
86 void setDesiredWidth(uint16_t desiredWidth);
87
88 void setDesiredHeight(uint16_t desiredHeight);
89
90 void setDesiredX(int desiredX);
91
92 void setDesiredY(int desiredY);
93
94 virtual void setBackgroundColor(uint8_t red, uint8_t green, uint8_t blue);
95
96 virtual void setTextColor(uint8_t red, uint8_t green, uint8_t blue);
97
98 BaseComponent* getParent() const;
99
100 HWND getHandle() const;
101
102 std::wstring_view getWindowName() const;
103
104 std::wstring_view getClassName() const;
105
106 uint16_t getDesiredWidth() const;
107
108 uint16_t getDesiredHeight() const;
109
110 uint16_t getActualWidth() const;
111
112 uint16_t getActualHeight() const;
113
114 RECT getActualCoordinates() const;
115
116 int getDesiredX() const;
117
118 int getDesiredY() const;
119
122 uint32_t getId() const;
123
124 COLORREF getBackgroundColor() const;
125
126 COLORREF getTextColor() const;
127
128 const smartPointerType<interfaces::IStyles>& getStyles() const;
129
132 virtual size_t getHash() const = 0;
133
134 virtual json::JSONBuilder getStructure() const override;
135
136 virtual ~BaseComponent();
137
138 friend class BaseComposite;
139 };
140}
#define GUI_FRAMEWORK_API
std::unique_ptr< T > smartPointerType
Compatible smart pointer type.
Base class for all windows, controls, etc.
static void runFunctionAsync(const std::function< void()> &callable, const std::function< void()> &callback=nullptr) noexcept
Add task to thread pool.
Base class for all windows that has children windows.
Provides interface for serializable to JSON format.