From: Robert Roebling Date: Fri, 19 Nov 2004 23:15:14 +0000 (+0000) Subject: Corrected positioning of rotated text. X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/1d65e535d5b827097a4c11bbf705b0987eadd895 Corrected positioning of rotated text. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@30663 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/src/gtk/dcclient.cpp b/src/gtk/dcclient.cpp index 9879635b32..3af3e2924f 100644 --- a/src/gtk/dcclient.cpp +++ b/src/gtk/dcclient.cpp @@ -1670,8 +1670,29 @@ void wxWindowDC::DoDrawRotatedText( const wxString &text, wxCoord x, wxCoord y, m_textForegroundColour.Blue() ); image = image.Rotate( rad, wxPoint(0,0) ); + int i_angle = (int) angle; + i_angle = i_angle % 360; + int xoffset = 0; + if ((i_angle >= 90.0) && (i_angle < 270.0)) + xoffset = image.GetWidth(); + int yoffset = 0; + if ((i_angle >= 0.0) && (i_angle < 180.0)) + yoffset = image.GetHeight(); + + if ((i_angle >= 0) && (i_angle < 90)) + yoffset -= (int)( cos(rad)*h ); + if ((i_angle >= 90) && (i_angle < 180)) + xoffset -= (int)( sin(rad)*h ); + if ((i_angle >= 180) && (i_angle < 270)) + yoffset -= (int)( cos(rad)*h ); + if ((i_angle >= 270) && (i_angle < 360)) + xoffset -= (int)( sin(rad)*h ); + + int i_x = x - xoffset; + int i_y = y - yoffset; + src = image; - DoDrawBitmap( src, x /*- (int)(sin(rad)*h)*/ , y-image.GetHeight()+h, true ); + DoDrawBitmap( src, i_x, i_y, true ); // it would be better to draw with non underlined font and draw the line diff --git a/src/gtk1/dcclient.cpp b/src/gtk1/dcclient.cpp index 9879635b32..3af3e2924f 100644 --- a/src/gtk1/dcclient.cpp +++ b/src/gtk1/dcclient.cpp @@ -1670,8 +1670,29 @@ void wxWindowDC::DoDrawRotatedText( const wxString &text, wxCoord x, wxCoord y, m_textForegroundColour.Blue() ); image = image.Rotate( rad, wxPoint(0,0) ); + int i_angle = (int) angle; + i_angle = i_angle % 360; + int xoffset = 0; + if ((i_angle >= 90.0) && (i_angle < 270.0)) + xoffset = image.GetWidth(); + int yoffset = 0; + if ((i_angle >= 0.0) && (i_angle < 180.0)) + yoffset = image.GetHeight(); + + if ((i_angle >= 0) && (i_angle < 90)) + yoffset -= (int)( cos(rad)*h ); + if ((i_angle >= 90) && (i_angle < 180)) + xoffset -= (int)( sin(rad)*h ); + if ((i_angle >= 180) && (i_angle < 270)) + yoffset -= (int)( cos(rad)*h ); + if ((i_angle >= 270) && (i_angle < 360)) + xoffset -= (int)( sin(rad)*h ); + + int i_x = x - xoffset; + int i_y = y - yoffset; + src = image; - DoDrawBitmap( src, x /*- (int)(sin(rad)*h)*/ , y-image.GetHeight()+h, true ); + DoDrawBitmap( src, i_x, i_y, true ); // it would be better to draw with non underlined font and draw the line