]>
git.saurik.com Git - wxWidgets.git/blob - interface/dcsvg.h
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: interface of wxSVGFileDC
4 // Author: wxWidgets team
6 // Licence: wxWindows license
7 /////////////////////////////////////////////////////////////////////////////
13 A wxSVGFileDC is a device context onto which graphics and text can be
14 drawn, and the output produced as a vector file, in SVG format (see the W3C
15 SVG Specifications <http://www.w3.org/TR/2001/REC-SVG-20010904/>). This
16 format can be read by a range of programs, including a Netscape plugin
17 (Adobe), full details are given in the SVG Implementation and Resource
18 Directory <http://www.svgi.org/>. Vector formats may often be smaller than
21 The intention behind wxSVGFileDC is that it can be used to produce a file
22 corresponding to the screen display context, wxSVGFileDC, by passing the
23 wxSVGFileDC as a parameter instead of a wxSVGFileDC. Thus the wxSVGFileDC
24 is a write-only class.
26 As the wxSVGFileDC is a vector format, raster operations like GetPixel()
27 are unlikely to be supported. However, the SVG specification allows for PNG
28 format raster files to be embedded in the SVG, and so bitmaps, icons and
29 blit operations in wxSVGFileDC are supported.
31 A more substantial SVG library (for reading and writing) is available at
32 the wxArt2D website <http://wxart2d.sourceforge.net/>.
37 class wxSVGFileDC
: public wxDC
43 a filename @a f with default size 340x240 at 72.0 dots per inch (a frequent
45 a filename @a f with size @a Width by @a Height at 72.0 dots per inch
46 a filename @a f with size @a Width by @a Height at @a dpi resolution.
48 wxSVGFileDC(wxString f
);
49 wxSVGFileDC(wxString f
, int Width
, int Height
);
50 wxSVGFileDC(wxString f
, int Width
, int Height
, float dpi
);
64 As wxDC: Copy from a source DC to this DC, specifying the destination
65 coordinates, size of area to copy, source DC, source coordinates,
66 logical function, whether to use a bitmap mask, and mask source position.
68 bool Blit(wxCoord xdest
, wxCoord ydest
, wxCoord width
,
69 wxCoord height
, wxSVGFileDC
* source
,
70 wxCoord xsrc
, wxCoord ysrc
,
71 int logicalFunc
= wxCOPY
,
73 wxCoord xsrcMask
= -1,
74 wxCoord ysrcMask
= -1);
77 Adds the specified point to the bounding box which can be retrieved with
78 wxDC::MinX, wxDC::MaxX and
79 wxDC::MinY, wxDC::MaxY functions.
81 void CalcBoundingBox(wxCoord x
, wxCoord y
);
84 This makes no sense in wxSVGFileDC and does nothing
91 void CrossHair(wxCoord x
, wxCoord y
);
96 void DestroyClippingRegion();
99 Convert device X coordinate to logical coordinate, using the current
102 wxCoord
DeviceToLogicalX(wxCoord x
);
105 Convert device X coordinate to relative logical coordinate, using the current
106 mapping mode but ignoring the x axis orientation.
107 Use this function for converting a width, for example.
109 wxCoord
DeviceToLogicalXRel(wxCoord x
);
112 Converts device Y coordinate to logical coordinate, using the current
115 wxCoord
DeviceToLogicalY(wxCoord y
);
118 Convert device Y coordinate to relative logical coordinate, using the current
119 mapping mode but ignoring the y axis orientation.
120 Use this function for converting a height, for example.
122 wxCoord
DeviceToLogicalYRel(wxCoord y
);
125 Draws an arc of a circle, centred on (@e xc, yc), with starting point (@e x1,
127 and ending at (@e x2, y2). The current pen is used for the outline
128 and the current brush for filling the shape.
129 The arc is drawn in an anticlockwise direction from the start point to the end
132 void DrawArc(wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
,
133 wxCoord xc
, wxCoord yc
);
136 Draw a bitmap on the device context at the specified point. If @a transparent
137 is @true and the bitmap has
138 a transparency mask, the bitmap will be drawn transparently.
139 When drawing a mono-bitmap, the current text foreground colour will be used to
141 of the bitmap (all bits set to 1), and the current text background colour to
143 (all bits set to 0). See also wxDC::SetTextForeground,
144 wxDC::SetTextBackground and wxMemoryDC.
146 void DrawBitmap(const wxBitmap
& bitmap
, wxCoord x
, wxCoord y
,
151 Draws a check mark inside the given rectangle.
153 void DrawCheckMark(wxCoord x
, wxCoord y
, wxCoord width
,
155 void DrawCheckMark(const wxRect
& rect
);
160 Draws a circle with the given centre and radius.
162 @see wxDC::DrawEllipse
164 void DrawCircle(wxCoord x
, wxCoord y
, wxCoord radius
);
165 void DrawCircle(const wxPoint
& pt
, wxCoord radius
);
170 Draws an ellipse contained in the rectangle specified either with the given top
171 left corner and the given size or directly. The current pen is used for the
172 outline and the current brush for filling the shape.
174 @see wxDC::DrawCircle
176 void DrawEllipse(wxCoord x
, wxCoord y
, wxCoord width
,
178 void DrawEllipse(const wxPoint
& pt
, const wxSize
& size
);
179 void DrawEllipse(const wxRect
& rect
);
183 Draws an arc of an ellipse. The current pen is used for drawing the arc and
184 the current brush is used for drawing the pie.
185 @a x and @a y specify the x and y coordinates of the upper-left corner of the
186 rectangle that contains
188 @a width and @a height specify the width and height of the rectangle that
191 @a start and @a end specify the start and end of the arc relative to the
193 position from the center of the rectangle. Angles are specified
194 in degrees (360 is a complete circle). Positive values mean
195 counter-clockwise motion. If @a start is equal to @e end, a
196 complete ellipse will be drawn.
198 void DrawEllipticArc(wxCoord x
, wxCoord y
, wxCoord width
,
204 Draw an icon on the display (does nothing if the device context is PostScript).
205 This can be the simplest way of drawing bitmaps on a window.
207 void DrawIcon(const wxIcon
& icon
, wxCoord x
, wxCoord y
);
210 Draws a line from the first point to the second. The current pen is used
211 for drawing the line.
213 void DrawLine(wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
);
217 Draws lines using an array of @a points of size @e n, or list of
218 pointers to points, adding the optional offset coordinate. The current
219 pen is used for drawing the lines. The programmer is responsible for
220 deleting the list of points.
222 void DrawLines(int n
, wxPoint points
[], wxCoord xoffset
= 0,
223 wxCoord yoffset
= 0);
224 void DrawLines(wxList
* points
, wxCoord xoffset
= 0,
225 wxCoord yoffset
= 0);
229 Draws a point using the current pen.
231 void DrawPoint(wxCoord x
, wxCoord y
);
235 Draws a filled polygon using an array of @a points of size @e n,
236 or list of pointers to points, adding the optional offset coordinate.
237 The last argument specifies the fill rule: @b wxODDEVEN_RULE (the
238 default) or @b wxWINDING_RULE.
239 The current pen is used for drawing the outline, and the current brush
240 for filling the shape. Using a transparent brush suppresses filling.
241 The programmer is responsible for deleting the list of points.
242 Note that wxWindows automatically closes the first and last points.
244 void DrawPolygon(int n
, wxPoint points
[], wxCoord xoffset
= 0,
246 int fill_style
= wxODDEVEN_RULE
);
247 void DrawPolygon(wxList
* points
, wxCoord xoffset
= 0,
249 int fill_style
= wxODDEVEN_RULE
);
253 Draws a rectangle with the given top left corner, and with the given
254 size. The current pen is used for the outline and the current brush
255 for filling the shape.
257 void DrawRectangle(wxCoord x
, wxCoord y
, wxCoord width
,
261 Draws the text rotated by @a angle degrees.
262 The wxMSW wxDC and wxSVGFileDC rotate the text around slightly different
263 points, depending on the size of the font
265 void DrawRotatedText(const wxString
& text
, wxCoord x
, wxCoord y
,
269 Draws a rectangle with the given top left corner, and with the given
270 size. The corners are quarter-circles using the given radius. The
271 current pen is used for the outline and the current brush for filling
273 If @a radius is positive, the value is assumed to be the
274 radius of the rounded corner. If @a radius is negative,
275 the absolute value is assumed to be the @e proportion of the smallest
276 dimension of the rectangle. This means that the corner can be
277 a sensible size relative to the size of the rectangle, and also avoids
278 the strange effects X produces when the corners are too big for
281 void DrawRoundedRectangle(wxCoord x
, wxCoord y
, wxCoord width
,
287 Draws a three-point spline using the current pen.
289 void DrawSpline(wxList
* points
);
290 void DrawSpline(wxCoord x1
, wxCoord y1
, wxCoord x2
,
297 Draws a text string at the specified point, using the current text font,
298 and the current text foreground and background colours.
299 The coordinates refer to the top-left corner of the rectangle bounding
300 the string. See GetTextExtent() for how
301 to get the dimensions of a text string, which can be used to position the
304 void DrawText(const wxString
& text
, wxCoord x
, wxCoord y
);
324 void FloodFill(wxCoord x
, wxCoord y
, const wxColour
& colour
,
325 int style
= wxFLOOD_SURFACE
);
329 Gets the brush used for painting the background (see
330 wxSVGFileDC::SetBackground).
332 wxBrush
GetBackground() const;
333 const wxBrush
GetBackground() const;
337 Returns the current background mode: @c wxSOLID or @c wxTRANSPARENT.
339 @see wxDC::SetBackgroundMode
341 int GetBackgroundMode() const;
345 Gets the current brush (see wxSVGFileDC::SetBrush).
347 wxBrush
GetBrush() const;
348 const wxBrush
GetBrush() const;
352 Gets the character height of the currently set font.
354 wxCoord
GetCharHeight();
357 Gets the average character width of the currently set font.
359 wxCoord
GetCharWidth();
364 void GetClippingBox(wxCoord x
, wxCoord y
, wxCoord width
,
369 Gets the current font (see wxSVGFileDC::SetFont).
371 wxFont
GetFont() const;
372 const wxFont
GetFont() const;
376 Gets the current logical function (see wxSVGFileDC::SetLogicalFunction).
378 int GetLogicalFunction();
381 Gets the @e mapping mode for the device context (see wxSVGFileDC::SetMapMode).
387 Gets the current pen (see wxSVGFileDC::SetPen).
389 wxPen
GetPen() const;
390 const wxPen
GetPen() const;
396 bool GetPixel(wxCoord x
, wxCoord y
, wxColour
* colour
);
399 For a Windows printer device context, this gets the horizontal and vertical
402 void GetSize(wxCoord
* width
, wxCoord
* height
);
406 Gets the current text background colour (see wxSVGFileDC::SetTextBackground).
408 wxColour
GetTextBackground() const;
409 const wxColour
GetTextBackground() const;
413 Gets the dimensions of the string using the currently selected font.
414 @a string is the text string to measure, @a w and @a h are
415 the total width and height respectively, @a descent is the
416 dimension from the baseline of the font to the bottom of the
417 descender, and @a externalLeading is any extra vertical space added
418 to the font by the font designer (usually is zero).
419 The optional parameter @a font specifies an alternative
420 to the currently selected font: but note that this does not
421 yet work under Windows, so you need to set a font for
422 the device context first.
423 See also wxFont, SetFont().
425 void GetTextExtent(const wxString
& string
, wxCoord
* w
,
427 wxCoord
* descent
= NULL
,
428 wxCoord
* externalLeading
= NULL
,
429 wxFont
* font
= NULL
);
433 Gets the current text foreground colour (see wxSVGFileDC::SetTextForeground).
435 wxColour
GetTextForeground() const;
436 const wxColour
GetTextForeground() const;
440 Gets the current user scale factor (set by wxDC::SetUserScale).
442 void GetUserScale(double x
, double y
);
445 Converts logical X coordinate to device coordinate, using the current
448 wxCoord
LogicalToDeviceX(wxCoord x
);
451 Converts logical X coordinate to relative device coordinate, using the current
452 mapping mode but ignoring the x axis orientation.
453 Use this for converting a width, for example.
455 wxCoord
LogicalToDeviceXRel(wxCoord x
);
458 Converts logical Y coordinate to device coordinate, using the current
461 wxCoord
LogicalToDeviceY(wxCoord y
);
464 Converts logical Y coordinate to relative device coordinate, using the current
465 mapping mode but ignoring the y axis orientation.
466 Use this for converting a height, for example.
468 wxCoord
LogicalToDeviceYRel(wxCoord y
);
471 Gets the maximum horizontal extent used in drawing commands so far.
476 Gets the maximum vertical extent used in drawing commands so far.
481 Gets the minimum horizontal extent used in drawing commands so far.
486 Gets the minimum vertical extent used in drawing commands so far.
491 Returns @true if the DC is ok to use; False values arise from being unable to
497 Resets the bounding box: after a call to this function, the bounding box
498 doesn't contain anything.
500 @see wxDC::CalcBoundingBox
502 void ResetBoundingBox();
505 Sets the x and y axis orientation (i.e., the direction from lowest to
506 highest values on the axis). The default orientation is the natural
507 orientation, e.g. x axis from left to right and y axis from bottom up.
510 True to set the x axis orientation to the natural
511 left to right orientation, @false to invert it.
513 True to set the y axis orientation to the natural
514 bottom up orientation, @false to invert it.
516 void SetAxisOrientation(bool xLeftRight
, bool yBottomUp
);
519 Sets the current background brush for the DC.
521 void SetBackground(const wxBrush
& brush
);
524 @a mode may be one of wxSOLID and wxTRANSPARENT. This setting determines
525 whether text will be drawn with a background colour or not.
527 void SetBackgroundMode(int mode
);
530 Sets the current brush for the DC.
531 If the argument is wxNullBrush, the current brush is selected out of the device
532 context, and the original brush restored, allowing the current brush to
535 See also wxMemoryDC for the interpretation of colours
536 when drawing into a monochrome bitmap.
538 void SetBrush(const wxBrush
& brush
);
544 void SetClippingRegion(wxCoord x
, wxCoord y
, wxCoord width
,
546 void SetClippingRegion(const wxPoint
& pt
, const wxSize
& sz
);
547 void SetClippingRegion(const wxRect
& rect
);
548 void SetClippingRegion(const wxRegion
& region
);
552 Sets the device origin (i.e., the origin in pixels after scaling has been
554 This function may be useful in Windows printing
555 operations for placing a graphic on a page.
557 void SetDeviceOrigin(wxCoord x
, wxCoord y
);
560 Sets the current font for the DC. It must be a valid font, in particular you
561 should not pass @c wxNullFont to this method.
564 void SetFont(const wxFont
& font
);
567 Only wxCOPY is avalaible; trying to set one of the othe values will fail
569 void SetLogicalFunction(int function
);
572 The @e mapping mode of the device context defines the unit of
573 measurement used to convert logical units to device units. Note that
574 in X, text drawing isn't handled consistently with the mapping mode; a
575 font is always specified in point size. However, setting the @e user scale (see
576 wxSVGFileDC::SetUserScale) scales the text appropriately. In
577 Windows, scaleable TrueType fonts are always used; in X, results depend
578 on availability of fonts, but usually a reasonable match is found.
579 Note that the coordinate origin should ideally be selectable, but for
580 now is always at the top left of the screen/printer.
581 Drawing to a Windows printer device context under UNIX
582 uses the current mapping mode, but mapping mode is currently ignored for
584 The mapping mode can be one of the following:
588 Each logical unit is 1/20 of a point, or 1/1440 of
593 Each logical unit is a point, or 1/72 of an inch.
597 Each logical unit is 1 mm.
601 Each logical unit is 1/10 of a mm.
605 Each logical unit is 1 pixel.
607 void SetMapMode(int int);
612 void SetPalette(const wxPalette
& palette
);
615 Sets the current pen for the DC.
616 If the argument is wxNullPen, the current pen is selected out of the device
617 context, and the original pen restored.
618 See also wxMemoryDC for the interpretation of colours
619 when drawing into a monochrome bitmap.
621 void SetPen(const wxPen
& pen
);
624 Sets the current text background colour for the DC.
626 void SetTextBackground(const wxColour
& colour
);
629 Sets the current text foreground colour for the DC.
630 See also wxMemoryDC for the interpretation of colours
631 when drawing into a monochrome bitmap.
633 void SetTextForeground(const wxColour
& colour
);
636 Sets the user scaling factor, useful for applications which require
639 void SetUserScale(double xScale
, double yScale
);
644 bool StartDoc(const wxString
& message
);