X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/4660e6acfcf29631ac601081f5a64b25ff27770a..3c1f8cb1f5cbef0f7699110fd28027948e644c6f:/include/wx/dc.h diff --git a/include/wx/dc.h b/include/wx/dc.h index e824590966..a5784f471c 100644 --- a/include/wx/dc.h +++ b/include/wx/dc.h @@ -18,6 +18,7 @@ #include "wx/object.h" // the base class +#include "wx/intl.h" // for wxLayoutDirection #include "wx/cursor.h" // we have member variables of these classes #include "wx/font.h" // so we can't do without them #include "wx/colour.h" @@ -93,8 +94,6 @@ protected: // global variables // --------------------------------------------------------------------------- -extern WXDLLEXPORT_DATA(int) wxPageNumber; - // --------------------------------------------------------------------------- // wxDC is the device context - object on which any drawing is done // --------------------------------------------------------------------------- @@ -134,12 +133,7 @@ public: ResetClipping(); } - ~wxDCBase() { } - -#if WXWIN_COMPATIBILITY_2_6 - wxDEPRECATED( virtual void BeginDrawing() ); - wxDEPRECATED( virtual void EndDrawing() ); -#endif // WXWIN_COMPATIBILITY_2_6 + virtual ~wxDCBase() { } // graphic primitives // ------------------ @@ -170,7 +164,8 @@ public: void GradientFillConcentric(const wxRect& rect, const wxColour& initialColour, const wxColour& destColour, - const wxPoint& circleCenter); + const wxPoint& circleCenter) + { DoGradientFillConcentric(rect, initialColour, destColour, circleCenter); } // fill the area specified by rect with a linear gradient void GradientFillLinear(const wxRect& rect, @@ -388,6 +383,12 @@ public: virtual void StartPage() { } virtual void EndPage() { } +#if WXWIN_COMPATIBILITY_2_6 + wxDEPRECATED( void BeginDrawing() ); + wxDEPRECATED( void EndDrawing() ); +#endif // WXWIN_COMPATIBILITY_2_6 + + // set objects to use for drawing // ------------------------------ @@ -498,25 +499,26 @@ public: // Resolution in Pixels per inch virtual wxSize GetPPI() const = 0; - virtual bool Ok() const { return m_ok; } + virtual bool Ok() const { return IsOk(); } + virtual bool IsOk() const { return m_ok; } // accessors and setters // --------------------- - int GetBackgroundMode() const { return m_backgroundMode; } - const wxBrush& GetBackground() const { return m_backgroundBrush; } - const wxBrush& GetBrush() const { return m_brush; } - const wxFont& GetFont() const { return m_font; } - const wxPen& GetPen() const { return m_pen; } + virtual int GetBackgroundMode() const { return m_backgroundMode; } + virtual const wxBrush& GetBackground() const { return m_backgroundBrush; } + virtual const wxBrush& GetBrush() const { return m_brush; } + virtual const wxFont& GetFont() const { return m_font; } + virtual const wxPen& GetPen() const { return m_pen; } - const wxColour& GetTextForeground() const { return m_textForegroundColour; } - const wxColour& GetTextBackground() const { return m_textBackgroundColour; } + virtual const wxColour& GetTextForeground() const { return m_textForegroundColour; } + virtual const wxColour& GetTextBackground() const { return m_textBackgroundColour; } virtual void SetTextForeground(const wxColour& colour) { m_textForegroundColour = colour; } virtual void SetTextBackground(const wxColour& colour) { m_textBackgroundColour = colour; } - int GetMapMode() const { return m_mappingMode; } + virtual int GetMapMode() const { return m_mappingMode; } virtual void SetMapMode(int mode) = 0; virtual void GetUserScale(double *x, double *y) const @@ -553,7 +555,7 @@ public: virtual void SetAxisOrientation(bool xLeftRight, bool yBottomUp) = 0; - int GetLogicalFunction() const { return m_logicalFunction; } + virtual int GetLogicalFunction() const { return m_logicalFunction; } virtual void SetLogicalFunction(int function) = 0; #if WXWIN_COMPATIBILITY_2_4 @@ -650,6 +652,16 @@ public: if (h) *h = hh; } + // RTL related functions + // --------------------- + + // get or change the layout direction (LTR or RTL) for this dc, + // wxLayout_Default is returned if layout direction is not supported + virtual wxLayoutDirection GetLayoutDirection() const + { return wxLayout_Default; } + virtual void SetLayoutDirection(wxLayoutDirection WXUNUSED(dir)) + { } + protected: // the pure virtual functions which should be implemented by wxDC virtual bool DoFloodFill(wxCoord x, wxCoord y, const wxColour& col, @@ -660,6 +672,11 @@ protected: const wxColour& destColour, wxDirection nDirection = wxEAST); + virtual void DoGradientFillConcentric(const wxRect& rect, + const wxColour& initialColour, + const wxColour& destColour, + const wxPoint& circleCenter); + virtual bool DoGetPixel(wxCoord x, wxCoord y, wxColour *col) const = 0; virtual void DoDrawPoint(wxCoord x, wxCoord y) = 0; @@ -829,6 +846,8 @@ private: #include "wx/x11/dc.h" #elif defined(__WXMGL__) #include "wx/mgl/dc.h" +#elif defined(__WXDFB__) + #include "wx/dfb/dc.h" #elif defined(__WXMAC__) #include "wx/mac/dc.h" #elif defined(__WXCOCOA__) @@ -837,6 +856,10 @@ private: #include "wx/os2/dc.h" #endif +#if wxUSE_GRAPHICS_CONTEXT + #include "wx/dcgraph.h" +#endif + // ---------------------------------------------------------------------------- // helper class: you can use it to temporarily change the DC text colour and // restore it automatically when the object goes out of scope @@ -876,7 +899,10 @@ private: class WXDLLEXPORT wxDCPenChanger { public: - wxDCPenChanger(wxDC& dc) : m_dc(dc), m_penOld() { } + wxDCPenChanger(wxDC& dc, const wxPen& pen) : m_dc(dc), m_penOld(dc.GetPen()) + { + m_dc.SetPen(pen); + } ~wxDCPenChanger() { @@ -884,13 +910,6 @@ public: m_dc.SetPen(m_penOld); } - void Set(const wxPen& pen) - { - if ( !m_penOld.Ok() ) - m_penOld = m_dc.GetPen(); - m_dc.SetPen(pen); - } - private: wxDC& m_dc; @@ -907,7 +926,10 @@ private: class WXDLLEXPORT wxDCBrushChanger { public: - wxDCBrushChanger(wxDC& dc) : m_dc(dc), m_brushOld() { } + wxDCBrushChanger(wxDC& dc, const wxBrush& brush) : m_dc(dc), m_brushOld(dc.GetBrush()) + { + m_dc.SetBrush(brush); + } ~wxDCBrushChanger() { @@ -915,13 +937,6 @@ public: m_dc.SetBrush(m_brushOld); } - void Set(const wxBrush& brush) - { - if ( !m_brushOld.Ok() ) - m_brushOld = m_dc.GetBrush(); - m_dc.SetBrush(brush); - } - private: wxDC& m_dc; @@ -953,5 +968,72 @@ private: DECLARE_NO_COPY_CLASS(wxDCClipper) }; -#endif - // _WX_DC_H_BASE_ +// ---------------------------------------------------------------------------- +// creates an overlay over an existing window, allowing for manipulations like +// rubberbanding etc. this API is not stable yet, not to be used outside wx +// internal code +// ---------------------------------------------------------------------------- + +class WXDLLEXPORT wxOverlayImpl; +class WXDLLEXPORT wxWindowDC; + +class WXDLLEXPORT wxOverlay +{ +public: + wxOverlay(); + ~wxOverlay(); + + // clears the overlay without restoring the former state + // to be done eg when the window content has been changed and repainted + void Reset(); + +private: + friend class WXDLLEXPORT wxDCOverlay; + + // returns true if it has been setup + bool IsOk(); + + void Init(wxWindowDC* dc, int x , int y , int width , int height); + + void BeginDrawing(wxWindowDC* dc); + + void EndDrawing(wxWindowDC* dc); + + void Clear(wxWindowDC* dc); + + wxOverlayImpl* m_impl; + + bool m_inDrawing; + + + DECLARE_NO_COPY_CLASS(wxOverlay) +}; + +class WXDLLEXPORT wxDCOverlay +{ +public: + // connects this overlay to the corresponding drawing dc, if the overlay is not initialized yet + // this call will do so + wxDCOverlay(wxOverlay &overlay, wxWindowDC *dc, int x , int y , int width , int height); + + // convenience wrapper that behaves the same using the entire area of the dc + wxDCOverlay(wxOverlay &overlay, wxWindowDC *dc); + + // removes the connection between the overlay and the dc + virtual ~wxDCOverlay(); + + // clears the layer, restoring the state at the last init + void Clear(); + +private: + void Init(wxWindowDC *dc, int x , int y , int width , int height); + + wxOverlay& m_overlay; + + wxWindowDC* m_dc; + + + DECLARE_NO_COPY_CLASS(wxDCOverlay) +}; + +#endif // _WX_DC_H_BASE_