mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
cppkore uses string/wstring as StringBase while we use std::string/std::wstring as string/wstring. Changed all types in cppkore to String/WString instead.
33 lines
1003 B
C++
33 lines
1003 B
C++
#include "stdafx.h"
|
|
#include "TextRenderer.h"
|
|
|
|
namespace Drawing
|
|
{
|
|
void TextRenderer::DrawText(HDC hDC, const String& Text, Font& Font, Rectangle Bounds, Color ForeColor, TextFormatFlags Flags)
|
|
{
|
|
SelectObject(hDC, Font.GetFontHandle());
|
|
SetBkMode(hDC, TRANSPARENT); // Default text rendering doesn't have a background.
|
|
// just draw text.
|
|
|
|
SetTextColor(hDC, ForeColor.ToCOLORREF());
|
|
|
|
RECT RcDraw{};
|
|
RcDraw.top = Bounds.Y;
|
|
RcDraw.left = Bounds.X;
|
|
RcDraw.right = Bounds.X + Bounds.Width;
|
|
RcDraw.bottom = Bounds.Y + Bounds.Height;
|
|
|
|
DRAWTEXTPARAMS Params{};
|
|
Params.cbSize = sizeof(Params);
|
|
|
|
DrawTextExA(hDC, (LPSTR)Text.ToCString(), Text.Length(), &RcDraw, (UINT)Flags, &Params);
|
|
}
|
|
|
|
void TextRenderer::DrawText(std::unique_ptr<Drawing::Graphics>& Graphics, const String& Text, Font& Font, Rectangle Bounds, Color ForeColor, TextFormatFlags Flags)
|
|
{
|
|
auto hDC = Graphics->GetHDC();
|
|
DrawText(hDC, Text, Font, Bounds, ForeColor, Flags);
|
|
Graphics->ReleaseHDC(hDC);
|
|
}
|
|
}
|