From c8ce6bccc3a92ad6844f72515c152f333436d37e Mon Sep 17 00:00:00 2001 From: David Webster Date: Mon, 6 Dec 1999 23:47:52 +0000 Subject: [PATCH] wxDC new virtual function git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@4848 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/os2/dc.h | 2 ++ src/os2/dc.cpp | 56 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+) diff --git a/include/wx/os2/dc.h b/include/wx/os2/dc.h index 434082c111..2df64604bc 100644 --- a/include/wx/os2/dc.h +++ b/include/wx/os2/dc.h @@ -162,6 +162,8 @@ protected: bool useMask = FALSE); virtual void DoDrawText(const wxString& text, wxCoord x, wxCoord y); + virtual void DoDrawRotatedText(const wxString& text, wxCoord x, wxCoord y, + double angle); virtual bool DoBlit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height, wxDC *source, wxCoord xsrc, wxCoord ysrc, diff --git a/src/os2/dc.cpp b/src/os2/dc.cpp index 14f009b007..8983710b32 100644 --- a/src/os2/dc.cpp +++ b/src/os2/dc.cpp @@ -282,6 +282,62 @@ void wxDC::DoDrawText(const wxString& text, wxCoord x, wxCoord y) // TODO } +void wxDC::DoDrawRotatedText(const wxString& text, + wxCoord x, wxCoord y, + double angle) +{ + // TODO: + /* + if ( angle == 0.0 ) + { + DoDrawText(text, x, y); + } + else + { + LOGFONT lf; + wxFillLogFont(&lf, &m_font); + + // GDI wants the angle in tenth of degree + long angle10 = (long)(angle * 10); + lf.lfEscapement = angle10; + lf. lfOrientation = angle10; + + HFONT hfont = ::CreateFontIndirect(&lf); + if ( !hfont ) + { + wxLogLastError("CreateFont"); + } + else + { + HFONT hfontOld = ::SelectObject(GetHdc(), hfont); + + DrawAnyText(text, x, y); + + (void)::SelectObject(GetHdc(), hfontOld); + } + + // call the bounding box by adding all four vertices of the rectangle + // containing the text to it (simpler and probably not slower than + // determining which of them is really topmost/leftmost/...) + wxCoord w, h; + GetTextExtent(text, &w, &h); + + double rad = DegToRad(angle); + + // "upper left" and "upper right" + CalcBoundingBox(x, y); + CalcBoundingBox(x + w*cos(rad), y - h*sin(rad)); + CalcBoundingBox(x + h*sin(rad), y + h*cos(rad)); + + // "bottom left" and "bottom right" + x += (wxCoord)(h*sin(rad)); + y += (wxCoord)(h*cos(rad)); + CalcBoundingBox(x, y); + CalcBoundingBox(x + h*sin(rad), y + h*cos(rad)); + } +*/ +} + // --------------------------------------------------------------------------- // set GDI objects // --------------------------------------------------------------------------- -- 2.45.2