GUIFramework 1.1.0
Framework for desktop GUI applications in C++.
Loading...
Searching...
No Matches
BaseEditControl.cpp
Go to the documentation of this file.
1#include "BaseEditControl.h"
2
5
6using namespace std;
7
8namespace gui_framework
9{
10 void BaseEditControl::updateLocalization(wstring_view localizedText)
11 {
12 this->setPlaceholder(localizedText);
13 }
14
15 BaseEditControl::BaseEditControl(const std::wstring& editControlName, const utility::ComponentSettings& settings, BaseComposite* parent, bool isMultiLine) :
17 (
18 standard_classes::editControl,
19 editControlName,
20 settings,
21 styles::EditControlStyles(isMultiLine),
22 parent
23 ),
24 ITextOperations(handle)
25 {
26 ITextOperations::setText(L"");
27 }
28
29 bool BaseEditControl::setPlaceholder(std::wstring_view placeholder)
30 {
31 bool result = SendMessageW(handle, EM_SETCUEBANNER, false, reinterpret_cast<LPARAM>(placeholder.data()));
32
33 if (result)
34 {
35 this->placeholder = placeholder;
36 }
37
38 return result;
39 }
40
41 const wstring& BaseEditControl::getPlaceholder() const
42 {
43 return placeholder;
44 }
45
46 json::JSONBuilder BaseEditControl::getStructure() const
47 {
48 using json::utility::jsonObject;
49
50 json::JSONBuilder builder = BaseComponent::getStructure();
51 uint32_t codepage = ISerializable::getCodepage();
52
53 get<jsonObject>(builder[utility::to_string(windowName, codepage)]).data.push_back({ "placeholder"s, utility::to_string(placeholder, codepage) });
54
55 return builder;
56 }
57
58 void BaseEditControl::setText(string_view localizationKey)
59 {
60 this->setLocalizationKey(localizationKey);
61
62 ITextOperations::setText(localizationKey);
63 }
64}
Base class for all windows, controls, etc.
virtual json::JSONBuilder getStructure() const override
const std::wstring windowName
Base class for all windows that has children windows.
virtual bool setPlaceholder(std::wstring_view placeholder) final
Set placeholder to single line edit control.
BaseEditControl(const std::wstring &editControlName, const utility::ComponentSettings &settings, BaseComposite *parent, bool isMultiLine=false)
virtual json::JSONBuilder getStructure() const override
virtual void updateLocalization(std::wstring_view localizedText) override
virtual const std::wstring & getPlaceholder() const final
virtual void setText(std::string_view localizationKey) final override
virtual void setLocalizationKey(std::string_view localizationKey) final
string to_string(wstring_view stringToConvert, uint32_t codepage)
Definition Utility.cpp:41