Class: Wx::BufferedDC

Inherits:
MemoryDC show all
Defined in:
lib/wx/doc/gen/memory_dc.rb,
lib/wx/doc/memory_dc.rb

Overview

Note:

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

This class provides a simple way to avoid flicker: when drawing on it, everything is in fact first drawn on an in-memory buffer (a Bitmap) and then copied to the screen, using the associated DC, only once, when this object is destroyed.

BufferedDC itself is typically associated with ClientDC, if you want to use it in your EVT_PAINT handler, you should look at BufferedPaintDC instead. When used like this, a valid DC must be specified in the constructor while the buffer bitmap doesn’t have to be explicitly provided, by default this class will allocate the bitmap of required size itself. However using a dedicated bitmap can speed up the redrawing process by eliminating the repeated creation and destruction of a possibly big bitmap. Otherwise, BufferedDC can be used in the same way as any other device context. Another possible use for BufferedDC is to use it to maintain a backing store for the window contents. In this case, the associated DC may be NULL but a valid backing store bitmap should be specified. Finally, please note that GTK+ 2.0 as well as macOS provide double buffering themselves natively. You can either use Window#is_double_buffered to determine whether you need to use buffering or not, or use AutoBufferedPaintDC to avoid needless double buffering on the systems which already do it automatically.

Category: Device Contexts

Direct Known Subclasses

BufferedPaintDC

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from MemoryDC

#get_selected_bitmap, #select_object, #select_object_as_source

Methods inherited from DC

#blit, #calc_bounding_box, #can_draw_bitmap, #can_get_text_extent, #can_use_transform_matrix, #clear, #copy_attributes, #cross_hair, #destroy_clipping_region, #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, #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, #from_dip, #get_as_bitmap, #get_background, #get_background_mode, #get_brush, #get_char_height, #get_char_width, #get_clipping_box, #get_content_scale_factor, #get_depth, #get_device_origin, #get_dimensions, #get_dimensions_mm, #get_font, #get_font_metrics, #get_graphics_context, #get_layout_direction, #get_logical_function, #get_logical_origin, #get_logical_scale, #get_map_mode, #get_multi_line_text_extent, #get_multi_line_text_size, #get_pen, #get_pixel, #get_ppi, #get_size, #get_size_mm, #get_text_background, #get_text_extent, #get_text_foreground, #get_text_size, #get_transform_matrix, #get_user_scale, #gradient_fill_concentric, #gradient_fill_linear, #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, #max_x, #max_y, #min_x, #min_y, #reset_bounding_box, #reset_transform_matrix, #set_axis_orientation, #set_background, #set_background_mode, #set_brush, #set_clipping_region, #set_device_clipping_region, #set_device_origin, #set_font, #set_graphics_context, #set_layout_direction, #set_logical_function, #set_logical_origin, #set_logical_scale, #set_map_mode, #set_palette, #set_pen, #set_text_background, #set_text_foreground, #set_transform_matrix, #set_user_scale, #start_doc, #start_page, #stretch_blit, #to_dip, #with_background_mode, #with_brush, #with_font, #with_pen, #with_text_background, #with_text_foreground

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

.self.draw_on {|dc| ... } ⇒ Object .self.draw_on(tgt, area, style = Wx::BUFFER_CLIENT_AREA) {|dc| ... } ⇒ Object .self.draw_on(tgt, buffer = Wx::NULL_BITMAP, style = Wx::BUFFER_CLIENT_AREA) {|dc| ... } ⇒ Object

Creates a Buffered DC and passes that to the given block to draw on. Destroys the DC after the block returns.

