16 #ifndef __WXGRAPHICSA_H__
17 #define __WXGRAPHICSA_H__
20 #include "a2dprivate.h"
22 #if wxART2D_USE_GRAPHICS_CONTEXT
28 #include "wx/dcprint.h"
30 #include "wx/graphics.h"
31 #if wxCHECK_VERSION(2, 9, 0)
42 class a2dStrokeData :
public wxGraphicsObjectRefData
45 a2dStrokeData( wxGraphicsRenderer* renderer = 0,
const wxPen& pen = wxNullPen );
46 a2dStrokeData( wxGraphicsRenderer* renderer,
const a2dStroke& stroke );
51 virtual void Apply( wxGraphicsContext* context );
52 virtual wxDouble GetWidth() {
return m_stroke.GetWidth(); }
59 class a2dFillData :
public wxGraphicsObjectRefData
62 a2dFillData( wxGraphicsRenderer* renderer = 0 );
63 a2dFillData( wxGraphicsRenderer* renderer,
const wxBrush& brush );
64 a2dFillData( wxGraphicsRenderer* renderer,
const a2dFill& fill );
67 virtual void Apply( wxGraphicsContext* context );
70 #if wxCHECK_VERSION(2, 9, 1)
71 void CreateLinearGradientBrush( wxDouble x1, wxDouble y1, wxDouble x2, wxDouble y2,
72 const wxGraphicsGradientStops& stops );
73 void CreateRadialGradientBrush( wxDouble xo, wxDouble yo, wxDouble xc, wxDouble yc, wxDouble radius,
74 const wxGraphicsGradientStops& stops );
76 void CreateLinearGradientBrush( wxDouble x1, wxDouble y1, wxDouble x2, wxDouble y2,
77 const wxColour& c1,
const wxColour& c2 );
78 void CreateRadialGradientBrush( wxDouble xo, wxDouble yo, wxDouble xc, wxDouble yc, wxDouble radius,
79 const wxColour& oColor,
const wxColour& cColor );
92 class a2dFontData :
public wxGraphicsObjectRefData
95 a2dFontData( wxGraphicsRenderer* renderer,
const wxFont& font,
const wxColour& col );
96 a2dFontData( wxGraphicsRenderer* renderer,
const a2dFont& font );
99 virtual void Apply( wxGraphicsContext* context );
105 class a2dBitmapData :
public wxGraphicsObjectRefData
108 a2dBitmapData( wxGraphicsRenderer* renderer,
const wxBitmap& bmp );
109 a2dBitmapData( wxGraphicsRenderer* renderer,
const wxImage& image );
110 a2dBitmapData( wxGraphicsRenderer* renderer,
const wxGraphicsBitmap& a2dbitmap );
113 virtual wxImage GetImage()
const {
return m_image; }
114 virtual wxSize GetSize()
const {
return wxSize( m_width, m_height ); }
122 class a2dMatrixData :
public wxGraphicsMatrixData
125 a2dMatrixData( wxGraphicsRenderer* renderer,
const a2dAffineMatrix* matrix = NULL ) ;
126 virtual ~a2dMatrixData() ;
128 virtual wxGraphicsObjectRefData* Clone()
const ;
131 virtual void Concat(
const wxGraphicsMatrixData* t );
134 virtual void Set( wxDouble a = 1.0, wxDouble b = 0.0, wxDouble c = 0.0, wxDouble d = 1.0,
135 wxDouble tx = 0.0, wxDouble ty = 0.0 );
138 virtual void Get( wxDouble* a = NULL, wxDouble* b = NULL, wxDouble* c = NULL,
139 wxDouble* d = NULL, wxDouble* tx = NULL, wxDouble* ty = NULL )
const;
142 virtual void Invert();
145 virtual bool IsEqual(
const wxGraphicsMatrixData* t )
const ;
148 virtual bool IsIdentity()
const;
155 virtual void Translate( wxDouble dx , wxDouble dy );
158 virtual void Scale( wxDouble xScale , wxDouble yScale );
161 virtual void Rotate( wxDouble angle );
168 virtual void TransformPoint( wxDouble* x, wxDouble* y )
const;
171 virtual void TransformDistance( wxDouble* dx, wxDouble* dy )
const;
174 virtual void* GetNativeMatrix()
const;
179 class a2dPathData :
public wxGraphicsPathData
182 a2dPathData( wxGraphicsRenderer* renderer,
a2dVpath* path = NULL );
185 virtual wxGraphicsObjectRefData* Clone()
const;
192 virtual void MoveToPoint( wxDouble x, wxDouble y );
195 virtual void AddLineToPoint( wxDouble x, wxDouble y );
198 virtual void AddCurveToPoint( wxDouble cx1, wxDouble cy1, wxDouble cx2, wxDouble cy2, wxDouble x, wxDouble y );
202 virtual void AddArc( wxDouble x, wxDouble y, wxDouble r, wxDouble startAngle, wxDouble endAngle,
bool clockwise ) ;
205 virtual void GetCurrentPoint( wxDouble* x, wxDouble* y )
const;
208 virtual void AddPath(
const wxGraphicsPathData* path );
211 virtual void CloseSubpath();
230 virtual void* GetNativePath()
const ;
233 virtual void UnGetNativePath(
void* p )
const;
236 virtual void Transform(
const wxGraphicsMatrixData* matrix ) ;
239 virtual void GetBox( wxDouble* x, wxDouble* y, wxDouble* w, wxDouble* h )
const;
241 virtual bool Contains( wxDouble x, wxDouble y, wxPolygonFillMode fillStyle = wxWINDING_RULE )
const;
247 class a2dContext :
public wxGraphicsContext
249 DECLARE_NO_COPY_CLASS( a2dContext )
253 a2dContext( wxGraphicsRenderer* renderer,
int width,
int height );
254 a2dContext( wxGraphicsRenderer* renderer );
255 a2dContext( wxGraphicsRenderer* renderer, a2dContext* context );
260 virtual ~a2dContext();
262 #if wxCHECK_VERSION(2,9,0)
264 virtual bool SetAntialiasMode( wxAntialiasMode antialias ) {
return false; }
267 virtual bool SetCompositionMode( wxCompositionMode op ) {
return false; }
270 virtual void Clip(
const wxRegion& region );
273 virtual void Clip( wxDouble x, wxDouble y, wxDouble w, wxDouble h );
276 virtual void ResetClip();
278 virtual void* GetNativeContext();
280 virtual void StrokePath(
const wxGraphicsPath& p );
281 virtual void FillPath(
const wxGraphicsPath& p , wxPolygonFillMode fillStyle = wxWINDING_RULE );
283 void DrawPath(
const wxGraphicsPath& path, wxPolygonFillMode fillStyle = wxWINDING_RULE );
285 virtual void Translate( wxDouble dx , wxDouble dy );
286 virtual void Scale( wxDouble xScale , wxDouble yScale );
287 virtual void Rotate( wxDouble angle );
290 virtual void ConcatTransform(
const wxGraphicsMatrix& matrix );
293 virtual void SetPen(
const wxGraphicsPen& pen );
296 virtual void SetBrush(
const wxGraphicsBrush& brush );
299 virtual void SetFont(
const wxGraphicsFont& font );
301 void SetStroke(
const a2dStroke& stroke );
303 void SetFill(
const a2dFill& fill );
305 void SetFont(
const a2dFont& font );
320 virtual void SetDrawStyle(
a2dDrawStyle drawstyle ) = 0;
326 void BeginLayer( wxDouble opacity ) {};
333 virtual void SetTransform(
const wxGraphicsMatrix& matrix );
336 virtual wxGraphicsMatrix GetTransform()
const;
338 #if wxCHECK_VERSION(2,9,0)
339 virtual void DrawBitmap(
const wxGraphicsBitmap& bmp, wxDouble x, wxDouble y, wxDouble w, wxDouble h );
341 virtual void DrawGraphicsBitmap(
const wxGraphicsBitmap& bmp, wxDouble x, wxDouble y, wxDouble w, wxDouble h );
344 virtual void DrawBitmap(
const wxBitmap& bmp, wxDouble x, wxDouble y, wxDouble w, wxDouble h );
345 virtual void DrawIcon(
const wxIcon& icon, wxDouble x, wxDouble y, wxDouble w, wxDouble h );
346 virtual void PushState();
347 virtual void PopState();
349 #if wxCHECK_VERSION(2,9,0)
350 void DoDrawText(
const wxString& str, wxDouble x, wxDouble y );
352 void DrawText(
const wxString& str, wxDouble x, wxDouble y );
354 virtual void GetTextExtent(
const wxString& str, wxDouble* width, wxDouble* height,
355 wxDouble* descent, wxDouble* externalLeading )
const;
356 virtual void GetPartialTextExtents(
const wxString& text, wxArrayDouble& widths )
const;
365 void SetDisplayAberration(
double aber ) { m_displayaberration = aber; }
371 double GetDisplayAberration() {
return m_displayaberration; }
374 inline void SetPrimitiveThreshold( wxUint16 pixels ) { m_drawingthreshold = pixels; }
377 inline wxUint16 GetPrimitiveThreshold() {
return m_drawingthreshold; }
383 void SetOpacityFactor( wxUint8 OpacityFactor ) { m_OpacityFactor = OpacityFactor; }
386 wxUint8 GetOpacityFactor() {
return m_OpacityFactor; }
389 inline bool GetYaxis()
const {
return m_yaxis; }
392 virtual void SetYaxis(
bool up );
400 inline bool IsStrokeOnly()
406 m_activefill.IsNoFill() ||
413 inline bool IsStroked()
419 virtual void DoSetActiveStroke() = 0;
422 virtual void DoSetActiveFill() = 0;
425 virtual void DrawPolygon(
const a2dVertexList* list, wxPolygonFillMode fillStyle = wxODDEVEN_RULE );
431 virtual void DrawLine(
double x1,
double y1,
double x2,
double y2 );
433 virtual void DrawVpath(
const a2dVpath* path );
465 void SetMappingUpp(
double x,
double y,
double wx,
double wy,
double vx1,
double vy1,
double xpp,
double ypp );
468 void FillPolygon(
int n, wxRealPoint points[] );
471 bool MoveUp(
int n, wxRealPoint points[] ,
double horline,
int& index,
int direction );
474 void DetectCriticalPoints(
int n, wxRealPoint points[] );
487 void DrawTextGeneric(
const wxString& text,
double x,
double y,
void ( a2dContext::*drawchar )( wxChar ) );
490 virtual void DrawCharUnknown( wxChar c );
501 virtual void DrawTextUnknown(
const wxString& text,
double x,
double y,
bool words =
false );
509 virtual void DrawCharStroke( wxChar c );
520 void DrawCharStrokeCb( wxChar c ) { DrawCharStroke( c ); }
526 virtual void DrawTextStroke(
const wxString& text,
double x,
double y )
527 { DrawTextGeneric( text, x, y, &a2dContext::DrawCharStrokeCb ); }
535 virtual void DrawCharFreetype( wxChar c ) { DrawCharUnknown( c ); }
539 void DrawCharFreetypeCb( wxChar c ) { DrawCharFreetype( c ); }
545 virtual void DrawTextFreetype(
const wxString& text,
double x,
double y )
546 { DrawTextGeneric( text, x, y, &a2dContext::DrawCharFreetypeCb ); }
554 virtual void DrawCharDc( wxChar c ) { DrawCharUnknown( c ); }
558 void DrawCharDcCb( wxChar c ) { DrawCharDc( c ); }
564 virtual void DrawTextDc(
const wxString& text,
double x,
double y )
565 { DrawTextGeneric( text, x, y, &a2dContext::DrawCharDcCb ); }
568 wxPoint* _convertToIntPointCache(
int n, wxRealPoint* pts );
571 virtual void DeviceDrawPolygon(
unsigned int n,
bool spline , wxPolygonFillMode fillStyle );
574 virtual void DeviceDrawLines(
unsigned int n,
bool spline );
577 virtual void DeviceDrawLine(
double x1,
double y1,
double x2,
double y2 );
588 virtual void DeviceDrawHorizontalLine(
int x1,
int y1,
int x2,
bool use_stroke_color );
599 virtual void DeviceDrawVerticalLine(
int x1,
int y1,
int y2,
bool use_stroke_color );
602 virtual void DeviceDrawPixel(
int x1,
int y1,
unsigned char r,
unsigned char g,
unsigned char b,
unsigned char a = 255 );
605 wxUint8 m_StrokeOpacityCol1;
607 wxUint8 m_StrokeOpacityCol2;
609 wxUint8 m_FillOpacityCol1;
611 wxUint8 m_FillOpacityCol2;
614 unsigned char m_colour1redStroke;
616 unsigned char m_colour1greenStroke;
618 unsigned char m_colour1blueStroke;
621 unsigned char m_colour1redFill;
623 unsigned char m_colour1greenFill;
625 unsigned char m_colour1blueFill;
628 unsigned char m_colour2redFill;
630 unsigned char m_colour2greenFill;
632 unsigned char m_colour2blueFill;
659 a2dCriticalPointList m_CRlist;
662 a2dAETList m_AETlist;
665 std::vector<wxPoint> m_cpointsInt;
668 std::vector<wxRealPoint> m_cpointsDouble;
671 double m_displayaberration;
674 wxUint16 m_drawingthreshold;
677 wxUint8 m_OpacityFactor;
681 void ColourXYLinear(
int x1,
int x2,
int y );
682 void ColourXYRadial(
int x1,
int x2,
int y );
685 double m_dx1, m_dy1, m_dx2, m_dy2, m_radiusd, m_length, m_max_x, m_min_x, m_max_y, m_min_y;
690 class a2dDcContext :
public a2dContext
692 DECLARE_NO_COPY_CLASS( a2dDcContext )
696 a2dDcContext( wxGraphicsRenderer* renderer, wxMemoryDC* dc, wxBitmap* drawable );
697 a2dDcContext( wxGraphicsRenderer* renderer, wxBitmap* drawable );
698 virtual ~a2dDcContext();
701 virtual
void Clip( wxDouble x, wxDouble y, wxDouble w, wxDouble h );
704 virtual
void ResetClip();
722 virtual
bool SetLogicalFunction( wxRasterOperationMode function ) ;
724 #if wxCHECK_VERSION(2,9,0)
725 virtual void DrawBitmap(
const wxGraphicsBitmap& bmp, wxDouble x, wxDouble y, wxDouble w, wxDouble h );
727 virtual void DrawGraphicsBitmap(
const wxGraphicsBitmap& bmp, wxDouble x, wxDouble y, wxDouble w, wxDouble h );
730 virtual void DrawCharDc( wxChar c );
731 virtual void DrawTextDc(
const wxString& text,
double x,
double y );
732 virtual void DrawCharFreetype( wxChar c );
737 virtual void DoSetActiveStroke();
740 virtual void DoSetActiveFill();
742 virtual void DrawVpath(
const a2dVpath* path );
744 void DeviceDrawBitmap(
const wxBitmap& bmp,
double x,
double y,
bool useMask );
747 virtual void DeviceDrawPolygon(
unsigned int n,
bool spline , wxPolygonFillMode fillStyle );
748 virtual void DeviceDrawLines(
unsigned int n,
bool spline );
749 virtual void DeviceDrawLine(
double x1,
double y1,
double x2,
double y2 );
750 virtual void DeviceDrawHorizontalLine(
int x1,
int y1,
int x2,
bool use_stroke_color );
751 virtual void DeviceDrawVerticalLine(
int x1,
int y1,
int y2,
bool use_stroke_color );
752 virtual void DeviceDrawPixel(
int x1,
int y1,
unsigned char r,
unsigned char g,
unsigned char b,
unsigned char a = 255 );
766 class a2dRenderer :
public wxGraphicsRenderer
771 virtual ~a2dRenderer() {}
775 virtual wxGraphicsContext* CreateContext(
const wxWindowDC& dc );
777 virtual wxGraphicsContext* CreateContext(
const wxMemoryDC& dc );
779 virtual wxGraphicsContext* CreateContext( wxMemoryDC* dc, wxBitmap* drawable );
781 virtual wxGraphicsContext* CreateContextFromNativeContext(
void* context );
783 virtual wxGraphicsContext* CreateContextFromNativeWindow(
void* window );
785 virtual wxGraphicsContext* CreateContext( wxWindow* window );
787 virtual wxGraphicsContext* CreateMeasuringContext();
789 #if wxCHECK_VERSION(2, 9, 0)
790 #if wxUSE_PRINTING_ARCHITECTURE
791 virtual wxGraphicsContext* CreateContext(
const wxPrinterDC& dc );
793 virtual wxGraphicsContext* CreateContext(
const wxEnhMetaFileDC& dc );
796 #endif // wxUSE_PRINTING_ARCHITECTURE
797 #endif //wxCHECK_VERSION(2, 9, 0)
801 virtual wxGraphicsPath CreatePath();
804 virtual wxGraphicsMatrix CreateMatrix( wxDouble a = 1.0, wxDouble b = 0.0, wxDouble c = 0.0, wxDouble d = 1.0,
805 wxDouble tx = 0.0, wxDouble ty = 0.0 );
807 virtual wxGraphicsPen CreatePen(
const wxPen& pen ) ;
809 virtual wxGraphicsBrush CreateBrush(
const wxBrush& brush ) ;
811 virtual wxGraphicsPen CreateStroke(
const a2dStroke& stroke ) ;
813 virtual wxGraphicsBrush CreateFill(
const a2dFill& fill ) ;
815 #if wxCHECK_VERSION(2, 9, 1)
816 virtual wxGraphicsBrush
817 CreateLinearGradientBrush( wxDouble x1, wxDouble y1,
818 wxDouble x2, wxDouble y2,
819 const wxGraphicsGradientStops& stops );
821 virtual wxGraphicsBrush
822 CreateRadialGradientBrush( wxDouble xo, wxDouble yo,
823 wxDouble xc, wxDouble yc,
825 const wxGraphicsGradientStops& stops );
828 virtual wxGraphicsBitmap CreateBitmapFromNativeBitmap(
void* bitmap );
832 virtual wxGraphicsBrush CreateLinearGradientBrush( wxDouble x1, wxDouble y1, wxDouble x2, wxDouble y2,
833 const wxColour& c1,
const wxColour& c2 ) ;
837 virtual wxGraphicsBrush CreateRadialGradientBrush( wxDouble xo, wxDouble yo, wxDouble xc, wxDouble yc, wxDouble radius,
838 const wxColour& oColor,
const wxColour& cColor ) ;
844 virtual wxGraphicsFont CreateFont(
const wxFont& font ,
const wxColour& col = *wxBLACK ) ;
846 virtual wxGraphicsFont CreateFont(
const a2dFont& font ) ;
848 wxGraphicsBitmap CreateBitmap(
const wxBitmap& bitmap ) ;
850 wxGraphicsBitmap CreateBitmap(
const wxImage& image ) ;
852 virtual wxGraphicsBitmap CreateSubBitmap(
const wxGraphicsBitmap& bitmap, wxDouble x, wxDouble y, wxDouble w, wxDouble h );
856 DECLARE_DYNAMIC_CLASS_NO_COPY( a2dRenderer )
861 #endif //wxART2D_USE_GRAPHICS_CONTEXT
Base class for all types of strokes, understood by a2dDrawer2D classes.
Stroke and fill base classes.
Defines a font to be set to a2dDrawer2D or stored in a2dCanvsObject etc.
vertex array of line and arc segments.
vertex list of line and arc segments.
general vertexlist and array and vector path functions and classes.
a2dDrawStyle
Define the manner in which a2dCanvasView draws to the device.
classes for initializing the artbase modules, and set paths to be used for fonts etc.
A 2x3 affine matrix class for 2D transformations.
Contains image with RGBA per pixel.
The a2dBoundingBox class stores one a2dBoundingBox of a a2dCanvasObject.