Use automatic resource management in wxMSW wxDC::DrawRotatedText().
No real changes, just simplify the code by using RAII classes. Also avoid unnecessary indentation by returning after checking for the special cases. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@75751 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -1483,17 +1483,16 @@ void wxMSWDCImpl::DoDrawRotatedText(const wxString& text,
|
|||||||
DoDrawText(text, x, y);
|
DoDrawText(text, x, y);
|
||||||
|
|
||||||
// Bounding box already updated by DoDrawText(), no need to do it again.
|
// Bounding box already updated by DoDrawText(), no need to do it again.
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef __WXMICROWIN__
|
#ifndef __WXMICROWIN__
|
||||||
else
|
|
||||||
{
|
|
||||||
// NB: don't take DEFAULT_GUI_FONT (a.k.a. wxSYS_DEFAULT_GUI_FONT)
|
// NB: don't take DEFAULT_GUI_FONT (a.k.a. wxSYS_DEFAULT_GUI_FONT)
|
||||||
// because it's not TrueType and so can't have non zero
|
// because it's not TrueType and so can't have non zero
|
||||||
// orientation/escapement under Win9x
|
// orientation/escapement under Win9x
|
||||||
wxFont font = m_font.IsOk() ? m_font : *wxSWISS_FONT;
|
wxFont font = m_font.IsOk() ? m_font : *wxSWISS_FONT;
|
||||||
HFONT hfont = (HFONT)font.GetResourceHandle();
|
|
||||||
LOGFONT lf;
|
LOGFONT lf;
|
||||||
if ( ::GetObject(hfont, sizeof(lf), &lf) == 0 )
|
if ( ::GetObject(GetHfontOf(font), sizeof(lf), &lf) == 0 )
|
||||||
{
|
{
|
||||||
wxLogLastError(wxT("GetObject(hfont)"));
|
wxLogLastError(wxT("GetObject(hfont)"));
|
||||||
}
|
}
|
||||||
@@ -1503,14 +1502,14 @@ void wxMSWDCImpl::DoDrawRotatedText(const wxString& text,
|
|||||||
lf.lfEscapement = angle10;
|
lf.lfEscapement = angle10;
|
||||||
lf.lfOrientation = angle10;
|
lf.lfOrientation = angle10;
|
||||||
|
|
||||||
hfont = ::CreateFontIndirect(&lf);
|
AutoHFONT hfont(lf);
|
||||||
if ( !hfont )
|
if ( !hfont )
|
||||||
{
|
{
|
||||||
wxLogLastError(wxT("CreateFont"));
|
wxLogLastError(wxT("CreateFont"));
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
SelectInHDC selRotatedFont(GetHdc(), hfont);
|
||||||
HFONT hfontOld = (HFONT)::SelectObject(GetHdc(), hfont);
|
|
||||||
|
|
||||||
// Get extent of whole text.
|
// Get extent of whole text.
|
||||||
wxCoord w, h, heightLine;
|
wxCoord w, h, heightLine;
|
||||||
@@ -1536,8 +1535,6 @@ void wxMSWDCImpl::DoDrawRotatedText(const wxString& text,
|
|||||||
y + wxRound(lineNum*dy));
|
y + wxRound(lineNum*dy));
|
||||||
}
|
}
|
||||||
|
|
||||||
(void)::SelectObject(GetHdc(), hfontOld);
|
|
||||||
(void)::DeleteObject(hfont);
|
|
||||||
|
|
||||||
// call the bounding box by adding all four vertices of the rectangle
|
// call the bounding box by adding all four vertices of the rectangle
|
||||||
// containing the text to it (simpler and probably not slower than
|
// containing the text to it (simpler and probably not slower than
|
||||||
@@ -1552,9 +1549,6 @@ void wxMSWDCImpl::DoDrawRotatedText(const wxString& text,
|
|||||||
y += (wxCoord)(h*cos(rad));
|
y += (wxCoord)(h*cos(rad));
|
||||||
CalcBoundingBox(x, y);
|
CalcBoundingBox(x, y);
|
||||||
CalcBoundingBox(x + wxCoord(w*cos(rad)), y - wxCoord(w*sin(rad)));
|
CalcBoundingBox(x + wxCoord(w*cos(rad)), y - wxCoord(w*sin(rad)));
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user