]> git.saurik.com Git - wxWidgets.git/blame - interface/wx/graphics.h
add note for wxWidgets user with a skeleton for a very minimal console app
[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 /**
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 */
a44f3b5a
FM
56 virtual void AddCurveToPoint(wxDouble cx1, wxDouble cy1,
57 wxDouble cx2, wxDouble cy2,
58 wxDouble x, wxDouble y);
23d291c2
BP
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*/
182class wxGraphicsObject : public wxObject
183{
184public:
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
9cc4ab85
BP
202 A wxGraphicsContext instance is the object that is drawn upon. It is
203 created by a renderer using wxGraphicsRenderer::CreateContext(). This can
204 be either directly using a renderer instance, or indirectly using the
205 static convenience Create() functions of wxGraphicsContext that always
206 delegate the task to the default renderer.
7c913512 207
d974a494
RR
208 @code
209 void MyCanvas::OnPaint(wxPaintEvent &event)
210 {
211 // Create paint DC
212 wxPaintDC dc(this);
23d291c2 213
d974a494 214 // Create graphics context from it
ea077571 215 wxGraphicsContext *gc = wxGraphicsContext::Create( dc );
23d291c2 216
7e38ae60
RR
217 if (gc)
218 {
0b822969 219 // make a path that contains a circle and some lines
7e38ae60
RR
220 gc->SetPen( *wxRED_PEN );
221 wxGraphicsPath path = gc->CreatePath();
222 path.AddCircle( 50.0, 50.0, 50.0 );
223 path.MoveToPoint(0.0, 50.0);
224 path.AddLineToPoint(100.0, 50.0);
225 path.MoveToPoint(50.0, 0.0);
226 path.AddLineToPoint(50.0, 100.0 );
227 path.CloseSubpath();
228 path.AddRectangle(25.0, 25.0, 50.0, 50.0);
23d291c2 229
ea077571 230 gc->StrokePath(path);
23d291c2 231
ea077571 232 delete gc;
7e38ae60
RR
233 }
234 }
d974a494
RR
235 @endcode
236
23324ae1 237 @library{wxcore}
23d291c2 238 @category{gdi,dc}
7c913512 239
6d99a337 240 @see wxGraphicsRenderer::CreateContext(), wxGCDC, wxDC
23324ae1
FM
241*/
242class wxGraphicsContext : public wxGraphicsObject
243{
244public:
23324ae1 245 /**
0b822969
RR
246 Creates a wxGraphicsContext from a wxWindow.
247
248 @see wxGraphicsRenderer::CreateContext()
249 */
9cc4ab85 250 static wxGraphicsContext* Create(wxWindow* window);
23d291c2 251
0b822969
RR
252 /**
253 Creates a wxGraphicsContext from a wxWindowDC
254
255 @see wxGraphicsRenderer::CreateContext()
256 */
9cc4ab85 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 */
9cc4ab85 264 static wxGraphicsContext* Create(const wxMemoryDC& dc);
23d291c2 265
0b822969 266 /**
9cc4ab85
BP
267 Creates a wxGraphicsContext from a wxPrinterDC. Under GTK+, this will
268 only work when using the GtkPrint printing backend which is available
269 since GTK+ 2.10.
0b822969 270
9cc4ab85 271 @see wxGraphicsRenderer::CreateContext(), @ref overview_unixprinting
0b822969 272 */
9cc4ab85 273 static wxGraphicsContext* Create(const wxPrinterDC& dc);
0b822969
RR
274
275 /**
9cc4ab85 276 Clips drawings to the specified region.
23324ae1 277 */
da1ed74c 278 virtual void Clip(const wxRegion& region) = 0;
0b822969
RR
279
280 /**
9cc4ab85 281 Clips drawings to the specified rectangle.
0b822969 282 */
da1ed74c 283 virtual void Clip(wxDouble x, wxDouble y, wxDouble w, wxDouble h) = 0;
23324ae1
FM
284
285 /**
9cc4ab85
BP
286 Concatenates the passed in transform with the current transform of this
287 context.
23324ae1 288 */
da1ed74c 289 virtual void ConcatTransform(const wxGraphicsMatrix& matrix) = 0;
23324ae1 290
23324ae1
FM
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 /**
9cc4ab85
BP
303 Creates a wxGraphicsContext from a native context. This native context
304 must be a CGContextRef for Core Graphics, a Graphics pointer for
305 GDIPlus, or a cairo_t pointer for cairo.
3c4f71cc 306
9cc4ab85 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
9cc4ab85 314 @see wxGraphicsRenderer::CreateContextFromNativeWindow()
23324ae1 315 */
da1ed74c 316 static wxGraphicsContext* CreateFromNativeWindow(void* window);
23324ae1
FM
317
318 /**
9cc4ab85
BP
319 Creates a native brush, having a linear gradient, starting at
320 (@a x1, @a y1) with color @a c1 to (@a x2, @a y2) with color @a c2.
23324ae1 321 */
a44f3b5a
FM
322 virtual wxGraphicsBrush CreateLinearGradientBrush(wxDouble x1,
323 wxDouble y1,
324 wxDouble x2,
325 wxDouble y2,
326 const wxColour& c1,
327 const wxColour& c2) const;
23324ae1
FM
328
329 /**
9cc4ab85
BP
330 Creates a native affine transformation matrix from the passed in
331 values. The default parameters result in an identity matrix.
23324ae1 332 */
5267aefd
FM
333 virtual wxGraphicsMatrix CreateMatrix(wxDouble a = 1.0, wxDouble b = 0.0,
334 wxDouble c = 0.0, wxDouble d = 1.0,
a44f3b5a
FM
335 wxDouble tx = 0.0,
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 /**
9cc4ab85
BP
349 Creates a native brush, having a radial gradient originating at
350 (@a xo, @a yc) with color @a oColour and ends on a circle around
351 (@a xc, @a yc) with the given @a radius and color @a cColour.
23324ae1 352 */
da1ed74c
FM
353 virtual wxGraphicsBrush CreateRadialGradientBrush(wxDouble xo, wxDouble yo,
354 wxDouble xc, wxDouble yc,
355 wxDouble radius,
356 const wxColour& oColor,
357 const wxColour& cColor) const;
23324ae1
FM
358
359 /**
9cc4ab85
BP
360 Draws the bitmap. In case of a mono bitmap, this is treated as a mask
361 and the current brushed is used for filling.
23324ae1 362 */
fadc2df6
FM
363 virtual void DrawBitmap(const wxBitmap& bmp, wxDouble x, wxDouble y,
364 wxDouble w, wxDouble h) = 0;
23324ae1
FM
365
366 /**
367 Draws an ellipse.
368 */
da1ed74c 369 virtual void DrawEllipse(wxDouble x, wxDouble y, wxDouble w, wxDouble h);
23324ae1
FM
370
371 /**
372 Draws the icon.
373 */
fadc2df6
FM
374 virtual void DrawIcon(const wxIcon& icon, wxDouble x, wxDouble y,
375 wxDouble w, wxDouble h) = 0;
23324ae1
FM
376
377 /**
378 Draws a polygon.
379 */
fadc2df6 380 virtual void DrawLines(size_t n, const wxPoint2DDouble* points,
382f12e4 381 wxPolygonFillMode fillStyle = wxODDEVEN_RULE);
23324ae1
FM
382
383 /**
384 Draws the path by first filling and then stroking.
385 */
fadc2df6 386 virtual void DrawPath(const wxGraphicsPath& path,
382f12e4 387 wxPolygonFillMode fillStyle = wxODDEVEN_RULE);
23324ae1
FM
388
389 /**
390 Draws a rectangle.
391 */
fadc2df6 392 virtual void DrawRectangle(wxDouble x, wxDouble y, wxDouble w, wxDouble h);
23324ae1
FM
393
394 /**
395 Draws a rounded rectangle.
396 */
da1ed74c
FM
397 virtual void DrawRoundedRectangle(wxDouble x, wxDouble y, wxDouble w,
398 wxDouble h, wxDouble radius);
23324ae1 399
23324ae1 400 /**
9cc4ab85 401 Draws text at the defined position.
23324ae1 402 */
7c913512 403 void DrawText(const wxString& str, wxDouble x, wxDouble y);
9cc4ab85
BP
404 /**
405 Draws text at the defined position.
406
cbd251ac
BP
407 @param str
408 The text to draw.
409 @param x
410 The x coordinate position to draw the text at.
411 @param y
412 The y coordinate position to draw the text at.
9cc4ab85
BP
413 @param angle
414 The angle relative to the (default) horizontal direction to draw
415 the string.
416 */
417 void DrawText(const wxString& str, wxDouble x, wxDouble y, wxDouble angle);
418 /**
419 Draws text at the defined position.
420
cbd251ac
BP
421 @param str
422 The text to draw.
423 @param x
424 The x coordinate position to draw the text at.
425 @param y
426 The y coordinate position to draw the text at.
9cc4ab85
BP
427 @param backgroundBrush
428 Brush to fill the text with.
429 */
5a395566 430 void DrawText(const wxString& str, wxDouble x, wxDouble y,
9cc4ab85
BP
431 const wxGraphicsBrush& backgroundBrush);
432 /**
433 Draws text at the defined position.
434
cbd251ac
BP
435 @param str
436 The text to draw.
437 @param x
438 The x coordinate position to draw the text at.
439 @param y
440 The y coordinate position to draw the text at.
9cc4ab85
BP
441 @param angle
442 The angle relative to the (default) horizontal direction to draw
443 the string.
444 @param backgroundBrush
445 Brush to fill the text with.
446 */
5a395566 447 void DrawText(const wxString& str, wxDouble x, wxDouble y,
9cc4ab85 448 wxDouble angle, const wxGraphicsBrush& backgroundBrush);
23324ae1
FM
449
450 /**
451 Fills the path with the current brush.
452 */
fadc2df6 453 virtual void FillPath(const wxGraphicsPath& path,
382f12e4 454 wxPolygonFillMode fillStyle = wxODDEVEN_RULE) = 0;
23324ae1
FM
455
456 /**
9cc4ab85
BP
457 Returns the native context (CGContextRef for Core Graphics, Graphics
458 pointer for GDIPlus and cairo_t pointer for cairo).
23324ae1 459 */
da1ed74c 460 virtual void* GetNativeContext() = 0;
23324ae1
FM
461
462 /**
4cc4bfaf 463 Fills the @a widths array with the widths from the beginning of
9cc4ab85 464 @a text to the corresponding character of @a text.
23324ae1 465 */
fadc2df6
FM
466 virtual void GetPartialTextExtents(const wxString& text,
467 wxArrayDouble& widths) const = 0;
23324ae1
FM
468
469 /**
470 Gets the dimensions of the string using the currently selected font.
9cc4ab85
BP
471
472 @param text
473 The text string to measure.
474 @param width
475 Variable to store the total calculated width of the text.
476 @param height
477 Variable to store the total calculated height of the text.
478 @param descent
479 Variable to store the dimension from the baseline of the font to
480 the bottom of the descender.
481 @param externalLeading
482 Any extra vertical space added to the font by the font designer
483 (usually is zero).
23324ae1 484 */
da1ed74c
FM
485 virtual void GetTextExtent(const wxString& text, wxDouble* width,
486 wxDouble* height, wxDouble* descent,
487 wxDouble* externalLeading) const = 0;
23324ae1
FM
488
489 /**
490 Gets the current transformation matrix of this context.
491 */
da1ed74c 492 virtual wxGraphicsMatrix GetTransform() const = 0;
23324ae1
FM
493
494 /**
495 Resets the clipping to original shape.
496 */
da1ed74c 497 virtual void ResetClip() = 0;
23324ae1
FM
498
499 /**
9cc4ab85 500 Rotates the current transformation matrix (in radians).
23324ae1 501 */
da1ed74c 502 virtual void Rotate(wxDouble angle) = 0;
23324ae1
FM
503
504 /**
505 Scales the current transformation matrix.
506 */
da1ed74c 507 virtual void Scale(wxDouble xScale, wxDouble yScale) = 0;
23324ae1 508
23324ae1
FM
509 /**
510 Sets the brush for filling paths.
511 */
512 void SetBrush(const wxBrush& brush);
9cc4ab85
BP
513 /**
514 Sets the brush for filling paths.
515 */
ccf39540 516 virtual void SetBrush(const wxGraphicsBrush& brush);
23324ae1 517
23324ae1
FM
518 /**
519 Sets the font for drawing text.
520 */
521 void SetFont(const wxFont& font, const wxColour& colour);
9cc4ab85
BP
522 /**
523 Sets the font for drawing text.
524 */
ccf39540 525 virtual void SetFont(const wxGraphicsFont& font);
23324ae1 526
23324ae1
FM
527 /**
528 Sets the pen used for stroking.
529 */
ccf39540 530 void SetPen(const wxPen& pen);
9cc4ab85
BP
531 /**
532 Sets the pen used for stroking.
533 */
ccf39540 534 virtual void SetPen(const wxGraphicsPen& pen);
23324ae1
FM
535
536 /**
537 Sets the current transformation matrix of this context
538 */
da1ed74c 539 virtual void SetTransform(const wxGraphicsMatrix& matrix) = 0;
23324ae1
FM
540
541 /**
542 Strokes a single line.
543 */
fadc2df6 544 virtual void StrokeLine(wxDouble x1, wxDouble y1, wxDouble x2, wxDouble y2);
23324ae1 545
23324ae1 546 /**
9cc4ab85
BP
547 Stroke disconnected lines from begin to end points, fastest method
548 available for this purpose.
23324ae1 549 */
ccf39540
FM
550 virtual void StrokeLines(size_t n, const wxPoint2DDouble* beginPoints,
551 const wxPoint2DDouble* endPoints);
9cc4ab85
BP
552 /**
553 Stroke disconnected lines from begin to end points, fastest method
554 available for this purpose.
555 */
ccf39540 556 virtual void StrokeLines(size_t n, const wxPoint2DDouble* points);
23324ae1
FM
557
558 /**
559 Strokes along a path with the current pen.
560 */
da1ed74c 561 virtual void StrokePath(const wxGraphicsPath& path) = 0;
23324ae1
FM
562
563 /**
564 Translates the current transformation matrix.
565 */
da1ed74c 566 virtual void Translate(wxDouble dx, wxDouble dy) = 0;
23324ae1
FM
567};
568
569
e54c96f1 570
23324ae1
FM
571/**
572 @class wxGraphicsRenderer
7c913512 573
23324ae1 574 A wxGraphicsRenderer is the instance corresponding to the rendering engine
ea077571 575 used. There may be multiple instances on a system, if there are different
9cc4ab85
BP
576 rendering engines present, but there is always only one instance per
577 engine. This instance is pointed back to by all objects created by it
578 (wxGraphicsContext, wxGraphicsPath etc) and can be retrieved through their
579 wxGraphicsObject::GetRenderer() method. Therefore you can create an
580 additional instance of a path etc. by calling
581 wxGraphicsObject::GetRenderer() and then using the appropriate CreateXXX()
582 function of that renderer.
ea077571
RR
583
584 @code
585 wxGraphicsPath *path = // from somewhere
586 wxGraphicsBrush *brush = path->GetRenderer()->CreateBrush( *wxBLACK_BRUSH );
587 @endcode
7c913512 588
23324ae1 589 @library{wxcore}
9cc4ab85 590 @category{gdi}
23324ae1
FM
591*/
592class wxGraphicsRenderer : public wxObject
593{
594public:
595 /**
ea077571 596 Creates a wxGraphicsContext from a wxWindow.
23324ae1 597 */
ea077571 598 virtual wxGraphicsContext* CreateContext(wxWindow* window) = 0;
23d291c2 599
ea077571
RR
600 /**
601 Creates a wxGraphicsContext from a wxWindowDC
602 */
9cc4ab85 603 virtual wxGraphicsContext* CreateContext(const wxWindowDC& dc) = 0 ;
23d291c2 604
ea077571
RR
605 /**
606 Creates a wxGraphicsContext from a wxMemoryDC
607 */
9cc4ab85 608 virtual wxGraphicsContext* CreateContext(const wxMemoryDC& dc) = 0 ;
23d291c2 609
ea077571
RR
610 /**
611 Creates a wxGraphicsContext from a wxPrinterDC
612 */
9cc4ab85 613 virtual wxGraphicsContext* CreateContext(const wxPrinterDC& dc) = 0 ;
23324ae1 614
23324ae1 615 /**
ea077571 616 Creates a native brush from a wxBrush.
23324ae1 617 */
da1ed74c 618 virtual wxGraphicsBrush CreateBrush(const wxBrush& brush) = 0;
ea077571 619
23324ae1 620 /**
9cc4ab85
BP
621 Creates a wxGraphicsContext from a native context. This native context
622 must be a CGContextRef for Core Graphics, a Graphics pointer for
623 GDIPlus, or a cairo_t pointer for cairo.
23324ae1 624 */
da1ed74c 625 virtual wxGraphicsContext* CreateContextFromNativeContext(void* context) = 0;
23324ae1
FM
626
627 /**
628 Creates a wxGraphicsContext from a native window.
629 */
da1ed74c 630 virtual wxGraphicsContext* CreateContextFromNativeWindow(void* window) = 0;
23324ae1
FM
631
632 /**
633 Creates a native graphics font from a wxFont and a text colour.
634 */
5267aefd
FM
635 virtual wxGraphicsFont CreateFont(const wxFont& font,
636 const wxColour& col = *wxBLACK) = 0;
23324ae1
FM
637
638 /**
9cc4ab85
BP
639 Creates a native brush, having a linear gradient, starting at
640 (@a x1, @a y1) with color @a c1 to (@a x2, @a y2) with color @a c2.
23324ae1 641 */
9cc4ab85
BP
642 virtual wxGraphicsBrush CreateLinearGradientBrush(wxDouble x1,
643 wxDouble y1,
644 wxDouble x2,
645 wxDouble y2,
646 const wxColour& c1,
647 const wxColour& c2) = 0;
23324ae1
FM
648
649 /**
9cc4ab85
BP
650 Creates a native affine transformation matrix from the passed in
651 values. The defaults result in an identity matrix.
23324ae1 652 */
5267aefd
FM
653 virtual wxGraphicsMatrix CreateMatrix(wxDouble a = 1.0, wxDouble b = 0.0,
654 wxDouble c = 0.0, wxDouble d = 1.0,
a44f3b5a 655 wxDouble tx = 0.0,
5267aefd 656 wxDouble ty = 0.0) = 0;
23324ae1
FM
657
658 /**
659 Creates a native graphics path which is initially empty.
660 */
da1ed74c 661 virtual wxGraphicsPath CreatePath() = 0;
23324ae1
FM
662
663 /**
664 Creates a native pen from a wxPen.
665 */
da1ed74c 666 virtual wxGraphicsPen CreatePen(const wxPen& pen) = 0;
23324ae1
FM
667
668 /**
9cc4ab85
BP
669 Creates a native brush, having a radial gradient originating at
670 (@a xo, @a yc) with color @a oColour and ends on a circle around
671 (@a xc, @a yc) with the given @a radius and color @a cColour.
23324ae1 672 */
da1ed74c
FM
673 virtual wxGraphicsBrush CreateRadialGradientBrush(wxDouble xo, wxDouble yo,
674 wxDouble xc, wxDouble yc,
675 wxDouble radius,
676 const wxColour& oColour,
677 const wxColour& cColour) = 0;
23324ae1
FM
678
679 /**
680 Returns the default renderer on this platform. On OS X this is the Core
9cc4ab85
BP
681 Graphics (a.k.a. Quartz 2D) renderer, on MSW the GDIPlus renderer, and
682 on GTK we currently default to the cairo renderer.
23324ae1 683 */
ea077571 684 static wxGraphicsRenderer* GetDefaultRenderer();
23324ae1
FM
685};
686
687
e54c96f1 688
23324ae1
FM
689/**
690 @class wxGraphicsBrush
7c913512 691
9cc4ab85
BP
692 A wxGraphicsBrush is a native representation of a brush. The contents are
693 specific and private to the respective renderer. Instances are ref counted
694 and can therefore be assigned as usual. The only way to get a valid
695 instance is via wxGraphicsContext::CreateBrush() or
696 wxGraphicsRenderer::CreateBrush().
7c913512 697
23324ae1 698 @library{wxcore}
9cc4ab85 699 @category{gdi}
23324ae1
FM
700*/
701class wxGraphicsBrush : public wxGraphicsObject
702{
703public:
7c913512 704
23324ae1
FM
705};
706
707
e54c96f1 708
23324ae1
FM
709/**
710 @class wxGraphicsFont
7c913512 711
9cc4ab85
BP
712 A wxGraphicsFont is a native representation of a font. The contents are
713 specific and private to the respective renderer. Instances are ref counted
714 and can therefore be assigned as usual. The only way to get a valid
715 instance is via wxGraphicsContext::CreateFont() or
716 wxGraphicsRenderer::CreateFont().
7c913512 717
23324ae1 718 @library{wxcore}
9cc4ab85 719 @category{gdi}
23324ae1
FM
720*/
721class wxGraphicsFont : public wxGraphicsObject
722{
723public:
7c913512 724
23324ae1
FM
725};
726
727
e54c96f1 728
23324ae1
FM
729/**
730 @class wxGraphicsPen
7c913512 731
9cc4ab85
BP
732 A wxGraphicsPen is a native representation of a pen. The contents are
733 specific and private to the respective renderer. Instances are ref counted
734 and can therefore be assigned as usual. The only way to get a valid
735 instance is via wxGraphicsContext::CreatePen() or
736 wxGraphicsRenderer::CreatePen().
7c913512 737
23324ae1 738 @library{wxcore}
9cc4ab85 739 @category{gdi}
23324ae1
FM
740*/
741class wxGraphicsPen : public wxGraphicsObject
742{
743public:
7c913512 744
23324ae1
FM
745};
746
747
e54c96f1 748
23324ae1
FM
749/**
750 @class wxGraphicsMatrix
7c913512 751
9cc4ab85
BP
752 A wxGraphicsMatrix is a native representation of an affine matrix. The
753 contents are specific and private to the respective renderer. Instances are
754 ref counted and can therefore be assigned as usual. The only way to get a
755 valid instance is via wxGraphicsContext::CreateMatrix() or
756 wxGraphicsRenderer::CreateMatrix().
7c913512 757
23324ae1 758 @library{wxcore}
9cc4ab85 759 @category{gdi}
23324ae1
FM
760*/
761class wxGraphicsMatrix : public wxGraphicsObject
762{
763public:
23324ae1 764 /**
9cc4ab85
BP
765 Concatenates the matrix passed with the current matrix.
766 */
767 virtual void Concat(const wxGraphicsMatrix* t);
768 /**
769 Concatenates the matrix passed with the current matrix.
23324ae1 770 */
7c913512 771 void Concat(const wxGraphicsMatrix& t);
23324ae1
FM
772
773 /**
774 Returns the component values of the matrix via the argument pointers.
775 */
9cc4ab85
BP
776 virtual void Get(wxDouble* a = NULL, wxDouble* b = NULL,
777 wxDouble* c = NULL, wxDouble* d = NULL,
778 wxDouble* tx = NULL, wxDouble* ty = NULL) const;
23324ae1
FM
779
780 /**
9cc4ab85
BP
781 Returns the native representation of the matrix. For CoreGraphics this
782 is a CFAffineMatrix pointer, for GDIPlus a Matrix Pointer, and for
783 Cairo a cairo_matrix_t pointer.
23324ae1 784 */
da1ed74c 785 virtual void* GetNativeMatrix() const;
23324ae1
FM
786
787 /**
788 Inverts the matrix.
789 */
da1ed74c 790 virtual void Invert();
23324ae1 791
9cc4ab85
BP
792 /**
793 Returns @true if the elements of the transformation matrix are equal.
794 */
795 virtual bool IsEqual(const wxGraphicsMatrix* t) const;
23324ae1
FM
796 /**
797 Returns @true if the elements of the transformation matrix are equal.
798 */
328f5751 799 bool IsEqual(const wxGraphicsMatrix& t) const;
23324ae1
FM
800
801 /**
802 Return @true if this is the identity matrix.
803 */
da1ed74c 804 virtual bool IsIdentity() const;
23324ae1
FM
805
806 /**
9cc4ab85 807 Rotates this matrix (in radians).
23324ae1 808 */
da1ed74c 809 virtual void Rotate(wxDouble angle);
23324ae1
FM
810
811 /**
812 Scales this matrix.
813 */
da1ed74c 814 virtual void Scale(wxDouble xScale, wxDouble yScale);
23324ae1
FM
815
816 /**
9cc4ab85
BP
817 Sets the matrix to the respective values (default values are the
818 identity matrix).
23324ae1 819 */
5267aefd
FM
820 virtual void Set(wxDouble a = 1.0, wxDouble b = 0.0, wxDouble c = 0.0,
821 wxDouble d = 1.0, wxDouble tx = 0.0, wxDouble ty = 0.0);
23324ae1
FM
822
823 /**
824 Applies this matrix to a distance (ie. performs all transforms except
9cc4ab85 825 translations).
23324ae1 826 */
da1ed74c 827 virtual void TransformDistance(wxDouble* dx, wxDouble* dy) const;
23324ae1
FM
828
829 /**
830 Applies this matrix to a point.
831 */
da1ed74c 832 virtual void TransformPoint(wxDouble* x, wxDouble* y) const;
23324ae1
FM
833
834 /**
835 Translates this matrix.
836 */
da1ed74c 837 virtual void Translate(wxDouble dx, wxDouble dy);
23324ae1 838};
9cc4ab85 839