dcgraph.h 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: wx/dcgraph.h
  3. // Purpose: graphics context device bridge header
  4. // Author: Stefan Csomor
  5. // Modified by:
  6. // Created:
  7. // Copyright: (c) Stefan Csomor
  8. // Licence: wxWindows licence
  9. /////////////////////////////////////////////////////////////////////////////
  10. #ifndef _WX_GRAPHICS_DC_H_
  11. #define _WX_GRAPHICS_DC_H_
  12. #if wxUSE_GRAPHICS_CONTEXT
  13. #include "wx/dc.h"
  14. #include "wx/geometry.h"
  15. #include "wx/graphics.h"
  16. class WXDLLIMPEXP_FWD_CORE wxWindowDC;
  17. class WXDLLIMPEXP_CORE wxGCDC: public wxDC
  18. {
  19. public:
  20. wxGCDC( const wxWindowDC& dc );
  21. wxGCDC( const wxMemoryDC& dc );
  22. #if wxUSE_PRINTING_ARCHITECTURE
  23. wxGCDC( const wxPrinterDC& dc );
  24. #endif
  25. #if defined(__WXMSW__) && wxUSE_ENH_METAFILE
  26. wxGCDC( const wxEnhMetaFileDC& dc );
  27. #endif
  28. wxGCDC(wxGraphicsContext* context);
  29. wxGCDC();
  30. virtual ~wxGCDC();
  31. wxGraphicsContext* GetGraphicsContext() const;
  32. void SetGraphicsContext( wxGraphicsContext* ctx );
  33. #ifdef __WXMSW__
  34. // override wxDC virtual functions to provide access to HDC associated with
  35. // this Graphics object (implemented in src/msw/graphics.cpp)
  36. virtual WXHDC AcquireHDC();
  37. virtual void ReleaseHDC(WXHDC hdc);
  38. #endif // __WXMSW__
  39. private:
  40. DECLARE_DYNAMIC_CLASS(wxGCDC)
  41. wxDECLARE_NO_COPY_CLASS(wxGCDC);
  42. };
  43. class WXDLLIMPEXP_CORE wxGCDCImpl: public wxDCImpl
  44. {
  45. public:
  46. wxGCDCImpl( wxDC *owner, const wxWindowDC& dc );
  47. wxGCDCImpl( wxDC *owner, const wxMemoryDC& dc );
  48. #if wxUSE_PRINTING_ARCHITECTURE
  49. wxGCDCImpl( wxDC *owner, const wxPrinterDC& dc );
  50. #endif
  51. #if defined(__WXMSW__) && wxUSE_ENH_METAFILE
  52. wxGCDCImpl( wxDC *owner, const wxEnhMetaFileDC& dc );
  53. #endif
  54. wxGCDCImpl( wxDC *owner );
  55. virtual ~wxGCDCImpl();
  56. // implement base class pure virtuals
  57. // ----------------------------------
  58. virtual void Clear();
  59. virtual bool StartDoc( const wxString& message );
  60. virtual void EndDoc();
  61. virtual void StartPage();
  62. virtual void EndPage();
  63. // flushing the content of this dc immediately onto screen
  64. virtual void Flush();
  65. virtual void SetFont(const wxFont& font);
  66. virtual void SetPen(const wxPen& pen);
  67. virtual void SetBrush(const wxBrush& brush);
  68. virtual void SetBackground(const wxBrush& brush);
  69. virtual void SetBackgroundMode(int mode);
  70. virtual void SetPalette(const wxPalette& palette);
  71. virtual void DestroyClippingRegion();
  72. virtual wxCoord GetCharHeight() const;
  73. virtual wxCoord GetCharWidth() const;
  74. virtual bool CanDrawBitmap() const;
  75. virtual bool CanGetTextExtent() const;
  76. virtual int GetDepth() const;
  77. virtual wxSize GetPPI() const;
  78. virtual void SetLogicalFunction(wxRasterOperationMode function);
  79. virtual void SetTextForeground(const wxColour& colour);
  80. virtual void SetTextBackground(const wxColour& colour);
  81. virtual void ComputeScaleAndOrigin();
  82. wxGraphicsContext* GetGraphicsContext() const { return m_graphicContext; }
  83. virtual void SetGraphicsContext( wxGraphicsContext* ctx );
  84. virtual void* GetHandle() const;
  85. // the true implementations
  86. virtual bool DoFloodFill(wxCoord x, wxCoord y, const wxColour& col,
  87. wxFloodFillStyle style = wxFLOOD_SURFACE);
  88. virtual void DoGradientFillLinear(const wxRect& rect,
  89. const wxColour& initialColour,
  90. const wxColour& destColour,
  91. wxDirection nDirection = wxEAST);
  92. virtual void DoGradientFillConcentric(const wxRect& rect,
  93. const wxColour& initialColour,
  94. const wxColour& destColour,
  95. const wxPoint& circleCenter);
  96. virtual bool DoGetPixel(wxCoord x, wxCoord y, wxColour *col) const;
  97. virtual void DoDrawPoint(wxCoord x, wxCoord y);
  98. #if wxUSE_SPLINES
  99. virtual void DoDrawSpline(const wxPointList *points);
  100. #endif
  101. virtual void DoDrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2);
  102. virtual void DoDrawArc(wxCoord x1, wxCoord y1,
  103. wxCoord x2, wxCoord y2,
  104. wxCoord xc, wxCoord yc);
  105. virtual void DoDrawCheckMark(wxCoord x, wxCoord y,
  106. wxCoord width, wxCoord height);
  107. virtual void DoDrawEllipticArc(wxCoord x, wxCoord y, wxCoord w, wxCoord h,
  108. double sa, double ea);
  109. virtual void DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
  110. virtual void DoDrawRoundedRectangle(wxCoord x, wxCoord y,
  111. wxCoord width, wxCoord height,
  112. double radius);
  113. virtual void DoDrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
  114. virtual void DoCrossHair(wxCoord x, wxCoord y);
  115. virtual void DoDrawIcon(const wxIcon& icon, wxCoord x, wxCoord y);
  116. virtual void DoDrawBitmap(const wxBitmap &bmp, wxCoord x, wxCoord y,
  117. bool useMask = false);
  118. virtual void DoDrawText(const wxString& text, wxCoord x, wxCoord y);
  119. virtual void DoDrawRotatedText(const wxString& text, wxCoord x, wxCoord y,
  120. double angle);
  121. virtual bool DoBlit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height,
  122. wxDC *source, wxCoord xsrc, wxCoord ysrc,
  123. wxRasterOperationMode rop = wxCOPY, bool useMask = false,
  124. wxCoord xsrcMask = -1, wxCoord ysrcMask = -1);
  125. virtual bool DoStretchBlit(wxCoord xdest, wxCoord ydest,
  126. wxCoord dstWidth, wxCoord dstHeight,
  127. wxDC *source,
  128. wxCoord xsrc, wxCoord ysrc,
  129. wxCoord srcWidth, wxCoord srcHeight,
  130. wxRasterOperationMode = wxCOPY, bool useMask = false,
  131. wxCoord xsrcMask = wxDefaultCoord, wxCoord ysrcMask = wxDefaultCoord);
  132. virtual void DoGetSize(int *,int *) const;
  133. virtual void DoGetSizeMM(int* width, int* height) const;
  134. virtual void DoDrawLines(int n, const wxPoint points[],
  135. wxCoord xoffset, wxCoord yoffset);
  136. virtual void DoDrawPolygon(int n, const wxPoint points[],
  137. wxCoord xoffset, wxCoord yoffset,
  138. wxPolygonFillMode fillStyle = wxODDEVEN_RULE);
  139. virtual void DoDrawPolyPolygon(int n, const int count[], const wxPoint points[],
  140. wxCoord xoffset, wxCoord yoffset,
  141. wxPolygonFillMode fillStyle);
  142. virtual void DoSetDeviceClippingRegion(const wxRegion& region);
  143. virtual void DoSetClippingRegion(wxCoord x, wxCoord y,
  144. wxCoord width, wxCoord height);
  145. virtual void DoGetTextExtent(const wxString& string,
  146. wxCoord *x, wxCoord *y,
  147. wxCoord *descent = NULL,
  148. wxCoord *externalLeading = NULL,
  149. const wxFont *theFont = NULL) const;
  150. virtual bool DoGetPartialTextExtents(const wxString& text, wxArrayInt& widths) const;
  151. #ifdef __WXMSW__
  152. virtual wxRect MSWApplyGDIPlusTransform(const wxRect& r) const;
  153. #endif // __WXMSW__
  154. protected:
  155. // unused int parameter distinguishes this version, which does not create a
  156. // wxGraphicsContext, in the expectation that the derived class will do it
  157. wxGCDCImpl(wxDC* owner, int);
  158. // scaling variables
  159. bool m_logicalFunctionSupported;
  160. wxGraphicsMatrix m_matrixOriginal;
  161. wxGraphicsMatrix m_matrixCurrent;
  162. double m_formerScaleX, m_formerScaleY;
  163. wxGraphicsContext* m_graphicContext;
  164. private:
  165. void Init(wxGraphicsContext*);
  166. DECLARE_CLASS(wxGCDCImpl)
  167. wxDECLARE_NO_COPY_CLASS(wxGCDCImpl);
  168. };
  169. #endif // wxUSE_GRAPHICS_CONTEXT
  170. #endif // _WX_GRAPHICS_DC_H_