GUIFramework 1.1.0
Framework for desktop GUI applications in C++.
Loading...
Searching...
No Matches
ChildWindowDeserializer.cpp
Go to the documentation of this file.
2
4#include "GUIFramework.h"
6
7using namespace std;
8
9namespace gui_framework
10{
11 namespace deserializers
12 {
13 BaseComponent* ChildWindowDeserializer::deserialize(const string& componentName, const json::utility::jsonObject& description, BaseComposite* parent) const
14 {
15 using json::utility::jsonObject;
16
18
19 parser.parse(description);
20
21 ChildWindow* result = nullptr;
22 uint32_t codepage = interfaces::ISerializable::getCodepage();
25
26 result = static_cast<ChildWindow*>(creator->create(utility::to_wstring(componentName, codepage), parser.settings, creationData.getData(), parent));
27
28 result->setBackgroundColor(parser.backgroundColor[0], parser.backgroundColor[1], parser.backgroundColor[2]);
29
30 result->setTextColor(parser.textColor[0], parser.textColor[1], parser.textColor[2]);
31
32 result->setExitMode(parser.mode);
33
34 if (parser.onDestroyFunctionName.size())
35 {
37 }
38
39 if (description.contains("children", json::utility::variantTypeEnum::jJSONArray))
40 {
41 const auto& children = description.getArray("children");
42
43 for (const auto& i : children)
44 {
45 const auto& [componentName, data] = get<jsonObject>(i.data.front().second).data.front();
46 const auto& description = get<jsonObject>(data);
47
48 const smartPointerType<interfaces::IDeserializer>& deserializer = GUIFramework::get().getDeserializers().at(description.getUnsignedInt("hash"));
49
50 deserializer->deserialize(componentName, description, result);
51 }
52 }
53
54 return result;
55 }
56 }
57}
std::unique_ptr< T > smartPointerType
Compatible smart pointer type.
Base class for all windows, controls, etc.
virtual void setTextColor(uint8_t red, uint8_t green, uint8_t blue)
Base class for all windows that has children windows.
void setOnDestroy(const std::function< void()> &onDestroy)
void setExitMode(exitMode mode)
virtual void setBackgroundColor(uint8_t red, uint8_t green, uint8_t blue) final override
Standard child window.
Definition ChildWindow.h:12
const std::unordered_map< size_t, smartPointerType< utility::BaseComponentCreator > > & getCreators() const
Get all current registered creators.
const std::unordered_map< size_t, smartPointerType< interfaces::IDeserializer > > & getDeserializers() const
Get all current registered deserializers.
static GUIFramework & get()
Singleton instance access.
BaseComponent * deserialize(const std::string &componentName, const json::utility::jsonObject &description, BaseComposite *parent) const override
Created component pointer already handled by its parent.
Base templated class for component creators.
wstring to_wstring(const string &stringToConvert, uint32_t codepage)
Definition Utility.cpp:82
virtual void parse(const json::utility::jsonObject &description) override