Update render.hpp

utf8
This commit is contained in:
FarikLoL
2023-10-19 00:56:22 +03:00
committed by GitHub
parent ec4dd4f831
commit bde5ce4012
+13 -4
View File
@@ -1,7 +1,8 @@
#pragma once
#include <wtypes.h>
namespace render {
namespace render
{
void DrawBorderBox(HDC hdc, int x, int y, int w, int h, COLORREF borderColor)
{
HBRUSH hBorderBrush = CreateSolidBrush(borderColor);
@@ -14,7 +15,8 @@ namespace render {
DeleteObject(hBorderBrush); // Delete the temporary brush
}
void DrawFilledBox(HDC hdc, int x, int y, int width, int height, COLORREF color) {
void DrawFilledBox(HDC hdc, int x, int y, int width, int height, COLORREF color)
{
HBRUSH hBrush = CreateSolidBrush(color);
RECT rect = {x, y, x + width, y + height};
FillRect(hdc, &rect, hBrush);
@@ -44,8 +46,15 @@ namespace render {
void RenderText(HDC hdc, int x, int y, const char *text, COLORREF textColor, int textSize)
{
SetTextSize(hdc, textSize); // Set the desired text size
SetTextSize(hdc, textSize);
SetTextColor(hdc, textColor);
TextOutA(hdc, x, y, text, strlen(text));
int len = MultiByteToWideChar(CP_UTF8, 0, text, -1, NULL, 0);
wchar_t *wide_text = new wchar_t[len];
MultiByteToWideChar(CP_UTF8, 0, text, -1, wide_text, len);
TextOutW(hdc, x, y, wide_text, len - 1);
delete[] wide_text;
}
}