graphics.h 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: wx/private/graphics.h
  3. // Purpose: private graphics context header
  4. // Author: Stefan Csomor
  5. // Modified by:
  6. // Created:
  7. // Copyright: (c) Stefan Csomor
  8. // Licence: wxWindows licence
  9. /////////////////////////////////////////////////////////////////////////////
  10. #ifndef _WX_GRAPHICS_PRIVATE_H_
  11. #define _WX_GRAPHICS_PRIVATE_H_
  12. #if wxUSE_GRAPHICS_CONTEXT
  13. #include "wx/graphics.h"
  14. class WXDLLIMPEXP_CORE wxGraphicsObjectRefData : public wxObjectRefData
  15. {
  16. public :
  17. wxGraphicsObjectRefData( wxGraphicsRenderer* renderer );
  18. wxGraphicsObjectRefData( const wxGraphicsObjectRefData* data );
  19. wxGraphicsRenderer* GetRenderer() const ;
  20. virtual wxGraphicsObjectRefData* Clone() const ;
  21. protected :
  22. wxGraphicsRenderer* m_renderer;
  23. } ;
  24. class WXDLLIMPEXP_CORE wxGraphicsBitmapData : public wxGraphicsObjectRefData
  25. {
  26. public :
  27. wxGraphicsBitmapData( wxGraphicsRenderer* renderer) :
  28. wxGraphicsObjectRefData(renderer) {}
  29. virtual ~wxGraphicsBitmapData() {}
  30. // returns the native representation
  31. virtual void * GetNativeBitmap() const = 0;
  32. } ;
  33. class WXDLLIMPEXP_CORE wxGraphicsMatrixData : public wxGraphicsObjectRefData
  34. {
  35. public :
  36. wxGraphicsMatrixData( wxGraphicsRenderer* renderer) :
  37. wxGraphicsObjectRefData(renderer) {}
  38. virtual ~wxGraphicsMatrixData() {}
  39. // concatenates the matrix
  40. virtual void Concat( const wxGraphicsMatrixData *t ) = 0;
  41. // sets the matrix to the respective values
  42. virtual void Set(wxDouble a=1.0, wxDouble b=0.0, wxDouble c=0.0, wxDouble d=1.0,
  43. wxDouble tx=0.0, wxDouble ty=0.0) = 0;
  44. // gets the component valuess of the matrix
  45. virtual void Get(wxDouble* a=NULL, wxDouble* b=NULL, wxDouble* c=NULL,
  46. wxDouble* d=NULL, wxDouble* tx=NULL, wxDouble* ty=NULL) const = 0;
  47. // makes this the inverse matrix
  48. virtual void Invert() = 0;
  49. // returns true if the elements of the transformation matrix are equal ?
  50. virtual bool IsEqual( const wxGraphicsMatrixData* t) const = 0;
  51. // return true if this is the identity matrix
  52. virtual bool IsIdentity() const = 0;
  53. //
  54. // transformation
  55. //
  56. // add the translation to this matrix
  57. virtual void Translate( wxDouble dx , wxDouble dy ) = 0;
  58. // add the scale to this matrix
  59. virtual void Scale( wxDouble xScale , wxDouble yScale ) = 0;
  60. // add the rotation to this matrix (radians)
  61. virtual void Rotate( wxDouble angle ) = 0;
  62. //
  63. // apply the transforms
  64. //
  65. // applies that matrix to the point
  66. virtual void TransformPoint( wxDouble *x, wxDouble *y ) const = 0;
  67. // applies the matrix except for translations
  68. virtual void TransformDistance( wxDouble *dx, wxDouble *dy ) const =0;
  69. // returns the native representation
  70. virtual void * GetNativeMatrix() const = 0;
  71. } ;
  72. class WXDLLIMPEXP_CORE wxGraphicsPathData : public wxGraphicsObjectRefData
  73. {
  74. public :
  75. wxGraphicsPathData(wxGraphicsRenderer* renderer) : wxGraphicsObjectRefData(renderer) {}
  76. virtual ~wxGraphicsPathData() {}
  77. //
  78. // These are the path primitives from which everything else can be constructed
  79. //
  80. // begins a new subpath at (x,y)
  81. virtual void MoveToPoint( wxDouble x, wxDouble y ) = 0;
  82. // adds a straight line from the current point to (x,y)
  83. virtual void AddLineToPoint( wxDouble x, wxDouble y ) = 0;
  84. // adds a cubic Bezier curve from the current point, using two control points and an end point
  85. virtual void AddCurveToPoint( wxDouble cx1, wxDouble cy1, wxDouble cx2, wxDouble cy2, wxDouble x, wxDouble y ) = 0;
  86. // adds another path
  87. virtual void AddPath( const wxGraphicsPathData* path ) =0;
  88. // closes the current sub-path
  89. virtual void CloseSubpath() = 0;
  90. // gets the last point of the current path, (0,0) if not yet set
  91. virtual void GetCurrentPoint( wxDouble* x, wxDouble* y) const = 0;
  92. // adds an arc of a circle centering at (x,y) with radius (r) from startAngle to endAngle
  93. virtual void AddArc( wxDouble x, wxDouble y, wxDouble r, wxDouble startAngle, wxDouble endAngle, bool clockwise ) = 0;
  94. //
  95. // These are convenience functions which - if not available natively will be assembled
  96. // using the primitives from above
  97. //
  98. // adds a quadratic Bezier curve from the current point, using a control point and an end point
  99. virtual void AddQuadCurveToPoint( wxDouble cx, wxDouble cy, wxDouble x, wxDouble y );
  100. // appends a rectangle as a new closed subpath
  101. virtual void AddRectangle( wxDouble x, wxDouble y, wxDouble w, wxDouble h );
  102. // appends an ellipsis as a new closed subpath fitting the passed rectangle
  103. virtual void AddCircle( wxDouble x, wxDouble y, wxDouble r );
  104. // appends a an arc to two tangents connecting (current) to (x1,y1) and (x1,y1) to (x2,y2), also a straight line from (current) to (x1,y1)
  105. virtual void AddArcToPoint( wxDouble x1, wxDouble y1 , wxDouble x2, wxDouble y2, wxDouble r ) ;
  106. // appends an ellipse
  107. virtual void AddEllipse( wxDouble x, wxDouble y, wxDouble w, wxDouble h);
  108. // appends a rounded rectangle
  109. virtual void AddRoundedRectangle( wxDouble x, wxDouble y, wxDouble w, wxDouble h, wxDouble radius);
  110. // returns the native path
  111. virtual void * GetNativePath() const = 0;
  112. // give the native path returned by GetNativePath() back (there might be some deallocations necessary)
  113. virtual void UnGetNativePath(void *p) const= 0;
  114. // transforms each point of this path by the matrix
  115. virtual void Transform( const wxGraphicsMatrixData* matrix ) =0;
  116. // gets the bounding box enclosing all points (possibly including control points)
  117. virtual void GetBox(wxDouble *x, wxDouble *y, wxDouble *w, wxDouble *h) const=0;
  118. virtual bool Contains( wxDouble x, wxDouble y, wxPolygonFillMode fillStyle = wxODDEVEN_RULE) const=0;
  119. };
  120. #endif
  121. #endif // _WX_GRAPHICS_PRIVATE_H_