GUIFramework 1.1.0
Framework for desktop GUI applications in C++.
Loading...
Searching...
No Matches
DialogBox.cpp
Go to the documentation of this file.
1#include "DialogBox.h"
2
3#include "GUIFramework.h"
4
5using namespace std;
6
7namespace gui_framework
8{
10
11 DialogBoxBuilder::DialogBoxBuilder(const wstring& className, const wstring& dialogBoxName, int x, int y, const string& dialogBoxFunctionName, const string& moduleName, uint16_t smallIconResource, uint16_t largeIconResource) :
12 settings
13 (
14 x,
15 y,
16 standard_sizes::dialogBoxBuilderMinWidth,
17 standard_sizes::dialogBoxBuilderMinHeight
18 ),
19 className(className),
20 dialogBoxName(dialogBoxName),
21 functionName(dialogBoxFunctionName),
22 moduleName(moduleName),
23 smallIconResource(smallIconResource),
24 largeIconResource(largeIconResource)
25 {
26
27 }
28
30 {
31 (*this) = DialogBoxBuilder(className, dialogBoxName, settings.x, settings.y, functionName);
32
33 return *this;
34 }
35
37 {
38 DialogBox* result = new DialogBox(className, dialogBoxName, settings, functionName, moduleName, smallIconResource, largeIconResource);
39 GUIFramework& reference = GUIFramework::get();
40 uint16_t currentTopOffset = 0;
41
42 for (const builderComponentData& i : components)
43 {
44 currentTopOffset += static_cast<uint16_t>(i.offsets.top);
45 int xPosition = 0;
46
47 switch (i.type)
48 {
50 xPosition = i.offsets.left;
51
52 break;
54 xPosition = (settings.width - i.settings.width) / 2;
55
56 break;
58 xPosition = settings.width - i.settings.width - i.offsets.right;
59
60 break;
61 }
62
63 const_cast<builderComponentData&>(i).settings.x = xPosition;
64 const_cast<builderComponentData&>(i).settings.y = currentTopOffset;
65
66 reference.getCreators().at(i.typeHash)->create
67 (
68 i.componentName,
69 i.settings,
70 i.additionalData,
71 result
72 );
73
74 currentTopOffset += static_cast<uint16_t>(i.settings.height + i.offsets.bottom);
75 }
76
77 return result;
78 }
79
80 DialogBoxBuilder::builderComponentData::builderComponentData(const wstring& componentName, const interfaces::IStyles& styles, RECT&& offsets, size_t typeHash, uint16_t width, uint16_t height, alignment type, any&& additionalData) :
81 componentName(componentName),
82 offsets(move(offsets)),
83 typeHash(typeHash),
84 type(type),
85 additionalData(move(additionalData))
86 {
87 settings.width = width;
88 settings.height = height;
89 settings.styles = styles;
90 }
91
93
94 DialogBox::DialogBox(const wstring& className, const wstring& dialogBoxName, const utility::ComponentSettings& settings, const string& dialogBoxFunctionName, const string& moduleName, uint16_t smallIconResource, uint16_t largeIconResource) :
96 (
98 dialogBoxName,
99 settings,
100 dialogBoxFunctionName,
101 moduleName,
102 smallIconResource,
103 largeIconResource
104 ),
106 (
107 handle
108 )
109 {
110
111 }
112
113 size_t DialogBox::getHash() const
114 {
115 return typeid(DialogBox).hash_code();
116 }
117}
const std::wstring className
Base class for all dialog boxes.
DialogBoxBuilder(const std::wstring &className, const std::wstring &dialogBoxName, int x, int y, const std::string &dialogBoxFunctionName, const std::string &moduleName="", uint16_t smallIconResource=NULL, uint16_t largeIconResource=NULL)
Definition DialogBox.cpp:11
Standard dialog box.
Definition DialogBox.h:15
DialogBox(const std::wstring &className, const std::wstring &dialogBoxName, const utility::ComponentSettings &settings, const std::string &dialogBoxFunctionName="", const std::string &moduleName="", uint16_t smallIconResource=NULL, uint16_t largeIconResource=NULL)
Definition DialogBox.cpp:94
size_t getHash() const override
Used as key in creators.
Singleton with GUIFramework settings and some functionality.
const std::unordered_map< size_t, smartPointerType< utility::BaseComponentCreator > > & getCreators() const
Get all current registered creators.
static GUIFramework & get()
Singleton instance access.
Provides styles for other classes.
Definition IStyles.h:11
DialogBox::DialogBoxBuilder DialogBoxBuilder
Definition DialogBox.cpp:9