Class: Wx::SVGFileDC

Inherits:
DC show all
Defined in:
lib/wx/doc/gen/svg_file_dc.rb,
lib/wx/doc/svg_file_dc.rb

Overview

Note:

This class is untracked and should not be derived from nor instances extended!

A SVGFileDC is a device context onto which graphics and text can be drawn, and the output produced as a vector file, in SVG format.

This format can be read by a range of programs, including most web browsers and the open source Inkscape program (https://inkscape.org/). Full details are given in the W3C SVG recommendation (https://www.w3.org/TR/SVG/). The intention behind SVGFileDC is that it can be used to produce a file corresponding to the screen display context, SVGFileDC, by passing the SVGFileDC as a parameter instead of a DC. Thus the SVGFileDC is a write-only class. Starting with wxWidgets 3.3.3, SVGFileDC provides integrated support for GraphicsContext. By calling #get_graphics_context, you can access a SVGGraphicsContext which supports advanced vector features such as:

  • Cubic and quadratic Bézier curves via GraphicsPath.
  • Linear and radial gradient brushes.
  • Semi-transparent colors and alpha blending.
  • Arbitrary affine transformations.

As the SVGFileDC is a vector format, raster operations like DC#get_pixel are unlikely to be supported. However, the SVG specification allows for raster files to be embedded in the SVG, and so bitmaps, icons and blit operations in SVGFileDC are supported. By default only PNG format bitmaps are supported and these are saved as separate files in the same folder as the SVG file, however it is possible to change this behaviour by replacing the built in bitmap handler using #set_bitmap_handler. More substantial SVG libraries (for reading and writing) are available at Art2D and SVG.

Category: Device Contexts

Requires:

  • USE_SVG

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from DC

#are_automatic_bounding_box_updates_enabled, #blit, #calc_bounding_box, #copy_attributes, #cross_hair, #destroy_clipping_region, #disable_automatic_bounding_box_updates, #draw_arc, #draw_bitmap, #draw_check_mark, #draw_circle, #draw_ellipse, #draw_elliptic_arc, #draw_icon, #draw_label, #draw_line, #draw_lines, #draw_point, #draw_poly_polygon, #draw_polygon, #draw_rectangle, #draw_rotated_text, #draw_rounded_rectangle, #draw_spline, #draw_text, #end_doc, #end_page, #flood_fill, #get_as_bitmap, #get_background, #get_background_mode, #get_brush, #get_clipping_box, #get_logical_function, #get_pen, #get_pixel, #get_text_background, #get_text_foreground, #gradient_fill_concentric, #gradient_fill_linear, #max_x, #max_y, #min_x, #min_y, #reset_bounding_box, #set_background, #set_background_mode, #set_brush, #set_clipping_region, #set_device_clipping_region, #set_graphics_context, #set_logical_function, #set_palette, #set_pen, #set_text_background, #set_text_foreground, #start_doc, #start_page, #stretch_blit, #with_background_mode, #with_brush, #with_font, #with_pen, #with_text_background, #with_text_foreground

Methods inherited from ReadOnlyDC

#can_draw_bitmap, #can_get_text_extent, #can_use_transform_matrix, #device_to_logical, #device_to_logical_rel, #device_to_logical_x, #device_to_logical_x_rel, #device_to_logical_y, #device_to_logical_y_rel, #from_dip, #get_char_height, #get_char_width, #get_content_scale_factor, #get_depth, #get_device_origin, #get_dimensions, #get_dimensions_mm, #get_font, #get_font_metrics, #get_layout_direction, #get_logical_origin, #get_logical_scale, #get_map_mode, #get_multi_line_text_extent, #get_multi_line_text_size, #get_ppi, #get_size, #get_size_mm, #get_text_extent, #get_text_size, #get_transform_matrix, #get_user_scale, #is_ok, #logical_to_device, #logical_to_device_rel, #logical_to_device_x, #logical_to_device_x_rel, #logical_to_device_y, #logical_to_device_y_rel, #reset_transform_matrix, #set_axis_orientation, #set_device_origin, #set_font, #set_layout_direction, #set_logical_origin, #set_logical_scale, #set_map_mode, #set_transform_matrix, #set_user_scale, #to_dip

Methods inherited from Object

#clone, #dup, #initialize, #is_same_as, #un_share

Constructor Details

This class inherits a constructor from Wx::Object

Class Method Details

.draw_on(filename, width = 320, height = 240, dpi = 72, title = '') {|dc| ... } ⇒ ::Object

Executes the given block providing a temporary dc as it's single argument. Initializes a wxSVGFileDC with the given filename, width and height at dpi resolution, and an optional title. The title provides a readable name for the SVG document.

Parameters:

  • filename (String)

    name of file to create

  • width (Integer) (defaults to: 320)

    width for SVG image

  • height (Integer) (defaults to: 240)

    height for SVG image

  • dpi (Float) (defaults to: 72)

    resolution for SVG image

  • title (String) (defaults to: '')

    readable name for the SVG document

Yield Parameters:

Returns:

  • (::Object)

    result of the block



22
# File 'lib/wx/doc/svg_file_dc.rb', line 22

def self.draw_on(filename, width=320, height=240, dpi=72, title='') end

Instance Method Details

#begin_accessible_group(attributes, title = (''), desc = ('')) ⇒ void

This method returns an undefined value.

Opens an accessible group wrapping all subsequent drawing until the matching #end_accessible_group call.

The group is emitted as an SVG element carrying the given attributes, optionally followed by and children supplying an accessible name and long description. Prefer Wx::SVGAccessibleGroup for RAII-style scoping, which guarantees #end_accessible_group is called on scope exit.

Parameters:

  • attributes (Wx::SVGAttributes)
  • title (String) (defaults to: (''))
  • desc (String) (defaults to: (''))


97
# File 'lib/wx/doc/gen/svg_file_dc.rb', line 97

def begin_accessible_group(attributes, title=(''), desc=('')) end

#begin_layer(opacity) ⇒ void

This method returns an undefined value.

Opens a new layer with the given opacity.

All drawing commands until the matching #end_layer call will be composited with this opacity. Layers can be nested.

Parameters:

  • opacity (Float)


108
# File 'lib/wx/doc/gen/svg_file_dc.rb', line 108

def begin_layer(opacity) end

#clearvoid

This method returns an undefined value.

Draws a rectangle the size of the SVG using the DC#set_background brush.



65
# File 'lib/wx/doc/gen/svg_file_dc.rb', line 65

def clear; end

#end_accessible_groupvoid

This method returns an undefined value.

Closes the accessible group opened by the most recent #begin_accessible_group call.



101
# File 'lib/wx/doc/gen/svg_file_dc.rb', line 101

def end_accessible_group; end

#end_layervoid

This method returns an undefined value.

Closes the layer opened by the most recent #begin_layer call.



112
# File 'lib/wx/doc/gen/svg_file_dc.rb', line 112

def end_layer; end

#get_graphics_contextWx::GraphicsContext Also known as: graphics_context

Returns the graphics context associated with this DC.

The returned object is a Wx::SVGGraphicsContext instance. While Wx::SVGFileDC provides standard DC drawing methods, retrieving the GraphicsContext allows using more advanced drawing features that are not available in the base DC API, such as:

  • Complex paths including cubic and quadratic Bézier curves.
  • Linear and radial gradient brushes.
  • Transparency and alpha blending for all drawing operations.
  • Advanced coordinate transformations (scaling, rotation, skewing) applied to groups of objects.

Note that any state changes (pen, brush, font) made to the returned context are mirrored back to the DC, and vice versa.

Returns:



139
# File 'lib/wx/doc/gen/svg_file_dc.rb', line 139

def get_graphics_context; end

#get_svg_documentString Also known as: svg_document

Returns the SVG document as a string.

This can be used to retrieve the generated SVG content regardless of whether it was also written to a file. This can be called after all drawing commands to get the current SVG content.

Returns:

  • (String)


118
# File 'lib/wx/doc/gen/svg_file_dc.rb', line 118

def get_svg_document; end

#saveBoolean

Saves the SVG document to the file specified in the constructor.

This is called automatically by the destructor if a filename was provided, but calling it explicitly allows checking for errors. Does nothing if no filename was provided or if the file has already been saved. true if the file was written successfully, false otherwise.

Returns:

  • (Boolean)


126
# File 'lib/wx/doc/gen/svg_file_dc.rb', line 126

def save; end

#set_bitmap_handler(handler) ⇒ void Also known as: bitmap_handler=

This method returns an undefined value.

Replaces the default bitmap handler with handler.

By default, an object of Wx::SVGBitmapFileHandler class is used as bitmap handler. You may want to replace it with an object of predefined Wx::SVGBitmapEmbedHandler class to embed the bitmaps in the generated SVG instead of storing them in separate files like this:

  mySVGFileDC.set_bitmap_handler(Wx::SVGBitmapEmbedHandler.new)

or derive your own bitmap handler class and use it if you need to customize the bitmap handling further.

Parameters:

  • handler (Wx::SVGBitmapHandler)

    The new bitmap handler. If non-null, this object takes ownership of this handler and will delete it when it is not needed any more.



77
# File 'lib/wx/doc/gen/svg_file_dc.rb', line 77

def set_bitmap_handler(handler) end

#set_shape_rendering_mode(renderingMode) ⇒ void Also known as: shape_rendering_mode=

This method returns an undefined value.

Set the shape rendering mode of the generated SVG.

All subsequent drawing calls will have this rendering mode set in the SVG file. The default mode is Wx::SVGShapeRenderingMode::SVG_SHAPE_RENDERING_AUTO.

Parameters:



86
# File 'lib/wx/doc/gen/svg_file_dc.rb', line 86

def set_shape_rendering_mode(renderingMode) end