]> git.saurik.com Git - wxWidgets.git/blobdiff - include/wx/dc.h
don't generate a scroll event when setting scroll position from scroll event handler
[wxWidgets.git] / include / wx / dc.h
index 0e6d1d055bd64fce4005246461b4d0200891e5e2..a6423af998f99763c3208d3fe84ea1f280ac757d 100644 (file)
@@ -1,5 +1,5 @@
 /////////////////////////////////////////////////////////////////////////////
 /////////////////////////////////////////////////////////////////////////////
-// Name:        dc.h
+// Name:        wx/dc.h
 // Purpose:     wxDC class
 // Author:      Vadim Zeitlin
 // Modified by:
 // Purpose:     wxDC class
 // Author:      Vadim Zeitlin
 // Modified by:
 #ifndef _WX_DC_H_BASE_
 #define _WX_DC_H_BASE_
 
 #ifndef _WX_DC_H_BASE_
 #define _WX_DC_H_BASE_
 
-#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
-    #pragma interface "dcbase.h"
-#endif
-
 // ----------------------------------------------------------------------------
 // headers which we must include here
 // ----------------------------------------------------------------------------
 // ----------------------------------------------------------------------------
 // headers which we must include here
 // ----------------------------------------------------------------------------
@@ -97,8 +93,6 @@ protected:
 // global variables
 // ---------------------------------------------------------------------------
 
 // global variables
 // ---------------------------------------------------------------------------
 
-extern WXDLLEXPORT_DATA(int) wxPageNumber;
-
 // ---------------------------------------------------------------------------
 // wxDC is the device context - object on which any drawing is done
 // ---------------------------------------------------------------------------
 // ---------------------------------------------------------------------------
 // wxDC is the device context - object on which any drawing is done
 // ---------------------------------------------------------------------------
@@ -140,8 +134,10 @@ public:
 
     ~wxDCBase() { }
 
 
     ~wxDCBase() { }
 
-    virtual void BeginDrawing() { }
-    virtual void EndDrawing() { }
+#if WXWIN_COMPATIBILITY_2_6
+    wxDEPRECATED( virtual void BeginDrawing() );
+    wxDEPRECATED( virtual void EndDrawing() );
+#endif // WXWIN_COMPATIBILITY_2_6
 
     // graphic primitives
     // ------------------
 
     // graphic primitives
     // ------------------
@@ -160,6 +156,27 @@ public:
                    int style = wxFLOOD_SURFACE)
         { return DoFloodFill(pt.x, pt.y, col, style); }
 
                    int style = wxFLOOD_SURFACE)
         { return DoFloodFill(pt.x, pt.y, col, style); }
 
+    // fill the area specified by rect with a radial gradient, starting from
+    // initialColour in the centre of the cercle and fading to destColour.
+    void GradientFillConcentric(const wxRect& rect,
+                                const wxColour& initialColour,
+                                const wxColour& destColour)
+        { GradientFillConcentric(rect, initialColour, destColour,
+                                 wxPoint(rect.GetWidth() / 2,
+                                         rect.GetHeight() / 2)); }
+
+    void GradientFillConcentric(const wxRect& rect,
+                                const wxColour& initialColour,
+                                const wxColour& destColour,
+                                const wxPoint& circleCenter);
+
+    // fill the area specified by rect with a linear gradient
+    void GradientFillLinear(const wxRect& rect,
+                            const wxColour& initialColour,
+                            const wxColour& destColour,
+                            wxDirection nDirection = wxEAST)
+        { DoGradientFillLinear(rect, initialColour, destColour, nDirection); }
+
     bool GetPixel(wxCoord x, wxCoord y, wxColour *col) const
         { return DoGetPixel(x, y, col); }
     bool GetPixel(const wxPoint& pt, wxColour *col) const
     bool GetPixel(wxCoord x, wxCoord y, wxColour *col) const
         { return DoGetPixel(x, y, col); }
     bool GetPixel(const wxPoint& pt, wxColour *col) const
@@ -636,6 +653,11 @@ protected:
     virtual bool DoFloodFill(wxCoord x, wxCoord y, const wxColour& col,
                              int style = wxFLOOD_SURFACE) = 0;
 
     virtual bool DoFloodFill(wxCoord x, wxCoord y, const wxColour& col,
                              int style = wxFLOOD_SURFACE) = 0;
 
