// ----------------------------------------------------------------------------
// the application icon
-#if defined(__WXGTK__) || defined(__WXMOTIF__)
+#if defined(__WXGTK__) || defined(__WXMOTIF__) || defined(__WXMAC__)
#include "mondrian.xpm"
#endif
void DrawCircles(wxDC& dc);
void DrawDefault(wxDC& dc);
+ void DrawRegionsHelper(wxDC& dc, wxCoord x);
+
private:
MyFrame *m_owner;
if ( !LoadImages() )
{
- wxLogError("Can't load one of the bitmap files needed for this sample "
- "from the current or parent directory, please copy them "
- "there.");
+ wxLogError(wxT("Can't load one of the bitmap files needed ")
+ wxT("for this sample from the current or parent ")
+ wxT("directory, please copy them there."));
// stop here
DeleteBitmaps();
{
dc.SetPen( wxPen( "black", width, wxSOLID) );
dc.SetBrush( *wxRED_BRUSH );
- dc.DrawText(wxString::Format("Testing lines of width %d", width), x + 10, y - 10);
+ dc.DrawText(wxString::Format(wxT("Testing lines of width %d"), width), x + 10, y - 10);
dc.DrawRectangle( x+10, y+10, 100, 190 );
dc.DrawText("Solid/dot/short dash/long dash/dot dash", x + 150, y + 10);
{
// mark the origin
dc.DrawCircle(0, 0, 10);
-#if !(defined __WXGTK__) && !(defined __WXMOTIF__)
+#if !(defined __WXGTK__) && !(defined __WXMOTIF__) && !(defined __WXMGL__)
// not implemented in wxGTK or wxMOTIF :-(
dc.FloodFill(0, 0, wxColour(255, 0, 0));
#endif //
dc.DrawText( "This is text", 110, 10 );
dc.DrawRotatedText( "That is text", 20, 10, -45 );
- dc.SetFont( *wxNORMAL_FONT );
+ // use wxSWISS_FONT and not wxNORMAL_FONT as the latter can't be rotated
+ // under Win9x (it is not TrueType)
+ dc.SetFont( *wxSWISS_FONT );
wxString text;
dc.SetBackgroundMode(wxTRANSPARENT);
for ( int n = -180; n < 180; n += 30 )
{
- text.Printf(" %d rotated text", n);
+ text.Printf(wxT(" %d rotated text"), n);
dc.DrawRotatedText(text , 400, 400, n);
}
long height;
long descent;
dc.GetTextExtent( "This is Swiss 18pt text.", &length, &height, &descent );
- text.Printf( "Dimensions are length %ld, height %ld, descent %ld", length, height, descent );
+ text.Printf( wxT("Dimensions are length %ld, height %ld, descent %ld"), length, height, descent );
dc.DrawText( text, 110, 80 );
- text.Printf( "CharHeight() returns: %d", dc.GetCharHeight() );
+ text.Printf( wxT("CharHeight() returns: %d"), dc.GetCharHeight() );
dc.DrawText( text, 110, 120 );
dc.DrawRectangle( 100, 40, 4, height );
int rop;
} rasterOperations[] =
{
- { "wxAND", wxAND },
- { "wxAND_INVERT", wxAND_INVERT },
- { "wxAND_REVERSE", wxAND_REVERSE },
- { "wxCLEAR", wxCLEAR },
- { "wxCOPY", wxCOPY },
- { "wxEQUIV", wxEQUIV },
- { "wxINVERT", wxINVERT },
- { "wxNAND", wxNAND },
- { "wxNO_OP", wxNO_OP },
- { "wxOR", wxOR },
- { "wxOR_INVERT", wxOR_INVERT },
- { "wxOR_REVERSE", wxOR_REVERSE },
- { "wxSET", wxSET },
- { "wxSRC_INVERT", wxSRC_INVERT },
- { "wxXOR", wxXOR },
+ { wxT("wxAND"), wxAND },
+ { wxT("wxAND_INVERT"), wxAND_INVERT },
+ { wxT("wxAND_REVERSE"), wxAND_REVERSE },
+ { wxT("wxCLEAR"), wxCLEAR },
+ { wxT("wxCOPY"), wxCOPY },
+ { wxT("wxEQUIV"), wxEQUIV },
+ { wxT("wxINVERT"), wxINVERT },
+ { wxT("wxNAND"), wxNAND },
+ { wxT("wxNO_OP"), wxNO_OP },
+ { wxT("wxOR"), wxOR },
+ { wxT("wxOR_INVERT"), wxOR_INVERT },
+ { wxT("wxOR_REVERSE"), wxOR_REVERSE },
+ { wxT("wxSET"), wxSET },
+ { wxT("wxSRC_INVERT"), wxSRC_INVERT },
+ { wxT("wxXOR"), wxXOR },
};
void MyCanvas::DrawImages(wxDC& dc)
dc.DrawText("You should see a red rect partly covered by a cyan one "
"on the left", 10, 5);
dc.DrawText("and 5 smileys from which 4 are partially clipped on the "
- "right", 10, 5 + dc.GetCharHeight());
+ "right (2 copies should be identical)",
+ 10, 5 + dc.GetCharHeight());
+
+ DrawRegionsHelper(dc, 10);
+ DrawRegionsHelper(dc, 350);
+}
+void MyCanvas::DrawRegionsHelper(wxDC& dc, wxCoord x)
+{
+ dc.DestroyClippingRegion();
dc.SetBrush( *wxWHITE_BRUSH );
dc.SetPen( *wxTRANSPARENT_PEN );
- dc.DrawRectangle( 10,50,310,310 );
+ dc.DrawRectangle( x,50,310,310 );
- dc.SetClippingRegion( 20,60,100,270 );
+ dc.SetClippingRegion( x+10,60,100,270 );
dc.SetBrush( *wxRED_BRUSH );
- dc.DrawRectangle( 10,50,310,310 );
+ dc.DrawRectangle( x,50,310,310 );
- dc.SetClippingRegion( 20,60,100,100 );
+ dc.SetClippingRegion( x+10,60,100,100 );
dc.SetBrush( *wxCYAN_BRUSH );
- dc.DrawRectangle( 10,50,310,310 );
+ dc.DrawRectangle( x,50,310,310 );
- dc.DestroyClippingRegion();
- dc.SetClippingRegion( 120,70,100,270 );
+ // when drawing the left half, destroy the clipping region, when drawing
+ // the right one - leave it
+ //
+ // normally it shouldn't make any difference as SetClippingRegion()
+ // replaces the old clipping region
+ if ( x < 300 )
+ dc.DestroyClippingRegion();
+ dc.SetClippingRegion( x+110,70,100,270 );
dc.SetBrush( *wxGREY_BRUSH );
- dc.DrawRectangle( 10,50,310,310 );
+ dc.DrawRectangle( x,50,310,310 );
if (m_smile_bmp.Ok())
{
- dc.DrawBitmap( m_smile_bmp, 160, 200, TRUE );
- dc.DrawBitmap( m_smile_bmp, 140, 60, TRUE );
- dc.DrawBitmap( m_smile_bmp, 140, 330, TRUE );
- dc.DrawBitmap( m_smile_bmp, 110, 120, TRUE );
- dc.DrawBitmap( m_smile_bmp, 210, 120, TRUE );
+ dc.DrawBitmap( m_smile_bmp, x+150, 200, TRUE );
+ dc.DrawBitmap( m_smile_bmp, x+130, 60, TRUE );
+ dc.DrawBitmap( m_smile_bmp, x+130, 330, TRUE );
+ dc.DrawBitmap( m_smile_bmp, x+100, 120, TRUE );
+ dc.DrawBitmap( m_smile_bmp, x+200, 120, TRUE );
}
}
long x = dc.DeviceToLogicalX( pos.x );
long y = dc.DeviceToLogicalY( pos.y );
wxString str;
- str.Printf( "Current mouse position: %d,%d", (int)x, (int)y );
+ str.Printf( wxT("Current mouse position: %d,%d"), (int)x, (int)y );
m_owner->SetStatusText( str );
}