From bbbbe360a81bab2ce9bc83aed4719765fd46d297 Mon Sep 17 00:00:00 2001 From: Robert Roebling Date: Fri, 5 Feb 1999 14:58:50 +0000 Subject: [PATCH] synched Clear() and SetBackgroundColour() git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@1609 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/gtk/dcclient.h | 1 + include/wx/gtk1/dcclient.h | 1 + samples/image/image.cpp | 2 -- src/gtk/dcclient.cpp | 39 ++++++++++++++++++++++++++------------ src/gtk/window.cpp | 1 - src/gtk1/dcclient.cpp | 39 ++++++++++++++++++++++++++------------ src/gtk1/window.cpp | 1 - 7 files changed, 56 insertions(+), 28 deletions(-) diff --git a/include/wx/gtk/dcclient.h b/include/wx/gtk/dcclient.h index 4f4999affb..eb2ed88ec7 100644 --- a/include/wx/gtk/dcclient.h +++ b/include/wx/gtk/dcclient.h @@ -101,6 +101,7 @@ public: GdkGC *m_bgGC; GdkColormap *m_cmap; bool m_isMemDC; + wxWindow *m_owner; void SetUpDC(); void Destroy(); diff --git a/include/wx/gtk1/dcclient.h b/include/wx/gtk1/dcclient.h index 4f4999affb..eb2ed88ec7 100644 --- a/include/wx/gtk1/dcclient.h +++ b/include/wx/gtk1/dcclient.h @@ -101,6 +101,7 @@ public: GdkGC *m_bgGC; GdkColormap *m_cmap; bool m_isMemDC; + wxWindow *m_owner; void SetUpDC(); void Destroy(); diff --git a/samples/image/image.cpp b/samples/image/image.cpp index 74cb31a6c7..33e4408a76 100644 --- a/samples/image/image.cpp +++ b/samples/image/image.cpp @@ -144,8 +144,6 @@ void MyCanvas::CreateAntiAliasedBitmap() wxMemoryDC dc; dc.SelectObject( bitmap ); - dc.SetPen( *wxTRANSPARENT_PEN ); - dc.Clear(); dc.SetFont( wxFont( 24, wxDECORATIVE, wxDEFAULT, wxDEFAULT ) ); diff --git a/src/gtk/dcclient.cpp b/src/gtk/dcclient.cpp index 244ab12552..2dec4c304d 100644 --- a/src/gtk/dcclient.cpp +++ b/src/gtk/dcclient.cpp @@ -96,6 +96,7 @@ wxWindowDC::wxWindowDC() m_bgGC = (GdkGC *) NULL; m_cmap = (GdkColormap *) NULL; m_isMemDC = FALSE; + m_owner = (wxWindow *)NULL; } wxWindowDC::wxWindowDC( wxWindow *window ) @@ -105,6 +106,7 @@ wxWindowDC::wxWindowDC( wxWindow *window ) m_textGC = (GdkGC *) NULL; m_bgGC = (GdkGC *) NULL; m_cmap = (GdkColormap *) NULL; + m_owner = (wxWindow *)NULL; if (!window) return; GtkWidget *widget = window->m_wxwindow; @@ -119,7 +121,15 @@ wxWindowDC::wxWindowDC( wxWindow *window ) m_isMemDC = FALSE; SetUpDC(); + + /* this must be done after SetUpDC, bacause SetUpDC calls the + repective SetBrush, SetPen, SetBackground etc functions + to set up the DC. SetBackground call m_owner->SetBackground + and this might not be desired as the standard dc background + is white whereas a window might assume gray to be the + standard (as e.g. wxStatusBar) */ + m_owner = window; } wxWindowDC::~wxWindowDC() @@ -758,7 +768,7 @@ void wxWindowDC::DrawText( const wxString &text, long x, long y, bool WXUNUSED(u x = XLOG2DEV(x); y = YLOG2DEV(y); - // CMB 21/5/98: draw text background if mode is wxSOLID + /* CMB 21/5/98: draw text background if mode is wxSOLID */ if (m_backgroundMode == wxSOLID) { long width = gdk_string_width( font, text ); @@ -769,9 +779,9 @@ void wxWindowDC::DrawText( const wxString &text, long x, long y, bool WXUNUSED(u } gdk_draw_string( m_window, font, m_textGC, x, y + font->ascent, text ); - // CMB 17/7/98: simple underline: ignores scaling and underlying - // X font's XA_UNDERLINE_POSITION and XA_UNDERLINE_THICKNESS - // properties (see wxXt implementation) + /* CMB 17/7/98: simple underline: ignores scaling and underlying + X font's XA_UNDERLINE_POSITION and XA_UNDERLINE_THICKNESS + properties (see wxXt implementation) */ if (m_font.GetUnderlined()) { long width = gdk_string_width( font, text ); @@ -941,8 +951,8 @@ void wxWindowDC::SetBrush( const wxBrush &brush ) void wxWindowDC::SetBackground( const wxBrush &brush ) { - // CMB 21/7/98: Added SetBackground. Sets background brush - // for Clear() and bg colour for shapes filled with cross-hatch brush + /* CMB 21/7/98: Added SetBackground. Sets background brush + * for Clear() and bg colour for shapes filled with cross-hatch brush */ wxCHECK_RET( Ok(), "invalid window dc" ); @@ -952,6 +962,11 @@ void wxWindowDC::SetBackground( const wxBrush &brush ) if (!m_backgroundBrush.Ok()) return; + if (m_owner) + { + m_owner->SetBackgroundColour( m_backgroundBrush.GetColour() ); + } + m_backgroundBrush.GetColour().CalcPixel( m_cmap ); gdk_gc_set_background( m_brushGC, m_backgroundBrush.GetColour().GetColor() ); gdk_gc_set_background( m_penGC, m_backgroundBrush.GetColour().GetColor() ); @@ -961,11 +976,11 @@ void wxWindowDC::SetBackground( const wxBrush &brush ) GdkFill fillStyle = GDK_SOLID; switch (m_backgroundBrush.GetStyle()) { - case wxSOLID: - case wxTRANSPARENT: - break; - default: - fillStyle = GDK_STIPPLED; + case wxSOLID: + case wxTRANSPARENT: + break; + default: + fillStyle = GDK_STIPPLED; } gdk_gc_set_fill( m_bgGC, fillStyle ); @@ -979,7 +994,7 @@ void wxWindowDC::SetBackground( const wxBrush &brush ) { int num = m_backgroundBrush.GetStyle() - wxBDIAGONAL_HATCH; gdk_gc_set_stipple( m_bgGC, hatches[num] ); - } + } } void wxWindowDC::SetLogicalFunction( int function ) diff --git a/src/gtk/window.cpp b/src/gtk/window.cpp index 787c96e000..4c95e23186 100644 --- a/src/gtk/window.cpp +++ b/src/gtk/window.cpp @@ -2536,7 +2536,6 @@ void wxWindow::SetBackgroundColour( const wxColour &colour ) GdkWindow *window = m_wxwindow->window; m_backgroundColour.CalcPixel( gdk_window_get_colormap( window ) ); gdk_window_set_background( window, m_backgroundColour.GetColor() ); - gdk_window_clear( window ); } wxColour sysbg = wxSystemSettings::GetSystemColour( wxSYS_COLOUR_BTNFACE ); diff --git a/src/gtk1/dcclient.cpp b/src/gtk1/dcclient.cpp index 244ab12552..2dec4c304d 100644 --- a/src/gtk1/dcclient.cpp +++ b/src/gtk1/dcclient.cpp @@ -96,6 +96,7 @@ wxWindowDC::wxWindowDC() m_bgGC = (GdkGC *) NULL; m_cmap = (GdkColormap *) NULL; m_isMemDC = FALSE; + m_owner = (wxWindow *)NULL; } wxWindowDC::wxWindowDC( wxWindow *window ) @@ -105,6 +106,7 @@ wxWindowDC::wxWindowDC( wxWindow *window ) m_textGC = (GdkGC *) NULL; m_bgGC = (GdkGC *) NULL; m_cmap = (GdkColormap *) NULL; + m_owner = (wxWindow *)NULL; if (!window) return; GtkWidget *widget = window->m_wxwindow; @@ -119,7 +121,15 @@ wxWindowDC::wxWindowDC( wxWindow *window ) m_isMemDC = FALSE; SetUpDC(); + + /* this must be done after SetUpDC, bacause SetUpDC calls the + repective SetBrush, SetPen, SetBackground etc functions + to set up the DC. SetBackground call m_owner->SetBackground + and this might not be desired as the standard dc background + is white whereas a window might assume gray to be the + standard (as e.g. wxStatusBar) */ + m_owner = window; } wxWindowDC::~wxWindowDC() @@ -758,7 +768,7 @@ void wxWindowDC::DrawText( const wxString &text, long x, long y, bool WXUNUSED(u x = XLOG2DEV(x); y = YLOG2DEV(y); - // CMB 21/5/98: draw text background if mode is wxSOLID + /* CMB 21/5/98: draw text background if mode is wxSOLID */ if (m_backgroundMode == wxSOLID) { long width = gdk_string_width( font, text ); @@ -769,9 +779,9 @@ void wxWindowDC::DrawText( const wxString &text, long x, long y, bool WXUNUSED(u } gdk_draw_string( m_window, font, m_textGC, x, y + font->ascent, text ); - // CMB 17/7/98: simple underline: ignores scaling and underlying - // X font's XA_UNDERLINE_POSITION and XA_UNDERLINE_THICKNESS - // properties (see wxXt implementation) + /* CMB 17/7/98: simple underline: ignores scaling and underlying + X font's XA_UNDERLINE_POSITION and XA_UNDERLINE_THICKNESS + properties (see wxXt implementation) */ if (m_font.GetUnderlined()) { long width = gdk_string_width( font, text ); @@ -941,8 +951,8 @@ void wxWindowDC::SetBrush( const wxBrush &brush ) void wxWindowDC::SetBackground( const wxBrush &brush ) { - // CMB 21/7/98: Added SetBackground. Sets background brush - // for Clear() and bg colour for shapes filled with cross-hatch brush + /* CMB 21/7/98: Added SetBackground. Sets background brush + * for Clear() and bg colour for shapes filled with cross-hatch brush */ wxCHECK_RET( Ok(), "invalid window dc" ); @@ -952,6 +962,11 @@ void wxWindowDC::SetBackground( const wxBrush &brush ) if (!m_backgroundBrush.Ok()) return; + if (m_owner) + { + m_owner->SetBackgroundColour( m_backgroundBrush.GetColour() ); + } + m_backgroundBrush.GetColour().CalcPixel( m_cmap ); gdk_gc_set_background( m_brushGC, m_backgroundBrush.GetColour().GetColor() ); gdk_gc_set_background( m_penGC, m_backgroundBrush.GetColour().GetColor() ); @@ -961,11 +976,11 @@ void wxWindowDC::SetBackground( const wxBrush &brush ) GdkFill fillStyle = GDK_SOLID; switch (m_backgroundBrush.GetStyle()) { - case wxSOLID: - case wxTRANSPARENT: - break; - default: - fillStyle = GDK_STIPPLED; + case wxSOLID: + case wxTRANSPARENT: + break; + default: + fillStyle = GDK_STIPPLED; } gdk_gc_set_fill( m_bgGC, fillStyle ); @@ -979,7 +994,7 @@ void wxWindowDC::SetBackground( const wxBrush &brush ) { int num = m_backgroundBrush.GetStyle() - wxBDIAGONAL_HATCH; gdk_gc_set_stipple( m_bgGC, hatches[num] ); - } + } } void wxWindowDC::SetLogicalFunction( int function ) diff --git a/src/gtk1/window.cpp b/src/gtk1/window.cpp index 787c96e000..4c95e23186 100644 --- a/src/gtk1/window.cpp +++ b/src/gtk1/window.cpp @@ -2536,7 +2536,6 @@ void wxWindow::SetBackgroundColour( const wxColour &colour ) GdkWindow *window = m_wxwindow->window; m_backgroundColour.CalcPixel( gdk_window_get_colormap( window ) ); gdk_window_set_background( window, m_backgroundColour.GetColor() ); - gdk_window_clear( window ); } wxColour sysbg = wxSystemSettings::GetSystemColour( wxSYS_COLOUR_BTNFACE ); -- 2.45.2