X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/03647350fc7cd141953c72e0284e928847d30f44..83ef387efe9fd569ba388aff0bf7e9ade58f5208:/src/x11/dcclient.cpp diff --git a/src/x11/dcclient.cpp b/src/x11/dcclient.cpp index 3e1db0c360..3f127c442b 100644 --- a/src/x11/dcclient.cpp +++ b/src/x11/dcclient.cpp @@ -183,7 +183,7 @@ wxWindowDCImpl::wxWindowDCImpl( wxDC* owner, wxWindow *window ) m_font = window->GetFont(); - m_x11window = (WXWindow*) window->GetMainWindow(); + m_x11window = (WXWindow*) window->X11GetMainWindow(); // not realized ? if (!m_x11window) @@ -1570,8 +1570,8 @@ void wxWindowDCImpl::DoDrawText( const wxString &text, wxCoord x, wxCoord y ) PangoLayout *layout = pango_layout_new(m_context); pango_layout_set_font_description(layout, m_fontdesc); - const wxCharBuffer data = wxConvUTF8.cWC2MB( text ); - pango_layout_set_text(layout, (const char*) data, strlen( (const char*) data )); + const wxScopedCharBuffer data(text.utf8_str()); + pango_layout_set_text(layout, data, data.length()); // Measure layout. int w,h; @@ -1658,7 +1658,9 @@ void wxWindowDCImpl::DoGetTextExtent( const wxString &string, wxCoord *width, wx wxCoord *descent, wxCoord *externalLeading, const wxFont *font ) const { - wxCHECK_RET( IsOk(), wxT("invalid dc") ); + // Do not test for DC validity here, querying text extents is supposed to + // work even with a non-initialized wxMemoryDC. And the code below does + // actually work in this case. if (string.empty()) { @@ -1675,8 +1677,8 @@ void wxWindowDCImpl::DoGetTextExtent( const wxString &string, wxCoord *width, wx else pango_layout_set_font_description(layout, m_fontdesc); - const wxCharBuffer data = wxConvUTF8.cWC2MB( string ); - pango_layout_set_text(layout, (const char*) data, strlen( (const char*) data )); + const wxScopedCharBuffer data(string.utf8_str()); + pango_layout_set_text(layout, data, data.length()); // Measure text. int w,h; @@ -1721,7 +1723,8 @@ void wxWindowDCImpl::DoGetTextExtent( const wxString &string, wxCoord *width, wx wxCoord wxWindowDCImpl::GetCharWidth() const { - wxCHECK_MSG( IsOk(), 0, wxT("invalid dc") ); + // Do not test for DC validity here for the same reasons as in + // DoGetTextExtent() above. #if wxUSE_UNICODE PangoLayout *layout = pango_layout_new( m_context ); @@ -1755,7 +1758,8 @@ wxCoord wxWindowDCImpl::GetCharWidth() const wxCoord wxWindowDCImpl::GetCharHeight() const { - wxCHECK_MSG( IsOk(), 0, wxT("invalid dc") ); + // Do not test for DC validity here for the same reasons as in + // DoGetTextExtent() above. #if wxUSE_UNICODE PangoLayout *layout = pango_layout_new( m_context ); @@ -2356,7 +2360,7 @@ wxClientDCImpl::wxClientDCImpl( wxDC *owner, wxWindow *window ) m_x11window = (WXWindow*) window->GetClientAreaWindow(); // Adjust the client area when the wxWindow is not using 2 X11 windows. - if (m_x11window == (WXWindow*) window->GetMainWindow()) + if (m_x11window == (WXWindow*) window->X11GetMainWindow()) { wxPoint ptOrigin = window->GetClientAreaOrigin(); SetDeviceOrigin(ptOrigin.x, ptOrigin.y);