X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/ca7db61eace93e5b8c710113dbab743085a155fa..859588540321276b8e813f479dbedbd53f23a0c5:/include/wx/dc.h diff --git a/include/wx/dc.h b/include/wx/dc.h index 84f9b5f4d5..97f362589c 100644 --- a/include/wx/dc.h +++ b/include/wx/dc.h @@ -26,7 +26,6 @@ #include "wx/brush.h" #include "wx/pen.h" #include "wx/palette.h" -#include "wx/list.h" // we use wxList in inline functions #include "wx/dynarray.h" #include "wx/math.h" #include "wx/image.h" @@ -37,6 +36,13 @@ #if wxUSE_NEW_DC class WXDLLIMPEXP_FWD_CORE wxDC; +class WXDLLIMPEXP_FWD_CORE wxClientDC; +class WXDLLIMPEXP_FWD_CORE wxPaintDC; +class WXDLLIMPEXP_FWD_CORE wxWindowDC; +class WXDLLIMPEXP_FWD_CORE wxScreenDC; +class WXDLLIMPEXP_FWD_CORE wxMemoryDC; +class WXDLLIMPEXP_FWD_CORE wxPrinterDC; +#include "wx/cmndata.h" #else class WXDLLIMPEXP_FWD_CORE wxDCBase; #endif @@ -117,15 +123,17 @@ public: wxDCFactory() {} virtual ~wxDCFactory() {} - virtual wxImplDC* CreateWindowDC() = 0; - virtual wxImplDC* CreateWindowDC( wxWindow *window ) = 0; - virtual wxImplDC* CreateClientDC() = 0; - virtual wxImplDC* CreateClientDC( wxWindow *window ) = 0; - virtual wxImplDC* CreatePaintDC() = 0; - virtual wxImplDC* CreatePaintDC( wxWindow *window ) = 0; - virtual wxImplDC* CreateMemoryDC() = 0; - virtual wxImplDC* CreateMemoryDC( wxBitmap &bitmap ) = 0; - virtual wxImplDC* CreateMemoryDC( wxDC *dc ) = 0; + virtual wxImplDC* CreateWindowDC( wxWindowDC *owner ) = 0; + virtual wxImplDC* CreateWindowDC( wxWindowDC *owner, wxWindow *window ) = 0; + virtual wxImplDC* CreateClientDC( wxClientDC *owner ) = 0; + virtual wxImplDC* CreateClientDC( wxClientDC *owner, wxWindow *window ) = 0; + virtual wxImplDC* CreatePaintDC( wxPaintDC *owner ) = 0; + virtual wxImplDC* CreatePaintDC( wxPaintDC *owner, wxWindow *window ) = 0; + virtual wxImplDC* CreateMemoryDC( wxMemoryDC *owner ) = 0; + virtual wxImplDC* CreateMemoryDC( wxMemoryDC *owner, wxBitmap &bitmap ) = 0; + virtual wxImplDC* CreateMemoryDC( wxMemoryDC *owner, wxDC *dc ) = 0; + virtual wxImplDC* CreateScreenDC( wxScreenDC *owner ) = 0; + virtual wxImplDC* CreatePrinterDC( wxPrinterDC *owner, const wxPrintData &data ) = 0; static void SetDCFactory( wxDCFactory *factory ); static wxDCFactory *GetFactory(); @@ -137,20 +145,22 @@ private: // wxNativeDCFactory //----------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxNativeDCFactory +class WXDLLIMPEXP_CORE wxNativeDCFactory: public wxDCFactory { public: wxNativeDCFactory() {} - virtual wxImplDC* CreateWindowDC(); - virtual wxImplDC* CreateWindowDC( wxWindow *window ); - virtual wxImplDC* CreateClientDC(); - virtual wxImplDC* CreateClientDC( wxWindow *window ); - virtual wxImplDC* CreatePaintDC(); - virtual wxImplDC* CreatePaintDC( wxWindow *window ); - virtual wxImplDC* CreateMemoryDC(); - virtual wxImplDC* CreateMemoryDC( wxBitmap &bitmap ); - virtual wxImplDC* CreateMemoryDC( wxDC *dc ); + virtual wxImplDC* CreateWindowDC( wxWindowDC *owner ); + virtual wxImplDC* CreateWindowDC( wxWindowDC *owner, wxWindow *window ); + virtual wxImplDC* CreateClientDC( wxClientDC *owner ); + virtual wxImplDC* CreateClientDC( wxClientDC *owner, wxWindow *window ); + virtual wxImplDC* CreatePaintDC( wxPaintDC *owner ); + virtual wxImplDC* CreatePaintDC( wxPaintDC *owner, wxWindow *window ); + virtual wxImplDC* CreateMemoryDC( wxMemoryDC *owner ); + virtual wxImplDC* CreateMemoryDC( wxMemoryDC *owner, wxBitmap &bitmap ); + virtual wxImplDC* CreateMemoryDC( wxMemoryDC *owner, wxDC *dc ); + virtual wxImplDC* CreateScreenDC( wxScreenDC *owner ); + virtual wxImplDC* CreatePrinterDC( wxPrinterDC *owner, const wxPrintData &data ); }; //----------------------------------------------------------------------------- @@ -163,7 +173,7 @@ public: wxImplDC( wxDC *owner ); ~wxImplDC(); - wxDC *GetOwner() { return m_owner; } + wxDC *GetOwner() const { return m_owner; } virtual bool IsOk() const { return m_ok; } @@ -193,6 +203,9 @@ public: virtual void StartPage() { } virtual void EndPage() { } + // flushing the content of this dc immediately eg onto screen + virtual void Flush() { } + // bounding box virtual void CalcBoundingBox(wxCoord x, wxCoord y) @@ -421,22 +434,47 @@ public: virtual void DoDrawLines(int n, wxPoint points[], - wxCoord xoffset, wxCoord yoffset) = 0; + wxCoord xoffset, wxCoord yoffset ) = 0; + virtual void DrawLines(const wxPointList *list, + wxCoord xoffset, wxCoord yoffset ); + virtual void DoDrawPolygon(int n, wxPoint points[], wxCoord xoffset, wxCoord yoffset, int fillStyle = wxODDEVEN_RULE) = 0; virtual void DoDrawPolyPolygon(int n, int count[], wxPoint points[], wxCoord xoffset, wxCoord yoffset, int fillStyle); - + void DrawPolygon(const wxPointList *list, + wxCoord xoffset, wxCoord yoffset, + int fillStyle ); #if wxUSE_SPLINES virtual void DoDrawSpline(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2, wxCoord x3, wxCoord y3); virtual void DoDrawSpline(int n, wxPoint points[]); - virtual void DoDrawSpline(wxList *points); + virtual void DoDrawSpline(const wxPointList *points); #endif + // --------------------------------------------------------- + // wxMemoryDC Impl API + + virtual void DoSelect(const wxBitmap& WXUNUSED(bmp)) + { } + + virtual const wxBitmap& GetSelectedBitmap() const + { return wxNullBitmap; } + virtual wxBitmap& GetSelectedBitmap() + { return wxNullBitmap; } + + // --------------------------------------------------------- + // wxPrinterDC Impl API + + virtual wxRect GetPaperRect() + { int w = 0; int h = 0; DoGetSize( &w, &h ); return wxRect(0,0,w,h); } + + virtual int GetResolution() + { return -1; } + private: wxDC *m_owner; @@ -507,6 +545,12 @@ class wxDC: public wxObject public: wxDC() { m_pimpl = NULL; } + wxImplDC *GetImpl() + { return m_pimpl; } + const wxImplDC *GetImpl() const + { return m_pimpl; } + + bool IsOk() const { return m_pimpl && m_pimpl->IsOk(); } @@ -543,6 +587,9 @@ public: wxSize GetPPI() const { return m_pimpl->GetPPI(); } + virtual int GetResolution() + { return m_pimpl->GetResolution(); } + // Right-To-Left (RTL) modes void SetLayoutDirection(wxLayoutDirection dir) @@ -828,30 +875,31 @@ public: void DrawLines(int n, wxPoint points[], wxCoord xoffset = 0, wxCoord yoffset = 0) { m_pimpl->DoDrawLines(n, points, xoffset, yoffset); } - -#if 0 - // needs to be removed - void DrawLines(const wxList *list, + void DrawLines(const wxPointList *list, wxCoord xoffset = 0, wxCoord yoffset = 0) -#endif + { m_pimpl->DrawLines( list, xoffset, yoffset ); } +#if WXWIN_COMPATIBILITY_2_8 + wxDEPRECATED( void DrawLines(const wxList *list, + wxCoord xoffset = 0, wxCoord yoffset = 0) ); +#endif // WXWIN_COMPATIBILITY_2_8 void DrawPolygon(int n, wxPoint points[], wxCoord xoffset = 0, wxCoord yoffset = 0, int fillStyle = wxODDEVEN_RULE) { m_pimpl->DoDrawPolygon(n, points, xoffset, yoffset, fillStyle); } - -#if 0 - // needs to be removed - void DrawPolygon(const wxList *list, + void DrawPolygon(const wxPointList *list, wxCoord xoffset = 0, wxCoord yoffset = 0, int fillStyle = wxODDEVEN_RULE) { m_pimpl->DrawPolygon( list, xoffset, yoffset, fillStyle ); } -#endif - void DrawPolyPolygon(int n, int count[], wxPoint points[], wxCoord xoffset = 0, wxCoord yoffset = 0, int fillStyle = wxODDEVEN_RULE) { m_pimpl->DoDrawPolyPolygon(n, count, points, xoffset, yoffset, fillStyle); } +#if WXWIN_COMPATIBILITY_2_8 + wxDEPRECATED( void DrawPolygon(const wxList *list, + wxCoord xoffset = 0, wxCoord yoffset = 0, + int fillStyle = wxODDEVEN_RULE) ); +#endif // WXWIN_COMPATIBILITY_2_8 void DrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height) { m_pimpl->DoDrawRectangle(x, y, width, height); } @@ -965,12 +1013,8 @@ public: { m_pimpl->DoDrawSpline(x1,y1,x2,y2,x3,y3); } void DrawSpline(int n, wxPoint points[]) { m_pimpl->DoDrawSpline(n,points); } - -#if 0 - // needs to be removed - void DrawSpline(wxList *points) + void DrawSpline(const wxPointList *points) { m_pimpl->DoDrawSpline(points); } -#endif #endif // wxUSE_SPLINES @@ -1023,21 +1067,6 @@ private: DECLARE_DYNAMIC_CLASS(wxClientDC) }; -//----------------------------------------------------------------------------- -// wxMemoryDC -//----------------------------------------------------------------------------- - -class WXDLLIMPEXP_CORE wxMemoryDC: public wxDC -{ -public: - wxMemoryDC(); - wxMemoryDC( wxBitmap& bitmap ); - wxMemoryDC( wxDC *dc ); - -private: - DECLARE_DYNAMIC_CLASS(wxMemoryDC) -}; - //----------------------------------------------------------------------------- // wxPaintDC //----------------------------------------------------------------------------- @@ -1081,6 +1110,8 @@ public: CalcBoundingBox(drawobject->MaxX(),drawobject->MaxY()); } + wxDC *GetOwner() const { return (wxDC*) this; } + bool FloodFill(wxCoord x, wxCoord y, const wxColour& col, int style = wxFLOOD_SURFACE) { return DoFloodFill(x, y, col, style); } @@ -1152,18 +1183,30 @@ public: void DrawLines(int n, wxPoint points[], wxCoord xoffset = 0, wxCoord yoffset = 0) { DoDrawLines(n, points, xoffset, yoffset); } - void DrawLines(const wxList *list, + void DrawLines(const wxPointList *list, wxCoord xoffset = 0, wxCoord yoffset = 0); +#if WXWIN_COMPATIBILITY_2_8 + wxDEPRECATED( void DrawLines(const wxList *list, + wxCoord xoffset = 0, wxCoord yoffset = 0) ); +#endif // WXWIN_COMPATIBILITY_2_8 + + void DrawPolygon(int n, wxPoint points[], wxCoord xoffset = 0, wxCoord yoffset = 0, int fillStyle = wxODDEVEN_RULE) { DoDrawPolygon(n, points, xoffset, yoffset, fillStyle); } - void DrawPolygon(const wxList *list, + void DrawPolygon(const wxPointList *list, wxCoord xoffset = 0, wxCoord yoffset = 0, int fillStyle = wxODDEVEN_RULE); +#if WXWIN_COMPATIBILITY_2_8 + wxDEPRECATED( void DrawPolygon(const wxList *list, + wxCoord xoffset = 0, wxCoord yoffset = 0, + int fillStyle = wxODDEVEN_RULE) ); +#endif // WXWIN_COMPATIBILITY_2_8 + void DrawPolyPolygon(int n, int count[], wxPoint points[], wxCoord xoffset = 0, wxCoord yoffset = 0, int fillStyle = wxODDEVEN_RULE) @@ -1275,13 +1318,17 @@ public: } #if wxUSE_SPLINES - // TODO: this API needs fixing (wxPointList, why (!const) "wxList *"?) void DrawSpline(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2, wxCoord x3, wxCoord y3); void DrawSpline(int n, wxPoint points[]); - void DrawSpline(wxList *points) { DoDrawSpline(points); } + void DrawSpline(const wxPointList *points) { DoDrawSpline(points); } + +#if WXWIN_COMPATIBILITY_2_8 + wxDEPRECATED( void DrawSpline(const wxList *points) ); +#endif // WXWIN_COMPATIBILITY_2_8 + #endif // wxUSE_SPLINES // Eventually we will have wxUSE_GENERIC_DRAWELLIPSE @@ -1322,11 +1369,11 @@ public: * \param angle Rotating angle (counterclockwise, start at 3 o'clock, 360 is full circle). * \param center Center of rotation. */ - void Rotate( wxList* points, double angle, wxPoint center = wxPoint(0,0) ); + void Rotate( wxPointList* points, double angle, wxPoint center = wxPoint(0,0) ); // used by DrawEllipticArcRot // Careful: wxList gets filled with points you have to delete later. - void CalculateEllipticPoints( wxList* points, + void CalculateEllipticPoints( wxPointList* points, wxCoord xStart, wxCoord yStart, wxCoord w, wxCoord h, double sa, double ea ); @@ -1459,6 +1506,9 @@ public: // Resolution in Pixels per inch virtual wxSize GetPPI() const = 0; + virtual int GetResolution() + { return -1; } + virtual bool Ok() const { return IsOk(); } virtual bool IsOk() const { return m_ok; } @@ -1713,7 +1763,7 @@ protected: virtual bool DoGetPartialTextExtents(const wxString& text, wxArrayInt& widths) const; #if wxUSE_SPLINES - virtual void DoDrawSpline(wxList *points); + virtual void DoDrawSpline(const wxPointList *points); #endif protected: