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