X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/96285a18aa6f39e754ae562cc427f005a3402f43..fe45b493dcc42fea4ad4f781a4fb7844d2e95fd0:/wxPython/src/_dc.i diff --git a/wxPython/src/_dc.i b/wxPython/src/_dc.i index c589d0d282..38162ff448 100644 --- a/wxPython/src/_dc.i +++ b/wxPython/src/_dc.i @@ -352,6 +352,63 @@ position.", " :param srcPtMask: Source position on the mask. ", BlitPointSize); + + + DocDeclStr( + bool , StretchBlit(wxCoord dstX, wxCoord dstY, + wxCoord dstWidth, wxCoord dstHeight, + wxDC *source, + wxCoord srcX, wxCoord srcY, + wxCoord srcWidth, wxCoord srcHeight, + int rop = wxCOPY, bool useMask = false, + wxCoord srcMaskX = wxDefaultCoord, + wxCoord srcMaskY = wxDefaultCoord), + "Copy from a source DC to this DC, specifying the destination +coordinates, destination size, source DC, source coordinates, size of +source area to copy, logical function, whether to use a bitmap mask, +and mask source position.", " + + :param xdest: Destination device context x position. + :param ydest: Destination device context y position. + :param dstWidth: Width of destination area. + :param dstHeight: Height of destination area. + :param source: Source device context. + :param xsrc: Source device context x position. + :param ysrc: Source device context y position. + :param srcWidth: Width of source area to be copied. + :param srcHeight: Height of source area to be copied. + :param logicalFunc: Logical function to use: see `SetLogicalFunction`. + :param useMask: If true, StretchBlit does a transparent blit using + the mask that is associated with the bitmap selected + into the source device context. + :param xsrcMask: Source x position on the mask. If both xsrcMask and + ysrcMask are -1, xsrc and ysrc will be assumed for + the mask source position. Currently only implemented + on Windows. + :param ysrcMask: Source y position on the mask. +"); + + + + DocDeclStrName( + bool , StretchBlit(const wxPoint& dstPt, const wxSize& dstSize, + wxDC *source, const wxPoint& srcPt, const wxSize& srcSize, + int rop = wxCOPY, bool useMask = false, + const wxPoint& srcMaskPt = wxDefaultPosition), + "Copy from a source DC to this DC, specifying the destination +coordinates, destination size, source DC, source coordinates, size of +source area to copy, logical function, whether to use a bitmap mask, +and mask source position. This version is the same as `StretchBlit` +except `wx.Point` and `wx.Size` objects are used instead of individual +position and size components.", "", + StretchBlitPointSize); + + + + DocDeclStr( + wxBitmap , GetAsBitmap(const wxRect *subrect = NULL) const, + "", ""); + DocStr( @@ -573,7 +630,7 @@ works for single line strings.", ""); DocDeclAStrName( void, GetTextExtent(const wxString& string, wxCoord *OUTPUT, wxCoord *OUTPUT, wxCoord *OUTPUT, wxCoord* OUTPUT, - wxFont* font = NULL), + const wxFont* font = NULL), "GetFullTextExtent(wxString string, Font font=None) ->\n (width, height, descent, externalLeading)", "Get the width, height, decent and leading of the text using the current or specified font. Only works for single line strings.", "", @@ -584,7 +641,7 @@ current or specified font. Only works for single line strings.", "", DocDeclAStr( void, GetMultiLineTextExtent(const wxString& text, wxCoord *OUTPUT, wxCoord *OUTPUT, wxCoord *OUTPUT, - wxFont *font = NULL), + const wxFont *font = NULL), "GetMultiLineTextExtent(wxString string, Font font=None) ->\n (width, height, lineHeight)", "Get the width, height, and line height of the text using the current or specified font. Works for single as well as multi-line @@ -1235,6 +1292,182 @@ static void wxDC_GetBoundingBox(wxDC* dc, int* x1, int* y1, int* x2, int* y2) { %} +//--------------------------------------------------------------------------- +%newgroup + +DocStr(wxDCTextColourChanger, +"wx.DCTextColourChanger can be used to temporarily change the DC text +colour and restore it automatically when the object goes out of scope", ""); + +class wxDCTextColourChanger +{ +public: + wxDCTextColourChanger(wxDC& dc, const wxColour& col); + ~wxDCTextColourChanger(); +}; + + +DocStr(wxDCPenChanger, +"wx.DCPenChanger can be used to temporarily change the DC pen and +restore it automatically when the object goes out of scope", ""); + +class wxDCPenChanger +{ +public: + wxDCPenChanger(wxDC& dc, const wxPen& pen); + ~wxDCPenChanger(); +}; + + + +DocStr(wxDCBrushChanger, +"wx.DCBrushChanger can be used to temporarily change the DC brush and +restore it automatically when the object goes out of scope", ""); + +class wxDCBrushChanger +{ +public: + wxDCBrushChanger(wxDC& dc, const wxBrush& brush); + ~wxDCBrushChanger(); +}; + + +DocStr(wxDCClipper, +"wx.wxDCClipper sets the DC's clipping region when it is constructed, +and then automatically destroys the clipping region when the clipper +goes out of scope.", ""); + +class wxDCClipper +{ +public: + %nokwargs wxDCClipper; + wxDCClipper(wxDC& dc, const wxRegion& r); + wxDCClipper(wxDC& dc, const wxRect& r); + wxDCClipper(wxDC& dc, wxCoord x, wxCoord y, wxCoord w, wxCoord h); + ~wxDCClipper(); +}; + + + + +//--------------------------------------------------------------------------- +%newgroup + +MustHaveApp(wxScreenDC); + +DocStr(wxScreenDC, +"A wxScreenDC can be used to paint anywhere on the screen. This should +normally be constructed as a temporary stack object; don't store a +wxScreenDC object. +", ""); +class wxScreenDC : public wxDC { +public: + wxScreenDC(); + + DocDeclStrName( + bool , StartDrawingOnTop(wxWindow* window), + "Specify that the area of the screen to be drawn upon coincides with +the given window. + +:see: `EndDrawingOnTop`", "", + StartDrawingOnTopWin); + + + DocDeclStr( + bool , StartDrawingOnTop(wxRect* rect = NULL), + "Specify that the area is the given rectangle, or the whole screen if +``None`` is passed. + +:see: `EndDrawingOnTop`", ""); + + + DocDeclStr( + bool , EndDrawingOnTop(), + "Use this in conjunction with `StartDrawingOnTop` or +`StartDrawingOnTopWin` to ensure that drawing to the screen occurs on +top of existing windows. Without this, some window systems (such as X) +only allow drawing to take place underneath other windows. + +You might use this pair of functions when implementing a drag feature, +for example as in the `wx.SplitterWindow` implementation. + +These functions are probably obsolete since the X implementations +allow drawing directly on the screen now. However, the fact that this +function allows the screen to be refreshed afterwards may be useful +to some applications.", ""); + +}; + +//--------------------------------------------------------------------------- +%newgroup + +MustHaveApp(wxWindowDC); + +DocStr(wxWindowDC, + "A wx.WindowDC must be constructed if an application wishes to paint on +the whole area of a window (client and decorations). This should +normally be constructed as a temporary stack object; don't store a +wx.WindowDC object.",""); +class wxWindowDC : public wxDC { +public: + DocCtorStr( + wxWindowDC(wxWindow* win), + "Constructor. Pass the window on which you wish to paint.",""); +}; + +//--------------------------------------------------------------------------- +%newgroup + +MustHaveApp(wxClientDC); + +DocStr(wxClientDC, +"A wx.ClientDC must be constructed if an application wishes to paint on +the client area of a window from outside an EVT_PAINT event. This should +normally be constructed as a temporary stack object; don't store a +wx.ClientDC object long term. + +To draw on a window from within an EVT_PAINT handler, construct a +`wx.PaintDC` object. + +To draw on the whole window including decorations, construct a +`wx.WindowDC` object (Windows only). +", ""); +class wxClientDC : public wxWindowDC { +public: + DocCtorStr( + wxClientDC(wxWindow* win), + "Constructor. Pass the window on which you wish to paint.", ""); +}; + +//--------------------------------------------------------------------------- +%newgroup + +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 @@ -1255,10 +1488,10 @@ 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 wxDC { +class wxMemoryDC : public wxWindowDC { public: DocCtorStr( - wxMemoryDC(const wxBitmap& bitmap = wxNullBitmap), + wxMemoryDC(wxBitmap& bitmap = wxNullBitmap), "Constructs a new memory device context. Use the Ok member to test whether the constructor was successful in @@ -1275,7 +1508,7 @@ drawing on it.", " DocDeclStr( - void , SelectObject(const wxBitmap& bitmap), + 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 @@ -1285,9 +1518,16 @@ 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 @@ -1298,7 +1538,8 @@ destroyed safely.", ""); enum { wxBUFFER_VIRTUAL_AREA, - wxBUFFER_CLIENT_AREA + wxBUFFER_CLIENT_AREA, + wxBUFFER_USES_SHARED_BUFFER }; MustHaveApp(wxBufferedDC); @@ -1307,25 +1548,31 @@ 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. +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. -It can be used in the same way as any other device context. +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`. +`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. wxBufferedDC is aware of this however, and will bypass the buffering -unless an explicit buffer bitmap is given. +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: - %pythonAppend wxBufferedDC - "self.__dc = args[0] # save a ref so the other dc will not be deleted before self"; - - %nokwargs wxBufferedDC; DocStr( wxBufferedDC, @@ -1351,10 +1598,18 @@ public: 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, - const wxBitmap& buffer=wxNullBitmap, + wxBitmap& buffer=wxNullBitmap, int style = wxBUFFER_CLIENT_AREA ); wxBufferedDC( wxDC* dc, const wxSize& area, @@ -1376,7 +1631,10 @@ associated with this object, if any.", ""); "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; }; @@ -1408,9 +1666,11 @@ class wxBufferedPaintDC : public wxBufferedDC { public: + %pythonAppend wxBufferedPaintDC "if len(args) > 1: self.__bmp = args[1]"; + DocCtorStr( wxBufferedPaintDC( wxWindow *window, - const wxBitmap &buffer = wxNullBitmap, + 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 @@ -1422,150 +1682,47 @@ window is automatically used).", ""); //--------------------------------------------------------------------------- %newgroup -MustHaveApp(wxScreenDC); - -DocStr(wxScreenDC, -"A wxScreenDC can be used to paint anywhere on the screen. This should -normally be constructed as a temporary stack object; don't store a -wxScreenDC object. -", ""); -class wxScreenDC : public wxDC { -public: - wxScreenDC(); - - DocDeclStrName( - bool , StartDrawingOnTop(wxWindow* window), - "Specify that the area of the screen to be drawn upon coincides with -the given window. - -:see: `EndDrawingOnTop`", "", - StartDrawingOnTopWin); - - - DocDeclStr( - bool , StartDrawingOnTop(wxRect* rect = NULL), - "Specify that the area is the given rectangle, or the whole screen if -``None`` is passed. - -:see: `EndDrawingOnTop`", ""); - - - DocDeclStr( - bool , EndDrawingOnTop(), - "Use this in conjunction with `StartDrawingOnTop` or -`StartDrawingOnTopWin` to ensure that drawing to the screen occurs on -top of existing windows. Without this, some window systems (such as X) -only allow drawing to take place underneath other windows. - -You might use this pair of functions when implementing a drag feature, -for example as in the `wx.SplitterWindow` implementation. - -These functions are probably obsolete since the X implementations -allow drawing directly on the screen now. However, the fact that this -function allows the screen to be refreshed afterwards may be useful -to some applications.", ""); - -}; - -//--------------------------------------------------------------------------- -%newgroup - -MustHaveApp(wxWindowDC); - -DocStr(wxWindowDC, - "A wx.WindowDC must be constructed if an application wishes to paint on -the whole area of a window (client and decorations). This should -normally be constructed as a temporary stack object; don't store a -wx.WindowDC object.",""); -class wxWindowDC : public wxDC { -public: - DocCtorStr( - wxWindowDC(wxWindow* win), - "Constructor. Pass the window on which you wish to paint.",""); -}; - -//--------------------------------------------------------------------------- -%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`. -MustHaveApp(wxClientDC); +// :see: `wx.AutoBufferedPaintDCFactory` +// """ +// def __init__(self, window): +// _AutoBufferedPaintDCBase.__init__(self, window) +// } -DocStr(wxClientDC, -"A wx.ClientDC must be constructed if an application wishes to paint on -the client area of a window from outside an EVT_PAINT event. This should -normally be constructed as a temporary stack object; don't store a -wx.ClientDC object long term. -To draw on a window from within an EVT_PAINT handler, construct a -`wx.PaintDC` object. +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`. -To draw on the whole window including decorations, construct a -`wx.WindowDC` object (Windows only). +:see: `wx.AutoBufferedPaintDCFactory` ", ""); -class wxClientDC : public wxWindowDC { -public: - DocCtorStr( - wxClientDC(wxWindow* win), - "Constructor. Pass the window on which you wish to paint.", ""); -}; - -//--------------------------------------------------------------------------- -%newgroup -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 { +class wxAutoBufferedPaintDC: public wxDC +{ public: - DocCtorStr( - wxPaintDC(wxWindow* win), - "Constructor. Pass the window on which you wish to paint.", ""); + wxAutoBufferedPaintDC(wxWindow* win); }; - -//--------------------------------------------------------------------------- -%newgroup - -%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) -} - - %newobject wxAutoBufferedPaintDCFactory; DocDeclStr( wxDC* , wxAutoBufferedPaintDCFactory(wxWindow* window), "Checks if the window is natively double buffered and will return a -`wx.PaintDC` if it is, a `wx.BufferedPaintDC` otherwise. The -advantage of this function over `wx.AutoBufferedPaintDC` is that this -function will check if the the specified window supports has -double-buffering enabled rather than just going by platform defaults.", ""); +`wx.PaintDC` if it is, a `wx.BufferedPaintDC` otherwise. The advantage of +this function over `wx.AutoBufferedPaintDC` is that this function will check +if the the specified window has double-buffering enabled rather than just +going by platform defaults.", ""); @@ -1733,5 +1890,23 @@ public: }; #endif +//--------------------------------------------------------------------------- + +%{ +#include +%} + +class wxSVGFileDC : public wxDC +{ + %nokwargs wxSVGFileDC; + + wxSVGFileDC(wxString f); + wxSVGFileDC(wxString f, int Width, int Height); + wxSVGFileDC(wxString f, int Width, int Height, float dpi); + + ~wxSVGFileDC(); + +}; + //--------------------------------------------------------------------------- //---------------------------------------------------------------------------