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