]>
git.saurik.com Git - wxWidgets.git/blob - interface/dcsvg.h
2b55869d70bacddc897efa0957ba2924b43d5f5e
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: documentation for wxSVGFileDC class
4 // Author: wxWidgets team
6 // Licence: wxWindows license
7 /////////////////////////////////////////////////////////////////////////////
13 A wxSVGFileDC is a @e device context onto which graphics and text can be drawn,
15 produced as a vector file, in the SVG format
16 (see W3C specifications).
17 This format can be read by a range of programs, including a Netscape plugin
19 in the SVG Implementation and Resource Directory.
20 Vector formats may often be smaller than raster formats.
22 The intention behind wxSVGFileDC is that it can be used to produce a file
24 to the screen display context, wxSVGFileDC, by passing the wxSVGFileDC as a
25 parameter instead of a wxSVGFileDC. Thus the wxSVGFileDC is a write-only class.
27 As the wxSVGFileDC is a vector format, raster operations like GetPixel are
28 unlikely to be supported.
29 However, the SVG specification allows for PNG format raster files to be
30 embedded in the SVG, and so
31 bitmaps, icons and blit operations into the wxSVGFileDC are supported.
33 A more substantial SVG library (for reading and writing) is available at the
42 class wxSVGFileDC
: public wxDC
48 a filename @a f with default size 340x240 at 72.0 dots per inch (a frequent
50 a filename @a f with size @a Width by @a Height at 72.0 dots per inch
51 a filename @a f with size @a Width by @a Height at @a dpi resolution.
53 wxSVGFileDC(wxString f
);
54 wxSVGFileDC(wxString f
, int Width
, int Height
);
55 wxSVGFileDC(wxString f
, int Width
, int Height
, float dpi
);
69 As wxDC: Copy from a source DC to this DC, specifying the destination
70 coordinates, size of area to copy, source DC, source coordinates,
71 logical function, whether to use a bitmap mask, and mask source position.
73 bool Blit(wxCoord xdest
, wxCoord ydest
, wxCoord width
,
74 wxCoord height
, wxSVGFileDC
* source
,
75 wxCoord xsrc
, wxCoord ysrc
,
76 int logicalFunc
= wxCOPY
,
78 wxCoord xsrcMask
= -1,
79 wxCoord ysrcMask
= -1);
82 Adds the specified point to the bounding box which can be retrieved with
83 wxDC::MinX, wxDC::MaxX and
84 wxDC::MinY, wxDC::MaxY functions.
86 void CalcBoundingBox(wxCoord x
, wxCoord y
);
89 This makes no sense in wxSVGFileDC and does nothing
96 void CrossHair(wxCoord x
, wxCoord y
);
101 void DestroyClippingRegion();
104 Convert device X coordinate to logical coordinate, using the current
107 wxCoord
DeviceToLogicalX(wxCoord x
);
110 Convert device X coordinate to relative logical coordinate, using the current
111 mapping mode but ignoring the x axis orientation.
112 Use this function for converting a width, for example.
114 wxCoord
DeviceToLogicalXRel(wxCoord x
);
117 Converts device Y coordinate to logical coordinate, using the current
120 wxCoord
DeviceToLogicalY(wxCoord y
);
123 Convert device Y coordinate to relative logical coordinate, using the current
124 mapping mode but ignoring the y axis orientation.
125 Use this function for converting a height, for example.
127 wxCoord
DeviceToLogicalYRel(wxCoord y
);
130 Draws an arc of a circle, centred on (@e xc, yc), with starting point (@e x1,
132 and ending at (@e x2, y2). The current pen is used for the outline
133 and the current brush for filling the shape.
134 The arc is drawn in an anticlockwise direction from the start point to the end
137 void DrawArc(wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
,
138 wxCoord xc
, wxCoord yc
);
141 Draw a bitmap on the device context at the specified point. If @a transparent
142 is @true and the bitmap has
143 a transparency mask, the bitmap will be drawn transparently.
144 When drawing a mono-bitmap, the current text foreground colour will be used to
146 of the bitmap (all bits set to 1), and the current text background colour to
148 (all bits set to 0). See also wxDC::SetTextForeground,
149 wxDC::SetTextBackground and wxMemoryDC.
151 void DrawBitmap(const wxBitmap
& bitmap
, wxCoord x
, wxCoord y
,
156 Draws a check mark inside the given rectangle.
158 void DrawCheckMark(wxCoord x
, wxCoord y
, wxCoord width
,
160 void DrawCheckMark(const wxRect
& rect
);
165 Draws a circle with the given centre and radius.
167 @see wxDC::DrawEllipse
169 void DrawCircle(wxCoord x
, wxCoord y
, wxCoord radius
);
170 void DrawCircle(const wxPoint
& pt
, wxCoord radius
);
175 Draws an ellipse contained in the rectangle specified either with the given top
176 left corner and the given size or directly. The current pen is used for the
177 outline and the current brush for filling the shape.
179 @see wxDC::DrawCircle
181 void DrawEllipse(wxCoord x
, wxCoord y
, wxCoord width
,
183 void DrawEllipse(const wxPoint
& pt
, const wxSize
& size
);
184 void DrawEllipse(const wxRect
& rect
);
188 Draws an arc of an ellipse. The current pen is used for drawing the arc and
189 the current brush is used for drawing the pie.
190 @a x and @a y specify the x and y coordinates of the upper-left corner of the
191 rectangle that contains
193 @a width and @a height specify the width and height of the rectangle that
196 @a start and @a end specify the start and end of the arc relative to the
198 position from the center of the rectangle. Angles are specified
199 in degrees (360 is a complete circle). Positive values mean
200 counter-clockwise motion. If @a start is equal to @e end, a
201 complete ellipse will be drawn.
203 void DrawEllipticArc(wxCoord x
, wxCoord y
, wxCoord width
,
209 Draw an icon on the display (does nothing if the device context is PostScript).
210 This can be the simplest way of drawing bitmaps on a window.
212 void DrawIcon(const wxIcon
& icon
, wxCoord x
, wxCoord y
);
215 Draws a line from the first point to the second. The current pen is used
216 for drawing the line.
218 void DrawLine(wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
);
222 Draws lines using an array of @a points of size @e n, or list of
223 pointers to points, adding the optional offset coordinate. The current
224 pen is used for drawing the lines. The programmer is responsible for
225 deleting the list of points.
227 void DrawLines(int n
, wxPoint points
[], wxCoord xoffset
= 0,
228 wxCoord yoffset
= 0);
229 void DrawLines(wxList
* points
, wxCoord xoffset
= 0,
230 wxCoord yoffset
= 0);
234 Draws a point using the current pen.
236 void DrawPoint(wxCoord x
, wxCoord y
);
240 Draws a filled polygon using an array of @a points of size @e n,
241 or list of pointers to points, adding the optional offset coordinate.
242 The last argument specifies the fill rule: @b wxODDEVEN_RULE (the
243 default) or @b wxWINDING_RULE.
244 The current pen is used for drawing the outline, and the current brush
245 for filling the shape. Using a transparent brush suppresses filling.
246 The programmer is responsible for deleting the list of points.
247 Note that wxWindows automatically closes the first and last points.
249 void DrawPolygon(int n
, wxPoint points
[], wxCoord xoffset
= 0,
251 int fill_style
= wxODDEVEN_RULE
);
252 void DrawPolygon(wxList
* points
, wxCoord xoffset
= 0,
254 int fill_style
= wxODDEVEN_RULE
);
258 Draws a rectangle with the given top left corner, and with the given
259 size. The current pen is used for the outline and the current brush
260 for filling the shape.
262 void DrawRectangle(wxCoord x
, wxCoord y
, wxCoord width
,
266 Draws the text rotated by @a angle degrees.
267 The wxMSW wxDC and wxSVGFileDC rotate the text around slightly different
268 points, depending on the size of the font
270 void DrawRotatedText(const wxString
& text
, wxCoord x
, wxCoord y
,
274 Draws a rectangle with the given top left corner, and with the given
275 size. The corners are quarter-circles using the given radius. The
276 current pen is used for the outline and the current brush for filling
278 If @a radius is positive, the value is assumed to be the
279 radius of the rounded corner. If @a radius is negative,
280 the absolute value is assumed to be the @e proportion of the smallest
281 dimension of the rectangle. This means that the corner can be
282 a sensible size relative to the size of the rectangle, and also avoids
283 the strange effects X produces when the corners are too big for
286 void DrawRoundedRectangle(wxCoord x
, wxCoord y
, wxCoord width
,
292 Draws a three-point spline using the current pen.
294 void DrawSpline(wxList
* points
);
295 void DrawSpline(wxCoord x1
, wxCoord y1
, wxCoord x2
,
302 Draws a text string at the specified point, using the current text font,
303 and the current text foreground and background colours.
304 The coordinates refer to the top-left corner of the rectangle bounding
305 the string. See GetTextExtent() for how
306 to get the dimensions of a text string, which can be used to position the
309 void DrawText(const wxString
& text
, wxCoord x
, wxCoord y
);
329 void FloodFill(wxCoord x
, wxCoord y
, const wxColour
& colour
,
330 int style
= wxFLOOD_SURFACE
);
334 Gets the brush used for painting the background (see
335 wxSVGFileDC::SetBackground).
337 wxBrush
GetBackground() const;
338 const wxBrush
GetBackground() const;
342 Returns the current background mode: @c wxSOLID or @c wxTRANSPARENT.
344 @see wxDC::SetBackgroundMode
346 int GetBackgroundMode() const;
350 Gets the current brush (see wxSVGFileDC::SetBrush).
352 wxBrush
GetBrush() const;
353 const wxBrush
GetBrush() const;
357 Gets the character height of the currently set font.
359 wxCoord
GetCharHeight();
362 Gets the average character width of the currently set font.
364 wxCoord
GetCharWidth();
369 void GetClippingBox(wxCoord x
, wxCoord y
, wxCoord width
,
374 Gets the current font (see wxSVGFileDC::SetFont).
376 wxFont
GetFont() const;
377 const wxFont
GetFont() const;
381 Gets the current logical function (see wxSVGFileDC::SetLogicalFunction).
383 int GetLogicalFunction();
386 Gets the @e mapping mode for the device context (see wxSVGFileDC::SetMapMode).
392 Gets the current pen (see wxSVGFileDC::SetPen).
394 wxPen
GetPen() const;
395 const wxPen
GetPen() const;
401 bool GetPixel(wxCoord x
, wxCoord y
, wxColour
* colour
);
404 For a Windows printer device context, this gets the horizontal and vertical
407 void GetSize(wxCoord
* width
, wxCoord
* height
);
411 Gets the current text background colour (see wxSVGFileDC::SetTextBackground).
413 wxColour
GetTextBackground() const;
414 const wxColour
GetTextBackground() const;
418 Gets the dimensions of the string using the currently selected font.
419 @a string is the text string to measure, @a w and @a h are
420 the total width and height respectively, @a descent is the
421 dimension from the baseline of the font to the bottom of the
422 descender, and @a externalLeading is any extra vertical space added
423 to the font by the font designer (usually is zero).
424 The optional parameter @a font specifies an alternative
425 to the currently selected font: but note that this does not
426 yet work under Windows, so you need to set a font for
427 the device context first.
428 See also wxFont, SetFont().
430 void GetTextExtent(const wxString
& string
, wxCoord
* w
,
432 wxCoord
* descent
= NULL
,
433 wxCoord
* externalLeading
= NULL
,
434 wxFont
* font
= NULL
);
438 Gets the current text foreground colour (see wxSVGFileDC::SetTextForeground).
440 wxColour
GetTextForeground() const;
441 const wxColour
GetTextForeground() const;
445 Gets the current user scale factor (set by wxDC::SetUserScale).
447 void GetUserScale(double x
, double y
);
450 Converts logical X coordinate to device coordinate, using the current
453 wxCoord
LogicalToDeviceX(wxCoord x
);
456 Converts logical X coordinate to relative device coordinate, using the current
457 mapping mode but ignoring the x axis orientation.
458 Use this for converting a width, for example.
460 wxCoord
LogicalToDeviceXRel(wxCoord x
);
463 Converts logical Y coordinate to device coordinate, using the current
466 wxCoord
LogicalToDeviceY(wxCoord y
);
469 Converts logical Y coordinate to relative device coordinate, using the current
470 mapping mode but ignoring the y axis orientation.
471 Use this for converting a height, for example.
473 wxCoord
LogicalToDeviceYRel(wxCoord y
);
476 Gets the maximum horizontal extent used in drawing commands so far.
481 Gets the maximum vertical extent used in drawing commands so far.
486 Gets the minimum horizontal extent used in drawing commands so far.
491 Gets the minimum vertical extent used in drawing commands so far.
496 Returns @true if the DC is ok to use; False values arise from being unable to
502 Resets the bounding box: after a call to this function, the bounding box
503 doesn't contain anything.
505 @see wxDC::CalcBoundingBox
507 void ResetBoundingBox();
510 Sets the x and y axis orientation (i.e., the direction from lowest to
511 highest values on the axis). The default orientation is the natural
512 orientation, e.g. x axis from left to right and y axis from bottom up.
515 True to set the x axis orientation to the natural
516 left to right orientation, @false to invert it.
518 True to set the y axis orientation to the natural
519 bottom up orientation, @false to invert it.
521 void SetAxisOrientation(bool xLeftRight
, bool yBottomUp
);
524 Sets the current background brush for the DC.
526 void SetBackground(const wxBrush
& brush
);
529 @a mode may be one of wxSOLID and wxTRANSPARENT. This setting determines
530 whether text will be drawn with a background colour or not.
532 void SetBackgroundMode(int mode
);
535 Sets the current brush for the DC.
536 If the argument is wxNullBrush, the current brush is selected out of the device
537 context, and the original brush restored, allowing the current brush to
540 See also wxMemoryDC for the interpretation of colours
541 when drawing into a monochrome bitmap.
543 void SetBrush(const wxBrush
& brush
);
549 void SetClippingRegion(wxCoord x
, wxCoord y
, wxCoord width
,
551 void SetClippingRegion(const wxPoint
& pt
, const wxSize
& sz
);
552 void SetClippingRegion(const wxRect
& rect
);
553 void SetClippingRegion(const wxRegion
& region
);
557 Sets the device origin (i.e., the origin in pixels after scaling has been
559 This function may be useful in Windows printing
560 operations for placing a graphic on a page.
562 void SetDeviceOrigin(wxCoord x
, wxCoord y
);
565 Sets the current font for the DC. It must be a valid font, in particular you
566 should not pass @c wxNullFont to this method.
569 void SetFont(const wxFont
& font
);
572 Only wxCOPY is avalaible; trying to set one of the othe values will fail
574 void SetLogicalFunction(int function
);
577 The @e mapping mode of the device context defines the unit of
578 measurement used to convert logical units to device units. Note that
579 in X, text drawing isn't handled consistently with the mapping mode; a
580 font is always specified in point size. However, setting the @e user scale (see
581 wxSVGFileDC::SetUserScale) scales the text appropriately. In
582 Windows, scaleable TrueType fonts are always used; in X, results depend
583 on availability of fonts, but usually a reasonable match is found.
584 Note that the coordinate origin should ideally be selectable, but for
585 now is always at the top left of the screen/printer.
586 Drawing to a Windows printer device context under UNIX
587 uses the current mapping mode, but mapping mode is currently ignored for
589 The mapping mode can be one of the following:
593 Each logical unit is 1/20 of a point, or 1/1440 of
598 Each logical unit is a point, or 1/72 of an inch.
602 Each logical unit is 1 mm.
606 Each logical unit is 1/10 of a mm.
610 Each logical unit is 1 pixel.
612 void SetMapMode(int int);
617 void SetPalette(const wxPalette
& palette
);
620 Sets the current pen for the DC.
621 If the argument is wxNullPen, the current pen is selected out of the device
622 context, and the original pen restored.
623 See also wxMemoryDC for the interpretation of colours
624 when drawing into a monochrome bitmap.
626 void SetPen(const wxPen
& pen
);
629 Sets the current text background colour for the DC.
631 void SetTextBackground(const wxColour
& colour
);
634 Sets the current text foreground colour for the DC.
635 See also wxMemoryDC for the interpretation of colours
636 when drawing into a monochrome bitmap.
638 void SetTextForeground(const wxColour
& colour
);
641 Sets the user scaling factor, useful for applications which require
644 void SetUserScale(double xScale
, double yScale
);
649 bool StartDoc(const wxString
& message
);