]>
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 @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
41 class wxSVGFileDC
: public wxDC
47 a filename @a f with default size 340x240 at 72.0 dots per inch (a frequent
49 a filename @a f with size @a Width by @a Height at 72.0 dots per inch
50 a filename @a f with size @a Width by @a Height at @a dpi resolution.
52 wxSVGFileDC(wxString f
);
53 wxSVGFileDC(wxString f
, int Width
, int Height
);
54 wxSVGFileDC(wxString f
, int Width
, int Height
, float dpi
);
68 As wxDC: Copy from a source DC to this DC, specifying the destination
69 coordinates, size of area to copy, source DC, source coordinates,
70 logical function, whether to use a bitmap mask, and mask source position.
72 bool Blit(wxCoord xdest
, wxCoord ydest
, wxCoord width
,
73 wxCoord height
, wxSVGFileDC
* source
,
74 wxCoord xsrc
, wxCoord ysrc
,
75 int logicalFunc
= wxCOPY
,
77 wxCoord xsrcMask
= -1,
78 wxCoord ysrcMask
= -1);
81 Adds the specified point to the bounding box which can be retrieved with
82 wxDC::MinX, wxDC::MaxX and
83 wxDC::MinY, wxDC::MaxY functions.
85 void CalcBoundingBox(wxCoord x
, wxCoord y
);
88 This makes no sense in wxSVGFileDC and does nothing
95 void CrossHair(wxCoord x
, wxCoord y
);
100 void DestroyClippingRegion();
103 Convert device X coordinate to logical coordinate, using the current
106 wxCoord
DeviceToLogicalX(wxCoord x
);
109 Convert device X coordinate to relative logical coordinate, using the current
110 mapping mode but ignoring the x axis orientation.
111 Use this function for converting a width, for example.
113 wxCoord
DeviceToLogicalXRel(wxCoord x
);
116 Converts device Y coordinate to logical coordinate, using the current
119 wxCoord
DeviceToLogicalY(wxCoord y
);
122 Convert device Y coordinate to relative logical coordinate, using the current
123 mapping mode but ignoring the y axis orientation.
124 Use this function for converting a height, for example.
126 wxCoord
DeviceToLogicalYRel(wxCoord y
);
129 Draws an arc of a circle, centred on (@e xc, yc), with starting point (@e x1,
131 and ending at (@e x2, y2). The current pen is used for the outline
132 and the current brush for filling the shape.
133 The arc is drawn in an anticlockwise direction from the start point to the end
136 void DrawArc(wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
,
137 wxCoord xc
, wxCoord yc
);
140 Draw a bitmap on the device context at the specified point. If @a transparent
141 is @true and the bitmap has
142 a transparency mask, the bitmap will be drawn transparently.
143 When drawing a mono-bitmap, the current text foreground colour will be used to
145 of the bitmap (all bits set to 1), and the current text background colour to
147 (all bits set to 0). See also wxDC::SetTextForeground,
148 wxDC::SetTextBackground and wxMemoryDC.
150 void DrawBitmap(const wxBitmap
& bitmap
, wxCoord x
, wxCoord y
,
155 Draws a check mark inside the given rectangle.
157 void DrawCheckMark(wxCoord x
, wxCoord y
, wxCoord width
,
159 void DrawCheckMark(const wxRect
& rect
);
164 Draws a circle with the given centre and radius.
166 @see wxDC::DrawEllipse
168 void DrawCircle(wxCoord x
, wxCoord y
, wxCoord radius
);
169 void DrawCircle(const wxPoint
& pt
, wxCoord radius
);
174 Draws an ellipse contained in the rectangle specified either with the given top
175 left corner and the given size or directly. The current pen is used for the
176 outline and the current brush for filling the shape.
178 @see wxDC::DrawCircle
180 void DrawEllipse(wxCoord x
, wxCoord y
, wxCoord width
,
182 void DrawEllipse(const wxPoint
& pt
, const wxSize
& size
);
183 void DrawEllipse(const wxRect
& rect
);
187 Draws an arc of an ellipse. The current pen is used for drawing the arc and
188 the current brush is used for drawing the pie.
189 @a x and @a y specify the x and y coordinates of the upper-left corner of the
190 rectangle that contains
192 @a width and @a height specify the width and height of the rectangle that
195 @a start and @a end specify the start and end of the arc relative to the
197 position from the center of the rectangle. Angles are specified
198 in degrees (360 is a complete circle). Positive values mean
199 counter-clockwise motion. If @a start is equal to @e end, a
200 complete ellipse will be drawn.
202 void DrawEllipticArc(wxCoord x
, wxCoord y
, wxCoord width
,
208 Draw an icon on the display (does nothing if the device context is PostScript).
209 This can be the simplest way of drawing bitmaps on a window.
211 void DrawIcon(const wxIcon
& icon
, wxCoord x
, wxCoord y
);
214 Draws a line from the first point to the second. The current pen is used
215 for drawing the line.
217 void DrawLine(wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
);
221 Draws lines using an array of @a points of size @e n, or list of
222 pointers to points, adding the optional offset coordinate. The current
223 pen is used for drawing the lines. The programmer is responsible for
224 deleting the list of points.
226 void DrawLines(int n
, wxPoint points
[], wxCoord xoffset
= 0,
227 wxCoord yoffset
= 0);
228 void DrawLines(wxList
* points
, wxCoord xoffset
= 0,
229 wxCoord yoffset
= 0);
233 Draws a point using the current pen.
235 void DrawPoint(wxCoord x
, wxCoord y
);
239 Draws a filled polygon using an array of @a points of size @e n,
240 or list of pointers to points, adding the optional offset coordinate.
241 The last argument specifies the fill rule: @b wxODDEVEN_RULE (the
242 default) or @b wxWINDING_RULE.
243 The current pen is used for drawing the outline, and the current brush
244 for filling the shape. Using a transparent brush suppresses filling.
245 The programmer is responsible for deleting the list of points.
246 Note that wxWindows automatically closes the first and last points.
248 void DrawPolygon(int n
, wxPoint points
[], wxCoord xoffset
= 0,
250 int fill_style
= wxODDEVEN_RULE
);
251 void DrawPolygon(wxList
* points
, wxCoord xoffset
= 0,
253 int fill_style
= wxODDEVEN_RULE
);
257 Draws a rectangle with the given top left corner, and with the given
258 size. The current pen is used for the outline and the current brush
259 for filling the shape.
261 void DrawRectangle(wxCoord x
, wxCoord y
, wxCoord width
,
265 Draws the text rotated by @a angle degrees.
266 The wxMSW wxDC and wxSVGFileDC rotate the text around slightly different
267 points, depending on the size of the font
269 void DrawRotatedText(const wxString
& text
, wxCoord x
, wxCoord y
,
273 Draws a rectangle with the given top left corner, and with the given
274 size. The corners are quarter-circles using the given radius. The
275 current pen is used for the outline and the current brush for filling
277 If @a radius is positive, the value is assumed to be the
278 radius of the rounded corner. If @a radius is negative,
279 the absolute value is assumed to be the @e proportion of the smallest
280 dimension of the rectangle. This means that the corner can be
281 a sensible size relative to the size of the rectangle, and also avoids
282 the strange effects X produces when the corners are too big for
285 void DrawRoundedRectangle(wxCoord x
, wxCoord y
, wxCoord width
,
291 Draws a three-point spline using the current pen.
293 void DrawSpline(wxList
* points
);
294 void DrawSpline(wxCoord x1
, wxCoord y1
, wxCoord x2
,
301 Draws a text string at the specified point, using the current text font,
302 and the current text foreground and background colours.
303 The coordinates refer to the top-left corner of the rectangle bounding
304 the string. See GetTextExtent() for how
305 to get the dimensions of a text string, which can be used to position the
308 void DrawText(const wxString
& text
, wxCoord x
, wxCoord y
);
328 void FloodFill(wxCoord x
, wxCoord y
, const wxColour
& colour
,
329 int style
= wxFLOOD_SURFACE
);
333 Gets the brush used for painting the background (see
334 wxSVGFileDC::SetBackground).
336 wxBrush
GetBackground() const;
337 const wxBrush
GetBackground() const;
341 Returns the current background mode: @c wxSOLID or @c wxTRANSPARENT.
343 @see wxDC::SetBackgroundMode
345 int GetBackgroundMode() const;
349 Gets the current brush (see wxSVGFileDC::SetBrush).
351 wxBrush
GetBrush() const;
352 const wxBrush
GetBrush() const;
356 Gets the character height of the currently set font.
358 wxCoord
GetCharHeight();
361 Gets the average character width of the currently set font.
363 wxCoord
GetCharWidth();
368 void GetClippingBox(wxCoord x
, wxCoord y
, wxCoord width
,
373 Gets the current font (see wxSVGFileDC::SetFont).
375 wxFont
GetFont() const;
376 const wxFont
GetFont() const;
380 Gets the current logical function (see wxSVGFileDC::SetLogicalFunction).
382 int GetLogicalFunction();
385 Gets the @e mapping mode for the device context (see wxSVGFileDC::SetMapMode).
391 Gets the current pen (see wxSVGFileDC::SetPen).
393 wxPen
GetPen() const;
394 const wxPen
GetPen() const;
400 bool GetPixel(wxCoord x
, wxCoord y
, wxColour
* colour
);
403 For a Windows printer device context, this gets the horizontal and vertical
406 void GetSize(wxCoord
* width
, wxCoord
* height
);
410 Gets the current text background colour (see wxSVGFileDC::SetTextBackground).
412 wxColour
GetTextBackground() const;
413 const wxColour
GetTextBackground() const;
417 Gets the dimensions of the string using the currently selected font.
418 @a string is the text string to measure, @a w and @a h are
419 the total width and height respectively, @a descent is the
420 dimension from the baseline of the font to the bottom of the
421 descender, and @a externalLeading is any extra vertical space added
422 to the font by the font designer (usually is zero).
423 The optional parameter @a font specifies an alternative
424 to the currently selected font: but note that this does not
425 yet work under Windows, so you need to set a font for
426 the device context first.
427 See also wxFont, SetFont().
429 void GetTextExtent(const wxString
& string
, wxCoord
* w
,
431 wxCoord
* descent
= NULL
,
432 wxCoord
* externalLeading
= NULL
,
433 wxFont
* font
= NULL
);
437 Gets the current text foreground colour (see wxSVGFileDC::SetTextForeground).
439 wxColour
GetTextForeground() const;
440 const wxColour
GetTextForeground() const;
444 Gets the current user scale factor (set by wxDC::SetUserScale).
446 void GetUserScale(double x
, double y
);
449 Converts logical X coordinate to device coordinate, using the current
452 wxCoord
LogicalToDeviceX(wxCoord x
);
455 Converts logical X coordinate to relative device coordinate, using the current
456 mapping mode but ignoring the x axis orientation.
457 Use this for converting a width, for example.
459 wxCoord
LogicalToDeviceXRel(wxCoord x
);
462 Converts logical Y coordinate to device coordinate, using the current
465 wxCoord
LogicalToDeviceY(wxCoord y
);
468 Converts logical Y coordinate to relative device coordinate, using the current
469 mapping mode but ignoring the y axis orientation.
470 Use this for converting a height, for example.
472 wxCoord
LogicalToDeviceYRel(wxCoord y
);
475 Gets the maximum horizontal extent used in drawing commands so far.
480 Gets the maximum vertical extent used in drawing commands so far.
485 Gets the minimum horizontal extent used in drawing commands so far.
490 Gets the minimum vertical extent used in drawing commands so far.
495 Returns @true if the DC is ok to use; False values arise from being unable to
501 Resets the bounding box: after a call to this function, the bounding box
502 doesn't contain anything.
504 @see wxDC::CalcBoundingBox
506 void ResetBoundingBox();
509 Sets the x and y axis orientation (i.e., the direction from lowest to
510 highest values on the axis). The default orientation is the natural
511 orientation, e.g. x axis from left to right and y axis from bottom up.
514 True to set the x axis orientation to the natural
515 left to right orientation, @false to invert it.
517 True to set the y axis orientation to the natural
518 bottom up orientation, @false to invert it.
520 void SetAxisOrientation(bool xLeftRight
, bool yBottomUp
);
523 Sets the current background brush for the DC.
525 void SetBackground(const wxBrush
& brush
);
528 @a mode may be one of wxSOLID and wxTRANSPARENT. This setting determines
529 whether text will be drawn with a background colour or not.
531 void SetBackgroundMode(int mode
);
534 Sets the current brush for the DC.
535 If the argument is wxNullBrush, the current brush is selected out of the device
536 context, and the original brush restored, allowing the current brush to
539 See also wxMemoryDC for the interpretation of colours
540 when drawing into a monochrome bitmap.
542 void SetBrush(const wxBrush
& brush
);
548 void SetClippingRegion(wxCoord x
, wxCoord y
, wxCoord width
,
550 void SetClippingRegion(const wxPoint
& pt
, const wxSize
& sz
);
551 void SetClippingRegion(const wxRect
& rect
);
552 void SetClippingRegion(const wxRegion
& region
);
556 Sets the device origin (i.e., the origin in pixels after scaling has been
558 This function may be useful in Windows printing
559 operations for placing a graphic on a page.
561 void SetDeviceOrigin(wxCoord x
, wxCoord y
);
564 Sets the current font for the DC. It must be a valid font, in particular you
565 should not pass @c wxNullFont to this method.
568 void SetFont(const wxFont
& font
);
571 Only wxCOPY is avalaible; trying to set one of the othe values will fail
573 void SetLogicalFunction(int function
);
576 The @e mapping mode of the device context defines the unit of
577 measurement used to convert logical units to device units. Note that
578 in X, text drawing isn't handled consistently with the mapping mode; a
579 font is always specified in point size. However, setting the @e user scale (see
580 wxSVGFileDC::SetUserScale) scales the text appropriately. In
581 Windows, scaleable TrueType fonts are always used; in X, results depend
582 on availability of fonts, but usually a reasonable match is found.
583 Note that the coordinate origin should ideally be selectable, but for
584 now is always at the top left of the screen/printer.
585 Drawing to a Windows printer device context under UNIX
586 uses the current mapping mode, but mapping mode is currently ignored for
588 The mapping mode can be one of the following:
592 Each logical unit is 1/20 of a point, or 1/1440 of
597 Each logical unit is a point, or 1/72 of an inch.
601 Each logical unit is 1 mm.
605 Each logical unit is 1/10 of a mm.
609 Each logical unit is 1 pixel.
611 void SetMapMode(int int);
616 void SetPalette(const wxPalette
& palette
);
619 Sets the current pen for the DC.
620 If the argument is wxNullPen, the current pen is selected out of the device
621 context, and the original pen restored.
622 See also wxMemoryDC for the interpretation of colours
623 when drawing into a monochrome bitmap.
625 void SetPen(const wxPen
& pen
);
628 Sets the current text background colour for the DC.
630 void SetTextBackground(const wxColour
& colour
);
633 Sets the current text foreground colour for the DC.
634 See also wxMemoryDC for the interpretation of colours
635 when drawing into a monochrome bitmap.
637 void SetTextForeground(const wxColour
& colour
);
640 Sets the user scaling factor, useful for applications which require
643 void SetUserScale(double xScale
, double yScale
);
648 bool StartDoc(const wxString
& message
);