]>
Commit | Line | Data |
---|---|---|
23324ae1 FM |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: graphics.h | |
e54c96f1 | 3 | // Purpose: interface of wxGraphicsPath |
23324ae1 FM |
4 | // Author: wxWidgets team |
5 | // RCS-ID: $Id$ | |
6 | // Licence: wxWindows license | |
7 | ///////////////////////////////////////////////////////////////////////////// | |
8 | ||
9 | /** | |
10 | @class wxGraphicsPath | |
7c913512 | 11 | |
23324ae1 | 12 | A wxGraphicsPath is a native representation of an geometric path. The contents |
7c913512 | 13 | are specific an private to the respective renderer. Instances are ref counted and can |
68a514e7 SC |
14 | therefore be assigned as usual. The only way to get a valid instance is via |
15 | wxGraphicsContext::CreatePath or wxGraphicsRenderer::CreatePath. | |
7c913512 | 16 | |
23324ae1 FM |
17 | @library{wxcore} |
18 | @category{FIXME} | |
19 | */ | |
20 | class wxGraphicsPath : public wxGraphicsObject | |
21 | { | |
22 | public: | |
23 | //@{ | |
24 | /** | |
3c4f71cc | 25 | |
23324ae1 FM |
26 | */ |
27 | void AddArc(wxDouble x, wxDouble y, wxDouble r, | |
28 | wxDouble startAngle, | |
29 | wxDouble endAngle, bool clockwise); | |
7c913512 FM |
30 | void AddArc(const wxPoint2DDouble& c, wxDouble r, |
31 | wxDouble startAngle, | |
32 | wxDouble endAngle, | |
33 | bool clockwise); | |
23324ae1 FM |
34 | //@} |
35 | ||
36 | /** | |
37 | Appends a an arc to two tangents connecting (current) to (x1,y1) and (x1,y1) to | |
38 | (x2,y2), also a straight line from (current) to (x1,y1). | |
39 | */ | |
da1ed74c FM |
40 | virtual void AddArcToPoint(wxDouble x1, wxDouble y1, wxDouble x2, |
41 | wxDouble y2, wxDouble r); | |
23324ae1 FM |
42 | |
43 | /** | |
44 | Appends a circle around (x,y) with radius r as a new closed subpath. | |
45 | */ | |
da1ed74c | 46 | virtual void AddCircle(wxDouble x, wxDouble y, wxDouble r); |
23324ae1 FM |
47 | |
48 | //@{ | |
49 | /** | |
3c4f71cc | 50 | |
23324ae1 FM |
51 | */ |
52 | void AddCurveToPoint(wxDouble cx1, wxDouble cy1, wxDouble cx2, | |
53 | wxDouble cy2, | |
54 | wxDouble x, | |
55 | wxDouble y); | |
7c913512 FM |
56 | void AddCurveToPoint(const wxPoint2DDouble& c1, |
57 | const wxPoint2DDouble& c2, | |
58 | const wxPoint2DDouble& e); | |
23324ae1 FM |
59 | //@} |
60 | ||
61 | /** | |
62 | Appends an ellipse fitting into the passed in rectangle. | |
63 | */ | |
da1ed74c | 64 | virtual void AddEllipse(wxDouble x, wxDouble y, wxDouble w, wxDouble h); |
23324ae1 FM |
65 | |
66 | //@{ | |
67 | /** | |
3c4f71cc | 68 | |
23324ae1 FM |
69 | */ |
70 | void AddLineToPoint(wxDouble x, wxDouble y); | |
7c913512 | 71 | void AddLineToPoint(const wxPoint2DDouble& p); |
23324ae1 FM |
72 | //@} |
73 | ||
74 | /** | |
75 | Adds another path. | |
76 | */ | |
da1ed74c | 77 | virtual void AddPath(const wxGraphicsPath& path); |
23324ae1 FM |
78 | |
79 | /** | |
80 | Adds a quadratic Bezier curve from the current point, using a control point and | |
81 | an end point. | |
82 | */ | |
83 | void AddQuadCurveToPoint(wxDouble cx, wxDouble cy, wxDouble x, | |
84 | wxDouble y); | |
85 | ||
86 | /** | |
87 | Appends a rectangle as a new closed subpath. | |
88 | */ | |
da1ed74c | 89 | virtual void AddRectangle(wxDouble x, wxDouble y, wxDouble w, wxDouble h); |
23324ae1 FM |
90 | |
91 | /** | |
92 | Appends a rounded rectangle as a new closed subpath. | |
93 | */ | |
da1ed74c FM |
94 | virtual void AddRoundedRectangle(wxDouble x, wxDouble y, wxDouble w, |
95 | wxDouble h, wxDouble radius); | |
23324ae1 FM |
96 | |
97 | /** | |
98 | Closes the current sub-path. | |
99 | */ | |
da1ed74c | 100 | virtual void CloseSubpath(); |
23324ae1 FM |
101 | |
102 | //@{ | |
103 | /** | |
104 | Returns @true if the point is within the path. | |
105 | */ | |
106 | bool Contains(const wxPoint2DDouble& c, | |
328f5751 FM |
107 | int fillStyle = wxODDEVEN_RULE) const; |
108 | const bool Contains(wxDouble x, wxDouble y, | |
109 | int fillStyle = wxODDEVEN_RULE) const; | |
23324ae1 FM |
110 | //@} |
111 | ||
112 | //@{ | |
113 | /** | |
114 | Gets the bounding box enclosing all points (possibly including control points). | |
115 | */ | |
328f5751 FM |
116 | wxRect2DDouble GetBox() const; |
117 | const void GetBox(wxDouble* x, wxDouble* y, wxDouble* w, | |
118 | wxDouble* h) const; | |
23324ae1 FM |
119 | //@} |
120 | ||
121 | //@{ | |
122 | /** | |
123 | Gets the last point of the current path, (0,0) if not yet set. | |
124 | */ | |
328f5751 FM |
125 | void GetCurrentPoint(wxDouble* x, wxDouble* y) const; |
126 | const wxPoint2DDouble GetCurrentPoint() const; | |
23324ae1 FM |
127 | //@} |
128 | ||
129 | /** | |
130 | Returns the native path (CGPathRef for Core Graphics, Path pointer for GDIPlus | |
131 | and a cairo_path_t pointer for cairo). | |
132 | */ | |
da1ed74c | 133 | virtual void* GetNativePath() const; |
23324ae1 FM |
134 | |
135 | //@{ | |
136 | /** | |
137 | Begins a new subpath at (x,y) | |
138 | */ | |
139 | void MoveToPoint(wxDouble x, wxDouble y); | |
7c913512 | 140 | void MoveToPoint(const wxPoint2DDouble& p); |
23324ae1 FM |
141 | //@} |
142 | ||
143 | /** | |
144 | Transforms each point of this path by the matrix. | |
145 | */ | |
da1ed74c | 146 | virtual void Transform(const wxGraphicsMatrix& matrix); |
23324ae1 FM |
147 | |
148 | /** | |
149 | Gives back the native path returned by GetNativePath() because there might be | |
7c913512 | 150 | some deallocations necessary (eg on cairo the native path returned by |
23324ae1 FM |
151 | GetNativePath is newly allocated each time). |
152 | */ | |
da1ed74c | 153 | virtual void UnGetNativePath(void* p) const; |
23324ae1 FM |
154 | }; |
155 | ||
156 | ||
e54c96f1 | 157 | |
23324ae1 FM |
158 | /** |
159 | @class wxGraphicsObject | |
7c913512 | 160 | |
23324ae1 FM |
161 | This class is the superclass of native graphics objects like pens etc. It |
162 | allows reference counting. Not instantiated by user code. | |
7c913512 | 163 | |
23324ae1 FM |
164 | @library{wxcore} |
165 | @category{FIXME} | |
7c913512 | 166 | |
e54c96f1 | 167 | @see wxGraphicsBrush, wxGraphicsPen, wxGraphicsMatrix, wxGraphicsPath |
23324ae1 FM |
168 | */ |
169 | class wxGraphicsObject : public wxObject | |
170 | { | |
171 | public: | |
172 | /** | |
173 | Returns the renderer that was used to create this instance, or @NULL if it has | |
174 | not been initialized yet | |
175 | */ | |
328f5751 | 176 | wxGraphicsRenderer* GetRenderer() const; |
23324ae1 FM |
177 | |
178 | /** | |
179 | Is this object valid (@false) or still empty (@true)? | |
180 | */ | |
328f5751 | 181 | bool IsNull() const; |
23324ae1 FM |
182 | }; |
183 | ||
184 | ||
e54c96f1 | 185 | |
23324ae1 FM |
186 | /** |
187 | @class wxGraphicsContext | |
7c913512 | 188 | |
23324ae1 | 189 | A wxGraphicsContext instance is the object that is drawn upon. It is created by |
0b822969 RR |
190 | a renderer using wxGraphicsRenderer::CreateContext(). This can be either directly |
191 | using a renderer instance, or indirectly using the static convenience Create() | |
192 | functions of wxGraphicsContext that always delegate the task to the default renderer. | |
7c913512 | 193 | |
d974a494 RR |
194 | @code |
195 | void MyCanvas::OnPaint(wxPaintEvent &event) | |
196 | { | |
197 | // Create paint DC | |
198 | wxPaintDC dc(this); | |
199 | ||
200 | // Create graphics context from it | |
ea077571 | 201 | wxGraphicsContext *gc = wxGraphicsContext::Create( dc ); |
d974a494 | 202 | |
7e38ae60 RR |
203 | if (gc) |
204 | { | |
0b822969 | 205 | // make a path that contains a circle and some lines |
7e38ae60 RR |
206 | gc->SetPen( *wxRED_PEN ); |
207 | wxGraphicsPath path = gc->CreatePath(); | |
208 | path.AddCircle( 50.0, 50.0, 50.0 ); | |
209 | path.MoveToPoint(0.0, 50.0); | |
210 | path.AddLineToPoint(100.0, 50.0); | |
211 | path.MoveToPoint(50.0, 0.0); | |
212 | path.AddLineToPoint(50.0, 100.0 ); | |
213 | path.CloseSubpath(); | |
214 | path.AddRectangle(25.0, 25.0, 50.0, 50.0); | |
d974a494 | 215 | |
ea077571 | 216 | gc->StrokePath(path); |
7e38ae60 | 217 | |
ea077571 | 218 | delete gc; |
7e38ae60 RR |
219 | } |
220 | } | |
d974a494 RR |
221 | @endcode |
222 | ||
223 | ||
23324ae1 FM |
224 | @library{wxcore} |
225 | @category{FIXME} | |
7c913512 | 226 | |
6d99a337 | 227 | @see wxGraphicsRenderer::CreateContext(), wxGCDC, wxDC |
23324ae1 FM |
228 | */ |
229 | class wxGraphicsContext : public wxGraphicsObject | |
230 | { | |
231 | public: | |
23324ae1 | 232 | /** |
0b822969 RR |
233 | Creates a wxGraphicsContext from a wxWindow. |
234 | ||
235 | @see wxGraphicsRenderer::CreateContext() | |
236 | */ | |
237 | static wxGraphicsContext* Create( wxWindow* window ) ; | |
238 | ||
239 | /** | |
240 | Creates a wxGraphicsContext from a wxWindowDC | |
241 | ||
242 | @see wxGraphicsRenderer::CreateContext() | |
243 | */ | |
244 | static wxGraphicsContext* Create( const wxWindowDC& dc) ; | |
245 | ||
246 | /** | |
247 | Creates a wxGraphicsContext from a wxMemoryDC | |
248 | ||
249 | @see wxGraphicsRenderer::CreateContext() | |
250 | */ | |
251 | static wxGraphicsContext * Create( const wxMemoryDC& dc) ; | |
252 | ||
253 | /** | |
19e496b6 RR |
254 | Creates a wxGraphicsContext from a wxPrinterDC. Under |
255 | GTK+, this will only work when using the GtkPrint | |
256 | printing backend which is available since GTK+ 2.10. | |
0b822969 | 257 | |
19e496b6 | 258 | @see wxGraphicsRenderer::CreateContext(), @ref overview_unixprinting "Printing under Unix" |
0b822969 RR |
259 | */ |
260 | static wxGraphicsContext * Create( const wxPrinterDC& dc) ; | |
261 | ||
262 | /** | |
263 | Clips drawings to the region | |
23324ae1 | 264 | */ |
da1ed74c | 265 | virtual void Clip(const wxRegion& region) = 0; |
0b822969 RR |
266 | |
267 | /** | |
268 | Clips drawings to the rectangle. | |
269 | */ | |
da1ed74c | 270 | virtual void Clip(wxDouble x, wxDouble y, wxDouble w, wxDouble h) = 0; |
23324ae1 FM |
271 | |
272 | /** | |
273 | Concatenates the passed in transform with the current transform of this context | |
274 | */ | |
da1ed74c | 275 | virtual void ConcatTransform(const wxGraphicsMatrix& matrix) = 0; |
23324ae1 | 276 | |
23324ae1 FM |
277 | |
278 | /** | |
279 | Creates a native brush from a wxBrush. | |
280 | */ | |
da1ed74c | 281 | virtual wxGraphicsBrush CreateBrush(const wxBrush& brush) const; |
23324ae1 FM |
282 | |
283 | /** | |
284 | Creates a native graphics font from a wxFont and a text colour. | |
285 | */ | |
286 | wxGraphicsFont CreateFont(const wxFont& font, | |
328f5751 | 287 | const wxColour& col = wxBLACK) const; |
23324ae1 FM |
288 | |
289 | /** | |
290 | Creates a wxGraphicsContext from a native context. This native context must be | |
7c913512 | 291 | eg a CGContextRef for Core Graphics, a Graphics pointer for GDIPlus or a |
23324ae1 | 292 | cairo_t pointer for cairo. |
3c4f71cc | 293 | |
4cc4bfaf | 294 | @see wxGraphicsRenderer:: CreateContextFromNativeContext |
23324ae1 | 295 | */ |
da1ed74c | 296 | static wxGraphicsContext* CreateFromNative(void* context); |
23324ae1 FM |
297 | |
298 | /** | |
19e496b6 RR |
299 | Creates a wxGraphicsContext from a native window. |
300 | ||
4cc4bfaf | 301 | @see wxGraphicsRenderer:: CreateContextFromNativeWindow |
23324ae1 | 302 | */ |
da1ed74c | 303 | static wxGraphicsContext* CreateFromNativeWindow(void* window); |
23324ae1 FM |
304 | |
305 | /** | |
306 | Creates a native brush, having a linear gradient, starting at (x1,y1) with | |
307 | color c1 to (x2,y2) with color c2 | |
308 | */ | |
309 | wxGraphicsBrush CreateLinearGradientBrush(wxDouble x1, | |
7c913512 FM |
310 | wxDouble y1, |
311 | wxDouble x2, | |
312 | wxDouble y2, | |
313 | const wxColouramp;c1, | |
328f5751 | 314 | const wxColouramp;c2) const; |
23324ae1 FM |
315 | |
316 | /** | |
317 | Creates a native affine transformation matrix from the passed in values. The | |
318 | defaults result in an identity matrix. | |
319 | */ | |
320 | wxGraphicsMatrix CreateMatrix(wxDouble a = 1.0, wxDouble b = 0.0, | |
321 | wxDouble c = 0.0, | |
322 | wxDouble d = 1.0, | |
323 | wxDouble tx = 0.0, | |
328f5751 | 324 | wxDouble ty = 0.0) const; |
23324ae1 FM |
325 | |
326 | /** | |
327 | Creates a native graphics path which is initially empty. | |
328 | */ | |
328f5751 | 329 | wxGraphicsPath CreatePath() const; |
23324ae1 FM |
330 | |
331 | /** | |
332 | Creates a native pen from a wxPen. | |
333 | */ | |
da1ed74c | 334 | virtual wxGraphicsPen CreatePen(const wxPen& pen) const; |
23324ae1 FM |
335 | |
336 | /** | |
337 | Creates a native brush, having a radial gradient originating at (xo,yc) with | |
338 | color oColour and ends on a circle around (xc,yc) with radius r and color cColour | |
339 | */ | |
da1ed74c FM |
340 | virtual wxGraphicsBrush CreateRadialGradientBrush(wxDouble xo, wxDouble yo, |
341 | wxDouble xc, wxDouble yc, | |
342 | wxDouble radius, | |
343 | const wxColour& oColor, | |
344 | const wxColour& cColor) const; | |
23324ae1 FM |
345 | |
346 | /** | |
347 | Draws the bitmap. In case of a mono bitmap, this is treated as a mask and the | |
348 | current brushed is used for filling. | |
349 | */ | |
350 | void DrawBitmap(const wxBitmap& bmp, wxDouble x, wxDouble y, | |
351 | wxDouble w, wxDouble h); | |
352 | ||
353 | /** | |
354 | Draws an ellipse. | |
355 | */ | |
da1ed74c | 356 | virtual void DrawEllipse(wxDouble x, wxDouble y, wxDouble w, wxDouble h); |
23324ae1 FM |
357 | |
358 | /** | |
359 | Draws the icon. | |
360 | */ | |
361 | void DrawIcon(const wxIcon& icon, wxDouble x, wxDouble y, | |
362 | wxDouble w, wxDouble h); | |
363 | ||
364 | /** | |
365 | Draws a polygon. | |
366 | */ | |
367 | void DrawLines(size_t n, const wxPoint2DDouble* points, | |
368 | int fillStyle = wxODDEVEN_RULE); | |
369 | ||
370 | /** | |
371 | Draws the path by first filling and then stroking. | |
372 | */ | |
373 | void DrawPath(const wxGraphicsPath& path, | |
374 | int fillStyle = wxODDEVEN_RULE); | |
375 | ||
376 | /** | |
377 | Draws a rectangle. | |
378 | */ | |
379 | void DrawRectangle(wxDouble x, wxDouble y, wxDouble w, | |
380 | wxDouble h); | |
381 | ||
382 | /** | |
383 | Draws a rounded rectangle. | |
384 | */ | |
da1ed74c FM |
385 | virtual void DrawRoundedRectangle(wxDouble x, wxDouble y, wxDouble w, |
386 | wxDouble h, wxDouble radius); | |
23324ae1 FM |
387 | |
388 | //@{ | |
389 | /** | |
390 | Draws a text at the defined position, at the given angle. | |
391 | */ | |
392 | void DrawText(const wxString& str, wxDouble x, wxDouble y, | |
393 | wxDouble angle); | |
7c913512 | 394 | void DrawText(const wxString& str, wxDouble x, wxDouble y); |
23324ae1 FM |
395 | //@} |
396 | ||
397 | /** | |
398 | Fills the path with the current brush. | |
399 | */ | |
400 | void FillPath(const wxGraphicsPath& path, | |
401 | int fillStyle = wxODDEVEN_RULE); | |
402 | ||
403 | /** | |
404 | Returns the native context (CGContextRef for Core Graphics, Graphics pointer | |
405 | for GDIPlus and cairo_t pointer for cairo). | |
406 | */ | |
da1ed74c | 407 | virtual void* GetNativeContext() = 0; |
23324ae1 FM |
408 | |
409 | /** | |
4cc4bfaf FM |
410 | Fills the @a widths array with the widths from the beginning of |
411 | @a text to the corresponding character of @e text. | |
23324ae1 FM |
412 | */ |
413 | void GetPartialTextExtents(const wxString& text, | |
328f5751 | 414 | wxArrayDouble& widths) const; |
23324ae1 FM |
415 | |
416 | /** | |
417 | Gets the dimensions of the string using the currently selected font. | |
418 | @e string is the text string to measure, @e w and @e h are | |
4cc4bfaf | 419 | the total width and height respectively, @a descent is the |
23324ae1 | 420 | dimension from the baseline of the font to the bottom of the |
4cc4bfaf | 421 | descender, and @a externalLeading is any extra vertical space added |
23324ae1 FM |
422 | to the font by the font designer (usually is zero). |
423 | */ | |
da1ed74c FM |
424 | virtual void GetTextExtent(const wxString& text, wxDouble* width, |
425 | wxDouble* height, wxDouble* descent, | |
426 | wxDouble* externalLeading) const = 0; | |
23324ae1 FM |
427 | |
428 | /** | |
429 | Gets the current transformation matrix of this context. | |
430 | */ | |
da1ed74c | 431 | virtual wxGraphicsMatrix GetTransform() const = 0; |
23324ae1 FM |
432 | |
433 | /** | |
434 | Resets the clipping to original shape. | |
435 | */ | |
da1ed74c | 436 | virtual void ResetClip() = 0; |
23324ae1 FM |
437 | |
438 | /** | |
439 | Rotates the current transformation matrix (radians), | |
440 | */ | |
da1ed74c | 441 | virtual void Rotate(wxDouble angle) = 0; |
23324ae1 FM |
442 | |
443 | /** | |
444 | Scales the current transformation matrix. | |
445 | */ | |
da1ed74c | 446 | virtual void Scale(wxDouble xScale, wxDouble yScale) = 0; |
23324ae1 FM |
447 | |
448 | //@{ | |
449 | /** | |
450 | Sets the brush for filling paths. | |
451 | */ | |
452 | void SetBrush(const wxBrush& brush); | |
7c913512 | 453 | void SetBrush(const wxGraphicsBrush& brush); |
23324ae1 FM |
454 | //@} |
455 | ||
456 | //@{ | |
457 | /** | |
458 | Sets the font for drawing text. | |
459 | */ | |
460 | void SetFont(const wxFont& font, const wxColour& colour); | |
7c913512 | 461 | void SetFont(const wxGraphicsFont& font); |
23324ae1 FM |
462 | //@} |
463 | ||
464 | //@{ | |
465 | /** | |
466 | Sets the pen used for stroking. | |
467 | */ | |
468 | void SetPen(const wxGraphicsPen& pen); | |
7c913512 | 469 | void SetPen(const wxPen& pen); |
23324ae1 FM |
470 | //@} |
471 | ||
472 | /** | |
473 | Sets the current transformation matrix of this context | |
474 | */ | |
da1ed74c | 475 | virtual void SetTransform(const wxGraphicsMatrix& matrix) = 0; |
23324ae1 FM |
476 | |
477 | /** | |
478 | Strokes a single line. | |
479 | */ | |
480 | void StrokeLine(wxDouble x1, wxDouble y1, wxDouble x2, | |
481 | wxDouble y2); | |
482 | ||
483 | //@{ | |
484 | /** | |
485 | Stroke disconnected lines from begin to end points, fastest method available | |
486 | for this purpose. | |
487 | */ | |
488 | void StrokeLines(size_t n, const wxPoint2DDouble* beginPoints, | |
489 | const wxPoint2DDouble* endPoints); | |
7c913512 | 490 | void StrokeLines(size_t n, const wxPoint2DDouble* points); |
23324ae1 FM |
491 | //@} |
492 | ||
493 | /** | |
494 | Strokes along a path with the current pen. | |
495 | */ | |
da1ed74c | 496 | virtual void StrokePath(const wxGraphicsPath& path) = 0; |
23324ae1 FM |
497 | |
498 | /** | |
499 | Translates the current transformation matrix. | |
500 | */ | |
da1ed74c | 501 | virtual void Translate(wxDouble dx, wxDouble dy) = 0; |
23324ae1 FM |
502 | }; |
503 | ||
504 | ||
e54c96f1 | 505 | |
23324ae1 FM |
506 | /** |
507 | @class wxGraphicsRenderer | |
7c913512 | 508 | |
23324ae1 | 509 | A wxGraphicsRenderer is the instance corresponding to the rendering engine |
ea077571 RR |
510 | used. There may be multiple instances on a system, if there are different |
511 | rendering engines present, but there is always only one instance per engine. | |
512 | This instance is pointed back to by all objects created by it (wxGraphicsContext, | |
513 | wxGraphicsPath etc) and can be retrieved through their wxGraphicsObject::GetRenderer() | |
514 | method. Therefore you can create an additional instance of a path etc. by calling | |
515 | wxGraphicsObject::GetRenderer() and then using the appropriate CreateXXX function | |
516 | of that renderer. | |
517 | ||
518 | @code | |
519 | wxGraphicsPath *path = // from somewhere | |
520 | wxGraphicsBrush *brush = path->GetRenderer()->CreateBrush( *wxBLACK_BRUSH ); | |
521 | @endcode | |
7c913512 | 522 | |
23324ae1 FM |
523 | @library{wxcore} |
524 | @category{FIXME} | |
525 | */ | |
526 | class wxGraphicsRenderer : public wxObject | |
527 | { | |
528 | public: | |
529 | /** | |
ea077571 | 530 | Creates a wxGraphicsContext from a wxWindow. |
23324ae1 | 531 | */ |
ea077571 RR |
532 | virtual wxGraphicsContext* CreateContext(wxWindow* window) = 0; |
533 | ||
534 | /** | |
535 | Creates a wxGraphicsContext from a wxWindowDC | |
536 | */ | |
537 | virtual wxGraphicsContext * CreateContext( const wxWindowDC& dc) = 0 ; | |
538 | ||
539 | /** | |
540 | Creates a wxGraphicsContext from a wxMemoryDC | |
541 | */ | |
542 | virtual wxGraphicsContext * CreateContext( const wxMemoryDC& dc) = 0 ; | |
543 | ||
544 | /** | |
545 | Creates a wxGraphicsContext from a wxPrinterDC | |
546 | */ | |
547 | virtual wxGraphicsContext * CreateContext( const wxPrinterDC& dc) = 0 ; | |
23324ae1 | 548 | |
23324ae1 | 549 | /** |
ea077571 | 550 | Creates a native brush from a wxBrush. |
23324ae1 | 551 | */ |
da1ed74c | 552 | virtual wxGraphicsBrush CreateBrush(const wxBrush& brush) = 0; |
ea077571 | 553 | |
23324ae1 FM |
554 | |
555 | /** | |
556 | Creates a wxGraphicsContext from a native context. This native context must be | |
ea077571 RR |
557 | eg a CGContextRef for Core Graphics, a Graphics pointer for GDIPlus or a cairo_t |
558 | pointer for cairo. | |
23324ae1 | 559 | */ |
da1ed74c | 560 | virtual wxGraphicsContext* CreateContextFromNativeContext(void* context) = 0; |
23324ae1 FM |
561 | |
562 | /** | |
563 | Creates a wxGraphicsContext from a native window. | |
564 | */ | |
da1ed74c | 565 | virtual wxGraphicsContext* CreateContextFromNativeWindow(void* window) = 0; |
23324ae1 FM |
566 | |
567 | /** | |
568 | Creates a native graphics font from a wxFont and a text colour. | |
569 | */ | |
570 | wxGraphicsFont CreateFont(const wxFont& font, | |
571 | const wxColour& col = wxBLACK); | |
572 | ||
573 | /** | |
574 | Creates a native brush, having a linear gradient, starting at (x1,y1) with | |
575 | color c1 to (x2,y2) with color c2 | |
576 | */ | |
577 | wxGraphicsBrush CreateLinearGradientBrush(wxDouble x1, | |
7c913512 FM |
578 | wxDouble y1, |
579 | wxDouble x2, | |
580 | wxDouble y2, | |
581 | const wxColouramp;c1, | |
582 | const wxColouramp;c2); | |
23324ae1 FM |
583 | |
584 | /** | |
585 | Creates a native affine transformation matrix from the passed in values. The | |
586 | defaults result in an identity matrix. | |
587 | */ | |
588 | wxGraphicsMatrix CreateMatrix(wxDouble a = 1.0, wxDouble b = 0.0, | |
589 | wxDouble c = 0.0, | |
590 | wxDouble d = 1.0, | |
591 | wxDouble tx = 0.0, | |
592 | wxDouble ty = 0.0); | |
593 | ||
594 | /** | |
595 | Creates a native graphics path which is initially empty. | |
596 | */ | |
da1ed74c | 597 | virtual wxGraphicsPath CreatePath() = 0; |
23324ae1 FM |
598 | |
599 | /** | |
600 | Creates a native pen from a wxPen. | |
601 | */ | |
da1ed74c | 602 | virtual wxGraphicsPen CreatePen(const wxPen& pen) = 0; |
23324ae1 FM |
603 | |
604 | /** | |
605 | Creates a native brush, having a radial gradient originating at (xo,yc) with | |
606 | color oColour and ends on a circle around (xc,yc) with radius r and color cColour | |
607 | */ | |
da1ed74c FM |
608 | virtual wxGraphicsBrush CreateRadialGradientBrush(wxDouble xo, wxDouble yo, |
609 | wxDouble xc, wxDouble yc, | |
610 | wxDouble radius, | |
611 | const wxColour& oColour, | |
612 | const wxColour& cColour) = 0; | |
23324ae1 FM |
613 | |
614 | /** | |
615 | Returns the default renderer on this platform. On OS X this is the Core | |
616 | Graphics (a.k.a. Quartz 2D) renderer, on MSW the GDIPlus renderer, and on GTK we currently default to the cairo renderer. | |
617 | */ | |
ea077571 | 618 | static wxGraphicsRenderer* GetDefaultRenderer(); |
23324ae1 FM |
619 | }; |
620 | ||
621 | ||
e54c96f1 | 622 | |
23324ae1 FM |
623 | /** |
624 | @class wxGraphicsBrush | |
7c913512 | 625 | |
68a514e7 SC |
626 | A wxGraphicsBrush is a native representation of a brush. The contents |
627 | are specific and private to the respective renderer. Instances are ref counted and can | |
628 | therefore be assigned as usual. The only way to get a valid instance is via | |
629 | wxGraphicsContext::CreateBrush or wxGraphicsRenderer::CreateBrush. | |
7c913512 | 630 | |
23324ae1 FM |
631 | @library{wxcore} |
632 | @category{FIXME} | |
633 | */ | |
634 | class wxGraphicsBrush : public wxGraphicsObject | |
635 | { | |
636 | public: | |
7c913512 | 637 | |
23324ae1 FM |
638 | }; |
639 | ||
640 | ||
e54c96f1 | 641 | |
23324ae1 FM |
642 | /** |
643 | @class wxGraphicsFont | |
7c913512 | 644 | |
68a514e7 SC |
645 | A wxGraphicsFont is a native representation of a font. The contents |
646 | are specific and private to the respective renderer. Instances are ref counted and can | |
647 | therefore be assigned as usual. The only way to get a valid instance is via | |
648 | wxGraphicsContext::CreateFont or wxGraphicsRenderer::CreateFont. | |
7c913512 | 649 | |
23324ae1 FM |
650 | @library{wxcore} |
651 | @category{FIXME} | |
652 | */ | |
653 | class wxGraphicsFont : public wxGraphicsObject | |
654 | { | |
655 | public: | |
7c913512 | 656 | |
23324ae1 FM |
657 | }; |
658 | ||
659 | ||
e54c96f1 | 660 | |
23324ae1 FM |
661 | /** |
662 | @class wxGraphicsPen | |
7c913512 | 663 | |
68a514e7 SC |
664 | A wxGraphicsPen is a native representation of a pen. The contents |
665 | are specific and private to the respective renderer. Instances are ref counted and can | |
666 | therefore be assigned as usual. The only way to get a valid instance is via | |
667 | wxGraphicsContext::CreatePen or wxGraphicsRenderer::CreatePen. | |
7c913512 | 668 | |
23324ae1 FM |
669 | @library{wxcore} |
670 | @category{FIXME} | |
671 | */ | |
672 | class wxGraphicsPen : public wxGraphicsObject | |
673 | { | |
674 | public: | |
7c913512 | 675 | |
23324ae1 FM |
676 | }; |
677 | ||
678 | ||
e54c96f1 | 679 | |
23324ae1 FM |
680 | /** |
681 | @class wxGraphicsMatrix | |
7c913512 | 682 | |
23324ae1 | 683 | A wxGraphicsMatrix is a native representation of an affine matrix. The contents |
68a514e7 SC |
684 | are specific and private to the respective renderer. Instances are ref counted and can |
685 | therefore be assigned as usual. The only way to get a valid instance is via | |
686 | wxGraphicsContext::CreateMatrix or wxGraphicsRenderer::CreateMatrix. | |
7c913512 | 687 | |
23324ae1 FM |
688 | @library{wxcore} |
689 | @category{FIXME} | |
690 | */ | |
691 | class wxGraphicsMatrix : public wxGraphicsObject | |
692 | { | |
693 | public: | |
694 | //@{ | |
695 | /** | |
3c4f71cc | 696 | |
23324ae1 FM |
697 | */ |
698 | void Concat(const wxGraphicsMatrix* t); | |
7c913512 | 699 | void Concat(const wxGraphicsMatrix& t); |
23324ae1 FM |
700 | //@} |
701 | ||
702 | /** | |
703 | Returns the component values of the matrix via the argument pointers. | |
704 | */ | |
da1ed74c FM |
705 | virtual void Get(wxDouble* a = NULL, wxDouble* b = NULL, wxDouble* c = NULL, |
706 | wxDouble* d = NULL, wxDouble* tx = NULL, | |
707 | wxDouble* ty = NULL) const; | |
23324ae1 FM |
708 | |
709 | /** | |
710 | Returns the native representation of the matrix. For CoreGraphics this is a | |
711 | CFAffineMatrix pointer. For GDIPlus a Matrix Pointer and for Cairo a cairo_matrix_t pointer. | |
712 | */ | |
da1ed74c | 713 | virtual void* GetNativeMatrix() const; |
23324ae1 FM |
714 | |
715 | /** | |
716 | Inverts the matrix. | |
717 | */ | |
da1ed74c | 718 | virtual void Invert(); |
23324ae1 FM |
719 | |
720 | /** | |
721 | Returns @true if the elements of the transformation matrix are equal. | |
722 | */ | |
328f5751 | 723 | bool IsEqual(const wxGraphicsMatrix& t) const; |
23324ae1 FM |
724 | |
725 | /** | |
726 | Return @true if this is the identity matrix. | |
727 | */ | |
da1ed74c | 728 | virtual bool IsIdentity() const; |
23324ae1 FM |
729 | |
730 | /** | |
731 | Rotates this matrix (radians). | |
732 | */ | |
da1ed74c | 733 | virtual void Rotate(wxDouble angle); |
23324ae1 FM |
734 | |
735 | /** | |
736 | Scales this matrix. | |
737 | */ | |
da1ed74c | 738 | virtual void Scale(wxDouble xScale, wxDouble yScale); |
23324ae1 FM |
739 | |
740 | /** | |
741 | Sets the matrix to the respective values (default values are the identity | |
742 | matrix) | |
743 | */ | |
4cc4bfaf FM |
744 | void Set(wxDouble a = 1.0, wxDouble b = 0.0, wxDouble c = 0.0, |
745 | wxDouble d = 1.0, wxDouble tx = 0.0, | |
746 | wxDouble ty = 0.0); | |
23324ae1 FM |
747 | |
748 | /** | |
749 | Applies this matrix to a distance (ie. performs all transforms except | |
750 | translations) | |
751 | */ | |
da1ed74c | 752 | virtual void TransformDistance(wxDouble* dx, wxDouble* dy) const; |
23324ae1 FM |
753 | |
754 | /** | |
755 | Applies this matrix to a point. | |
756 | */ | |
da1ed74c | 757 | virtual void TransformPoint(wxDouble* x, wxDouble* y) const; |
23324ae1 FM |
758 | |
759 | /** | |
760 | Translates this matrix. | |
761 | */ | |
da1ed74c | 762 | virtual void Translate(wxDouble dx, wxDouble dy); |
23324ae1 | 763 | }; |
e54c96f1 | 764 |