/[pcsx2_0.9.7]/trunk/3rdparty/wxWidgets/include/wx/graphics.h
ViewVC logotype

Contents of /trunk/3rdparty/wxWidgets/include/wx/graphics.h

Parent Directory Parent Directory | Revision Log Revision Log


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

  ViewVC Help
Powered by ViewVC 1.1.22