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