]>
git.saurik.com Git - wxWidgets.git/blob - interface/dcsvg.h
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 @e f with default size 340x240 at 72.0 dots per inch (a frequent
50 a filename @e f with size @e Width by @e Height at 72.0 dots per inch
51 a filename @e f with size @e Width by @e Height at @e 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.
135 The arc is drawn in an anticlockwise direction from the start point to the end
138 void DrawArc(wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
,
139 wxCoord xc
, wxCoord yc
);
142 Draw a bitmap on the device context at the specified point. If @e transparent
143 is @true and the bitmap has
144 a transparency mask, the bitmap will be drawn transparently.
146 When drawing a mono-bitmap, the current text foreground colour will be used to
148 of the bitmap (all bits set to 1), and the current text background colour to
150 (all bits set to 0). See also wxDC::SetTextForeground,
151 wxDC::SetTextBackground and wxMemoryDC.
153 void DrawBitmap(const wxBitmap
& bitmap
, wxCoord x
, wxCoord y
,
158 Draws a check mark inside the given rectangle.
160 void DrawCheckMark(wxCoord x
, wxCoord y
, wxCoord width
,
162 void DrawCheckMark(const wxRect
& rect
);
167 Draws a circle with the given centre and radius.
169 @sa wxDC::DrawEllipse
171 void DrawCircle(wxCoord x
, wxCoord y
, wxCoord radius
);
172 void DrawCircle(const wxPoint
& pt
, wxCoord radius
);
177 Draws an ellipse contained in the rectangle specified either with the given top
178 left corner and the given size or directly. The current pen is used for the
179 outline and the current brush for filling the shape.
183 void DrawEllipse(wxCoord x
, wxCoord y
, wxCoord width
,
185 void DrawEllipse(const wxPoint
& pt
, const wxSize
& size
);
186 void DrawEllipse(const wxRect
& rect
);
190 Draws an arc of an ellipse. The current pen is used for drawing the arc and
191 the current brush is used for drawing the pie.
193 @e x and @e y specify the x and y coordinates of the upper-left corner of the
194 rectangle that contains
197 @e width and @e height specify the width and height of the rectangle that
201 @e start and @e end specify the start and end of the arc relative to the
203 position from the center of the rectangle. Angles are specified
204 in degrees (360 is a complete circle). Positive values mean
205 counter-clockwise motion. If @e start is equal to @e end, a
206 complete ellipse will be drawn.
208 void DrawEllipticArc(wxCoord x
, wxCoord y
, wxCoord width
,
214 Draw an icon on the display (does nothing if the device context is PostScript).
215 This can be the simplest way of drawing bitmaps on a window.
217 void DrawIcon(const wxIcon
& icon
, wxCoord x
, wxCoord y
);
220 Draws a line from the first point to the second. The current pen is used
221 for drawing the line.
223 void DrawLine(wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
);
227 Draws lines using an array of @e points of size @e n, or list of
228 pointers to points, adding the optional offset coordinate. The current
229 pen is used for drawing the lines. The programmer is responsible for
230 deleting the list of points.
232 void DrawLines(int n
, wxPoint points
[], wxCoord xoffset
= 0,
233 wxCoord yoffset
= 0);
234 void DrawLines(wxList
* points
, wxCoord xoffset
= 0,
235 wxCoord yoffset
= 0);
239 Draws a point using the current pen.
241 void DrawPoint(wxCoord x
, wxCoord y
);
245 Draws a filled polygon using an array of @e points of size @e n,
246 or list of pointers to points, adding the optional offset coordinate.
248 The last argument specifies the fill rule: @b wxODDEVEN_RULE (the
249 default) or @b wxWINDING_RULE.
251 The current pen is used for drawing the outline, and the current brush
252 for filling the shape. Using a transparent brush suppresses filling.
253 The programmer is responsible for deleting the list of points.
255 Note that wxWindows automatically closes the first and last points.
257 void DrawPolygon(int n
, wxPoint points
[], wxCoord xoffset
= 0,
259 int fill_style
= wxODDEVEN_RULE
);
260 void DrawPolygon(wxList
* points
, wxCoord xoffset
= 0,
262 int fill_style
= wxODDEVEN_RULE
);
266 Draws a rectangle with the given top left corner, and with the given
267 size. The current pen is used for the outline and the current brush
268 for filling the shape.
270 void DrawRectangle(wxCoord x
, wxCoord y
, wxCoord width
,
274 Draws the text rotated by @e angle degrees.
276 The wxMSW wxDC and wxSVGFileDC rotate the text around slightly different
277 points, depending on the size of the font
279 void DrawRotatedText(const wxString
& text
, wxCoord x
, wxCoord y
,
283 Draws a rectangle with the given top left corner, and with the given
284 size. The corners are quarter-circles using the given radius. The
285 current pen is used for the outline and the current brush for filling
288 If @e radius is positive, the value is assumed to be the
289 radius of the rounded corner. If @e radius is negative,
290 the absolute value is assumed to be the @e proportion of the smallest
291 dimension of the rectangle. This means that the corner can be
292 a sensible size relative to the size of the rectangle, and also avoids
293 the strange effects X produces when the corners are too big for
296 void DrawRoundedRectangle(wxCoord x
, wxCoord y
, wxCoord width
,
302 Draws a three-point spline using the current pen.
304 void DrawSpline(wxList
* points
);
305 void DrawSpline(wxCoord x1
, wxCoord y1
, wxCoord x2
,
312 Draws a text string at the specified point, using the current text font,
313 and the current text foreground and background colours.
315 The coordinates refer to the top-left corner of the rectangle bounding
316 the string. See GetTextExtent() for how
317 to get the dimensions of a text string, which can be used to position the
320 void DrawText(const wxString
& text
, wxCoord x
, wxCoord y
);
340 void FloodFill(wxCoord x
, wxCoord y
, const wxColour
& colour
,
341 int style
=wxFLOOD_SURFACE
);
345 Gets the brush used for painting the background (see
346 wxSVGFileDC::SetBackground).
348 wxBrush
GetBackground();
349 const wxBrush
GetBackground();
353 Returns the current background mode: @c wxSOLID or @c wxTRANSPARENT.
355 @sa wxDC::SetBackgroundMode
357 int GetBackgroundMode();
361 Gets the current brush (see wxSVGFileDC::SetBrush).
364 const wxBrush
GetBrush();
368 Gets the character height of the currently set font.
370 wxCoord
GetCharHeight();
373 Gets the average character width of the currently set font.
375 wxCoord
GetCharWidth();
380 void GetClippingBox(wxCoord x
, wxCoord y
, wxCoord width
,
385 Gets the current font (see wxSVGFileDC::SetFont).
388 const wxFont
GetFont();
392 Gets the current logical function (see wxSVGFileDC::SetLogicalFunction).
394 int GetLogicalFunction();
397 Gets the @e mapping mode for the device context (see wxSVGFileDC::SetMapMode).
403 Gets the current pen (see wxSVGFileDC::SetPen).
406 const wxPen
GetPen();
412 bool GetPixel(wxCoord x
, wxCoord y
, wxColour
* colour
);
415 For a Windows printer device context, this gets the horizontal and vertical
418 void GetSize(wxCoord
* width
, wxCoord
* height
);
422 Gets the current text background colour (see wxSVGFileDC::SetTextBackground).
424 wxColour
GetTextBackground();
425 const wxColour
GetTextBackground();
429 Gets the dimensions of the string using the currently selected font.
430 @e string is the text string to measure, @e w and @e h are
431 the total width and height respectively, @e descent is the
432 dimension from the baseline of the font to the bottom of the
433 descender, and @e externalLeading is any extra vertical space added
434 to the font by the font designer (usually is zero).
436 The optional parameter @e font specifies an alternative
437 to the currently selected font: but note that this does not
438 yet work under Windows, so you need to set a font for
439 the device context first.
441 See also wxFont, SetFont().
443 void GetTextExtent(const wxString
& string
, wxCoord
* w
,
445 wxCoord
* descent
= @NULL
,
446 wxCoord
* externalLeading
= @NULL
,
447 wxFont
* font
= @NULL
);
451 Gets the current text foreground colour (see wxSVGFileDC::SetTextForeground).
453 wxColour
GetTextForeground();
454 const wxColour
GetTextForeground();
458 Gets the current user scale factor (set by wxDC::SetUserScale).
460 void GetUserScale(double x
, double y
);
463 Converts logical X coordinate to device coordinate, using the current
466 wxCoord
LogicalToDeviceX(wxCoord x
);
469 Converts logical X coordinate to relative device coordinate, using the current
470 mapping mode but ignoring the x axis orientation.
471 Use this for converting a width, for example.
473 wxCoord
LogicalToDeviceXRel(wxCoord x
);
476 Converts logical Y coordinate to device coordinate, using the current
479 wxCoord
LogicalToDeviceY(wxCoord y
);
482 Converts logical Y coordinate to relative device coordinate, using the current
483 mapping mode but ignoring the y axis orientation.
484 Use this for converting a height, for example.
486 wxCoord
LogicalToDeviceYRel(wxCoord y
);
489 Gets the maximum horizontal extent used in drawing commands so far.
491 #define wxCoord MaxX() /* implementation is private */
494 Gets the maximum vertical extent used in drawing commands so far.
496 #define wxCoord MaxY() /* implementation is private */
499 Gets the minimum horizontal extent used in drawing commands so far.
501 #define wxCoord MinX() /* implementation is private */
504 Gets the minimum vertical extent used in drawing commands so far.
506 #define wxCoord MinY() /* implementation is private */
509 Returns @true if the DC is ok to use; False values arise from being unable to
512 #define bool Ok() /* implementation is private */
515 Resets the bounding box: after a call to this function, the bounding box
516 doesn't contain anything.
518 @sa wxDC::CalcBoundingBox
520 void ResetBoundingBox();
523 Sets the x and y axis orientation (i.e., the direction from lowest to
524 highest values on the axis). The default orientation is the natural
525 orientation, e.g. x axis from left to right and y axis from bottom up.
528 True to set the x axis orientation to the natural
529 left to right orientation, @false to invert it.
532 True to set the y axis orientation to the natural
533 bottom up orientation, @false to invert it.
535 void SetAxisOrientation(bool xLeftRight
, bool yBottomUp
);
538 Sets the current background brush for the DC.
540 void SetBackground(const wxBrush
& brush
);
543 @e mode may be one of wxSOLID and wxTRANSPARENT. This setting determines
544 whether text will be drawn with a background colour or not.
546 void SetBackgroundMode(int mode
);
549 Sets the current brush for the DC.
551 If the argument is wxNullBrush, the current brush is selected out of the device
552 context, and the original brush restored, allowing the current brush to
557 See also wxMemoryDC for the interpretation of colours
558 when drawing into a monochrome bitmap.
560 void SetBrush(const wxBrush
& brush
);
566 void SetClippingRegion(wxCoord x
, wxCoord y
, wxCoord width
,
568 void SetClippingRegion(const wxPoint
& pt
, const wxSize
& sz
);
569 void SetClippingRegion(const wxRect
& rect
);
570 void SetClippingRegion(const wxRegion
& region
);
574 Sets the device origin (i.e., the origin in pixels after scaling has been
577 This function may be useful in Windows printing
578 operations for placing a graphic on a page.
580 void SetDeviceOrigin(wxCoord x
, wxCoord y
);
583 Sets the current font for the DC. It must be a valid font, in particular you
584 should not pass @c wxNullFont to this method.
588 void SetFont(const wxFont
& font
);
591 Only wxCOPY is avalaible; trying to set one of the othe values will fail
593 void SetLogicalFunction(int function
);
596 The @e mapping mode of the device context defines the unit of
597 measurement used to convert logical units to device units. Note that
598 in X, text drawing isn't handled consistently with the mapping mode; a
599 font is always specified in point size. However, setting the @e user scale (see
600 wxSVGFileDC::SetUserScale) scales the text appropriately. In
601 Windows, scaleable TrueType fonts are always used; in X, results depend
602 on availability of fonts, but usually a reasonable match is found.
604 Note that the coordinate origin should ideally be selectable, but for
605 now is always at the top left of the screen/printer.
607 Drawing to a Windows printer device context under UNIX
608 uses the current mapping mode, but mapping mode is currently ignored for
611 The mapping mode can be one of the following:
616 Each logical unit is 1/20 of a point, or 1/1440 of
622 Each logical unit is a point, or 1/72 of an inch.
627 Each logical unit is 1 mm.
632 Each logical unit is 1/10 of a mm.
637 Each logical unit is 1 pixel.
639 void SetMapMode(int int);
644 void SetPalette(const wxPalette
& palette
);
647 Sets the current pen for the DC.
649 If the argument is wxNullPen, the current pen is selected out of the device
650 context, and the original pen restored.
652 See also wxMemoryDC for the interpretation of colours
653 when drawing into a monochrome bitmap.
655 void SetPen(const wxPen
& pen
);
658 Sets the current text background colour for the DC.
660 void SetTextBackground(const wxColour
& colour
);
663 Sets the current text foreground colour for the DC.
665 See also wxMemoryDC for the interpretation of colours
666 when drawing into a monochrome bitmap.
668 void SetTextForeground(const wxColour
& colour
);
671 Sets the user scaling factor, useful for applications which require
674 void SetUserScale(double xScale
, double yScale
);
679 bool StartDoc(const wxString
& message
);