black now denotes 0 on mono-bitmaps.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@5419 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robert Roebling
2000-01-15 10:39:27 +00:00
parent 5dd26b0839
commit 41fbc84101
7 changed files with 156 additions and 7 deletions

View File

@@ -174,6 +174,11 @@ The arc is drawn in an anticlockwise direction from the start point to the end p
Draw a bitmap on the device context at the specified point. If {\it transparent} is TRUE and the bitmap has
a transparency mask, the bitmap will be drawn transparently.
When drawing a mono-bitmap, the current text foreground colour will be used to draw the foreground
of the bitmap (all bit set to 1), and the current text background colour to draw the background
(all bits set 0). See also \helpref{SetTextForeground}{wxwindowsettextforeground},
\helpref{SetTextForeground}{wxwindowsettextforeground} and \helpref{wxMemoryDC}{wxmemorydc}.
\membersection{wxDC::DrawEllipse}\label{wxdcdrawellipse}
\func{void}{DrawEllipse}{\param{wxCoord}{ x}, \param{wxCoord}{ y}, \param{wxCoord}{ width}, \param{wxCoord}{ height}}

View File

@@ -1,6 +1,9 @@
\section{\class{wxMemoryDC}}\label{wxmemorydc}
A memory device context provides a means to draw graphics onto a bitmap.
A memory device context provides a means to draw graphics onto a bitmap. When
drawing in to a mono-bitmap, using {\tt wxWHITE}, {\tt wxWHITE_PEN} and {\tt wxWHITE_BRUSH}
will draw the background colour (i.e. 0) whereas all other colours will draw the
foreground colour (i.e. 1).
\wxheading{Derived from}

View File

@@ -37,6 +37,15 @@ public:
virtual void SelectObject( const wxBitmap& bitmap );
void DoGetSize( int *width, int *height ) const;
// these get reimplemented for mono-bitmaps to behave
// more like their Win32 couterparts. They now interpret
// wxWHITE, wxWHITE_BRUSH and wxWHITE_PEN as drawing 0
// and everything else as drawing 1.
virtual void SetPen( const wxPen &pen );
virtual void SetBrush( const wxBrush &brush );
virtual void SetTextForeground( const wxColour &col );
virtual void SetTextBackground( const wxColour &col );
// implementation
wxBitmap m_selected;

View File

@@ -37,6 +37,15 @@ public:
virtual void SelectObject( const wxBitmap& bitmap );
void DoGetSize( int *width, int *height ) const;
// these get reimplemented for mono-bitmaps to behave
// more like their Win32 couterparts. They now interpret
// wxWHITE, wxWHITE_BRUSH and wxWHITE_PEN as drawing 0
// and everything else as drawing 1.
virtual void SetPen( const wxPen &pen );
virtual void SetBrush( const wxBrush &brush );
virtual void SetTextForeground( const wxColour &col );
virtual void SetTextBackground( const wxColour &col );
// implementation
wxBitmap m_selected;

View File

