GUIFramework 1.1.0
Framework for desktop GUI applications in C++.
Loading...
Searching...
No Matches
BaseComponentParser.cpp
Go to the documentation of this file.
2
3#include "Utility/Utility.h"
6
7using namespace std;
8
9namespace gui_framework
10{
11 namespace parsers
12 {
14 backgroundColor{ 255, 255, 255 },
15 textColor{ 0, 0, 0 }
16 {
17
18 }
19
20 void BaseComponentParser::parse(const json::utility::jsonObject& description)
21 {
22 using json::utility::jsonObject;
23
24 uint32_t codepage = interfaces::ISerializable::getCodepage();
25
26 className = utility::to_wstring(description.getString("className"), CP_UTF8);
27 settings.x = static_cast<int>(description.getInt("desiredX"));
28 settings.y = static_cast<int>(description.getInt("desiredY"));
29 settings.width = static_cast<uint16_t>(description.getUnsignedInt("desiredWidth"));
30 settings.height = static_cast<uint16_t>(description.getUnsignedInt("desiredHeight"));
31 settings.styles = interfaces::IStyles(description.getInt("styles"), description.getInt("extendedStyles"));
32
33 const vector<int64_t>& temBackgroundColor = json::utility::JSONArrayWrapper(description.getArray("backgroundColor")).getAsInt64_tArray();
34 const vector<int64_t>& temTextColor = json::utility::JSONArrayWrapper(description.getArray("textColor")).getAsInt64_tArray();
35
36 try
37 {
38 const vector<string>& temLocalizationKeys = json::utility::JSONArrayWrapper(description.getArray("localizationKeys")).getAsStringArray();
39
40 ranges::copy(temLocalizationKeys, back_inserter(settings.localizationKeys));
41 }
42 catch (const json::exceptions::CantFindValueException&)
43 {
44
45 }
46
47 for (size_t i = 0; i < temBackgroundColor.size(); i++)
48 {
49 backgroundColor[i] = static_cast<uint8_t>(temBackgroundColor[i]);
50 }
51
52 for (size_t i = 0; i < temTextColor.size(); i++)
53 {
54 textColor[i] = static_cast<uint8_t>(temTextColor[i]);
55 }
56 }
57 }
58}
Provides styles for other classes.
Definition IStyles.h:11
wstring to_wstring(const string &stringToConvert, uint32_t codepage)
Definition Utility.cpp:82
virtual void parse(const json::utility::jsonObject &description)
std::vector< std::string > localizationKeys