From 8ab40c5227978dcca4e2a9a5dcc6eca3dd7c7d7c Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 1 May 2003 19:31:30 +0000 Subject: [PATCH] fixes for working with mono bitmaps (patch 728768) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@20416 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/gtk/dcmemory.h | 1 + include/wx/gtk1/dcmemory.h | 1 + src/gtk/dcmemory.cpp | 64 ++++++++++++++++++++------------------ src/gtk1/dcmemory.cpp | 64 ++++++++++++++++++++------------------ 4 files changed, 70 insertions(+), 60 deletions(-) diff --git a/include/wx/gtk/dcmemory.h b/include/wx/gtk/dcmemory.h index a4493740d1..78b712ef42 100644 --- a/include/wx/gtk/dcmemory.h +++ b/include/wx/gtk/dcmemory.h @@ -43,6 +43,7 @@ public: // and everything else as drawing 1. virtual void SetPen( const wxPen &pen ); virtual void SetBrush( const wxBrush &brush ); + virtual void SetBackground( const wxBrush &brush ); virtual void SetTextForeground( const wxColour &col ); virtual void SetTextBackground( const wxColour &col ); diff --git a/include/wx/gtk1/dcmemory.h b/include/wx/gtk1/dcmemory.h index a4493740d1..78b712ef42 100644 --- a/include/wx/gtk1/dcmemory.h +++ b/include/wx/gtk1/dcmemory.h @@ -43,6 +43,7 @@ public: // and everything else as drawing 1. virtual void SetPen( const wxPen &pen ); virtual void SetBrush( const wxBrush &brush ); + virtual void SetBackground( const wxBrush &brush ); virtual void SetTextForeground( const wxColour &col ); virtual void SetTextBackground( const wxColour &col ); diff --git a/src/gtk/dcmemory.cpp b/src/gtk/dcmemory.cpp index 46920d7d6d..3c843eae1d 100644 --- a/src/gtk/dcmemory.cpp +++ b/src/gtk/dcmemory.cpp @@ -79,44 +79,51 @@ void wxMemoryDC::SelectObject( const wxBitmap& bitmap ) } } -void wxMemoryDC::SetPen( const wxPen &pen ) +void wxMemoryDC::SetPen( const wxPen& penOrig ) { - if (m_selected.Ok() && m_selected.GetBitmap() && (*wxTRANSPARENT_PEN != pen)) + wxPen pen( penOrig ); + if ( m_selected.Ok() && + m_selected.GetBitmap() && + (pen != *wxTRANSPARENT_PEN) ) { - if (*wxWHITE_PEN == pen) - wxWindowDC::SetPen( *wxBLACK_PEN ); - else - wxWindowDC::SetPen( *wxWHITE_PEN ); - } - else - { - wxWindowDC::SetPen( pen ); + pen.SetColour( pen.GetColour() == *wxWHITE ? *wxBLACK : *wxWHITE ); } + + wxWindowDC::SetPen( pen ); } -void wxMemoryDC::SetBrush( const wxBrush &brush ) +void wxMemoryDC::SetBrush( const wxBrush& brushOrig ) { - if (m_selected.Ok() && m_selected.GetBitmap() && (*wxTRANSPARENT_BRUSH != brush)) + wxBrush brush( brushOrig ); + if ( m_selected.Ok() && + m_selected.GetBitmap() && + (brush != *wxTRANSPARENT_BRUSH) ) { - if (*wxWHITE_BRUSH == brush) - wxWindowDC::SetBrush( *wxBLACK_BRUSH ); - else - wxWindowDC::SetBrush( *wxWHITE_BRUSH ); - } - else - { - wxWindowDC::SetBrush( brush ); + brush.SetColour( brush.GetColour() == *wxWHITE ? *wxBLACK : *wxWHITE); } + + wxWindowDC::SetBrush( brush ); } -void wxMemoryDC::SetTextForeground( const wxColour &col ) +void wxMemoryDC::SetBackground( const wxBrush& brushOrig ) { - if (m_selected.Ok() && m_selected.GetBitmap()) + wxBrush brush(brushOrig); + + if ( m_selected.Ok() && + m_selected.GetBitmap() && + (brush != *wxTRANSPARENT_BRUSH) ) { - if (col == *wxWHITE) - wxWindowDC::SetTextForeground( *wxBLACK ); - else - wxWindowDC::SetTextForeground( *wxWHITE ); + brush.SetColour( brush.GetColour() == *wxWHITE ? *wxBLACK : *wxWHITE ); + } + + wxWindowDC::SetBackground( brush ); +} + +void wxMemoryDC::SetTextForeground( const wxColour& col ) +{ + if ( m_selected.Ok() && m_selected.GetBitmap() ) + { + wxWindowDC::SetTextForeground( col == *wxWHITE ? *wxBLACK : *wxWHITE); } else { @@ -128,10 +135,7 @@ void wxMemoryDC::SetTextBackground( const wxColour &col ) { if (m_selected.Ok() && m_selected.GetBitmap()) { - if (col == *wxWHITE) - wxWindowDC::SetTextBackground( *wxBLACK ); - else - wxWindowDC::SetTextBackground( *wxWHITE ); + wxWindowDC::SetTextBackground( col == *wxWHITE ? *wxBLACK : *wxWHITE ); } else { diff --git a/src/gtk1/dcmemory.cpp b/src/gtk1/dcmemory.cpp index 46920d7d6d..3c843eae1d 100644 --- a/src/gtk1/dcmemory.cpp +++ b/src/gtk1/dcmemory.cpp @@ -79,44 +79,51 @@ void wxMemoryDC::SelectObject( const wxBitmap& bitmap ) } } -void wxMemoryDC::SetPen( const wxPen &pen ) +void wxMemoryDC::SetPen( const wxPen& penOrig ) { - if (m_selected.Ok() && m_selected.GetBitmap() && (*wxTRANSPARENT_PEN != pen)) + wxPen pen( penOrig ); + if ( m_selected.Ok() && + m_selected.GetBitmap() && + (pen != *wxTRANSPARENT_PEN) ) { - if (*wxWHITE_PEN == pen) - wxWindowDC::SetPen( *wxBLACK_PEN ); - else - wxWindowDC::SetPen( *wxWHITE_PEN ); - } - else - { - wxWindowDC::SetPen( pen ); + pen.SetColour( pen.GetColour() == *wxWHITE ? *wxBLACK : *wxWHITE ); } + + wxWindowDC::SetPen( pen ); } -void wxMemoryDC::SetBrush( const wxBrush &brush ) +void wxMemoryDC::SetBrush( const wxBrush& brushOrig ) { - if (m_selected.Ok() && m_selected.GetBitmap() && (*wxTRANSPARENT_BRUSH != brush)) + wxBrush brush( brushOrig ); + if ( m_selected.Ok() && + m_selected.GetBitmap() && + (brush != *wxTRANSPARENT_BRUSH) ) { - if (*wxWHITE_BRUSH == brush) - wxWindowDC::SetBrush( *wxBLACK_BRUSH ); - else - wxWindowDC::SetBrush( *wxWHITE_BRUSH ); - } - else - { - wxWindowDC::SetBrush( brush ); + brush.SetColour( brush.GetColour() == *wxWHITE ? *wxBLACK : *wxWHITE); } + + wxWindowDC::SetBrush( brush ); } -void wxMemoryDC::SetTextForeground( const wxColour &col ) +void wxMemoryDC::SetBackground( const wxBrush& brushOrig ) { - if (m_selected.Ok() && m_selected.GetBitmap()) + wxBrush brush(brushOrig); + + if ( m_selected.Ok() && + m_selected.GetBitmap() && + (brush != *wxTRANSPARENT_BRUSH) ) { - if (col == *wxWHITE) - wxWindowDC::SetTextForeground( *wxBLACK ); - else - wxWindowDC::SetTextForeground( *wxWHITE ); + brush.SetColour( brush.GetColour() == *wxWHITE ? *wxBLACK : *wxWHITE ); + } + + wxWindowDC::SetBackground( brush ); +} + +void wxMemoryDC::SetTextForeground( const wxColour& col ) +{ + if ( m_selected.Ok() && m_selected.GetBitmap() ) + { + wxWindowDC::SetTextForeground( col == *wxWHITE ? *wxBLACK : *wxWHITE); } else { @@ -128,10 +135,7 @@ void wxMemoryDC::SetTextBackground( const wxColour &col ) { if (m_selected.Ok() && m_selected.GetBitmap()) { - if (col == *wxWHITE) - wxWindowDC::SetTextBackground( *wxBLACK ); - else - wxWindowDC::SetTextBackground( *wxWHITE ); + wxWindowDC::SetTextBackground( col == *wxWHITE ? *wxBLACK : *wxWHITE ); } else {