GUIFramework 1.1.0
Framework for desktop GUI applications in C++.
Loading...
Searching...
No Matches
ImageButtonDeserializer.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* ImageButtonDeserializer::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 ImageButton* result = nullptr;
22 uint32_t codepage = interfaces::ISerializable::getCodepage();
24 unique_ptr<utility::AdditionalCreationData<ImageButton>> creationData;
25
26 if (parser.pathToImage.empty())
27 {
28 creationData = make_unique<utility::AdditionalCreationData<ImageButton>>(parser.text, parser.pathToImage, parser.imageWidth, parser.imageHeight, parser.dType, parser.iType, parser.onClickFunctionName, parser.onClickFunctionModule);
29 }
30 else
31 {
32 creationData = make_unique<utility::AdditionalCreationData<ImageButton>>(parser.text, parser.imageResource, parser.resourceModuleName, parser.imageWidth, parser.imageHeight, parser.dType, parser.iType, parser.onClickFunctionName, parser.onClickFunctionModule);
33 }
34
35 result = static_cast<ImageButton*>(creator->create(utility::to_wstring(componentName, codepage), parser.settings, creationData->getData(), parent));
36
37 result->setBackgroundColor(parser.backgroundColor[0], parser.backgroundColor[1], parser.backgroundColor[2]);
38
39 return result;
40 }
41 }
42}
std::unique_ptr< T > smartPointerType
Compatible smart pointer type.
Base class for all windows, controls, etc.
virtual void setBackgroundColor(uint8_t red, uint8_t green, uint8_t blue)
Base class for all windows that has children windows.
const std::unordered_map< size_t, smartPointerType< utility::BaseComponentCreator > > & getCreators() const
Get all current registered creators.
static GUIFramework & get()
Singleton instance access.
Button with image.
Definition ImageButton.h:12
BaseComponent * deserialize(const std::string &componentName, const json::utility::jsonObject &description, BaseComposite *parent) const override
Created component pointer already handled by its parent.
wstring to_wstring(const string &stringToConvert, uint32_t codepage)
Definition Utility.cpp:82
Parse ImageButton specific properties.
void parse(const json::utility::jsonObject &description) override