X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/b11729f1496ef0bba192a00af430eb46a581e97d..55325d01e68cfb071e42699ca72ba84a7071aa2b:/samples/drawing/drawing.cpp?ds=sidebyside diff --git a/samples/drawing/drawing.cpp b/samples/drawing/drawing.cpp index 31f673167b..61df8bf913 100644 --- a/samples/drawing/drawing.cpp +++ b/samples/drawing/drawing.cpp @@ -17,11 +17,6 @@ // headers // ---------------------------------------------------------------------------- -#if defined(__GNUG__) && !defined(__APPLE__) - #pragma implementation - #pragma interface -#endif - // For compilers that support precompilation, includes "wx/wx.h". #include "wx/wxprec.h" @@ -65,7 +60,9 @@ enum ScreenToShow Show_Ops, Show_Regions, Show_Circles, - Show_Splines + Show_Splines, + Show_Gradient, + Show_Max }; // ---------------------------------------------------------------------------- @@ -169,6 +166,7 @@ protected: void DrawCircles(wxDC& dc); void DrawSplines(wxDC& dc); void DrawDefault(wxDC& dc); + void DrawGradients(wxDC& dc); void DrawRegionsHelper(wxDC& dc, wxCoord x, bool firstTime); @@ -205,7 +203,8 @@ enum File_ShowRegions, File_ShowCircles, File_ShowSplines, - MenuShow_Last = File_ShowSplines, + File_ShowGradients, + MenuShow_Last = File_ShowGradients, File_Clip, @@ -516,7 +515,7 @@ void MyCanvas::DrawDefault(wxDC& dc) // mark the origin dc.DrawCircle(0, 0, 10); -#if !wxMAC_USE_CORE_GRAPHICS +#if !defined(wxMAC_USE_CORE_GRAPHICS) || !wxMAC_USE_CORE_GRAPHICS // GetPixel and FloodFill not supported by Mac OS X CoreGraphics // (FloodFill uses Blit from a non-wxMemoryDC) //flood fill using brush, starting at 1,1 and replacing whatever colour we find there @@ -976,6 +975,36 @@ void MyCanvas::DrawSplines(wxDC& dc) #endif } +void MyCanvas::DrawGradients(wxDC& dc) +{ + // LHS: linear + wxRect r(10, 10, 100, 100); + dc.GradientFillLinear(r, *wxWHITE, *wxBLUE, wxRIGHT); + + r.Offset(0, 110); + dc.GradientFillLinear(r, *wxWHITE, *wxBLUE, wxLEFT); + + r.Offset(0, 110); + dc.GradientFillLinear(r, *wxWHITE, *wxBLUE, wxDOWN); + + r.Offset(0, 110); + dc.GradientFillLinear(r, *wxWHITE, *wxBLUE, wxUP); + + + // RHS: concentric + r = wxRect(200, 10, 100, 100); + dc.GradientFillConcentric(r, *wxBLUE, *wxWHITE); + + r.Offset(0, 110); + dc.GradientFillConcentric(r, *wxWHITE, *wxBLUE); + + r.Offset(0, 110); + dc.GradientFillConcentric(r, *wxBLUE, *wxWHITE, wxPoint(0, 0)); + + r.Offset(0, 110); + dc.GradientFillConcentric(r, *wxBLUE, *wxWHITE, wxPoint(100, 100)); +} + void MyCanvas::DrawRegions(wxDC& dc) { dc.DrawText(_T("You should see a red rect partly covered by a cyan one ") @@ -1110,6 +1139,13 @@ void MyCanvas::OnPaint(wxPaintEvent &WXUNUSED(event)) case Show_Ops: DrawWithLogicalOps(dc); break; + + case Show_Gradient: + DrawGradients(dc); + break; + + default: + break; } } @@ -1166,7 +1202,8 @@ MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size) menuFile->Append(File_ShowOps, _T("&ROP screen\tF7")); menuFile->Append(File_ShowRegions, _T("Re&gions screen\tF8")); menuFile->Append(File_ShowCircles, _T("&Circles screen\tF9")); - menuFile->Append(File_ShowSplines, _T("&Splines screen")); + menuFile->Append(File_ShowSplines, _T("&Splines screen\tF11")); + menuFile->Append(File_ShowGradients, _T("&Gradients screen\tF12")); menuFile->AppendSeparator(); menuFile->AppendCheckItem(File_Clip, _T("&Clip\tCtrl-C"), _T("Clip/unclip drawing")); menuFile->AppendSeparator();