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