X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/16c1f7f345e1850f590cfbf67c3b00fbb6d2e62e..524bf39144b894ebc489d599a99272540941debd:/src/motif/dcclient.cpp diff --git a/src/motif/dcclient.cpp b/src/motif/dcclient.cpp index 7ef4bf61ef..1a9b9abb6a 100644 --- a/src/motif/dcclient.cpp +++ b/src/motif/dcclient.cpp @@ -89,6 +89,7 @@ wxWindowDC::wxWindowDC(void) m_userRegion = (WXRegion) 0; m_pixmap = (WXPixmap) 0; m_autoSetting = 0; + m_oldFont = (WXFont) 0; }; wxWindowDC::wxWindowDC( wxWindow *window ) @@ -136,10 +137,23 @@ wxWindowDC::wxWindowDC( wxWindow *window ) } m_backgroundPixel = (int) gcvalues.background; + + // Get the current Font so we can set it back later + XGCValues valReturn; + XGetGCValues((Display*) m_display, (GC) m_gc, GCFont, &valReturn); + m_oldFont = (WXFont) valReturn.font; }; wxWindowDC::~wxWindowDC(void) { + if ((m_oldFont != (WXFont) 0) && ((long) m_oldFont != -1)) + { + XSetFont ((Display*) m_display, (GC) m_gc, (Font) m_oldFont); + + if (m_window && m_window->GetBackingPixmap()) + XSetFont ((Display*) m_display,(GC) m_gcBacking, (Font) m_oldFont); + } + if (m_gc) XFreeGC ((Display*) m_display, (GC) m_gc); m_gc = (WXGC) 0; @@ -1067,7 +1081,7 @@ void wxWindowDC::DrawText( const wxString &text, long x, long y, bool use16 ) if (m_font.Ok()) { - WXFontStructPtr pFontStruct = m_font.FindOrCreateFontStruct(m_userScaleY*m_logicalScaleY); + WXFontStructPtr pFontStruct = m_font.GetFontStruct(m_userScaleY*m_logicalScaleY, m_display); int direction, descent; XCharStruct overall_return; if (use16) @@ -1221,7 +1235,7 @@ void wxWindowDC::GetTextExtent( const wxString &string, long *width, long *heigh return; } - WXFontStructPtr pFontStruct = theFont->FindOrCreateFontStruct(m_userScaleY*m_logicalScaleY); + WXFontStructPtr pFontStruct = theFont->GetFontStruct(m_userScaleY*m_logicalScaleY, m_display); int direction, ascent, descent2; XCharStruct overall; @@ -1251,7 +1265,7 @@ long wxWindowDC::GetCharWidth(void) if (!m_font.Ok()) return 0; - WXFontStructPtr pFontStruct = m_font.FindOrCreateFontStruct(m_userScaleY * m_logicalScaleY); + WXFontStructPtr pFontStruct = m_font.GetFontStruct(m_userScaleY * m_logicalScaleY, m_display); int direction, ascent, descent; XCharStruct overall; @@ -1267,7 +1281,7 @@ long wxWindowDC::GetCharHeight(void) if (!m_font.Ok()) return 0; - WXFontStructPtr pFontStruct = m_font.FindOrCreateFontStruct(m_userScaleY*m_logicalScaleY); + WXFontStructPtr pFontStruct = m_font.GetFontStruct(m_userScaleY*m_logicalScaleY, m_display); int direction, ascent, descent; XCharStruct overall; @@ -1323,9 +1337,18 @@ void wxWindowDC::SetFont( const wxFont &font ) m_font = font; if (!m_font.Ok()) + { + if ((m_oldFont != (WXFont) 0) && ((long) m_oldFont != -1)) + { + XSetFont ((Display*) m_display, (GC) m_gc, (Font) m_oldFont); + + if (m_window && m_window->GetBackingPixmap()) + XSetFont ((Display*) m_display,(GC) m_gcBacking, (Font) m_oldFont); + } return; + } - WXFontStructPtr pFontStruct = m_font.FindOrCreateFontStruct(m_userScaleY*m_logicalScaleY); + WXFontStructPtr pFontStruct = m_font.GetFontStruct(m_userScaleY*m_logicalScaleY, m_display); Font fontId = ((XFontStruct*)pFontStruct)->fid; XSetFont ((Display*) m_display, (GC) m_gc, fontId); @@ -1339,7 +1362,7 @@ void wxWindowDC::SetPen( const wxPen &pen ) if (!Ok()) return; m_pen = pen; - if (m_pen.Ok()) + if (!m_pen.Ok()) return; wxBitmap oldStipple = m_currentStipple; @@ -2151,7 +2174,7 @@ static void wx_spline_draw_point_array(wxDC *dc) } } -void wxWindowDC::DrawOpenSpline( wxList *points ) +void wxWindowDC::DrawSpline( wxList *points ) { wxPoint *p; double cx1, cy1, cx2, cy2, cx3, cy3, cx4, cy4;