ultimatepp/uppsrc/CtrlCore/DrawTextWin32.cpp
cxl 277bd68665 CtrlCore: Win32 DrawTextOp MT fix
git-svn-id: svn://ultimatepp.org/upp/trunk@12672 f0d560ea-af0d-0410-9eb7-867de7ffcac7
2019-01-16 10:58:37 +00:00

37 lines
964 B
C++

#include "CtrlCore.h"
#ifdef GUI_WIN
namespace Upp {
#define LLOG(x)
HFONT GetWin32Font(Font fnt, int angle);
extern StaticMutex sFontLock;
void SystemDraw::DrawTextOp(int x, int y, int angle, const wchar *text, Font font, Color ink,
int n, const int *dx) {
Std(font);
GuiLock __;
COLORREF cr = GetColor(ink);
if(cr != lastTextColor) {
LLOG("Setting text color: " << ink);
::SetTextColor(handle, lastTextColor = cr);
}
Mutex::Lock ___(sFontLock);
HGDIOBJ orgfont = ::SelectObject(handle, GetWin32Font(font, angle));
int ascent = font.Info().GetAscent();
if(angle) {
double sina, cosa;
Draw::SinCos(angle, sina, cosa);
Size offset;
::ExtTextOutW(handle, x + fround(ascent * sina), y + fround(ascent * cosa), 0, NULL, (const WCHAR *)text, n, dx);
}
else
::ExtTextOutW(handle, x, y + ascent, 0, NULL, (const WCHAR *)text, n, dx);
::SelectObject(handle, orgfont);
}
}
#endif