GUIFramework 1.1.0
Framework for desktop GUI applications in C++.
Loading...
Searching...
No Matches
RichEditCreator.cpp
Go to the documentation of this file.
1#include "RichEditCreator.h"
2
4
5using namespace std;
6
7namespace gui_framework
8{
9 namespace utility
10 {
11 BaseComponent* RichEditCreator::create(const wstring& windowName, const utility::ComponentSettings& settings, const any& additionalData, BaseComposite* parent)
12 {
13 auto [callbacks, callbacksFunctionNamesAndModules, limitTextCount, isMultiLine] =
14 any_cast<tuple<array<function<void(const wstring&)>, BaseRichEdit::urlDetectEventSize>, array<pair<string, string>, BaseRichEdit::urlDetectEventSize>, uint64_t, bool>>(additionalData);
15
16 RichEdit* result = new RichEdit(windowName, settings, parent, isMultiLine);
17
18 if (any_of(callbacks.begin(), callbacks.end(), [](const function<void(const wstring&)>& callback) { return callback; }) ||
19 any_of(callbacksFunctionNamesAndModules.begin(), callbacksFunctionNamesAndModules.end(), [](const pair<string, string>& data) { return data.first.size(); }))
20 {
21 result->setAutoURLDetect(true);
22
23 for (size_t i = 0; i < BaseRichEdit::urlDetectEventSize; i++)
24 {
25 switch (i)
26 {
27 case 0:
28 if (callbacks[i])
29 {
30 result->addUrlDetectEvent(BaseRichEdit::urlDetectEvent::mouseMove, callbacks[i]);
31 }
32 else if (callbacksFunctionNamesAndModules[i].first.size())
33 {
34 result->addUrlDetectEvent(BaseRichEdit::urlDetectEvent::mouseMove, callbacksFunctionNamesAndModules[i].first, callbacksFunctionNamesAndModules[i].second);
35 }
36
37 break;
38
39 case 1:
40 if (callbacks[i])
41 {
42 result->addUrlDetectEvent(BaseRichEdit::urlDetectEvent::leftButtonDown, callbacks[i]);
43 }
44 else if (callbacksFunctionNamesAndModules[i].first.size())
45 {
46 result->addUrlDetectEvent(BaseRichEdit::urlDetectEvent::leftButtonDown, callbacksFunctionNamesAndModules[i].first, callbacksFunctionNamesAndModules[i].second);
47 }
48
49 break;
50
51 case 2:
52 if (callbacks[i])
53 {
54 result->addUrlDetectEvent(BaseRichEdit::urlDetectEvent::leftButtonUp, callbacks[i]);
55 }
56 else if (callbacksFunctionNamesAndModules[i].first.size())
57 {
58 result->addUrlDetectEvent(BaseRichEdit::urlDetectEvent::leftButtonUp, callbacksFunctionNamesAndModules[i].first, callbacksFunctionNamesAndModules[i].second);
59 }
60
61 break;
62
63 case 3:
64 if (callbacks[i])
65 {
66 result->addUrlDetectEvent(BaseRichEdit::urlDetectEvent::leftButtonDoubleClick, callbacks[i]);
67 }
68 else if (callbacksFunctionNamesAndModules[i].first.size())
69 {
70 result->addUrlDetectEvent(BaseRichEdit::urlDetectEvent::leftButtonDoubleClick, callbacksFunctionNamesAndModules[i].first, callbacksFunctionNamesAndModules[i].second);
71 }
72
73 break;
74
75 case 4:
76 if (callbacks[i])
77 {
78 result->addUrlDetectEvent(BaseRichEdit::urlDetectEvent::rightButtonDown, callbacks[i]);
79 }
80 else if (callbacksFunctionNamesAndModules[i].first.size())
81 {
82 result->addUrlDetectEvent(BaseRichEdit::urlDetectEvent::rightButtonDown, callbacksFunctionNamesAndModules[i].first, callbacksFunctionNamesAndModules[i].second);
83 }
84
85 break;
86
87 case 5:
88 if (callbacks[i])
89 {
90 result->addUrlDetectEvent(BaseRichEdit::urlDetectEvent::rightButtonUp, callbacks[i]);
91 }
92 else if (callbacksFunctionNamesAndModules[i].first.size())
93 {
94 result->addUrlDetectEvent(BaseRichEdit::urlDetectEvent::rightButtonUp, callbacksFunctionNamesAndModules[i].first, callbacksFunctionNamesAndModules[i].second);
95 }
96
97 break;
98
99 case 6:
100 if (callbacks[i])
101 {
102 result->addUrlDetectEvent(BaseRichEdit::urlDetectEvent::rightButtonDoubleClick, callbacks[i]);
103 }
104 else if (callbacksFunctionNamesAndModules[i].first.size())
105 {
106 result->addUrlDetectEvent(BaseRichEdit::urlDetectEvent::rightButtonDoubleClick, callbacksFunctionNamesAndModules[i].first, callbacksFunctionNamesAndModules[i].second);
107 }
108
109 break;
110
111 case 7:
112 if (callbacks[i])
113 {
114 result->addUrlDetectEvent(BaseRichEdit::urlDetectEvent::setCursor, callbacks[i]);
115 }
116 else if (callbacksFunctionNamesAndModules[i].first.size())
117 {
118 result->addUrlDetectEvent(BaseRichEdit::urlDetectEvent::setCursor, callbacksFunctionNamesAndModules[i].first, callbacksFunctionNamesAndModules[i].second);
119 }
120
121 break;
122
123 default:
124 break;
125 }
126 }
127 }
128
129 result->setLimitText(limitTextCount);
130
131 return result;
132 }
133 }
134}
Base class for all windows, controls, etc.
Base class for all windows that has children windows.
static constexpr uint8_t urlDetectEventSize
Standard rich edit control.
Definition RichEdit.h:9
BaseComponent * create(const std::wstring &windowName, const utility::ComponentSettings &settings, const std::any &additionalData, BaseComposite *parent) override