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