X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/cd9da200285e3c625be91768c9ca61dc218c94d0..ef7eaedd63ffc4d6ab9a0fe5e3c91c49c14ffa11:/include/wx/dc.h?ds=sidebyside diff --git a/include/wx/dc.h b/include/wx/dc.h index 1c2ddf548f..faee757e84 100644 --- a/include/wx/dc.h +++ b/include/wx/dc.h @@ -31,6 +31,65 @@ #include "wx/list.h" // we use wxList in inline functions +class WXDLLEXPORT wxDCBase; + +class WXDLLEXPORT wxDrawObject +{ +public: + + wxDrawObject() + { + ResetBoundingBox(); + } + + virtual ~wxDrawObject() { } + + virtual void Draw(wxDCBase& dc) const { } + + virtual void CalcBoundingBox(wxCoord x, wxCoord y) + { + if ( m_isBBoxValid ) + { + if ( x < m_minX ) m_minX = x; + if ( y < m_minY ) m_minY = y; + if ( x > m_maxX ) m_maxX = x; + if ( y > m_maxY ) m_maxY = y; + } + else + { + m_isBBoxValid = TRUE; + + m_minX = x; + m_minY = y; + m_maxX = x; + m_maxY = y; + } + } + + void ResetBoundingBox() + { + m_isBBoxValid = FALSE; + + m_minX = m_maxX = m_minY = m_maxY = 0; + } + + // Get the final bounding box of the PostScript or Metafile picture. + + wxCoord MinX() const { return m_minX; } + wxCoord MaxX() const { return m_maxX; } + wxCoord MinY() const { return m_minY; } + wxCoord MaxY() const { return m_maxY; } + + //to define the type of object for derived objects + virtual int GetType()=0; + +protected: + //for boundingbox calculation + bool m_isBBoxValid:1; + //for boundingbox calculation + wxCoord m_minX, m_minY, m_maxX, m_maxY; +}; + // --------------------------------------------------------------------------- // global variables // --------------------------------------------------------------------------- @@ -49,7 +108,7 @@ public: m_clipping = FALSE; m_ok = TRUE; - m_minX = m_minY = m_maxX = m_maxY = 0; + ResetBoundingBox(); m_signX = m_signY = 1; @@ -60,7 +119,7 @@ public: m_userScaleX = m_userScaleY = m_scaleX = m_scaleY = 1.0; - m_logicalFunction = -1; + m_logicalFunction = wxCOPY; m_backgroundMode = wxTRANSPARENT; @@ -82,6 +141,13 @@ public: // graphic primitives // ------------------ + virtual void DrawObject(wxDrawObject* drawobject) + { + drawobject->Draw(*this); + CalcBoundingBox(drawobject->MinX(),drawobject->MinY()); + CalcBoundingBox(drawobject->MaxX(),drawobject->MaxY()); + } + void FloodFill(wxCoord x, wxCoord y, const wxColour& col, int style = wxFLOOD_SURFACE) { DoFloodFill(x, y, col, style); } @@ -330,6 +396,7 @@ public: // --------- // const... + 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; } @@ -400,10 +467,29 @@ public: virtual void CalcBoundingBox(wxCoord x, wxCoord y) { - if ( x < m_minX ) m_minX = x; - if ( y < m_minY ) m_minY = y; - if ( x > m_maxX ) m_maxX = x; - if ( y > m_maxY ) m_maxY = y; + if ( m_isBBoxValid ) + { + if ( x < m_minX ) m_minX = x; + if ( y < m_minY ) m_minY = y; + if ( x > m_maxX ) m_maxX = x; + if ( y > m_maxY ) m_maxY = y; + } + else + { + m_isBBoxValid = TRUE; + + m_minX = x; + m_minY = y; + m_maxX = x; + m_maxY = y; + } + } + + void ResetBoundingBox() + { + m_isBBoxValid = FALSE; + + m_minX = m_maxX = m_minY = m_maxY = 0; } // Get the final bounding box of the PostScript or Metafile picture. @@ -577,6 +663,7 @@ protected: bool m_ok:1; bool m_clipping:1; bool m_isInteractive:1; + bool m_isBBoxValid:1; // coordinate system variables