Search documentation of wx

# View Source wxBufferedDC (wx v2.4.3)

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 `wxBitmap`) and then copied to the screen, using the associated `wxDC`, only once, when this object is destroyed.

`wxBufferedDC` itself is typically associated with `wxClientDC`, if you want to use it in your `EVT_PAINT` handler, you should look at `wxBufferedPaintDC` 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, `wxBufferedDC` can be used in the same way as any other device context.

Another possible use for `wxBufferedDC` 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 `wxWindow:isDoubleBuffered/1` to determine whether you need to use buffering or not, or use `wxAutoBufferedPaintDC` (not implemented in wx) to avoid needless double buffering on the systems which already do it automatically.

See:

- `wxDC`

- `wxMemoryDC`

- `wxBufferedPaintDC`

This class is derived, and can use functions, from:

- `wxMemoryDC`

- `wxDC`

wxWidgets docs: wxBufferedDC

# Summary

## Types

wxBufferedDC()

## Functions

destroy(This)

Destroys the object

init(This, Dc)

Equivalent to `init(This, Dc, [])`.

init/3
init/4

Initializes the object created using the default constructor.

new()

Default constructor.

new(Dc)

Equivalent to `new(Dc, [])`.

new/2

Creates a buffer for the provided dc.

new/3

Creates a buffer for the provided `dc`.

# Types

Link to this type

# wxBufferedDC()

View Source

    -type wxBufferedDC() :: wx:wx_object().

# Functions

Link to this function

# destroy(This)

View Source

    -spec destroy(This :: wxBufferedDC()) -> ok.

Destroys the object

Link to this function

# init(This, Dc)

View Source

    -spec init(This, Dc) -> ok when This :: wxBufferedDC(), Dc :: wxDC:wxDC().

Equivalent to `init(This, Dc, [])`.

Link to this function

# init/3

View Source

    -spec init(This, Dc, Area) -> ok
                  when This :: wxBufferedDC(), Dc :: wxDC:wxDC(), Area :: {W :: integer(), H :: integer()};
              (This, Dc, [Option]) -> ok
                  when
                      This :: wxBufferedDC(),
                      Dc :: wxDC:wxDC(),
                      Option :: {buffer, wxBitmap:wxBitmap()} | {style, integer()}.

Link to this function

# init/4

View Source

    -spec init(This, Dc, Area, [Option]) -> ok
                  when
                      This :: wxBufferedDC(),
                      Dc :: wxDC:wxDC(),
                      Area :: {W :: integer(), H :: integer()},
                      Option :: {style, integer()}.

Initializes the object created using the default constructor.

Please see the constructors for parameter details.

Link to this function

# new()

View Source

    -spec new() -> wxBufferedDC().

Default constructor.

You must call one of the `init/4` methods later in order to use the device context.

Link to this function

# new(Dc)

View Source

    -spec new(Dc) -> wxBufferedDC() when Dc :: wxDC:wxDC().

Equivalent to `new(Dc, [])`.

Link to this function

# new/2

View Source

    -spec new(Dc, Area) -> wxBufferedDC() when Dc :: wxDC:wxDC(), Area :: {W :: integer(), H :: integer()};
             (Dc, [Option]) -> wxBufferedDC()
                 when Dc :: wxDC:wxDC(), Option :: {buffer, wxBitmap:wxBitmap()} | {style, integer()}.

Creates a buffer for the provided dc.

`init/4` must not be called when using this constructor.

Link to this function

# new/3

View Source

    -spec new(Dc, Area, [Option]) -> wxBufferedDC()
                 when
                     Dc :: wxDC:wxDC(),
                     Area :: {W :: integer(), H :: integer()},
                     Option :: {style, integer()}.

Creates a buffer for the provided `dc`.

`init/4` must not be called when using this constructor.