X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/02761f6cd478e3c2c97cf6f93442747f7b029833..2523e9b70044baa92a1c63ffdfe179c28ad53536:/src/x11/dcclient.cpp diff --git a/src/x11/dcclient.cpp b/src/x11/dcclient.cpp index 849911fa69..cd0ed5f6a3 100644 --- a/src/x11/dcclient.cpp +++ b/src/x11/dcclient.cpp @@ -165,7 +165,7 @@ static void wxFreePoolGC( GC gc ) IMPLEMENT_DYNAMIC_CLASS(wxWindowDC, wxDC) -wxWindowDC::wxWindowDC() +void wxWindowDC::Init() { m_display = (WXDisplay *) NULL; m_penGC = (WXGC *) NULL; @@ -178,7 +178,7 @@ wxWindowDC::wxWindowDC() m_owner = (wxWindow *)NULL; #if wxUSE_UNICODE - m_context = (PangoContext *)NULL; + m_context = wxTheApp->GetPangoContext(); m_fontdesc = (PangoFontDescription *)NULL; #endif } @@ -187,15 +187,8 @@ wxWindowDC::wxWindowDC( wxWindow *window ) { wxASSERT_MSG( window, wxT("DC needs a window") ); - m_display = (WXDisplay *) NULL; - m_penGC = (WXGC *) NULL; - m_brushGC = (WXGC *) NULL; - m_textGC = (WXGC *) NULL; - m_bgGC = (WXGC *) NULL; - m_cmap = (WXColormap *) NULL; - m_owner = (wxWindow *)NULL; - m_isMemDC = false; - m_isScreenDC = false; + Init(); + m_font = window->GetFont(); m_window = (WXWindow*) window->GetMainWindow(); @@ -212,7 +205,6 @@ wxWindowDC::wxWindowDC( wxWindow *window ) m_display = (WXDisplay *) wxGlobalDisplay(); #if wxUSE_UNICODE - m_context = wxTheApp->GetPangoContext(); m_fontdesc = window->GetFont().GetNativeFontInfo()->description; #endif @@ -1571,7 +1563,7 @@ void wxWindowDC::DoDrawText( const wxString &text, wxCoord x, wxCoord y ) slen = strlen(text); XCharStruct overall_return; - (void)XTextExtents(xfont, (char*) text.c_str(), slen, &direction, + (void)XTextExtents(xfont, (const char*) text.c_str(), slen, &direction, &ascent, &descent, &overall_return); cx = overall_return.width; @@ -1620,7 +1612,7 @@ void wxWindowDC::DoDrawRotatedText( const wxString &text, wxCoord x, wxCoord y, void wxWindowDC::DoGetTextExtent( const wxString &string, wxCoord *width, wxCoord *height, wxCoord *descent, wxCoord *externalLeading, - wxFont *font ) const + const wxFont *font ) const { wxCHECK_RET( Ok(), wxT("invalid dc") ); @@ -1669,7 +1661,7 @@ void wxWindowDC::DoGetTextExtent( const wxString &string, wxCoord *width, wxCoor int direction, ascent, descent2; XCharStruct overall; - XTextExtents( xfont, (char*) string.c_str(), string.length(), &direction, + XTextExtents( xfont, (const char*) string.c_str(), string.length(), &direction, &ascent, &descent2, &overall); if (width) @@ -1787,8 +1779,6 @@ void wxWindowDC::SetFont( const wxFont &font ) m_font = font; - return; - #if wxUSE_UNICODE m_fontdesc = font.GetNativeFontInfo()->description; #endif @@ -2169,6 +2159,12 @@ void wxWindowDC::DoSetClippingRegion( wxCoord x, wxCoord y, wxCoord width, wxCoo if (!m_window) return; + if (width <= 0) + width = 1; + + if (height <= 0) + height = 1; + wxRect rect; rect.x = XLOG2DEV(x); rect.y = YLOG2DEV(y); @@ -2366,8 +2362,15 @@ wxPaintDC::wxPaintDC(wxWindow* window) class wxDCModule : public wxModule { public: - bool OnInit(); - void OnExit(); + // we must be cleaned up before wxDisplayModule which closes the global + // display + wxDCModule() + { + AddDependency(wxClassInfo::FindClass(_T("wxX11DisplayModule"))); + } + + bool OnInit() { wxInitGCPool(); return true; } + void OnExit() { wxCleanUpGCPool(); } private: DECLARE_DYNAMIC_CLASS(wxDCModule) @@ -2375,13 +2378,3 @@ private: IMPLEMENT_DYNAMIC_CLASS(wxDCModule, wxModule) -bool wxDCModule::OnInit() -{ - wxInitGCPool(); - return true; -} - -void wxDCModule::OnExit() -{ - wxCleanUpGCPool(); -}