X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/f772729b7cb4c851334dd674d8f754ca408d73d4..e6ba38871f6cc5c02391c04e37e481d0428cef3f:/src/msw/graphics.cpp?ds=sidebyside diff --git a/src/msw/graphics.cpp b/src/msw/graphics.cpp index 9d8aac3fbd..a25d643ccd 100644 --- a/src/msw/graphics.cpp +++ b/src/msw/graphics.cpp @@ -328,6 +328,7 @@ public: wxDouble *descent, wxDouble *externalLeading ) const; virtual void GetPartialTextExtents(const wxString& text, wxArrayDouble& widths) const; virtual bool ShouldOffset() const; + virtual void GetSize( wxDouble* width, wxDouble *height ); private: void Init(); @@ -1261,7 +1262,9 @@ void wxGDIPlusContext::DrawIcon( const wxIcon &icon, wxDouble x, wxDouble y, wxD void wxGDIPlusContext::DrawText( const wxString &str, wxDouble x, wxDouble y ) { - if ( m_font.IsNull() || str.IsEmpty()) + wxCHECK_RET( !m_font.IsNull(), wxT("wxGDIPlusContext::DrawText - no valid font set") ); + + if ( str.IsEmpty()) return ; wxWCharBuffer s = str.wc_str( *wxConvUI ); @@ -1272,6 +1275,8 @@ void wxGDIPlusContext::DrawText( const wxString &str, wxDouble x, wxDouble y ) void wxGDIPlusContext::GetTextExtent( const wxString &str, wxDouble *width, wxDouble *height, wxDouble *descent, wxDouble *externalLeading ) const { + wxCHECK_RET( !m_font.IsNull(), wxT("wxGDIPlusContext::GetTextExtent - no valid font set") ); + wxWCharBuffer s = str.wc_str( *wxConvUI ); FontFamily ffamily ; Font* f = ((wxGDIPlusFontData*)m_font.GetRefData())->GetGDIPlusFont(); @@ -1317,6 +1322,8 @@ void wxGDIPlusContext::GetPartialTextExtents(const wxString& text, wxArrayDouble widths.Empty(); widths.Add(0, text.length()); + wxCHECK_RET( !m_font.IsNull(), wxT("wxGDIPlusContext::GetPartialTextExtents - no valid font set") ); + if (text.empty()) return; @@ -1383,6 +1390,15 @@ wxGraphicsMatrix wxGDIPlusContext::GetTransform() const m_context->GetTransform((Matrix*) matrix.GetNativeMatrix()); return matrix; } + +void wxGDIPlusContext::GetSize( wxDouble* width, wxDouble *height ) +{ + if ( width ) + *width = ::GetDeviceCaps(m_context->GetHDC(), HORZRES); + if ( height ) + *height = ::GetDeviceCaps(m_context->GetHDC(), VERTRES); + +} //----------------------------------------------------------------------------- // wxGDIPlusRenderer declaration //-----------------------------------------------------------------------------