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