GUIFramework 1.1.0
Framework for desktop GUI applications in C++.
Loading...
Searching...
No Matches
GroupBox.cpp
Go to the documentation of this file.
1#include "GroupBox.h"
2
4#include "GUIFramework.h"
5
7
8using namespace std;
9
10namespace gui_framework
11{
12 GroupBox::RadioButton::RadioButton(const wstring& radioButtonName, const wstring& radioButtonText, const utility::ComponentSettings& settings, BaseComposite* parent, const function<void()>& onClick) :
13 BaseButton
14 (
15 radioButtonName,
16 radioButtonText,
17 settings,
18 styles::RadioButtonStyles(),
19 parent,
20 onClick
21 )
22 {
23
24 }
25
26 GroupBox::RadioButton::RadioButton(const wstring& radioButtonName, const wstring& radioButtonText, const utility::ComponentSettings& settings, BaseComposite* parent, const string& functionName, const string& moduleName) :
27 BaseButton
28 (
29 radioButtonName,
30 radioButtonText,
31 settings,
32 styles::RadioButtonStyles(),
33 parent,
34 functionName,
35 moduleName
36 )
37 {
38
39 }
40
41 size_t GroupBox::RadioButton::getHash() const
42 {
43 return typeid(RadioButton).hash_code();
44 }
45
46 GroupBox::radioButtonData::radioButtonData() :
47 x(0),
48 y(0),
49 width(0),
50 height(0)
51 {
52
53 }
54
55 GroupBox::radioButtonData::radioButtonData(const wstring& radioButtonName, const wstring& radioButtonText, const utility::ComponentSettings& settings, const function<void()>& onClick) :
56 radioButtonName(radioButtonName),
57 radioButtonText(radioButtonText),
58 x(settings.x),
59 y(settings.y),
60 width(settings.width),
61 height(settings.height),
62 onClick(onClick)
63 {
64
65 }
66
67 GroupBox::radioButtonData::radioButtonData(const wstring& radioButtonName, const wstring& radioButtonText, const utility::ComponentSettings& settings, const string& functionName, const string& moduleName) :
68 radioButtonName(radioButtonName),
69 radioButtonText(radioButtonText),
70 x(settings.x),
71 y(settings.y),
72 width(settings.width),
73 height(settings.height),
74 functionName(functionName),
75 moduleName(moduleName)
76 {
77 GUIFramework& instance = GUIFramework::get();
78 const HMODULE& module = instance.getModules().at(moduleName);
79
80 onClickSignature tem = reinterpret_cast<onClickSignature>(GetProcAddress(module, functionName.data()));
81
82 if (!tem)
83 {
84 throw exceptions::CantFindFunctionFromModuleException(functionName, moduleName, __FILE__, __FUNCTION__, __LINE__);
85 }
86
87 onClick = tem;
88 }
89
90 GroupBox::GroupBox(const wstring& groupBoxClassName, const wstring& groupBoxName, const utility::ComponentSettings& settings, BaseComposite* parent, const string& groupBoxFunctionName) :
92 (
93 groupBoxClassName,
94 groupBoxName,
95 settings,
96 styles::DefaultStyles(),
97 parent,
98 groupBoxFunctionName
99 )
100 {
101
102 }
103
105 {
106 if (data.functionName.empty())
107 {
108 new RadioButton(data.radioButtonName, data.radioButtonText, utility::ComponentSettings(data.x, data.y, data.width, data.height), this, data.onClick);
109 }
110 else
111 {
112 new RadioButton(data.radioButtonName, data.radioButtonText, utility::ComponentSettings(data.x, data.y, data.width, data.height), this, data.functionName, data.moduleName);
113 }
114 }
115
116 unique_ptr<Menu>& GroupBox::createMainMenu(const wstring& menuName)
117 {
118 __utility::throwNotImplementedException(__FUNCTION__, "GroupBox"sv);
119
120 return BaseComposite::createMainMenu(menuName);
121 }
122
123 Menu& GroupBox::addPopupMenu(const wstring& menuName)
124 {
125 __utility::throwNotImplementedException(__FUNCTION__, "GroupBox"sv);
126
127 return BaseComposite::addPopupMenu(menuName);
128 }
129
130 void GroupBox::removePopupMenus(const wstring& menuName)
131 {
132 __utility::throwNotImplementedException(__FUNCTION__, "GroupBox"sv);
133 }
134
135 size_t GroupBox::getHash() const
136 {
137 return typeid(GroupBox).hash_code();
138 }
139}
smartPointerType< interfaces::IStyles > styles
Base class for all windows that has children windows.
virtual std::unique_ptr< Menu > & createMainMenu(const std::wstring &menuName)
It needs to be called once.
virtual Menu & addPopupMenu(const std::wstring &menuName)
Don't call move operator with return value.
Singleton with GUIFramework settings and some functionality.
const std::unordered_map< std::string, HMODULE, localization::utility::StringViewHash, localization::utility::StringViewEqual > & getModules() const
Get all loaded modules.
static GUIFramework & get()
Singleton instance access.
void addRadioButton(const radioButtonData &data)
Definition GroupBox.cpp:104
GroupBox(const std::wstring &groupBoxClassName, const std::wstring &groupBoxName, const utility::ComponentSettings &settings, BaseComposite *parent, const std::string &groupBoxFunctionName)
Definition GroupBox.cpp:90
size_t getHash() const override
Used as key in creators.
Definition GroupBox.cpp:135
std::unique_ptr< Menu > & createMainMenu(const std::wstring &menuName) override
Not implemented.
Definition GroupBox.cpp:116
Menu & addPopupMenu(const std::wstring &menuName) override
Not implemented.
Definition GroupBox.cpp:123
void removePopupMenus(const std::wstring &menuName) override
Not implemented.
Definition GroupBox.cpp:130
Menu class.
Definition Menu.h:9
void throwNotImplementedException(string_view methodName, string_view className)
Definition Utility.cpp:186
void(*)() onClickSignature
Default on click signature.