mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-06-08 06:12:21 -06:00
Developing new draw
git-svn-id: svn://ultimatepp.org/upp/trunk@1361 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
156ba63fc3
commit
144066e580
12 changed files with 1846 additions and 1895 deletions
57
newdraw/Draw/DrawTextWin32.cpp
Normal file
57
newdraw/Draw/DrawTextWin32.cpp
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
#include "Draw.h"
|
||||
|
||||
NAMESPACE_UPP
|
||||
|
||||
#ifdef PLATFORM_WIN32
|
||||
|
||||
#define LLOG(x)
|
||||
|
||||
HFONT GetWin32Font(Font fnt, int angle);
|
||||
|
||||
void SystemDraw::SetFont(Font font, int angle) {
|
||||
DrawLock __;
|
||||
LLOG("Set font: " << font << " face: " << font.GetFaceName());
|
||||
if(lastFont == font && lastAngle == angle)
|
||||
return;
|
||||
lastFont = font;
|
||||
lastAngle = angle;
|
||||
HFONT h = (HFONT) SelectObject(handle, GetWin32Font(font, angle));
|
||||
if(!orgFont) orgFont = h;
|
||||
}
|
||||
|
||||
void SystemDraw::DrawTextOp(int x, int y, int angle, const wchar *text, Font font, Color ink,
|
||||
int n, const int *dx) {
|
||||
Std(font);
|
||||
while(n > 30000) {
|
||||
DrawTextOp(x, y, angle, text, font, ink, 30000, dx);
|
||||
if(dx) {
|
||||
for(int i = 0; i < 30000; i++)
|
||||
x += *dx++;
|
||||
}
|
||||
else
|
||||
x += GetTextSize(text, font, 30000).cx;
|
||||
n -= 30000;
|
||||
text += 30000;
|
||||
}
|
||||
DrawLock __;
|
||||
COLORREF cr = GetColor(ink);
|
||||
if(cr != lastTextColor) {
|
||||
LLOG("Setting text color: " << ink);
|
||||
::SetTextColor(handle, lastTextColor = cr);
|
||||
}
|
||||
SetFont(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);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
END_UPP_NAMESPACE
|
||||
Loading…
Add table
Add a link
Reference in a new issue