+    virtual void DoGradientFillLinear(const wxRect& rect,
+                                      const wxColour& initialColour,
+                                      const wxColour& destColour,
+                                      wxDirection nDirection = wxEAST);
+
     virtual bool DoGetPixel(wxCoord x, wxCoord y, wxColour *col) const = 0;
 
     virtual void DoDrawPoint(wxCoord x, wxCoord y) = 0;
     virtual bool DoGetPixel(wxCoord x, wxCoord y, wxColour *col) const = 0;
 
     virtual void DoDrawPoint(wxCoord x, wxCoord y) = 0;
@@ -797,8 +819,10 @@ private:
     #include "wx/msw/dc.h"
 #elif defined(__WXMOTIF__)
     #include "wx/motif/dc.h"
     #include "wx/msw/dc.h"
 #elif defined(__WXMOTIF__)
     #include "wx/motif/dc.h"
-#elif defined(__WXGTK__)
+#elif defined(__WXGTK20__)
     #include "wx/gtk/dc.h"
     #include "wx/gtk/dc.h"
+#elif defined(__WXGTK__)
+    #include "wx/gtk1/dc.h"
 #elif defined(__WXX11__)
     #include "wx/x11/dc.h"
 #elif defined(__WXMGL__)
 #elif defined(__WXX11__)
     #include "wx/x11/dc.h"
 #elif defined(__WXMGL__)
@@ -842,6 +866,60 @@ private:
     DECLARE_NO_COPY_CLASS(wxDCTextColourChanger)
 };
 
     DECLARE_NO_COPY_CLASS(wxDCTextColourChanger)
 };
 
+// ----------------------------------------------------------------------------
+// helper class: you can use it to temporarily change the DC pen and
+// restore it automatically when the object goes out of scope
+// ----------------------------------------------------------------------------
+
+class WXDLLEXPORT wxDCPenChanger
+{
+public:
+    wxDCPenChanger(wxDC& dc, const wxPen& pen) : m_dc(dc), m_penOld(dc.GetPen())
+    {
+        m_dc.SetPen(pen);
+    }
+
+    ~wxDCPenChanger()
+    {
+        if ( m_penOld.Ok() )
+            m_dc.SetPen(m_penOld);
+    }
+
+private:
+    wxDC& m_dc;
+
+    wxPen m_penOld;
+
+    DECLARE_NO_COPY_CLASS(wxDCPenChanger)
+};
+
+// ----------------------------------------------------------------------------
+// helper class: you can use it to temporarily change the DC brush and
+// restore it automatically when the object goes out of scope
+// ----------------------------------------------------------------------------
+
+class WXDLLEXPORT wxDCBrushChanger
+{
+public:
+    wxDCBrushChanger(wxDC& dc, const wxBrush& brush) : m_dc(dc), m_brushOld(dc.GetBrush())
+    {
+        m_dc.SetBrush(brush);
+    }
+
+    ~wxDCBrushChanger()
+    {
+        if ( m_brushOld.Ok() )
+            m_dc.SetBrush(m_brushOld);
+    }
+
+private:
+    wxDC& m_dc;
+
+    wxBrush m_brushOld;
+
+    DECLARE_NO_COPY_CLASS(wxDCBrushChanger)
+};
+
 // ----------------------------------------------------------------------------
 // another small helper class: sets the clipping region in its ctor and
 // destroys it in the dtor
 // ----------------------------------------------------------------------------
 // another small helper class: sets the clipping region in its ctor and
 // destroys it in the dtor
@@ -850,6 +928,8 @@ private:
 class WXDLLEXPORT wxDCClipper
 {
 public:
 class WXDLLEXPORT wxDCClipper
 {
 public:
+    wxDCClipper(wxDC& dc, const wxRegion& r) : m_dc(dc)
+        { dc.SetClippingRegion(r); }
     wxDCClipper(wxDC& dc, const wxRect& r) : m_dc(dc)
         { dc.SetClippingRegion(r.x, r.y, r.width, r.height); }
     wxDCClipper(wxDC& dc, wxCoord x, wxCoord y, wxCoord w, wxCoord h) : m_dc(dc)
     wxDCClipper(wxDC& dc, const wxRect& r) : m_dc(dc)
         { dc.SetClippingRegion(r.x, r.y, r.width, r.height); }
     wxDCClipper(wxDC& dc, wxCoord x, wxCoord y, wxCoord w, wxCoord h) : m_dc(dc)