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