X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/e75c685a46c462e761d4bdcb552b09b57e569100..e6ba38871f6cc5c02391c04e37e481d0428cef3f:/src/msw/graphics.cpp?ds=sidebyside diff --git a/src/msw/graphics.cpp b/src/msw/graphics.cpp index 06c784811f..a25d643ccd 100644 --- a/src/msw/graphics.cpp +++ b/src/msw/graphics.cpp @@ -23,16 +23,18 @@ #include "wx/msw/wrapcdlg.h" #include "wx/image.h" #include "wx/window.h" - #include "wx/dc.h" #include "wx/utils.h" #include "wx/dialog.h" #include "wx/app.h" #include "wx/bitmap.h" - #include "wx/dcmemory.h" #include "wx/log.h" #include "wx/icon.h" - #include "wx/dcprint.h" #include "wx/module.h" + // include all dc types that are used as a param + #include "wx/dc.h" + #include "wx/dcclient.h" + #include "wx/dcmemory.h" + #include "wx/dcprint.h" #endif #include "wx/private/graphics.h" @@ -326,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(); @@ -1259,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 ); @@ -1270,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(); @@ -1315,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; @@ -1381,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 //-----------------------------------------------------------------------------