X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/8a021e00749a317cfd381de4092d1cc02b39d698..05e0b047d879cdbfade7f2ab346c0acdf3e29f96:/samples/drawing/drawing.cpp?ds=sidebyside diff --git a/samples/drawing/drawing.cpp b/samples/drawing/drawing.cpp index 7c1e0d578f..8a41242bd5 100644 --- a/samples/drawing/drawing.cpp +++ b/samples/drawing/drawing.cpp @@ -35,25 +35,13 @@ #include "wx/artprov.h" #include "wx/dcgraph.h" #include "wx/overlay.h" - -#define wxTEST_GRAPHICS 1 +#include "wx/graphics.h" +#include "wx/filename.h" #define TEST_CAIRO_EVERYWHERE 0 -#if wxTEST_GRAPHICS -#include "wx/graphics.h" -#include "wx/dcgraph.h" -#if wxUSE_GRAPHICS_CONTEXT == 0 -#undef wxTEST_GRAPHICS -#define wxTEST_GRAPHICS 0 -#endif -#else -#undef wxUSE_GRAPHICS_CONTEXT -#define wxUSE_GRAPHICS_CONTEXT 0 -#endif - // ---------------------------------------------------------------------------- -// ressources +// resources // ---------------------------------------------------------------------------- // the application icon @@ -330,6 +318,9 @@ bool MyApp::LoadImages() gs_bmp36 = new wxBitmap; wxPathList pathList; + // special hack for Unix in-tree sample build, don't do this in real + // programs, use wxStandardPaths instead + pathList.Add(wxFileName(argv[0]).GetPath()); pathList.Add(_T(".")); pathList.Add(_T("..")); pathList.Add(_T("../..")); @@ -393,10 +384,8 @@ bool MyApp::OnInit() wxT("for this sample from the current or parent ") wxT("directory, please copy them there.")); - // stop here - DeleteBitmaps(); - - return false; + // still continue, the sample can be used without images too if they're + // missing for whatever reason } // ok, continue @@ -822,20 +811,20 @@ void MyCanvas::DrawText(wxDC& dc) // test the logical function effect wxCoord y = 150; dc.SetLogicalFunction(wxINVERT); - dc.DrawText( _T("There should be no text below"), 110, 150 ); + // text drawing should ignore logical function + dc.DrawText( _T("There should be a text below"), 110, 150 ); dc.DrawRectangle( 110, y, 100, height ); - // twice drawn inverted should result in invisible y += height; - dc.DrawText( _T("Invisible text"), 110, y ); + dc.DrawText( _T("Visible text"), 110, y ); dc.DrawRectangle( 110, y, 100, height ); - dc.DrawText( _T("Invisible text"), 110, y ); + dc.DrawText( _T("Visible text"), 110, y ); dc.DrawRectangle( 110, y, 100, height ); dc.SetLogicalFunction(wxCOPY); y += height; dc.DrawRectangle( 110, y, 100, height ); - dc.DrawText( _T("Visible text"), 110, y ); + dc.DrawText( _T("Another visible text"), 110, y ); } static const struct @@ -1364,7 +1353,7 @@ void MyCanvas::DrawRegionsHelper(wxDC& dc, wxCoord x, bool firstTime) if ( !firstTime ) region.Offset(10, 10); #endif - dc.SetClippingRegion(region); + dc.SetDeviceClippingRegion(region); dc.SetBrush( *wxGREY_BRUSH ); dc.DrawRectangle( x, y, 310, 310 ); @@ -1527,7 +1516,7 @@ void MyCanvas::OnMouseMove(wxMouseEvent &event) wxDCOverlay overlaydc( m_overlay, &dc ); overlaydc.Clear(); -#if __WXMAC__ +#ifdef __WXMAC__ dc.SetPen( *wxGREY_PEN ); dc.SetBrush( wxColour( 192,192,192,64 ) ); #else @@ -1556,6 +1545,7 @@ void MyCanvas::OnMouseUp(wxMouseEvent &event) { if ( m_rubberBand ) { + ReleaseMouse(); { wxClientDC dc( this ); PrepareDC( dc ); @@ -1613,7 +1603,7 @@ MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size) menuFile->Append(File_ShowPolygons, _T("&Polygons screen\tF5")); menuFile->Append(File_ShowMask, _T("&Mask screen\tF6")); menuFile->Append(File_ShowMaskStretch, _T("1/&2 scaled mask\tShift-F6")); - menuFile->Append(File_ShowOps, _T("&ROP screen\tF7")); + menuFile->Append(File_ShowOps, _T("&Raster operations screen\tF7")); menuFile->Append(File_ShowRegions, _T("Re&gions screen\tF8")); menuFile->Append(File_ShowCircles, _T("&Circles screen\tF9")); #if wxUSE_GRAPHICS_CONTEXT @@ -1622,7 +1612,7 @@ MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size) menuFile->Append(File_ShowSplines, _T("&Splines screen\tF11")); menuFile->Append(File_ShowGradients, _T("&Gradients screen\tF12")); #if wxUSE_GRAPHICS_CONTEXT - menuFile->Append(File_ShowGraphics, _T("&Graphics screen\tF13")); + menuFile->Append(File_ShowGraphics, _T("&Graphics screen")); #endif menuFile->AppendSeparator(); menuFile->AppendCheckItem(File_Clip, _T("&Clip\tCtrl-C"), _T("Clip/unclip drawing"));