synched Clear() and SetBackgroundColour()
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@1609 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -101,6 +101,7 @@ public:
|
|||||||
GdkGC *m_bgGC;
|
GdkGC *m_bgGC;
|
||||||
GdkColormap *m_cmap;
|
GdkColormap *m_cmap;
|
||||||
bool m_isMemDC;
|
bool m_isMemDC;
|
||||||
|
wxWindow *m_owner;
|
||||||
|
|
||||||
void SetUpDC();
|
void SetUpDC();
|
||||||
void Destroy();
|
void Destroy();
|
||||||
|
@@ -101,6 +101,7 @@ public:
|
|||||||
GdkGC *m_bgGC;
|
GdkGC *m_bgGC;
|
||||||
GdkColormap *m_cmap;
|
GdkColormap *m_cmap;
|
||||||
bool m_isMemDC;
|
bool m_isMemDC;
|
||||||
|
wxWindow *m_owner;
|
||||||
|
|
||||||
void SetUpDC();
|
void SetUpDC();
|
||||||
void Destroy();
|
void Destroy();
|
||||||
|
@@ -144,8 +144,6 @@ void MyCanvas::CreateAntiAliasedBitmap()
|
|||||||
wxMemoryDC dc;
|
wxMemoryDC dc;
|
||||||
dc.SelectObject( bitmap );
|
dc.SelectObject( bitmap );
|
||||||
|
|
||||||
dc.SetPen( *wxTRANSPARENT_PEN );
|
|
||||||
|
|
||||||
dc.Clear();
|
dc.Clear();
|
||||||
|
|
||||||
dc.SetFont( wxFont( 24, wxDECORATIVE, wxDEFAULT, wxDEFAULT ) );
|
dc.SetFont( wxFont( 24, wxDECORATIVE, wxDEFAULT, wxDEFAULT ) );
|
||||||
|
@@ -96,6 +96,7 @@ wxWindowDC::wxWindowDC()
|
|||||||
m_bgGC = (GdkGC *) NULL;
|
m_bgGC = (GdkGC *) NULL;
|
||||||
m_cmap = (GdkColormap *) NULL;
|
m_cmap = (GdkColormap *) NULL;
|
||||||
m_isMemDC = FALSE;
|
m_isMemDC = FALSE;
|
||||||
|
m_owner = (wxWindow *)NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxWindowDC::wxWindowDC( wxWindow *window )
|
wxWindowDC::wxWindowDC( wxWindow *window )
|
||||||
@@ -105,6 +106,7 @@ wxWindowDC::wxWindowDC( wxWindow *window )
|
|||||||
m_textGC = (GdkGC *) NULL;
|
m_textGC = (GdkGC *) NULL;
|
||||||
m_bgGC = (GdkGC *) NULL;
|
m_bgGC = (GdkGC *) NULL;
|
||||||
m_cmap = (GdkColormap *) NULL;
|
m_cmap = (GdkColormap *) NULL;
|
||||||
|
m_owner = (wxWindow *)NULL;
|
||||||
|
|
||||||
if (!window) return;
|
if (!window) return;
|
||||||
GtkWidget *widget = window->m_wxwindow;
|
GtkWidget *widget = window->m_wxwindow;
|
||||||
@@ -120,6 +122,14 @@ wxWindowDC::wxWindowDC( wxWindow *window )
|
|||||||
|
|
||||||
SetUpDC();
|
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()
|
wxWindowDC::~wxWindowDC()
|
||||||
@@ -758,7 +768,7 @@ void wxWindowDC::DrawText( const wxString &text, long x, long y, bool WXUNUSED(u
|
|||||||
x = XLOG2DEV(x);
|
x = XLOG2DEV(x);
|
||||||
y = YLOG2DEV(y);
|
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)
|
if (m_backgroundMode == wxSOLID)
|
||||||
{
|
{
|
||||||
long width = gdk_string_width( font, text );
|
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 );
|
gdk_draw_string( m_window, font, m_textGC, x, y + font->ascent, text );
|
||||||
|
|
||||||
// CMB 17/7/98: simple underline: ignores scaling and underlying
|
/* CMB 17/7/98: simple underline: ignores scaling and underlying
|
||||||
// X font's XA_UNDERLINE_POSITION and XA_UNDERLINE_THICKNESS
|
X font's XA_UNDERLINE_POSITION and XA_UNDERLINE_THICKNESS
|
||||||
// properties (see wxXt implementation)
|
properties (see wxXt implementation) */
|
||||||
if (m_font.GetUnderlined())
|
if (m_font.GetUnderlined())
|
||||||
{
|
{
|
||||||
long width = gdk_string_width( font, text );
|
long width = gdk_string_width( font, text );
|
||||||
@@ -941,8 +951,8 @@ void wxWindowDC::SetBrush( const wxBrush &brush )
|
|||||||
|
|
||||||
void wxWindowDC::SetBackground( const wxBrush &brush )
|
void wxWindowDC::SetBackground( const wxBrush &brush )
|
||||||
{
|
{
|
||||||
// CMB 21/7/98: Added SetBackground. Sets background brush
|
/* CMB 21/7/98: Added SetBackground. Sets background brush
|
||||||
// for Clear() and bg colour for shapes filled with cross-hatch brush
|
* for Clear() and bg colour for shapes filled with cross-hatch brush */
|
||||||
|
|
||||||
wxCHECK_RET( Ok(), "invalid window dc" );
|
wxCHECK_RET( Ok(), "invalid window dc" );
|
||||||
|
|
||||||
@@ -952,6 +962,11 @@ void wxWindowDC::SetBackground( const wxBrush &brush )
|
|||||||
|
|
||||||
if (!m_backgroundBrush.Ok()) return;
|
if (!m_backgroundBrush.Ok()) return;
|
||||||
|
|
||||||
|
if (m_owner)
|
||||||
|
{
|
||||||
|
m_owner->SetBackgroundColour( m_backgroundBrush.GetColour() );
|
||||||
|
}
|
||||||
|
|
||||||
m_backgroundBrush.GetColour().CalcPixel( m_cmap );
|
m_backgroundBrush.GetColour().CalcPixel( m_cmap );
|
||||||
gdk_gc_set_background( m_brushGC, m_backgroundBrush.GetColour().GetColor() );
|
gdk_gc_set_background( m_brushGC, m_backgroundBrush.GetColour().GetColor() );
|
||||||
gdk_gc_set_background( m_penGC, m_backgroundBrush.GetColour().GetColor() );
|
gdk_gc_set_background( m_penGC, m_backgroundBrush.GetColour().GetColor() );
|
||||||
|
@@ -2536,7 +2536,6 @@ void wxWindow::SetBackgroundColour( const wxColour &colour )
|
|||||||
GdkWindow *window = m_wxwindow->window;
|
GdkWindow *window = m_wxwindow->window;
|
||||||
m_backgroundColour.CalcPixel( gdk_window_get_colormap( window ) );
|
m_backgroundColour.CalcPixel( gdk_window_get_colormap( window ) );
|
||||||
gdk_window_set_background( window, m_backgroundColour.GetColor() );
|
gdk_window_set_background( window, m_backgroundColour.GetColor() );
|
||||||
gdk_window_clear( window );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wxColour sysbg = wxSystemSettings::GetSystemColour( wxSYS_COLOUR_BTNFACE );
|
wxColour sysbg = wxSystemSettings::GetSystemColour( wxSYS_COLOUR_BTNFACE );
|
||||||
|
@@ -96,6 +96,7 @@ wxWindowDC::wxWindowDC()
|
|||||||
m_bgGC = (GdkGC *) NULL;
|
m_bgGC = (GdkGC *) NULL;
|
||||||
m_cmap = (GdkColormap *) NULL;
|
m_cmap = (GdkColormap *) NULL;
|
||||||
m_isMemDC = FALSE;
|
m_isMemDC = FALSE;
|
||||||
|
m_owner = (wxWindow *)NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxWindowDC::wxWindowDC( wxWindow *window )
|
wxWindowDC::wxWindowDC( wxWindow *window )
|
||||||
@@ -105,6 +106,7 @@ wxWindowDC::wxWindowDC( wxWindow *window )
|
|||||||
m_textGC = (GdkGC *) NULL;
|
m_textGC = (GdkGC *) NULL;
|
||||||
m_bgGC = (GdkGC *) NULL;
|
m_bgGC = (GdkGC *) NULL;
|
||||||
m_cmap = (GdkColormap *) NULL;
|
m_cmap = (GdkColormap *) NULL;
|
||||||
|
m_owner = (wxWindow *)NULL;
|
||||||
|
|
||||||
if (!window) return;
|
if (!window) return;
|
||||||
GtkWidget *widget = window->m_wxwindow;
|
GtkWidget *widget = window->m_wxwindow;
|
||||||
@@ -120,6 +122,14 @@ wxWindowDC::wxWindowDC( wxWindow *window )
|
|||||||
|
|
||||||
SetUpDC();
|
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()
|
wxWindowDC::~wxWindowDC()
|
||||||
@@ -758,7 +768,7 @@ void wxWindowDC::DrawText( const wxString &text, long x, long y, bool WXUNUSED(u
|
|||||||
x = XLOG2DEV(x);
|
x = XLOG2DEV(x);
|
||||||
y = YLOG2DEV(y);
|
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)
|
if (m_backgroundMode == wxSOLID)
|
||||||
{
|
{
|
||||||
long width = gdk_string_width( font, text );
|
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 );
|
gdk_draw_string( m_window, font, m_textGC, x, y + font->ascent, text );
|
||||||
|
|
||||||
// CMB 17/7/98: simple underline: ignores scaling and underlying
|
/* CMB 17/7/98: simple underline: ignores scaling and underlying
|
||||||
// X font's XA_UNDERLINE_POSITION and XA_UNDERLINE_THICKNESS
|
X font's XA_UNDERLINE_POSITION and XA_UNDERLINE_THICKNESS
|
||||||
// properties (see wxXt implementation)
|
properties (see wxXt implementation) */
|
||||||
if (m_font.GetUnderlined())
|
if (m_font.GetUnderlined())
|
||||||
{
|
{
|
||||||
long width = gdk_string_width( font, text );
|
long width = gdk_string_width( font, text );
|
||||||
@@ -941,8 +951,8 @@ void wxWindowDC::SetBrush( const wxBrush &brush )
|
|||||||
|
|
||||||
void wxWindowDC::SetBackground( const wxBrush &brush )
|
void wxWindowDC::SetBackground( const wxBrush &brush )
|
||||||
{
|
{
|
||||||
// CMB 21/7/98: Added SetBackground. Sets background brush
|
/* CMB 21/7/98: Added SetBackground. Sets background brush
|
||||||
// for Clear() and bg colour for shapes filled with cross-hatch brush
|
* for Clear() and bg colour for shapes filled with cross-hatch brush */
|
||||||
|
|
||||||
wxCHECK_RET( Ok(), "invalid window dc" );
|
wxCHECK_RET( Ok(), "invalid window dc" );
|
||||||
|
|
||||||
@@ -952,6 +962,11 @@ void wxWindowDC::SetBackground( const wxBrush &brush )
|
|||||||
|
|
||||||
if (!m_backgroundBrush.Ok()) return;
|
if (!m_backgroundBrush.Ok()) return;
|
||||||
|
|
||||||
|
if (m_owner)
|
||||||
|
{
|
||||||
|
m_owner->SetBackgroundColour( m_backgroundBrush.GetColour() );
|
||||||
|
}
|
||||||
|
|
||||||
m_backgroundBrush.GetColour().CalcPixel( m_cmap );
|
m_backgroundBrush.GetColour().CalcPixel( m_cmap );
|
||||||
gdk_gc_set_background( m_brushGC, m_backgroundBrush.GetColour().GetColor() );
|
gdk_gc_set_background( m_brushGC, m_backgroundBrush.GetColour().GetColor() );
|
||||||
gdk_gc_set_background( m_penGC, m_backgroundBrush.GetColour().GetColor() );
|
gdk_gc_set_background( m_penGC, m_backgroundBrush.GetColour().GetColor() );
|
||||||
|
@@ -2536,7 +2536,6 @@ void wxWindow::SetBackgroundColour( const wxColour &colour )
|
|||||||
GdkWindow *window = m_wxwindow->window;
|
GdkWindow *window = m_wxwindow->window;
|
||||||
m_backgroundColour.CalcPixel( gdk_window_get_colormap( window ) );
|
m_backgroundColour.CalcPixel( gdk_window_get_colormap( window ) );
|
||||||
gdk_window_set_background( window, m_backgroundColour.GetColor() );
|
gdk_window_set_background( window, m_backgroundColour.GetColor() );
|
||||||
gdk_window_clear( window );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wxColour sysbg = wxSystemSettings::GetSystemColour( wxSYS_COLOUR_BTNFACE );
|
wxColour sysbg = wxSystemSettings::GetSystemColour( wxSYS_COLOUR_BTNFACE );
|
||||||
|
Reference in New Issue
Block a user