]>
Commit | Line | Data |
---|---|---|
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 | ||
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_FWD_CORE wxWindowDC; | |
23 | class WXDLLIMPEXP_FWD_CORE wxMemoryDC; | |
24 | class WXDLLIMPEXP_FWD_CORE wxGraphicsContext; | |
25 | class WXDLLIMPEXP_FWD_CORE wxGraphicsPath; | |
26 | class WXDLLIMPEXP_FWD_CORE wxGraphicsMatrix; | |
27 | class WXDLLIMPEXP_FWD_CORE wxGraphicsFigure; | |
28 | class WXDLLIMPEXP_FWD_CORE wxGraphicsRenderer; | |
29 | class WXDLLIMPEXP_FWD_CORE wxGraphicsPen; | |
30 | class WXDLLIMPEXP_FWD_CORE wxGraphicsBrush; | |
31 | class WXDLLIMPEXP_FWD_CORE wxGraphicsFont; | |
32 | class WXDLLIMPEXP_FWD_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_FWD_CORE wxGraphicsObjectRefData; | |
52 | class WXDLLIMPEXP_FWD_CORE wxGraphicsMatrixData; | |
53 | class WXDLLIMPEXP_FWD_CORE wxGraphicsPathData; | |
54 | ||
55 | class WXDLLIMPEXP_CORE wxGraphicsObject : public wxObject | |
56 | { | |
57 | public : | |
58 | wxGraphicsObject() ; | |
59 | wxGraphicsObject( wxGraphicsRenderer* renderer ) ; | |
60 | virtual ~wxGraphicsObject() ; | |
61 | ||
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 ; | |
67 | protected : | |
68 | virtual wxObjectRefData* CreateRefData() const; | |
69 | virtual wxObjectRefData* CloneRefData(const wxObjectRefData* data) const; | |
70 | ||
71 | DECLARE_DYNAMIC_CLASS(wxGraphicsObject) | |
72 | } ; | |
73 | ||
74 | class WXDLLIMPEXP_CORE wxGraphicsPen : public wxGraphicsObject | |
75 | { | |
76 | public : | |
77 | wxGraphicsPen() {} | |
78 | virtual ~wxGraphicsPen() {} | |
79 | private : | |
80 | DECLARE_DYNAMIC_CLASS(wxGraphicsPen) | |
81 | } ; | |
82 | ||
83 | extern WXDLLIMPEXP_DATA_CORE(wxGraphicsPen) wxNullGraphicsPen; | |
84 | ||
85 | class WXDLLIMPEXP_CORE wxGraphicsBrush : public wxGraphicsObject | |
86 | { | |
87 | public : | |
88 | wxGraphicsBrush() {} | |
89 | virtual ~wxGraphicsBrush() {} | |
90 | private : | |
91 | DECLARE_DYNAMIC_CLASS(wxGraphicsBrush) | |
92 | } ; | |
93 | ||
94 | extern WXDLLIMPEXP_DATA_CORE(wxGraphicsBrush) wxNullGraphicsBrush; | |
95 | ||
96 | class WXDLLIMPEXP_CORE wxGraphicsFont : public wxGraphicsObject | |
97 | { | |
98 | public : | |
99 | wxGraphicsFont() {} | |
100 | virtual ~wxGraphicsFont() {} | |
101 | private : | |
102 | DECLARE_DYNAMIC_CLASS(wxGraphicsFont) | |
103 | } ; | |
104 | ||
105 | extern WXDLLIMPEXP_DATA_CORE(wxGraphicsFont) wxNullGraphicsFont; | |
106 | ||
107 | class WXDLLIMPEXP_CORE wxGraphicsBitmap : public wxGraphicsObject | |
108 | { | |
109 | public : | |
110 | wxGraphicsBitmap() {} | |
111 | virtual ~wxGraphicsBitmap() {} | |
112 | private : | |
113 | DECLARE_DYNAMIC_CLASS(wxGraphicsBitmap) | |
114 | } ; | |
115 | ||
116 | extern WXDLLIMPEXP_DATA_CORE(wxGraphicsBitmap) wxNullGraphicsBitmap; | |
117 | ||
118 | class WXDLLIMPEXP_CORE wxGraphicsMatrix : public wxGraphicsObject | |
119 | { | |
120 | public : | |
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 | ||
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 | ||
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 | ||
178 | private : | |
179 | DECLARE_DYNAMIC_CLASS(wxGraphicsMatrix) | |
180 | } ; | |
181 | ||
182 | extern WXDLLIMPEXP_DATA_CORE(wxGraphicsMatrix) wxNullGraphicsMatrix; | |
183 | ||
184 | class WXDLLIMPEXP_CORE wxGraphicsPath : public wxGraphicsObject | |
185 | { | |
186 | public : | |
187 | wxGraphicsPath() {} | |
188 | virtual ~wxGraphicsPath() {} | |
189 | ||
190 | // | |
191 | // These are the path primitives from which everything else can be constructed | |
192 | // | |
193 | ||
194 | // begins a new subpath at (x,y) | |
195 | virtual void MoveToPoint( wxDouble x, wxDouble y ); | |
196 | void MoveToPoint( const wxPoint2DDouble& p); | |
197 | ||
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); | |
201 | ||
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); | |
205 | ||
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 | ||
220 | // | |
221 | // These are convenience functions which - if not available natively will be assembled | |
222 | // using the primitives from above | |
223 | // | |
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 ) ; | |
236 | ||
237 | // appends an ellipse | |
238 | virtual void AddEllipse( wxDouble x, wxDouble y, wxDouble w, wxDouble h); | |
239 | ||
240 | // appends a rounded rectangle | |
241 | virtual void AddRoundedRectangle( wxDouble x, wxDouble y, wxDouble w, wxDouble h, wxDouble radius); | |
242 | ||
243 | // returns the native path | |
244 | virtual void * GetNativePath() const; | |
245 | ||
246 | // give the native path returned by GetNativePath() back (there might be some deallocations necessary) | |
247 | virtual void UnGetNativePath(void *p)const; | |
248 | ||
249 | // transforms each point of this path by the matrix | |
250 | virtual void Transform( const wxGraphicsMatrix& matrix ); | |
251 | ||
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; | |
255 | ||
256 | virtual bool Contains( wxDouble x, wxDouble y, int fillStyle = wxODDEVEN_RULE)const; | |
257 | bool Contains( const wxPoint2DDouble& c, int fillStyle = wxODDEVEN_RULE)const; | |
258 | ||
259 | const wxGraphicsPathData* GetPathData() const | |
260 | { return (const wxGraphicsPathData*) GetRefData(); } | |
261 | wxGraphicsPathData* GetPathData() | |
262 | { return (wxGraphicsPathData*) GetRefData(); } | |
263 | ||
264 | private : | |
265 | DECLARE_DYNAMIC_CLASS(wxGraphicsPath) | |
266 | } ; | |
267 | ||
268 | extern WXDLLIMPEXP_DATA_CORE(wxGraphicsPath) wxNullGraphicsPath; | |
269 | ||
270 | ||
271 | class WXDLLIMPEXP_CORE wxGraphicsContext : public wxGraphicsObject | |
272 | { | |
273 | public: | |
274 | wxGraphicsContext(wxGraphicsRenderer* renderer); | |
275 | ||
276 | virtual ~wxGraphicsContext(); | |
277 | ||
278 | static wxGraphicsContext* Create( const wxWindowDC& dc) ; | |
279 | static wxGraphicsContext * Create( const wxMemoryDC& dc) ; | |
280 | ||
281 | static wxGraphicsContext* CreateFromNative( void * context ) ; | |
282 | ||
283 | static wxGraphicsContext* CreateFromNativeWindow( void * window ) ; | |
284 | ||
285 | static wxGraphicsContext* Create( wxWindow* window ) ; | |
286 | ||
287 | // create a context that can be used for measuring texts only, no drawing allowed | |
288 | static wxGraphicsContext * Create(); | |
289 | ||
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 | ||
306 | wxGraphicsPath CreatePath() const; | |
307 | ||
308 | virtual wxGraphicsPen CreatePen(const wxPen& pen) const; | |
309 | ||
310 | virtual wxGraphicsBrush CreateBrush(const wxBrush& brush ) const; | |
311 | ||
312 | // sets the brush to a linear gradient, starting at (x1,y1) with color c1 to (x2,y2) with color c2 | |
313 | virtual wxGraphicsBrush CreateLinearGradientBrush( wxDouble x1, wxDouble y1, wxDouble x2, wxDouble y2, | |
314 | const wxColour&c1, const wxColour&c2) const; | |
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 | |
318 | virtual wxGraphicsBrush CreateRadialGradientBrush( wxDouble xo, wxDouble yo, wxDouble xc, wxDouble yc, wxDouble radius, | |
319 | const wxColour &oColor, const wxColour &cColor) const; | |
320 | ||
321 | // sets the font | |
322 | virtual wxGraphicsFont CreateFont( const wxFont &font , const wxColour &col = *wxBLACK ) const; | |
323 | ||
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 | ||
330 | // create a 'native' matrix corresponding to these values | |
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; | |
333 | ||
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 | ||
340 | // clips drawings to the region intersected with the current clipping region | |
341 | virtual void Clip( const wxRegion ®ion ) = 0; | |
342 | ||
343 | // clips drawings to the rect intersected with the current clipping region | |
344 | virtual void Clip( wxDouble x, wxDouble y, wxDouble w, wxDouble h ) = 0; | |
345 | ||
346 | // resets the clipping to original extent | |
347 | virtual void ResetClip() = 0 ; | |
348 | ||
349 | // returns the native context | |
350 | virtual void * GetNativeContext() = 0; | |
351 | ||
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 | ||
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 | |
371 | // | |
372 | // transformation : changes the current transformation matrix CTM of the context | |
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; | |
383 | ||
384 | // concatenates this transform with the current transform of this context | |
385 | virtual void ConcatTransform( const wxGraphicsMatrix& matrix ) = 0; | |
386 | ||
387 | // sets the transform of this context | |
388 | virtual void SetTransform( const wxGraphicsMatrix& matrix ) = 0; | |
389 | ||
390 | // gets the matrix of this context | |
391 | virtual wxGraphicsMatrix GetTransform() const = 0; | |
392 | // | |
393 | // setting the paint | |
394 | // | |
395 | ||
396 | // sets the pen | |
397 | virtual void SetPen( const wxGraphicsPen& pen ); | |
398 | ||
399 | void SetPen( const wxPen& pen ); | |
400 | ||
401 | // sets the brush for filling | |
402 | virtual void SetBrush( const wxGraphicsBrush& brush ); | |
403 | ||
404 | void SetBrush( const wxBrush& brush ); | |
405 | ||
406 | // sets the font | |
407 | virtual void SetFont( const wxGraphicsFont& font ); | |
408 | ||
409 | void SetFont( const wxFont& font, const wxColour& colour ); | |
410 | ||
411 | ||
412 | // strokes along a path with the current pen | |
413 | virtual void StrokePath( const wxGraphicsPath& path ) = 0; | |
414 | ||
415 | // fills a path with the current brush | |
416 | virtual void FillPath( const wxGraphicsPath& path, int fillStyle = wxODDEVEN_RULE ) = 0; | |
417 | ||
418 | // draws a path by first filling and then stroking | |
419 | virtual void DrawPath( const wxGraphicsPath& path, int fillStyle = wxODDEVEN_RULE ); | |
420 | ||
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 | ||
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 | ||
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 | ||
442 | virtual void DrawBitmap( const wxGraphicsBitmap &bmp, wxDouble x, wxDouble y, wxDouble w, wxDouble h ) = 0; | |
443 | ||
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 | |
462 | virtual void DrawLines( size_t n, const wxPoint2DDouble *points, int fillStyle = wxODDEVEN_RULE ); | |
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 | ||
473 | // wrappers using wxPoint2DDouble TODO | |
474 | ||
475 | // helper to determine if a 0.5 offset should be applied for the drawing operation | |
476 | virtual bool ShouldOffset() const { return false; } | |
477 | ||
478 | protected : | |
479 | ||
480 | wxGraphicsPen m_pen; | |
481 | wxGraphicsBrush m_brush; | |
482 | wxGraphicsFont m_font; | |
483 | int m_logicalFunction; | |
484 | ||
485 | private : | |
486 | DECLARE_NO_COPY_CLASS(wxGraphicsContext) | |
487 | DECLARE_ABSTRACT_CLASS(wxGraphicsContext) | |
488 | }; | |
489 | ||
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 | ||
496 | class WXDLLIMPEXP_CORE wxGraphicsFigure : public wxGraphicsObject | |
497 | { | |
498 | public : | |
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 | ||
516 | private : | |
517 | wxGraphicsMatrix* m_matrix; | |
518 | wxGraphicsPath* m_path; | |
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 | ||
531 | class WXDLLIMPEXP_CORE wxGraphicsRenderer : public wxObject | |
532 | { | |
533 | public : | |
534 | wxGraphicsRenderer() {} | |
535 | ||
536 | virtual ~wxGraphicsRenderer() {} | |
537 | ||
538 | static wxGraphicsRenderer* GetDefaultRenderer(); | |
539 | ||
540 | // Context | |
541 | ||
542 | virtual wxGraphicsContext * CreateContext( const wxWindowDC& dc) = 0 ; | |
543 | virtual wxGraphicsContext * CreateContext( const wxMemoryDC& dc) = 0 ; | |
544 | ||
545 | virtual wxGraphicsContext * CreateContextFromNativeContext( void * context ) = 0; | |
546 | ||
547 | virtual wxGraphicsContext * CreateContextFromNativeWindow( void * window ) = 0; | |
548 | ||
549 | virtual wxGraphicsContext * CreateContext( wxWindow* window ) = 0; | |
550 | ||
551 | // create a context that can be used for measuring texts only, no drawing allowed | |
552 | virtual wxGraphicsContext * CreateMeasuringContext() = 0; | |
553 | ||
554 | // Path | |
555 | ||
556 | virtual wxGraphicsPath CreatePath() = 0; | |
557 | ||
558 | // Matrix | |
559 | ||
560 | virtual wxGraphicsMatrix CreateMatrix( wxDouble a=1.0, wxDouble b=0.0, wxDouble c=0.0, wxDouble d=1.0, | |
561 | wxDouble tx=0.0, wxDouble ty=0.0) = 0; | |
562 | ||
563 | // Paints | |
564 | ||
565 | virtual wxGraphicsPen CreatePen(const wxPen& pen) = 0 ; | |
566 | ||
567 | virtual wxGraphicsBrush CreateBrush(const wxBrush& brush ) = 0 ; | |
568 | ||
569 | // sets the brush to a linear gradient, starting at (x1,y1) with color c1 to (x2,y2) with color c2 | |
570 | virtual wxGraphicsBrush CreateLinearGradientBrush( wxDouble x1, wxDouble y1, wxDouble x2, wxDouble y2, | |
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 | |
575 | virtual wxGraphicsBrush CreateRadialGradientBrush( wxDouble xo, wxDouble yo, wxDouble xc, wxDouble yc, wxDouble radius, | |
576 | const wxColour &oColor, const wxColour &cColor) = 0; | |
577 | ||
578 | // sets the font | |
579 | virtual wxGraphicsFont CreateFont( const wxFont &font , const wxColour &col = *wxBLACK ) = 0; | |
580 | ||
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; | |
586 | private : | |
587 | DECLARE_NO_COPY_CLASS(wxGraphicsRenderer) | |
588 | DECLARE_ABSTRACT_CLASS(wxGraphicsRenderer) | |
589 | } ; | |
590 | ||
591 | #endif | |
592 | ||
593 | #endif // _WX_GRAPHICS_H_ |