Overloads:

  • .self.draw_on {|dc| ... } ⇒ Object

    Creates a buffer for the provided dc.

    Yield Parameters:

  • .self.draw_on(tgt, area, style = Wx::BUFFER_CLIENT_AREA) {|dc| ... } ⇒ Object

    Creates a buffer for the provided dc. #init must not be called when using this constructor.

    Parameters:

    • tgt (Wx::DC)

      The underlying DC: everything drawn to this object will be flushed to this DC when this object is destroyed. You may pass nil in order to just initialize the buffer, and not flush it.

    • area (Wx::Size)

      The size of the bitmap to be used for buffering (this bitmap is created internally when it is not given explicitly).

    • style (Integer) (defaults to: Wx::BUFFER_CLIENT_AREA)

      Wx::BUFFER_CLIENT_AREA to indicate that just the client area of the window is buffered, or Wx::BUFFER_VIRTUAL_AREA to indicate that the buffer bitmap covers the virtual area.

    Yield Parameters:

  • .self.draw_on(tgt, buffer = Wx::NULL_BITMAP, style = Wx::BUFFER_CLIENT_AREA) {|dc| ... } ⇒ Object

    Creates a buffer for the provided dc. #init must not be called when using this constructor.

    Parameters:

    • tgt (Wx::DC)

      The underlying DC: everything drawn to this object will be flushed to this DC when this object is destroyed. You may pass nil in order to just initialize the buffer, and not flush it.

    • buffer (Wx::Bitmap) (defaults to: Wx::NULL_BITMAP)

      Explicitly provided bitmap to be used for buffering: this is the most efficient solution as the bitmap doesn’t have to be recreated each time but it also requires more memory as the bitmap is never freed. The bitmap should have appropriate size, anything drawn outside of its bounds is clipped.

    • style (Integer) (defaults to: Wx::BUFFER_CLIENT_AREA)

      Wx::BUFFER_CLIENT_AREA to indicate that just the client area of the window is buffered, or Wx::BUFFER_VIRTUAL_AREA to indicate that the buffer bitmap covers the virtual area.

    Yield Parameters:



45
# File 'lib/wx/doc/memory_dc.rb', line 45

def self.draw_on(*arg) end

Instance Method Details

#get_styleInteger Also known as: style

Get the style.

Returns:

  • (Integer)


150
# File 'lib/wx/doc/gen/memory_dc.rb', line 150

def get_style; end

#init(dc, area, style = Wx::BUFFER_CLIENT_AREA) ⇒ void #init(dc, buffer = Wx::NULL_BITMAP, style = Wx::BUFFER_CLIENT_AREA) ⇒ void

Overloads:

  • #init(dc, area, style = Wx::BUFFER_CLIENT_AREA) ⇒ void

    This method returns an undefined value.

    Initializes the object created using the default constructor.

    Please see the constructors for parameter details.

    Parameters:

    • dc (Wx::DC)
    • area (Array(Integer, Integer), Wx::Size)
    • style (Integer) (defaults to: Wx::BUFFER_CLIENT_AREA)
  • #init(dc, buffer = Wx::NULL_BITMAP, style = Wx::BUFFER_CLIENT_AREA) ⇒ void

    This method returns an undefined value.

    Initializes the object created using the default constructor.

    Please see the constructors for parameter details.

    Parameters:

    • dc (Wx::DC)
    • buffer (Wx::Bitmap) (defaults to: Wx::NULL_BITMAP)
    • style (Integer) (defaults to: Wx::BUFFER_CLIENT_AREA)


134
# File 'lib/wx/doc/gen/memory_dc.rb', line 134

def init(*args) end

#set_style(style) ⇒ void Also known as: style=

This method returns an undefined value.

Set the style.

Parameters:

  • style (Integer)


145
# File 'lib/wx/doc/gen/memory_dc.rb', line 145

def set_style(style) end

#un_maskvoid

This method returns an undefined value.

Blits the buffer to the dc, and detaches the dc from the buffer (so it can be effectively used once only).

Usually only called in the destructor or by the destructor of derived classes if the BufferedDC must blit before the derived class (which may own the dc it’s blitting to) is destroyed.



140
# File 'lib/wx/doc/gen/memory_dc.rb', line 140

def un_mask; end