+MustHaveApp(wxPaintDC);
+
+DocStr(wxPaintDC,
+"A wx.PaintDC must be constructed if an application wishes to paint on
+the client area of a window from within an EVT_PAINT event
+handler. This should normally be constructed as a temporary stack
+object; don't store a wx.PaintDC object. If you have an EVT_PAINT
+handler, you **must** create a wx.PaintDC object within it even if you
+don't actually use it.
+
+Using wx.PaintDC within EVT_PAINT handlers is important because it
+automatically sets the clipping area to the damaged area of the
+window. Attempts to draw outside this area do not appear.
+
+To draw on a window from outside EVT_PAINT handlers, construct a
+`wx.ClientDC` object.
+","");
+class wxPaintDC : public wxClientDC {
+public:
+ DocCtorStr(
+ wxPaintDC(wxWindow* win),
+ "Constructor. Pass the window on which you wish to paint.", "");
+};
+
+
+
+//---------------------------------------------------------------------------
+%newgroup
+
+MustHaveApp(wxMemoryDC);
+
+DocStr(wxMemoryDC,
+"A memory device context provides a means to draw graphics onto a
+bitmap. A bitmap must be selected into the new memory DC before it may
+be used for anything. Typical usage is as follows::
+
+ dc = wx.MemoryDC()
+ dc.SelectObject(bitmap)
+ # draw on the dc using any of the Draw methods
+ dc.SelectObject(wx.NullBitmap)
+ # the bitmap now contains wahtever was drawn upon it
+
+Note that the memory DC *must* be deleted (or the bitmap selected out
+of it) before a bitmap can be reselected into another memory DC.
+", "");
+
+class wxMemoryDC : public wxWindowDC {
+public:
+ DocCtorStr(
+ wxMemoryDC(wxBitmap& bitmap = wxNullBitmap),
+ "Constructs a new memory device context.
+
+Use the Ok member to test whether the constructor was successful in
+creating a usable device context. If a bitmap is not given to this
+constructor then don't forget to select a bitmap into the DC before
+drawing on it.", "
+
+:see: `MemoryDCFromDC`");
+
+ DocCtorStrName(
+ wxMemoryDC(wxDC* oldDC),
+ "Creates a DC that is compatible with the oldDC.", "",
+ MemoryDCFromDC);
+
+
+ DocDeclStr(
+ void , SelectObject(wxBitmap& bitmap),
+ "Selects the bitmap into the device context, to use as the memory
+bitmap. Selecting the bitmap into a memory DC allows you to draw into
+the DC, and therefore the bitmap, and also to use Blit to copy the
+bitmap to a window.
+
+If the argument is wx.NullBitmap (or some other uninitialised
+`wx.Bitmap`) the current bitmap is selected out of the device context,
+and the original bitmap restored, allowing the current bitmap to be
+destroyed safely.", "");
+
+
+ DocDeclStr(
+ void , SelectObjectAsSource(const wxBitmap& bmp),
+ "", "");
+
+
+};
+
+
+//---------------------------------------------------------------------------
+%newgroup
+
+
+%{
+#include <wx/dcbuffer.h>
+%}
+
+enum {
+ wxBUFFER_VIRTUAL_AREA,
+ wxBUFFER_CLIENT_AREA
+};
+
+MustHaveApp(wxBufferedDC);
+
+DocStr(wxBufferedDC,
+"This simple class provides a simple way to avoid flicker: when drawing
+on it, everything is in fact first drawn on an in-memory buffer (a
+`wx.Bitmap`) and then copied to the screen only once, when this object
+is destroyed. You can either provide a buffer bitmap yourself, and
+reuse it the next time something needs painted, or you can let the
+buffered DC create and provide a buffer bitmap itself.
+
+Buffered DCs can be used in the same way as any other device context.
+wx.BufferedDC itself typically replaces `wx.ClientDC`, if you want to
+use it in your EVT_PAINT handler, you should look at
+`wx.BufferedPaintDC`. You can also use a wx.BufferedDC without
+providing a target DC. In this case the operations done on the dc
+will only be written to the buffer bitmap and *not* to any window, so
+you will want to have provided the buffer bitmap and then reuse it
+when it needs painted to the window.
+
+Please note that GTK+ 2.0 and OS X provide double buffering themselves
+natively. You may want to use `wx.Window.IsDoubleBuffered` to
+determine whether you need to use buffering or not, or use
+`wx.AutoBufferedPaintDC` to avoid needless double buffering on systems
+that already do it automatically.
+
+
+", "");
+
+class wxBufferedDC : public wxMemoryDC
+{
+public:
+
+ DocStr(
+ wxBufferedDC,
+ "Constructs a buffered DC.", "
+
+ :param dc: The underlying DC: everything drawn to this object will
+ be flushed to this DC when this object is destroyed. You may
+ pass ``None`` in order to just initialize the buffer, and not
+ flush it.
+
+ :param buffer: If a `wx.Size` object is passed as the 2nd arg then
+ it is the size of the bitmap that will be created internally
+ and used for an implicit buffer. If the 2nd arg is a
+ `wx.Bitmap` then it is the explicit buffer that will be
+ used. Using an explicit buffer 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. If wx.NullBitmap is used then a new
+ buffer will be allocated that is the same size as the dc.
+
+ :param style: The style parameter indicates whether the supplied buffer is
+ intended to cover the entire virtual size of a `wx.ScrolledWindow` or
+ if it only covers the client area. Acceptable values are
+ ``wx.BUFFER_VIRTUAL_AREA`` and ``wx.BUFFER_CLIENT_AREA``.
+");
+
+ %nokwargs wxBufferedDC;
+ %pythonAppend wxBufferedDC
+"# save a ref so the other dc will not be deleted before self
+ self.__dc = args[0]
+ # also save a ref to the bitmap
+ if len(args) > 1: self.__bmp = args[1]
+";
+
+ wxBufferedDC( wxDC* dc,
+ wxBitmap& buffer=wxNullBitmap,
+ int style = wxBUFFER_CLIENT_AREA );
+ wxBufferedDC( wxDC* dc,
+ const wxSize& area,
+ int style = wxBUFFER_CLIENT_AREA );
+// wxBufferedDC(wxWindow* win,
+// wxDC *dc,
+// const wxSize &area,
+// int style = wxBUFFER_CLIENT_AREA);
+
+
+ DocCtorStr(
+ ~wxBufferedDC(),
+ "Copies everything drawn on the DC so far to the underlying DC
+associated with this object, if any.", "");
+
+
+ DocDeclStr(
+ void , UnMask(),
+ "Blits the buffer to the dc, and detaches the dc from the buffer (so it
+can be effectively used once only). This is usually only called in
+the destructor.", "");
+
+ // Set and get the style
+ void SetStyle(int style);
+ int GetStyle() const;
+};
+
+
+
+
+MustHaveApp(wxBufferedPaintDC);
+
+DocStr(wxBufferedPaintDC,
+"This is a subclass of `wx.BufferedDC` which can be used inside of an
+EVT_PAINT event handler. Just create an object of this class instead
+of `wx.PaintDC` and that's all you have to do to (mostly) avoid
+flicker. The only thing to watch out for is that if you are using this
+class together with `wx.ScrolledWindow`, you probably do **not** want
+to call `wx.Window.PrepareDC` on it as it already does this internally
+for the real underlying `wx.PaintDC`.
+
+If your window is already fully buffered in a `wx.Bitmap` then your
+EVT_PAINT handler can be as simple as just creating a
+``wx.BufferedPaintDC`` as it will `Blit` the buffer to the window
+automatically when it is destroyed. For example::
+
+ def OnPaint(self, event):
+ dc = wx.BufferedPaintDC(self, self.buffer)
+
+
+", "");
+
+class wxBufferedPaintDC : public wxBufferedDC
+{
+public:
+
+ %pythonAppend wxBufferedPaintDC "if len(args) > 1: self.__bmp = args[1]";
+
+ DocCtorStr(
+ wxBufferedPaintDC( wxWindow *window,
+ wxBitmap &buffer = wxNullBitmap,
+ int style = wxBUFFER_CLIENT_AREA),
+ "Create a buffered paint DC. As with `wx.BufferedDC`, you may either
+provide the bitmap to be used for buffering or let this object create
+one internally (in the latter case, the size of the client part of the
+window is automatically used).", "");
+
+};
+
+//---------------------------------------------------------------------------
+%newgroup
+
+// Epydoc doesn't like this for some strange reason...
+// %pythoncode {
+// if 'wxMac' in wx.PlatformInfo or 'gtk2' in wx.PlatformInfo:
+// _AutoBufferedPaintDCBase = PaintDC
+// else:
+// _AutoBufferedPaintDCBase = BufferedPaintDC
+
+// class AutoBufferedPaintDC(_AutoBufferedPaintDCBase):
+// """
+// If the current platform double buffers by default then this DC is the
+// same as a plain `wx.PaintDC`, otherwise it is a `wx.BufferedPaintDC`.
+
+// :see: `wx.AutoBufferedPaintDCFactory`
+// """
+// def __init__(self, window):
+// _AutoBufferedPaintDCBase.__init__(self, window)
+// }
+
+
+DocStr(wxAutoBufferedPaintDC,
+"If the current platform double buffers by default then this DC is the
+same as a plain `wx.PaintDC`, otherwise it is a `wx.BufferedPaintDC`.
+
+:see: `wx.AutoBufferedPaintDCFactory`
+", "");
+
+class wxAutoBufferedPaintDC: public wxDC
+{