15 if (message >= WM_CTLCOLOREDIT && message <= WM_CTLCOLORSTATIC)
25 SetTextColor(
reinterpret_cast<HDC
>(wparam), component->
getTextColor());
30 else if (message == WM_MENUCOMMAND)
34 if (
mainMenu->getHandle() ==
reinterpret_cast<HMENU
>(lparam))
36 mainMenu->handleMessage(
static_cast<uint32_t
>(wparam));
40 popupMenus[
reinterpret_cast<HMENU
>(lparam)].handleMessage(
static_cast<uint32_t
>(wparam));
74 result = i->windowMessagesHandle(
handle, message, wparam, lparam, isUsed);
91 if (message == WM_SIZE)
102 uint16_t width = LOWORD(lparam);
103 uint16_t height = HIWORD(lparam);
105 for (
const auto& i : childrenToResize)
111 resizable->
resize(width, height);
123 vector<pair<string, json::utility::jsonObject>> BaseComposite::getChildrenStructure()
const
125 vector<json::JSONBuilder> childrenStructure;
126 vector<pair<string, json::utility::jsonObject>> data;
128 childrenStructure.reserve(
children.size());
130 ranges::for_each(
children, [&childrenStructure](
const unique_ptr<BaseComponent>& child) { childrenStructure.push_back(child->getStructure()); });
132 for (
size_t i = 0; i <
children.size(); i++)
136 auto& childStructure = get<json::utility::jsonObject>(childrenStructure[i][childWindowName]);
138 data.push_back({ move(childWindowName), move(childStructure) });
144 void BaseComposite::addChild(BaseComponent* child)
146 children.push_back(unique_ptr<BaseComponent>(child));
149 void BaseComposite::setExitCode(
int exitCode)
167 windowFunctionName(windowFunctionName),
179 if (it->get() == child)
192 erase_if(
children, [&componentName](
const unique_ptr<BaseComponent>& child) {
return child->getWindowName() == componentName; });
197 for (
const unique_ptr<BaseComponent>& component :
children)
201 return component.get();
217 for (
const unique_ptr<BaseComponent>& component :
children)
219 if (component->getHandle() ==
handle)
221 return component.get();
237 vector<BaseComponent*> result;
239 for (
const unique_ptr<BaseComponent>& component :
children)
243 result.push_back(component.get());
247 vector<BaseComponent*> subChildren = composite->findChildren(
windowName);
249 ranges::copy(subChildren, back_inserter(result));
267 Menu menu(menuName,
nullptr);
276 vector<HMENU> itemsToRemove;
280 if (popupMenu.getName() == menuName)
282 itemsToRemove.push_back(
handle);
286 for (
const auto& i : itemsToRemove)
350 vector<const Menu*> result;
356 result.push_back(&popupMenu);
391 SetClassLongPtrW(
handle, GCLP_HBRBACKGROUND,
reinterpret_cast<LONG_PTR
>(CreateSolidBrush(
backgroundColor)));
393 InvalidateRect(
handle,
nullptr,
true);
398 using json::utility::jsonObject;
401 vector<pair<string, jsonObject>> data = this->getChildrenStructure();
407 current.data.push_back({
"exitMode"s,
static_cast<int64_t
>(
mode) });
417 jsonObject menuStructure;
418 json::JSONBuilder mainMenuBuilder =
mainMenu->getStructure();
419 vector<jsonObject> popupItems;
421 menuStructure.data.push_back({
"mainMenuName"s, get<string>(mainMenuBuilder[
"menuName"]) });
423 menuStructure.data.push_back({
"mainMenuItems"s, move(mainMenuBuilder[
"items"]) });
425 for (
const auto& [menuHandle, menu] :
popupMenus)
428 json::JSONBuilder temBuilder = menu.getStructure();
430 tem.data.push_back({
"menuName"s, get<string>(temBuilder[
"menuName"]) });
431 tem.data.push_back({
"menuId"s, get<uint64_t>(temBuilder[
"menuId"]) });
432 tem.data.push_back({
"items"s, move(temBuilder[
"items"]) });
434 json::utility::appendArray(move(tem), popupItems);
437 menuStructure.data.push_back({
"popupItems"s, move(popupItems) });
439 current.data.push_back(make_pair(
"menuStructure"s, move(menuStructure)));
444 vector<jsonObject>& childrenStructures = get<vector<jsonObject>>(current.data.emplace_back(make_pair(
"children"s, vector<jsonObject>())).second);
451 tem.data.push_back(move(i));
453 topLevel.data.push_back({
""s, move(tem) });
455 childrenStructures.push_back(move(topLevel));
459 if (!builder.contains(
"hotkeys", json::utility::variantTypeEnum::jJSONObject) && instance.
getRegisteredHotkeys().size())
469 vector<BaseComponent*> components;
471 ranges::for_each(
children, [&components](
const unique_ptr<BaseComponent>& component) { components.push_back(component.get()); });
Base class for all windows, controls, etc.
std::wstring_view getWindowName() const
virtual LRESULT windowMessagesHandle(HWND handle, UINT message, WPARAM wparam, LPARAM lparam, bool &isUsed)
COLORREF getTextColor() const
virtual json::JSONBuilder getStructure() const override
friend class BaseComposite
const std::wstring windowName
COLORREF getBackgroundColor() const
virtual void setBackgroundColor(uint8_t red, uint8_t green, uint8_t blue)
Base class for all windows that has children windows.
std::unique_ptr< Menu > mainMenu
virtual json::JSONBuilder getStructure() const override
virtual iterators::composite_const_forward_iterator cbegin() const noexcept override
const std::unique_ptr< Menu > & getMainMenu() const
void setOnDestroy(const std::function< void()> &onDestroy)
exitMode getExitMode() const
virtual iterators::composite_forward_iterator end() noexcept override
virtual iterators::composite_forward_iterator begin() noexcept override
LRESULT windowMessagesHandle(HWND handle, UINT message, WPARAM wparam, LPARAM lparam, bool &isUsed) override
BaseComponent * findChild(const std::wstring &windowName) const
std::string onDestroyFunctionModuleName
virtual LRESULT compositeWindowMessagesHandle(HWND handle, UINT message, WPARAM wparam, LPARAM lparam, bool &isUsed)
std::unordered_map< HMENU, Menu > popupMenus
virtual void setBackgroundColor(uint8_t red, uint8_t green, uint8_t blue) override
void setExitMode(exitMode mode)
virtual std::unique_ptr< Menu > & createMainMenu(const std::wstring &menuName)
It needs to be called once.
std::vector< std::unique_ptr< BaseComponent > > children
void removeComponents(const std::wstring &componentName)
virtual LRESULT preWindowMessagesHandle(HWND handle, UINT message, WPARAM wparam, LPARAM lparam, bool &isUsed) override
virtual iterators::composite_const_forward_iterator cend() const noexcept override
virtual Menu & addPopupMenu(const std::wstring &menuName)
Don't call move operator with return value.
virtual void removePopupMenus(const std::wstring &menuName)
Remove all pop-up menus with menuName.
void removeChild(BaseComponent *child)
std::vector< const Menu * > getPopupMenus() const
std::string onDestroyFunctionName
const std::vector< std::unique_ptr< BaseComponent > > & getChildren() const
const std::function< void()> & getOnDestroy() const
std::vector< BaseComponent * > findChildren(const std::wstring &windowName) const
friend class BaseComponent
std::string windowFunctionName
std::function< void()> onDestroy
Singleton with GUIFramework settings and some functionality.
std::vector< json::utility::jsonObject > serializeHotkeys()
Serialize hotkeys.
std::vector< hotkeyData > getRegisteredHotkeys()
Thread safe get hotkeys.
static GUIFramework & get()
Singleton instance access.
Provides resize, setBlockResize, getBlockResize methods.
virtual void resize(uint16_t width, uint16_t height)
Resize component.
virtual bool getBlockResize() const final
static uint32_t getCodepage()
Provides styles for other classes.
IBaseConstForwardIterator implementation for BaseComponent.
IBaseForwardIterator implementation for BaseComponent.
constexpr uint32_t deinitTopLevelWindowPointer
Set to nullptr topLevelWindow for recreating window with same window class name.
string to_string(wstring_view stringToConvert, uint32_t codepage)
void(*)() onDestroySignature
Default on destroy signature. Called before window is destroyed.
All settings for windows.