GUIFramework 1.1.0
Framework for desktop GUI applications in C++.
Loading...
Searching...
No Matches
BaseListTextIconListView.cpp
Go to the documentation of this file.
2
4
5using namespace std;
6
7namespace gui_framework
8{
9 void BaseListTextIconListView::updateLocalization(size_t index, wstring_view localizedText)
10 {
11 auto&& [text, iconIndex, pathToIcon] = this->getTextIconItem(index);
12
13 ITextIconListView::changeTextIconItem(localizedText, pathToIcon, index);
14 }
15
16 BaseListTextIconListView::BaseListTextIconListView(const wstring& listViewName, const utility::ComponentSettings& settings, BaseComposite* parent, utility::iconListViewType type, uint16_t iconsWidth, uint16_t iconsHeight, size_t count) :
18 (
19 listViewName,
20 settings,
21 styles::ListIconListViewStyles(type),
22 parent
23 ),
24 ITextIconListView(handle, icons),
25 icons(iconsWidth, iconsHeight, count)
26 {
27 SendMessageW(handle, LVM_SETIMAGELIST, type == utility::iconListViewType::icon ? LVSIL_NORMAL : LVSIL_SMALL, reinterpret_cast<LPARAM>(icons.getImageList()));
28 }
29
31 {
32 using json::utility::jsonObject;
33
34 uint32_t codepage = ISerializable::getCodepage();
35 json::JSONBuilder builder = BaseListView::getStructure();
36 jsonObject& current = get<jsonObject>(builder[utility::to_string(windowName, codepage)]);
37 vector<jsonObject> textValues;
38 vector<jsonObject> iconValues;
39 size_t size = this->size();
40
41 current.data.push_back({ "imagesWidth"s, static_cast<uint64_t>(icons.getImagesWidth()) });
42 current.data.push_back({ "imagesHeight"s, static_cast<uint64_t>(icons.getImagesHeight()) });
43
44 if (size)
45 {
46 for (size_t i = 0; i < size; i++)
47 {
48 auto [text, _, pathToIcon] = this->getTextIconItem(i);
49
50 json::utility::appendArray(utility::to_string(text, codepage), textValues);
51
52 json::utility::appendArray(pathToIcon.string(), iconValues);
53 }
54
55 current.data.push_back({ "listViewTextValues"s, move(textValues) });
56 current.data.push_back({ "listViewIconValues"s, move(iconValues) });
57 }
58
59 return builder;
60 }
61
62 LRESULT BaseListTextIconListView::addTextIconItem(string_view localizationKey, const filesystem::path& pathToIcon)
63 {
64 this->addLocalizationKey(localizationKey);
65
66 return ITextIconListView::addTextIconItem(localizationKey, pathToIcon);
67 }
68
69 LRESULT BaseListTextIconListView::insertTextIconItem(string_view localizationKey, const filesystem::path& pathToIcon, size_t index)
70 {
71 this->addLocalizationKey(localizationKey);
72
73 return ITextIconListView::insertTextIconItem(localizationKey, pathToIcon, index);
74 }
75
76 LRESULT BaseListTextIconListView::changeTextIconItem(string_view localizationKey, const filesystem::path& pathToIcon, size_t index)
77 {
78 this->addLocalizationKey(localizationKey);
79
80 return ITextIconListView::changeTextIconItem(localizationKey, pathToIcon, index);
81 }
82}
virtual json::JSONBuilder getStructure() const override
const std::wstring windowName
Base class for all windows that has children windows.
Base class for all list views in list mode.
BaseListTextIconListView(const std::wstring &listViewName, const utility::ComponentSettings &settings, BaseComposite *parent, utility::iconListViewType type, uint16_t iconsWidth, uint16_t iconsHeight, size_t count=standard_sizes::defaultImagesCount)
virtual LRESULT addTextIconItem(std::string_view localizationKey, const std::filesystem::path &pathToIcon) final override
virtual json::JSONBuilder getStructure() const override
virtual LRESULT insertTextIconItem(std::string_view localizationKey, const std::filesystem::path &pathToIcon, size_t index) final override
virtual LRESULT changeTextIconItem(std::string_view localizationKey, const std::filesystem::path &pathToIcon, size_t index) final override
virtual void updateLocalization(size_t index, std::wstring_view localizedText) override
void addLocalizationKey(std::string_view localizationKey)
virtual std::tuple< std::wstring, uint16_t, std::filesystem::path > getTextIconItem(size_t index) const
virtual uint16_t getImagesWidth() const final
virtual HIMAGELIST getImageList() const final
virtual uint16_t getImagesHeight() const final
string to_string(wstring_view stringToConvert, uint32_t codepage)
Definition Utility.cpp:41