]> git.saurik.com Git - wxWidgets.git/blame - include/wx/graphics.h
Reorder event things a little.
[wxWidgets.git] / include / wx / graphics.h
CommitLineData
50581042
SC
1/////////////////////////////////////////////////////////////////////////////
2// Name: wx/graphics.h
3// Purpose: graphics context header
4// Author: Stefan Csomor
5// Modified by:
6// Created:
7// Copyright: (c) Stefan Csomor
8// RCS-ID: $Id$
9// Licence: wxWindows licence
10/////////////////////////////////////////////////////////////////////////////
11
12#ifndef _WX_GRAPHICS_H_
13#define _WX_GRAPHICS_H_
14
8acd14d1
SC
15#if wxUSE_GRAPHICS_CONTEXT
16
50581042 17#include "wx/geometry.h"
50581042
SC
18#include "wx/dynarray.h"
19
9e605538
SC
20class WXDLLIMPEXP_CORE wxWindowDC;
21class WXDLLIMPEXP_CORE wxGraphicsContext;
22class WXDLLIMPEXP_CORE wxGraphicsPath;
23class WXDLLIMPEXP_CORE wxGraphicsMatrix;
24class WXDLLIMPEXP_CORE wxGraphicsFigure;
25class WXDLLIMPEXP_CORE wxGraphicsRenderer;
26class WXDLLIMPEXP_CORE wxGraphicsPen;
27class WXDLLIMPEXP_CORE wxGraphicsBrush;
28class WXDLLIMPEXP_CORE wxGraphicsFont;
774f4d12 29
50581042
SC
30/*
31 * notes about the graphics context apis
32 *
33 * angles : are measured in radians, 0.0 being in direction of positiv x axis, PI/2 being
34 * in direction of positive y axis.
35 */
36
9e605538
SC
37// Base class of all objects used for drawing in the new graphics API, the always point back to their
38// originating rendering engine, there is no dynamic unloading of a renderer currently allowed,
39// these references are not counted
2c820406
SC
40
41//
42// The data used by objects like graphics pens etc is ref counted, in order to avoid unnecessary expensive
43// duplication. Any operation on a shared instance that results in a modified state, uncouples this
44// instance from the other instances that were shared - using copy on write semantics
45//
9e605538 46
2c820406
SC
47class WXDLLIMPEXP_CORE wxGraphicsObjectRefData : public wxObjectRefData
48{
49public :
50 wxGraphicsObjectRefData( wxGraphicsRenderer* renderer );
51 wxGraphicsObjectRefData( const wxGraphicsObjectRefData* data );
52 wxGraphicsRenderer* GetRenderer() const ;
53 virtual wxGraphicsObjectRefData* Clone() const ;
54
55protected :
56 wxGraphicsRenderer* m_renderer;
57} ;
58
9e605538
SC
59class WXDLLIMPEXP_CORE wxGraphicsObject : public wxObject
60{
61public :
2c820406
SC
62 wxGraphicsObject() ;
63 wxGraphicsObject( wxGraphicsRenderer* renderer ) ;
64 virtual ~wxGraphicsObject() ;
0d3675a6 65
2c820406
SC
66 bool IsNull() const ;
67
68 // returns the renderer that was used to create this instance, or NULL if it has not been initialized yet
69 wxGraphicsRenderer* GetRenderer() const ;
70 wxGraphicsObjectRefData* GetGraphicsData() const ;
9e605538 71protected :
2c820406
SC
72 virtual wxObjectRefData* CreateRefData() const;
73 virtual wxObjectRefData* CloneRefData(const wxObjectRefData* data) const;
74
0d3675a6 75 DECLARE_DYNAMIC_CLASS(wxGraphicsObject);
9e605538
SC
76} ;
77
78class WXDLLIMPEXP_CORE wxGraphicsPen : public wxGraphicsObject
79{
80public :
2c820406 81 wxGraphicsPen() {}
9e605538 82 virtual ~wxGraphicsPen() {}
9e605538 83private :
2c820406 84 DECLARE_DYNAMIC_CLASS(wxGraphicsPen)
9e605538
SC
85} ;
86
2c820406
SC
87extern WXDLLEXPORT_DATA(wxGraphicsPen) wxNullGraphicsPen;
88
9e605538
SC
89class WXDLLIMPEXP_CORE wxGraphicsBrush : public wxGraphicsObject
90{
91public :
2c820406 92 wxGraphicsBrush() {}
9e605538 93 virtual ~wxGraphicsBrush() {}
9e605538 94private :
2c820406 95 DECLARE_DYNAMIC_CLASS(wxGraphicsBrush)
9e605538
SC
96} ;
97
2c820406
SC
98extern WXDLLEXPORT_DATA(wxGraphicsBrush) wxNullGraphicsBrush;
99
9e605538 100class WXDLLIMPEXP_CORE wxGraphicsFont : public wxGraphicsObject
50581042
SC
101{
102public :
2c820406 103 wxGraphicsFont() {}
9e605538 104 virtual ~wxGraphicsFont() {}
9e605538 105private :
2c820406 106 DECLARE_DYNAMIC_CLASS(wxGraphicsFont)
9e605538
SC
107} ;
108
2c820406
SC
109extern WXDLLEXPORT_DATA(wxGraphicsFont) wxNullGraphicsFont;
110
111
a4e73390 112class WXDLLIMPEXP_CORE wxGraphicsMatrixData : public wxGraphicsObjectRefData
9e605538
SC
113{
114public :
a4e73390
SC
115 wxGraphicsMatrixData( wxGraphicsRenderer* renderer) :
116 wxGraphicsObjectRefData(renderer) {}
117
118 virtual ~wxGraphicsMatrixData() {}
119
120 // concatenates the matrix
121 virtual void Concat( const wxGraphicsMatrixData *t ) = 0;
122
123 // sets the matrix to the respective values
124 virtual void Set(wxDouble a=1.0, wxDouble b=0.0, wxDouble c=0.0, wxDouble d=1.0,
125 wxDouble tx=0.0, wxDouble ty=0.0) = 0;
126
127 // makes this the inverse matrix
128 virtual void Invert() = 0;
129
130 // returns true if the elements of the transformation matrix are equal ?
131 virtual bool IsEqual( const wxGraphicsMatrixData* t) const = 0;
132
133 // return true if this is the identity matrix
134 virtual bool IsIdentity() const = 0;
135
136 //
137 // transformation
138 //
139
140 // add the translation to this matrix
141 virtual void Translate( wxDouble dx , wxDouble dy ) = 0;
142
143 // add the scale to this matrix
144 virtual void Scale( wxDouble xScale , wxDouble yScale ) = 0;
145
146 // add the rotation to this matrix (radians)
147 virtual void Rotate( wxDouble angle ) = 0;
148
149 //
150 // apply the transforms
151 //
152
153 // applies that matrix to the point
154 virtual void TransformPoint( wxDouble *x, wxDouble *y ) const = 0;
155
156 // applies the matrix except for translations
157 virtual void TransformDistance( wxDouble *dx, wxDouble *dy ) const =0;
158
159 // returns the native representation
160 virtual void * GetNativeMatrix() const = 0;
161} ;
162
163class WXDLLIMPEXP_CORE wxGraphicsMatrix : public wxGraphicsObject
164{
165public :
166 wxGraphicsMatrix() {}
167
168 virtual ~wxGraphicsMatrix() {}
169
170 // concatenates the matrix
171 virtual void Concat( const wxGraphicsMatrix *t );
172 void Concat( const wxGraphicsMatrix &t ) { Concat( &t ); }
173
174 // sets the matrix to the respective values
175 virtual void Set(wxDouble a=1.0, wxDouble b=0.0, wxDouble c=0.0, wxDouble d=1.0,
176 wxDouble tx=0.0, wxDouble ty=0.0);
177
178 // makes this the inverse matrix
179 virtual void Invert();
180
181 // returns true if the elements of the transformation matrix are equal ?
182 virtual bool IsEqual( const wxGraphicsMatrix* t) const;
183 bool IsEqual( const wxGraphicsMatrix& t) const { return IsEqual( &t ); }
184
185 // return true if this is the identity matrix
186 virtual bool IsIdentity() const;
187
188 //
189 // transformation
190 //
191
192 // add the translation to this matrix
193 virtual void Translate( wxDouble dx , wxDouble dy );
194
195 // add the scale to this matrix
196 virtual void Scale( wxDouble xScale , wxDouble yScale );
197
198 // add the rotation to this matrix (radians)
199 virtual void Rotate( wxDouble angle );
200
201 //
202 // apply the transforms
203 //
204
205 // applies that matrix to the point
206 virtual void TransformPoint( wxDouble *x, wxDouble *y ) const;
207
208 // applies the matrix except for translations
209 virtual void TransformDistance( wxDouble *dx, wxDouble *dy ) const;
210
211 // returns the native representation
212 virtual void * GetNativeMatrix() const;
213
214 const wxGraphicsMatrixData* GetMatrixData() const
215 { return (const wxGraphicsMatrixData*) GetRefData(); }
216 wxGraphicsMatrixData* GetMatrixData()
217 { return (wxGraphicsMatrixData*) GetRefData(); }
218
219private :
220 DECLARE_DYNAMIC_CLASS(wxGraphicsMatrix)
221} ;
222
223extern WXDLLEXPORT_DATA(wxGraphicsMatrix) wxNullGraphicsMatrix;
224
225class WXDLLIMPEXP_CORE wxGraphicsPathData : public wxGraphicsObjectRefData
226{
227public :
228 wxGraphicsPathData(wxGraphicsRenderer* renderer) : wxGraphicsObjectRefData(renderer) {}
229 virtual ~wxGraphicsPathData() {}
9e605538 230
50581042
SC
231 //
232 // These are the path primitives from which everything else can be constructed
233 //
234
235 // begins a new subpath at (x,y)
236 virtual void MoveToPoint( wxDouble x, wxDouble y ) = 0;
237
238 // adds a straight line from the current point to (x,y)
239 virtual void AddLineToPoint( wxDouble x, wxDouble y ) = 0;
240
241 // adds a cubic Bezier curve from the current point, using two control points and an end point
242 virtual void AddCurveToPoint( wxDouble cx1, wxDouble cy1, wxDouble cx2, wxDouble cy2, wxDouble x, wxDouble y ) = 0;
a4e73390 243
0d3675a6 244 // adds another path
a4e73390 245 virtual void AddPath( const wxGraphicsPathData* path ) =0;
50581042
SC
246
247 // closes the current sub-path
248 virtual void CloseSubpath() = 0;
249
250 // gets the last point of the current path, (0,0) if not yet set
a4e73390 251 virtual void GetCurrentPoint( wxDouble* x, wxDouble* y) const = 0;
50581042
SC
252
253 // adds an arc of a circle centering at (x,y) with radius (r) from startAngle to endAngle
254 virtual void AddArc( wxDouble x, wxDouble y, wxDouble r, wxDouble startAngle, wxDouble endAngle, bool clockwise ) = 0;
255
256 //
257 // These are convenience functions which - if not available natively will be assembled
258 // using the primitives from above
259 //
260
261 // adds a quadratic Bezier curve from the current point, using a control point and an end point
262 virtual void AddQuadCurveToPoint( wxDouble cx, wxDouble cy, wxDouble x, wxDouble y );
263
264 // appends a rectangle as a new closed subpath
265 virtual void AddRectangle( wxDouble x, wxDouble y, wxDouble w, wxDouble h );
266
267 // appends an ellipsis as a new closed subpath fitting the passed rectangle
268 virtual void AddCircle( wxDouble x, wxDouble y, wxDouble r );
269
59720690 270 // 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)
50581042 271 virtual void AddArcToPoint( wxDouble x1, wxDouble y1 , wxDouble x2, wxDouble y2, wxDouble r ) ;
a4e73390 272
59720690
SC
273 // appends an ellipse
274 virtual void AddEllipse( wxDouble x, wxDouble y, wxDouble w, wxDouble h);
275
276 // appends a rounded rectangle
277 virtual void AddRoundedRectangle( wxDouble x, wxDouble y, wxDouble w, wxDouble h, wxDouble radius);
278
0d3675a6
RD
279 // returns the native path
280 virtual void * GetNativePath() const = 0;
a4e73390 281
0d3675a6 282 // give the native path returned by GetNativePath() back (there might be some deallocations necessary)
a4e73390
SC
283 virtual void UnGetNativePath(void *p) const= 0;
284
0d3675a6 285 // transforms each point of this path by the matrix
a4e73390
SC
286 virtual void Transform( const wxGraphicsMatrixData* matrix ) =0;
287
0d3675a6 288 // gets the bounding box enclosing all points (possibly including control points)
a4e73390
SC
289 virtual void GetBox(wxDouble *x, wxDouble *y, wxDouble *w, wxDouble *h) const=0;
290
291 virtual bool Contains( wxDouble x, wxDouble y, int fillStyle = wxODDEVEN_RULE) const=0;
50581042
SC
292};
293
a4e73390 294class WXDLLIMPEXP_CORE wxGraphicsPath : public wxGraphicsObject
774f4d12
SC
295{
296public :
a4e73390
SC
297 wxGraphicsPath() {}
298 virtual ~wxGraphicsPath() {}
0d3675a6 299
a4e73390
SC
300 //
301 // These are the path primitives from which everything else can be constructed
302 //
9e605538 303
a4e73390
SC
304 // begins a new subpath at (x,y)
305 virtual void MoveToPoint( wxDouble x, wxDouble y );
306 void MoveToPoint( const wxPoint2DDouble& p);
0d3675a6 307
a4e73390
SC
308 // adds a straight line from the current point to (x,y)
309 virtual void AddLineToPoint( wxDouble x, wxDouble y );
310 void AddLineToPoint( const wxPoint2DDouble& p);
0d3675a6 311
a4e73390
SC
312 // adds a cubic Bezier curve from the current point, using two control points and an end point
313 virtual void AddCurveToPoint( wxDouble cx1, wxDouble cy1, wxDouble cx2, wxDouble cy2, wxDouble x, wxDouble y ) ;
314 void AddCurveToPoint( const wxPoint2DDouble& c1, const wxPoint2DDouble& c2, const wxPoint2DDouble& e);
0d3675a6 315
a4e73390
SC
316 // adds another path
317 virtual void AddPath( const wxGraphicsPath& path );
318
319 // closes the current sub-path
320 virtual void CloseSubpath() ;
321
322 // gets the last point of the current path, (0,0) if not yet set
323 virtual void GetCurrentPoint( wxDouble* x, wxDouble* y) const;
324 wxPoint2DDouble GetCurrentPoint() const;
325
326 // adds an arc of a circle centering at (x,y) with radius (r) from startAngle to endAngle
327 virtual void AddArc( wxDouble x, wxDouble y, wxDouble r, wxDouble startAngle, wxDouble endAngle, bool clockwise ) ;
328 void AddArc( const wxPoint2DDouble& c, wxDouble r, wxDouble startAngle, wxDouble endAngle, bool clockwise);
329
774f4d12 330 //
a4e73390
SC
331 // These are convenience functions which - if not available natively will be assembled
332 // using the primitives from above
774f4d12 333 //
a4e73390
SC
334
335 // adds a quadratic Bezier curve from the current point, using a control point and an end point
336 virtual void AddQuadCurveToPoint( wxDouble cx, wxDouble cy, wxDouble x, wxDouble y );
337
338 // appends a rectangle as a new closed subpath
339 virtual void AddRectangle( wxDouble x, wxDouble y, wxDouble w, wxDouble h );
340
341 // appends an ellipsis as a new closed subpath fitting the passed rectangle
342 virtual void AddCircle( wxDouble x, wxDouble y, wxDouble r );
343
344 // 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)
345 virtual void AddArcToPoint( wxDouble x1, wxDouble y1 , wxDouble x2, wxDouble y2, wxDouble r ) ;
774f4d12 346
a4e73390
SC
347 // appends an ellipse
348 virtual void AddEllipse( wxDouble x, wxDouble y, wxDouble w, wxDouble h);
774f4d12 349
a4e73390
SC
350 // appends a rounded rectangle
351 virtual void AddRoundedRectangle( wxDouble x, wxDouble y, wxDouble w, wxDouble h, wxDouble radius);
774f4d12 352
a4e73390
SC
353 // returns the native path
354 virtual void * GetNativePath() const;
0d3675a6 355
a4e73390
SC
356 // give the native path returned by GetNativePath() back (there might be some deallocations necessary)
357 virtual void UnGetNativePath(void *p)const;
0d3675a6 358
a4e73390
SC
359 // transforms each point of this path by the matrix
360 virtual void Transform( const wxGraphicsMatrix& matrix );
0d3675a6 361
a4e73390
SC
362 // gets the bounding box enclosing all points (possibly including control points)
363 virtual void GetBox(wxDouble *x, wxDouble *y, wxDouble *w, wxDouble *h)const;
364 wxRect2DDouble GetBox()const;
0d3675a6 365
a4e73390
SC
366 virtual bool Contains( wxDouble x, wxDouble y, int fillStyle = wxODDEVEN_RULE)const;
367 bool Contains( const wxPoint2DDouble& c, int fillStyle = wxODDEVEN_RULE)const;
0d3675a6 368
a4e73390
SC
369 const wxGraphicsPathData* GetPathData() const
370 { return (const wxGraphicsPathData*) GetRefData(); }
371 wxGraphicsPathData* GetPathData()
372 { return (wxGraphicsPathData*) GetRefData(); }
373
374private :
375 DECLARE_DYNAMIC_CLASS(wxGraphicsPath)
774f4d12 376} ;
774f4d12 377
a4e73390
SC
378extern WXDLLEXPORT_DATA(wxGraphicsPath) wxNullGraphicsPath;
379
380
9e605538 381class WXDLLIMPEXP_CORE wxGraphicsContext : public wxGraphicsObject
50581042
SC
382{
383public:
9e605538 384 wxGraphicsContext(wxGraphicsRenderer* renderer);
774f4d12 385
9e605538 386 virtual ~wxGraphicsContext();
50581042
SC
387
388 static wxGraphicsContext* Create( const wxWindowDC& dc) ;
0d3675a6 389
bf2185eb 390 static wxGraphicsContext* CreateFromNative( void * context ) ;
774f4d12 391
bf2185eb 392 static wxGraphicsContext* CreateFromNativeWindow( void * window ) ;
9a02779a 393
774f4d12 394 static wxGraphicsContext* Create( wxWindow* window ) ;
50581042 395
ad667945
SC
396 // create a context that can be used for measuring texts only, no drawing allowed
397 static wxGraphicsContext * Create();
398
a4e73390 399 wxGraphicsPath CreatePath() const;
0d3675a6 400
a4e73390 401 virtual wxGraphicsPen CreatePen(const wxPen& pen) const;
9e605538 402
a4e73390 403 virtual wxGraphicsBrush CreateBrush(const wxBrush& brush ) const;
9e605538
SC
404
405 // sets the brush to a linear gradient, starting at (x1,y1) with color c1 to (x2,y2) with color c2
2c820406 406 virtual wxGraphicsBrush CreateLinearGradientBrush( wxDouble x1, wxDouble y1, wxDouble x2, wxDouble y2,
a4e73390 407 const wxColour&c1, const wxColour&c2) const;
9e605538
SC
408
409 // sets the brush to a radial gradient originating at (xo,yc) with color oColor and ends on a circle around (xc,yc)
410 // with radius r and color cColor
2c820406 411 virtual wxGraphicsBrush CreateRadialGradientBrush( wxDouble xo, wxDouble yo, wxDouble xc, wxDouble yc, wxDouble radius,
a4e73390 412 const wxColour &oColor, const wxColour &cColor) const;
9e605538
SC
413
414 // sets the font
a4e73390 415 virtual wxGraphicsFont CreateFont( const wxFont &font , const wxColour &col = *wxBLACK ) const;
9e605538 416
0d3675a6 417 // create a 'native' matrix corresponding to these values
a4e73390
SC
418 virtual wxGraphicsMatrix CreateMatrix( wxDouble a=1.0, wxDouble b=0.0, wxDouble c=0.0, wxDouble d=1.0,
419 wxDouble tx=0.0, wxDouble ty=0.0) const;
0d3675a6 420
50581042
SC
421 // push the current state of the context, ie the transformation matrix on a stack
422 virtual void PushState() = 0;
423
424 // pops a stored state from the stack
425 virtual void PopState() = 0;
426
774f4d12 427 // clips drawings to the region, combined to current clipping region
50581042
SC
428 virtual void Clip( const wxRegion &region ) = 0;
429
774f4d12
SC
430 // clips drawings to the rect
431 virtual void Clip( wxDouble x, wxDouble y, wxDouble w, wxDouble h ) = 0;
0d3675a6
RD
432
433 // resets the clipping to original extent
434 virtual void ResetClip() = 0 ;
774f4d12 435
0d3675a6
RD
436 // returns the native context
437 virtual void * GetNativeContext() = 0;
774f4d12 438
50581042 439 //
774f4d12 440 // transformation : changes the current transformation matrix CTM of the context
50581042
SC
441 //
442
443 // translate
444 virtual void Translate( wxDouble dx , wxDouble dy ) = 0;
445
446 // scale
447 virtual void Scale( wxDouble xScale , wxDouble yScale ) = 0;
448
449 // rotate (radians)
450 virtual void Rotate( wxDouble angle ) = 0;
0d3675a6
RD
451
452 // concatenates this transform with the current transform of this context
a4e73390 453 virtual void ConcatTransform( const wxGraphicsMatrix& matrix ) = 0;
9e605538 454
0d3675a6 455 // sets the transform of this context
a4e73390 456 virtual void SetTransform( const wxGraphicsMatrix& matrix ) = 0;
50581042 457
0d3675a6 458 // gets the matrix of this context
a4e73390 459 virtual wxGraphicsMatrix GetTransform() const = 0;
50581042
SC
460 //
461 // setting the paint
462 //
463
9e605538 464 // sets the pen
2c820406 465 virtual void SetPen( const wxGraphicsPen& pen );
9e605538
SC
466
467 void SetPen( const wxPen& pen );
50581042
SC
468
469 // sets the brush for filling
2c820406 470 virtual void SetBrush( const wxGraphicsBrush& brush );
9e605538
SC
471
472 void SetBrush( const wxBrush& brush );
50581042
SC
473
474 // sets the font
2c820406 475 virtual void SetFont( const wxGraphicsFont& font );
9e605538
SC
476
477 void SetFont( const wxFont& font, const wxColour& colour );
0d3675a6 478
50581042 479
50581042 480 // strokes along a path with the current pen
a4e73390 481 virtual void StrokePath( const wxGraphicsPath& path ) = 0;
50581042
SC
482
483 // fills a path with the current brush
a4e73390 484 virtual void FillPath( const wxGraphicsPath& path, int fillStyle = wxODDEVEN_RULE ) = 0;
50581042
SC
485
486 // draws a path by first filling and then stroking
a4e73390 487 virtual void DrawPath( const wxGraphicsPath& path, int fillStyle = wxODDEVEN_RULE );
0d3675a6 488
50581042
SC
489 //
490 // text
491 //
492
493 virtual void DrawText( const wxString &str, wxDouble x, wxDouble y ) = 0;
494
495 virtual void DrawText( const wxString &str, wxDouble x, wxDouble y, wxDouble angle );
496
068eb463
SC
497 virtual void DrawText( const wxString &str, wxDouble x, wxDouble y, const wxGraphicsBrush& backgroundBrush ) ;
498
499 virtual void DrawText( const wxString &str, wxDouble x, wxDouble y, wxDouble angle, const wxGraphicsBrush& backgroundBrush );
500
50581042
SC
501 virtual void GetTextExtent( const wxString &text, wxDouble *width, wxDouble *height,
502 wxDouble *descent, wxDouble *externalLeading ) const = 0;
503
504 virtual void GetPartialTextExtents(const wxString& text, wxArrayDouble& widths) const = 0;
505
506 //
507 // image support
508 //
509
510 virtual void DrawBitmap( const wxBitmap &bmp, wxDouble x, wxDouble y, wxDouble w, wxDouble h ) = 0;
511
512 virtual void DrawIcon( const wxIcon &icon, wxDouble x, wxDouble y, wxDouble w, wxDouble h ) = 0;
513
514 //
515 // convenience methods
516 //
517
518 // strokes a single line
519 virtual void StrokeLine( wxDouble x1, wxDouble y1, wxDouble x2, wxDouble y2);
520
521 // stroke lines connecting each of the points
522 virtual void StrokeLines( size_t n, const wxPoint2DDouble *points);
523
524 // stroke disconnected lines from begin to end points
525 virtual void StrokeLines( size_t n, const wxPoint2DDouble *beginPoints, const wxPoint2DDouble *endPoints);
526
527 // draws a polygon
a4e73390 528 virtual void DrawLines( size_t n, const wxPoint2DDouble *points, int fillStyle = wxODDEVEN_RULE );
50581042
SC
529
530 // draws a polygon
531 virtual void DrawRectangle( wxDouble x, wxDouble y, wxDouble w, wxDouble h);
532
533 // draws an ellipse
534 virtual void DrawEllipse( wxDouble x, wxDouble y, wxDouble w, wxDouble h);
535
536 // draws a rounded rectangle
537 virtual void DrawRoundedRectangle( wxDouble x, wxDouble y, wxDouble w, wxDouble h, wxDouble radius);
538
9e605538 539 // wrappers using wxPoint2DDouble TODO
50581042 540
de3cb39f
RD
541 // helper to determine if a 0.5 offset should be applied for the drawing operation
542 virtual bool ShouldOffset() const { return false; }
9e605538 543
9da34e21
JS
544protected :
545
2c820406
SC
546 wxGraphicsPen m_pen;
547 wxGraphicsBrush m_brush;
548 wxGraphicsFont m_font;
9e605538
SC
549
550private :
50581042 551 DECLARE_NO_COPY_CLASS(wxGraphicsContext)
8ddf8e82 552 DECLARE_ABSTRACT_CLASS(wxGraphicsContext)
50581042
SC
553};
554
9e605538
SC
555#if 0
556
557//
558// A graphics figure allows to cache path, pen etc creations, also will be a basis for layering/grouping elements
559//
560
561class WXDLLIMPEXP_CORE wxGraphicsFigure : public wxGraphicsObject
562{
563public :
0d3675a6
RD
564 wxGraphicsFigure(wxGraphicsRenderer* renderer) ;
565
566 virtual ~wxGraphicsFigure() ;
567
568 void SetPath( wxGraphicsMatrix* matrix );
569
570 void SetMatrix( wxGraphicsPath* path);
571
572 // draws this object on the context
573 virtual void Draw( wxGraphicsContext* cg );
574
575 // returns the path of this object
576 wxGraphicsPath* GetPath() { return m_path; }
577
578 // returns the transformation matrix of this object, may be null if there is no transformation necessary
579 wxGraphicsMatrix* GetMatrix() { return m_matrix; }
580
9e605538 581private :
0d3675a6
RD
582 wxGraphicsMatrix* m_matrix;
583 wxGraphicsPath* m_path;
9e605538
SC
584
585 DECLARE_DYNAMIC_CLASS(wxGraphicsFigure)
586} ;
587
588#endif
589
590//
591// The graphics renderer is the instance corresponding to the rendering engine used, eg there is ONE core graphics renderer
592// instance on OSX. This instance is pointed back to by all objects created by it. Therefore you can create eg additional
593// paths at any point from a given matrix etc.
594//
595
596class WXDLLIMPEXP_CORE wxGraphicsRenderer : public wxObject
597{
598public :
599 wxGraphicsRenderer() {}
600
601 virtual ~wxGraphicsRenderer() {}
602
0d3675a6 603 static wxGraphicsRenderer* GetDefaultRenderer();
9e605538 604
0d3675a6 605 // Context
9e605538 606
0d3675a6
RD
607 virtual wxGraphicsContext * CreateContext( const wxWindowDC& dc) = 0 ;
608
609 virtual wxGraphicsContext * CreateContextFromNativeContext( void * context ) = 0;
9e605538 610
0d3675a6 611 virtual wxGraphicsContext * CreateContextFromNativeWindow( void * window ) = 0;
9e605538 612
0d3675a6 613 virtual wxGraphicsContext * CreateContext( wxWindow* window ) = 0;
9e605538 614
ad667945
SC
615 // create a context that can be used for measuring texts only, no drawing allowed
616 virtual wxGraphicsContext * CreateMeasuringContext() = 0;
617
0d3675a6
RD
618 // Path
619
a4e73390 620 virtual wxGraphicsPath CreatePath() = 0;
9e605538 621
0d3675a6
RD
622 // Matrix
623
a4e73390 624 virtual wxGraphicsMatrix CreateMatrix( wxDouble a=1.0, wxDouble b=0.0, wxDouble c=0.0, wxDouble d=1.0,
0d3675a6 625 wxDouble tx=0.0, wxDouble ty=0.0) = 0;
9e605538
SC
626
627 // Paints
628
2c820406 629 virtual wxGraphicsPen CreatePen(const wxPen& pen) = 0 ;
9e605538 630
2c820406 631 virtual wxGraphicsBrush CreateBrush(const wxBrush& brush ) = 0 ;
9e605538
SC
632
633 // sets the brush to a linear gradient, starting at (x1,y1) with color c1 to (x2,y2) with color c2
2c820406 634 virtual wxGraphicsBrush CreateLinearGradientBrush( wxDouble x1, wxDouble y1, wxDouble x2, wxDouble y2,
9e605538
SC
635 const wxColour&c1, const wxColour&c2) = 0;
636
637 // sets the brush to a radial gradient originating at (xo,yc) with color oColor and ends on a circle around (xc,yc)
638 // with radius r and color cColor
2c820406 639 virtual wxGraphicsBrush CreateRadialGradientBrush( wxDouble xo, wxDouble yo, wxDouble xc, wxDouble yc, wxDouble radius,
9e605538
SC
640 const wxColour &oColor, const wxColour &cColor) = 0;
641
642 // sets the font
2c820406 643 virtual wxGraphicsFont CreateFont( const wxFont &font , const wxColour &col = *wxBLACK ) = 0;
9e605538
SC
644
645private :
0d3675a6 646 DECLARE_NO_COPY_CLASS(wxGraphicsRenderer)
9e605538
SC
647 DECLARE_ABSTRACT_CLASS(wxGraphicsRenderer)
648} ;
649
774f4d12 650#endif
50581042 651
8acd14d1 652#endif // _WX_GRAPHICS_H_