GUIFramework 1.1.0
Framework for desktop GUI applications in C++.
Loading...
Searching...
No Matches
CursorsHolder.cpp
Go to the documentation of this file.
1#include "CursorsHolder.h"
2
3using namespace std;
4
5namespace gui_framework
6{
7 namespace utility
8 {
9 CursorsHolder::CursorsHolder(uint16_t imagesWidth, uint16_t imagesHeight, size_t count) :
11 (
12 imagesWidth,
13 imagesHeight,
14 count
15 )
16 {
17
18 }
19
20 HCURSOR CursorsHolder::getCursor(const filesystem::path& pathToCursor) const
21 {
22 return any_cast<HCURSOR>(images.at(pathToCursor).data);
23 }
24
25 HCURSOR CursorsHolder::getCursor(uint16_t cursorIndex) const
26 {
27 const any* result = nullptr;
28
29 for (const auto& [path, data] : images)
30 {
31 if (data.index == cursorIndex)
32 {
33 result = &data.data;
34 }
35 }
36
37 if (!result)
38 {
39 throw out_of_range("Wrong index");
40 }
41
42 return any_cast<HCURSOR>(*result);
43 }
44
45 uint16_t CursorsHolder::addImage(const filesystem::path& pathToCursor)
46 {
47 return BaseLoadableHolder::insertImage(pathToCursor, imageType::cursor);
48 }
49 }
50}
Base class for all visual asset loaders.
virtual uint16_t insertImage(const std::filesystem::path &pathToImage, imageType type) final
std::unordered_map< std::wstring, imageData > images
CursorsHolder(uint16_t imagesWidth, uint16_t imagesHeight, size_t count=standard_sizes::defaultImagesCount)
HCURSOR getCursor(const std::filesystem::path &pathToCursor) const
uint16_t addImage(const std::filesystem::path &pathToCursor) override