20 void BaseWindow::drawedImages::addImage(BaseWindow* owner,
int x,
int y,
const filesystem::path& pathToImage)
22 uint16_t index = images->addImage(pathToImage);
24 coordinates.insert({ index, {x, y} });
27 void BaseWindow::drawedImages::removeImage(
const filesystem::path& pathToImage)
29 uint16_t index = images->getImageIndex(pathToImage);
31 images->removeImage(index);
33 coordinates.erase(index);
60 case utility::BaseLoadableHolder::imageType::bitmap:
64 case utility::BaseLoadableHolder::imageType::icon:
68 case utility::BaseLoadableHolder::imageType::cursor:
69 throw runtime_error(
"Wrong type value");
76 pictures.try_emplace(pictureBlockName, move(images), type);
79 void BaseWindow::addImage(
const string& pictureBlockName,
int x,
int y,
const filesystem::path& pathToImage)
81 drawedImages& images =
pictures.at(pictureBlockName);
83 if (!filesystem::exists(pathToImage))
88 images.addImage(
this, x, y, pathToImage);
95 drawedImages& images =
pictures.at(pictureBlockName);
97 images.removeImage(pathToImage);
104 InvalidateRect(
handle,
nullptr,
true);
106 PAINTSTRUCT paint = {};
107 HDC deviceContext = BeginPaint(
handle, &paint);
108 LPARAM drawData = NULL;
110 for (
const auto& [picturesBlockName, data] :
pictures)
112 uint32_t flags = DSS_NORMAL;
113 uint16_t width = data.images->getImagesWidth();
114 uint16_t height = data.images->getImagesHeight();
116 for (
const auto& [index, coordinates] : data.coordinates)
120 case utility::BaseLoadableHolder::imageType::bitmap:
121 drawData =
reinterpret_cast<LPARAM
>(
dynamic_cast<utility::ImagesHolder*
>(data.images.get())->getImage(index));
126 case utility::BaseLoadableHolder::imageType::icon:
127 drawData =
reinterpret_cast<LPARAM
>(
dynamic_cast<utility::IconsHolder*
>(data.images.get())->getIcon(index));
137 DrawStateW(deviceContext, NULL,
nullptr, drawData, NULL, coordinates.first, coordinates.second, width, height, flags);
141 ReleaseDC(
handle, deviceContext);
155 using json::utility::jsonObject;
165 for (
const auto& [pictureBlockName, data] :
pictures)
167 string imageHolderName = pictureBlockName +
"ImageHolder";
168 vector<jsonObject> jsonCoordinates;
170 auto& lastImageHolderStructure = data.images->loadBaseLoadableHolderStructure(current);
172 lastImageHolderStructure.first = imageHolderName;
174 for (
const auto& [index, coordinates] : data.coordinates)
178 object.data.push_back({
"x"s,
static_cast<int64_t
>(coordinates.first) });
179 object.data.push_back({
"y"s,
static_cast<int64_t
>(coordinates.second) });
181 json::utility::appendArray(move(
object), jsonCoordinates);
184 get<jsonObject>(lastImageHolderStructure.second).data.push_back({
"coordinates"s, move(jsonCoordinates) });
std::unique_ptr< T > smartPointerType
Compatible smart pointer type.
const std::wstring className
const std::wstring windowName
Base class for all windows that has children windows.
virtual json::JSONBuilder getStructure() const override
virtual void setBackgroundColor(uint8_t red, uint8_t green, uint8_t blue) override
std::string windowFunctionName
virtual void initDrawing(const std::string &pictureBlockName, uint16_t imagesWidth, uint16_t imagesHeight, utility::BaseLoadableHolder::imageType type) final
Initialize block of pictures with same size.
virtual void setBackgroundColor(uint8_t red, uint8_t green, uint8_t blue) final override
virtual json::JSONBuilder getStructure() const override
virtual void addImage(const std::string &pictureBlockName, int x, int y, const std::filesystem::path &pathToImage)
Draw image in window.
virtual void drawAllImages() final
Clear window and draw all images.
std::unordered_map< std::string, drawedImages > pictures
virtual void removeImage(const std::string &pictureBlockName, const std::filesystem::path &pathToImage)
Remove image from window.
BaseWindow(const std::wstring &className, const std::wstring &windowName, const utility::ComponentSettings &settings, const interfaces::IStyles &styles, BaseComposite *parent=nullptr, const std::string &windowFunctionName="", const std::string &moduleName="", uint16_t smallIconResource=NULL, uint16_t largeIconResource=NULL)
Throws by asset finding methods.
IComponentVisibility(HWND componentVisibilityHandle)
Provides styles for other classes.
smartPointerType< T > make_smart_pointer(Args &&... args)
Make function with current build configuration compatibility.
string to_string(wstring_view stringToConvert, uint32_t codepage)
All settings for windows.