- wxPaintDC dc(this);
- PrepareDC( dc );
-
- wxRegion region( 110, 110, 80, 80 );
- wxRegion hole( 130, 130, 40, 1 );
- region.Intersect( hole );
- dc.SetClippingRegion( region );
-
- dc.SetBrush( *wxRED_BRUSH );
- dc.DrawRectangle( 100, 100, 200, 200 );
-
- dc.DestroyClipingRegion();
-
- dc.SetPen( *wxTRANSPARENT_PEN );
-
- wxRegion strip( 110, 200, 30, 1 );
- wxRegionIterator it( strip );
- while (it)
+#if wxUSE_UNICODE
+ if (event.m_uniChar)
+ {
+ m_text += event.m_uniChar;
+ Refresh();
+ return;
+ }
+#endif
+
+ // some test cases
+ switch (event.m_keyCode)
+ {
+ case WXK_UP: m_text += wxT( "<UP>" ); break;
+ case WXK_LEFT: m_text += wxT( "<LEFT>" ); break;
+ case WXK_RIGHT: m_text += wxT( "<RIGHT>" ); break;
+ case WXK_DOWN: m_text += wxT( "<DOWN>" ); break;
+ case WXK_RETURN: m_text += wxT( "<ENTER>" ); break;
+ default: m_text += (wxChar)event.m_keyCode; break;
+ }
+}
+
+void MyCanvas::DoPaint(wxDC& dc)
+{
+ if ( m_eraseBgInPaint )
+ {
+ dc.SetBackground(*wxLIGHT_GREY);
+ dc.Clear();
+
+ dc.DrawText("Background erased in OnPaint", 65, 110);
+ }
+ else if ( GetBackgroundStyle() == wxBG_STYLE_PAINT )
+ {
+ dc.SetTextForeground(*wxRED);
+ dc.DrawText("You must enable erasing background in OnPaint to avoid "
+ "display corruption", 65, 110);
+ }
+
+ dc.SetBrush( *wxBLACK_BRUSH );
+ dc.DrawRectangle( 10,10,60,50 );
+
+ dc.DrawBitmap( m_bitmap, 20, 20, true );
+
+ dc.SetTextForeground(*wxWHITE);
+ dc.DrawText("This text is drawn from OnPaint", 65, 65);
+
+ wxString tmp;
+ tmp.Printf("Hit any key to display more text: %s", m_text);
+
+ int w,h;
+ dc.GetTextExtent( tmp, &w, &h );
+ dc.DrawRectangle( 65, 85, w, h );
+ dc.DrawText( tmp, 65, 85 );
+}
+
+void MyCanvas::OnPaint( wxPaintEvent &WXUNUSED(event) )
+{
+ if ( m_useBuffer )
+ {
+ wxAutoBufferedPaintDC dc(this);
+ PrepareDC(dc);
+
+ DoPaint(dc);
+ }
+ else