12 void BaseRichEdit::addCallback(urlDetectEvent event,
const function<
void(
const wstring&)>& callback,
const string& functionName,
const string& moduleName)
34 NMHDR* notification =
reinterpret_cast<NMHDR*
>(lparam);
36 if (notification->code == EN_LINK)
38 ENLINK* ptrLink =
reinterpret_cast<ENLINK*
>(lparam);
51 static_cast<size_t>(ptrLink->chrg.cpMax) - ptrLink->chrg.cpMin
66 standard_classes::richEdit,
69 styles::DefaultRichEditStyles(isMultiLine),
75 parent ? parent->getHandle() : nullptr
77 ITextOperations(handle),
78 isMultiLine(isMultiLine),
83 ranges::for_each(
callbacks, [](function<
void(
const wstring&)>& callback) { callback =
nullptr; });
90 this->addCallback(event, eventCallback,
""s,
""s);
96 const HMODULE& module = instance.getModules().at(moduleName);
102 throw exceptions::CantFindFunctionFromModuleException(functionName, moduleName, __FILE__, __FUNCTION__, __LINE__);
105 this->addCallback(event, tem, functionName, moduleName);
126 FINDTEXTEXW findText;
128 findText.chrg.cpMin = 0;
129 findText.chrg.cpMax = -1;
131 findText.lpstrText = subStringToFind.data();
133 return SendMessageW(
handle, EM_FINDTEXTEXW, NULL | FR_DOWN | (isMatchCase ? FR_MATCHCASE : NULL),
reinterpret_cast<LPARAM
>(&findText));
138 FINDTEXTEXW findText;
140 findText.chrg.cpMin = 0;
141 findText.chrg.cpMax = -1;
143 findText.lpstrText = stringToFind.data();
145 return SendMessageW(
handle, EM_FINDTEXTEXW, FR_WHOLEWORD | FR_DOWN | (isMatchCase ? FR_MATCHCASE : NULL),
reinterpret_cast<LPARAM
>(&findText));
152 SendMessageW(
handle, EM_SETEVENTMASK, NULL, SendMessageW(
handle, EM_GETEVENTMASK, NULL, NULL) | ENM_LINK);
154 SendMessageW(
handle, EM_AUTOURLDETECT, AURL_ENABLEURL, NULL);
158 SendMessageW(
handle, EM_SETEVENTMASK, NULL, SendMessageW(
handle, EM_GETEVENTMASK, NULL, NULL) & ~ENM_LINK);
160 SendMessageW(
handle, EM_AUTOURLDETECT, NULL, NULL);
168 SendMessageW(
handle, EM_EXLIMITTEXT, NULL, count);
173 return SendMessageW(
handle, EM_GETAUTOURLDETECT, NULL, NULL);
180 SendMessageW(
handle, EM_EXGETSEL, NULL,
reinterpret_cast<LPARAM
>(&range));
182 return this->
getText().substr(range.cpMin,
static_cast<size_t>(range.cpMax) - range.cpMin);
211 CHARFORMAT2W textFormat;
213 textFormat.cbSize =
sizeof(CHARFORMAT2W);
214 textFormat.dwMask = CFM_COLOR;
215 textFormat.crTextColor = RGB(red, green, blue);
216 textFormat.dwEffects = NULL;
218 SendMessageW(
handle, EM_SETCHARFORMAT, SCF_ALL,
reinterpret_cast<LPARAM
>(&textFormat));
223 using json::utility::jsonObject;
225 pair<string, string> emptyPair = make_pair(
""s,
""s);
228 vector<jsonObject> jsonCallbacks;
231 current.data.push_back({
"isMultiLine"s,
isMultiLine });
244 object.data.push_back({
"callbackType"s,
static_cast<uint64_t
>(i) });
250 json::utility::appendArray(move(
object), jsonCallbacks);
253 current.data.push_back({
"callbacks"s, move(jsonCallbacks) });
Base class for all windows, controls, etc.
virtual json::JSONBuilder getStructure() const override
virtual void setTextColor(uint8_t red, uint8_t green, uint8_t blue)
const std::wstring windowName
virtual void setBackgroundColor(uint8_t red, uint8_t green, uint8_t blue)
Base class for all windows that has children windows.
virtual void setLimitText(uint64_t count) final
std::array< std::pair< std::string, std::string >, urlDetectEventSize > callbacksFunctionNamesAndModules
virtual void setTextColor(uint8_t red, uint8_t green, uint8_t blue) final override
virtual LRESULT findString(const std::wstring &stringToFind, bool isMatchCase=true) final
virtual std::wstring getSelectedText() const final
virtual bool getIsMultiLine() const final
BaseRichEdit(const std::wstring &richEditName, const utility::ComponentSettings &settings, BaseComposite *parent, bool isMultiLine=false)
virtual LRESULT windowMessagesHandle(HWND handle, UINT message, WPARAM wparam, LPARAM lparam, bool &isUsed) override
virtual json::JSONBuilder getStructure() const override
static constexpr uint8_t urlDetectEventSize
virtual void setAutoURLDetect(bool autoURLDetect) final
std::array< std::function< void(const std::wstring &)>, urlDetectEventSize > callbacks
virtual const std::function< void(const std::wstring &)> & getCallback(urlDetectEvent event) const final
virtual void setBackgroundColor(uint8_t red, uint8_t green, uint8_t blue) final override
virtual LRESULT findSubstring(const std::wstring &subStringToFind, bool isMatchCase=true) final
virtual void removeUrlDetectEvent(urlDetectEvent event) final
virtual bool getAutoURLDetect() const final
virtual void addUrlDetectEvent(urlDetectEvent event, const std::function< void(const std::wstring &)> &eventCallback) final
const std::unordered_map< std::string, std::string > & getModulesPaths() const
Get all loaded modules paths.
static GUIFramework & get()
Singleton instance access.
void setText(std::wstring_view text)
virtual std::wstring getText() const final
Get text from control.
string to_string(wstring_view stringToConvert, uint32_t codepage)
void(*)(const std::wstring &) richEditCallbackSignature
Used in rich edit auto url detect events.
All settings for windows.