@@ -271,14 +271,18 @@ void MyCanvas::OnPaint( wxPaintEvent &WXUNUSED(event) )
}
dc.SetTextForeground( "BLACK" );
wxBitmap mono( 30,30,1 );
wxBitmap mono( 60,50,1 );
wxMemoryDC memdc;
memdc.SelectObject( mono );
memdc.SetPen( *wxTRANSPARENT_PEN );
memdc.SetBrush( *wxBLACK_BRUSH );
memdc.DrawRectangle( 0,0,30,30 );
memdc.SetBrush( *wxWHITE_BRUSH );
memdc.DrawRectangle( 5,5,20,20 );
memdc.DrawRectangle( 0,0,60,50 );
memdc.SetTextForeground( *wxBLACK );
memdc.DrawText( "Hi!", 5, 5 );
memdc.SetBrush( *wxBLACK_BRUSH );
memdc.DrawRectangle( 33,5,20,20 );
memdc.SetPen( *wxRED_PEN );
memdc.DrawLine( 5, 42, 50, 42 );
memdc.SelectObject( wxNullBitmap );
if (mono.Ok())
{
@@ -390,8 +394,7 @@ void MyFrame::OnQuit( wxCommandEvent &WXUNUSED(event) )
void MyFrame::OnAbout( wxCommandEvent &WXUNUSED(event) )
{
(void)wxMessageBox( "wxImage demo\n"
"\n"
"Robert Roebling (c) 1998",
"Robert Roebling (c) 1998,2000",
"About wxImage Demo", wxICON_INFORMATION | wxOK );
}

View File

@@ -66,6 +66,66 @@ void wxMemoryDC::SelectObject( const wxBitmap& bitmap )
}
}
void wxMemoryDC::SetPen( const wxPen &pen )
{
if (m_selected.Ok() && m_selected.GetBitmap() && (*wxTRANSPARENT_PEN != pen))
{
if (*wxWHITE_PEN == pen)
wxWindowDC::SetPen( *wxBLACK_PEN );
else
wxWindowDC::SetPen( *wxWHITE_PEN );
}
else
{
wxWindowDC::SetPen( pen );
}
}
void wxMemoryDC::SetBrush( const wxBrush &brush )
{
if (m_selected.Ok() && m_selected.GetBitmap() && (*wxTRANSPARENT_BRUSH != brush))
{
if (*wxWHITE_BRUSH == brush)
wxWindowDC::SetBrush( *wxBLACK_BRUSH );
else
wxWindowDC::SetBrush( *wxWHITE_BRUSH );
}
else
{
wxWindowDC::SetBrush( brush );
}
}
void wxMemoryDC::SetTextForeground( const wxColour &col )
{
if (m_selected.Ok() && m_selected.GetBitmap())
{
if (col == *wxWHITE)
wxWindowDC::SetTextForeground( *wxBLACK );
else
wxWindowDC::SetTextForeground( *wxWHITE );
}
else
{
wxWindowDC::SetTextForeground( col );
}
}
void wxMemoryDC::SetTextBackground( const wxColour &col )
{
if (m_selected.Ok() && m_selected.GetBitmap())
{
if (col == *wxWHITE)
wxWindowDC::SetTextBackground( *wxBLACK );
else
wxWindowDC::SetTextBackground( *wxWHITE );
}
else
{
wxWindowDC::SetTextBackground( col );
}
}
void wxMemoryDC::DoGetSize( int *width, int *height ) const
{
if (m_selected.Ok())

View File

@@ -66,6 +66,66 @@ void wxMemoryDC::SelectObject( const wxBitmap& bitmap )
}
}
void wxMemoryDC::SetPen( const wxPen &pen )
{
if (m_selected.Ok() && m_selected.GetBitmap() && (*wxTRANSPARENT_PEN != pen))
{
if (*wxWHITE_PEN == pen)
wxWindowDC::SetPen( *wxBLACK_PEN );
else
wxWindowDC::SetPen( *wxWHITE_PEN );
}
else
{
wxWindowDC::SetPen( pen );
}
}
void wxMemoryDC::SetBrush( const wxBrush &brush )
{
if (m_selected.Ok() && m_selected.GetBitmap() && (*wxTRANSPARENT_BRUSH != brush))
{
if (*wxWHITE_BRUSH == brush)
wxWindowDC::SetBrush( *wxBLACK_BRUSH );
else
wxWindowDC::SetBrush( *wxWHITE_BRUSH );
}
else
{
wxWindowDC::SetBrush( brush );
}
}
void wxMemoryDC::SetTextForeground( const wxColour &col )
{
if (m_selected.Ok() && m_selected.GetBitmap())
{
if (col == *wxWHITE)
wxWindowDC::SetTextForeground( *wxBLACK );
else
wxWindowDC::SetTextForeground( *wxWHITE );
}
else
{
wxWindowDC::SetTextForeground( col );
}
}
void wxMemoryDC::SetTextBackground( const wxColour &col )
{
if (m_selected.Ok() && m_selected.GetBitmap())
{
if (col == *wxWHITE)
wxWindowDC::SetTextBackground( *wxBLACK );
else
wxWindowDC::SetTextBackground( *wxWHITE );
}
else
{
wxWindowDC::SetTextBackground( col );
}
}
void wxMemoryDC::DoGetSize( int *width, int *height ) const
{
if (m_selected.Ok())