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}}
\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}
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;
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;
}
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())
{
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 );
}
}
}
+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())
}
}
+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())