X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/b159c5c4815594c9a15365dd2a520c3f21a3b3b6..015fd9ef4833ec3d8b0043a1c7e448c8be4f734a:/wxPython/src/_dc.i?ds=sidebyside diff --git a/wxPython/src/_dc.i b/wxPython/src/_dc.i index 7d0fa94a4f..0032639fe2 100644 --- a/wxPython/src/_dc.i +++ b/wxPython/src/_dc.i @@ -53,9 +53,11 @@ public: -#if defined(wxUSE_DC_OLD_METHODS) +#if 1 // The < 2.4 and > 2.5.1.5 way bool FloodFill(wxCoord x, wxCoord y, const wxColour& col, int style = wxFLOOD_SURFACE); + %name(FloodFillPoint) bool FloodFill(const wxPoint& pt, const wxColour& col, int style = wxFLOOD_SURFACE); + //bool GetPixel(wxCoord x, wxCoord y, wxColour *col) const; %extend { wxColour GetPixel(wxCoord x, wxCoord y) { @@ -63,30 +65,74 @@ public: self->GetPixel(x, y, &col); return col; } + wxColour GetPixelPoint(const wxPoint& pt) { + wxColour col; + self->GetPixel(pt, &col); + return col; + } } + void DrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2); + %name(DrawLinePoint) void DrawLine(const wxPoint& pt1, const wxPoint& pt2); + void CrossHair(wxCoord x, wxCoord y); + %name(CrossHairPoint) void CrossHair(const wxPoint& pt); + void DrawArc(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2, wxCoord xc, wxCoord yc); + %name(DrawArcPoint) void DrawArc(const wxPoint& pt1, const wxPoint& pt2, const wxPoint& centre); + void DrawCheckMark(wxCoord x, wxCoord y, wxCoord width, wxCoord height); + %name(DrawCheckMarkRect) void DrawCheckMark(const wxRect& rect); + void DrawEllipticArc(wxCoord x, wxCoord y, wxCoord w, wxCoord h, double sa, double ea); + %name(DrawEllipticArcPointSize) void DrawEllipticArc(const wxPoint& pt, const wxSize& sz, double sa, double ea); + void DrawPoint(wxCoord x, wxCoord y); + %name(DrawPointPoint) void DrawPoint(const wxPoint& pt); + void DrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height); %name(DrawRectangleRect)void DrawRectangle(const wxRect& rect); + %name(DrawRectanglePointSize) void DrawRectangle(const wxPoint& pt, const wxSize& sz); + void DrawRoundedRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height, double radius); + %name(DrawRoundedRectangleRect) void DrawRoundedRectangle(const wxRect& r, double radius); + %name(DrawRoundedRectanglePointSize) void DrawRoundedRectangle(const wxPoint& pt, const wxSize& sz, double radius); + void DrawCircle(wxCoord x, wxCoord y, wxCoord radius); + %name(DrawCirclePoint) void DrawCircle(const wxPoint& pt, wxCoord radius); + void DrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height); + %name(DrawEllipseRect) void DrawEllipse(const wxRect& rect); + %name(DrawEllipsePointSize) void DrawEllipse(const wxPoint& pt, const wxSize& sz); + void DrawIcon(const wxIcon& icon, wxCoord x, wxCoord y); + %name(DrawIconPoint) void DrawIcon(const wxIcon& icon, const wxPoint& pt); + void DrawBitmap(const wxBitmap &bmp, wxCoord x, wxCoord y, bool useMask = False); + %name(DrawBitmapPoint) void DrawBitmap(const wxBitmap &bmp, const wxPoint& pt, bool useMask = False); + void DrawText(const wxString& text, wxCoord x, wxCoord y); + %name(DrawTextPoint) void DrawText(const wxString& text, const wxPoint& pt); + void DrawRotatedText(const wxString& text, wxCoord x, wxCoord y, double angle); + %name(DrawRotatedTextPoint) void DrawRotatedText(const wxString& text, const wxPoint& pt, double angle); + bool Blit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height, wxDC *source, wxCoord xsrc, wxCoord ysrc, int rop = wxCOPY, bool useMask = False, wxCoord xsrcMask = -1, wxCoord ysrcMask = -1); + %name(BlitPointSize) bool Blit(const wxPoint& destPt, const wxSize& sz, + wxDC *source, const wxPoint& srcPt, + int rop = wxCOPY, bool useMask = False, + const wxPoint& srcPtMask = wxDefaultPosition); + void SetClippingRegion(wxCoord x, wxCoord y, wxCoord width, wxCoord height); + %name(SetClippingRegionPointSize) void SetClippingRegion(const wxPoint& pt, const wxSize& sz); + %name(SetClippingRegionAsRegion) void SetClippingRegion(const wxRegion& region); + %name(SetClippingRect) void SetClippingRegion(const wxRect& rect); -#else // The new way +#else // The doomed 2.5.1.5 %name(FloodFillXY) bool FloodFill(wxCoord x, wxCoord y, const wxColour& col, int style = wxFLOOD_SURFACE); bool FloodFill(const wxPoint& pt, const wxColour& col, int style = wxFLOOD_SURFACE); @@ -105,6 +151,7 @@ public: return col; } } + %name(DrawLineXY) void DrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2); void DrawLine(const wxPoint& pt1, const wxPoint& pt2); @@ -160,6 +207,12 @@ public: int rop = wxCOPY, bool useMask = False, const wxPoint& srcPtMask = wxDefaultPosition); + + %name(SetClippingRegionXY)void SetClippingRegion(wxCoord x, wxCoord y, wxCoord width, wxCoord height); + void SetClippingRegion(const wxPoint& pt, const wxSize& sz); + %name(SetClippingRect) void SetClippingRegion(const wxRect& rect); + %name(SetClippingRegionAsRegion) void SetClippingRegion(const wxRegion& region); + #endif void DrawLines(int points, wxPoint* points_array, wxCoord xoffset = 0, wxCoord yoffset = 0); @@ -168,12 +221,13 @@ public: wxCoord xoffset = 0, wxCoord yoffset = 0, int fillStyle = wxODDEVEN_RULE); - // TODO: Figure out what the start parameter means and devise a - // good typemap for this - //void DrawPolyPolygon(int n, int start[], wxPoint points[], - // wxCoord xoffset = 0, wxCoord yoffset = 0, - // int fillStyle = wxODDEVEN_RULE) + // TODO: Figure out a good typemap for this... + // Convert the first 3 args from a sequence of sequences? +// void DrawPolyPolygon(int n, int count[], wxPoint points[], +// wxCoord xoffset = 0, wxCoord yoffset = 0, +// int fillStyle = wxODDEVEN_RULE); + // this version puts both optional bitmap and the text into the given // rectangle and aligns is as specified by alignment parameter; it also // will emphasize the character with the given index if it is != -1 and @@ -222,14 +276,6 @@ public: virtual void SetPalette(const wxPalette& palette); - // clipping region - // --------------- - - %name(SetClippingRegionXY)void SetClippingRegion(wxCoord x, wxCoord y, wxCoord width, wxCoord height); - void SetClippingRegion(const wxPoint& pt, const wxSize& sz); - %name(SetClippingRect) void SetClippingRegion(const wxRect& rect); - %name(SetClippingRegionAsRegion) void SetClippingRegion(const wxRegion& region); - virtual void DestroyClippingRegion(); DocDeclA( @@ -256,15 +302,16 @@ public: DocDeclAStr( void, GetTextExtent(const wxString& string, wxCoord *OUTPUT, wxCoord *OUTPUT), "GetTextExtent(wxString string) -> (width, height)", - "Get the width and height of the text using the current font.\n" - "Only works for single line strings."); + "Get the width and height of the text using the current font. Only +works for single line strings.", ""); + DocDeclAStrName( void, GetTextExtent(const wxString& string, wxCoord *OUTPUT, wxCoord *OUTPUT, wxCoord *OUTPUT, wxCoord* OUTPUT, 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.\n" - "Only works for single line strings.", + "Get the width, height, decent and leading of the text using the +current or specified font. Only works for single line strings.", "", GetFullTextExtent); @@ -274,14 +321,24 @@ public: wxCoord *OUTPUT, wxCoord *OUTPUT, wxCoord *OUTPUT, wxFont *font = NULL), "GetMultiLineTextExtent(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.\n" - "Works for single as well as multi-line strings."); + "Get the width, height, decent and leading of the text using the +current or specified font. Works for single as well as multi-line +strings.", ""); + + %extend { + wxArrayInt GetPartialTextExtents(const wxString& text) { + wxArrayInt widths; + self->GetPartialTextExtents(text, widths); + return widths; + } + } + // size and resolution // ------------------- - DocStr(GetSize, "Get the DC size in device units."); + DocStr(GetSize, "Get the DC size in device units.", ""); wxSize GetSize(); DocDeclAName( void, GetSize( int *OUTPUT, int *OUTPUT ), @@ -289,7 +346,7 @@ public: GetSizeTuple); - DocStr(GetSizeMM, "Get the DC size in milimeters."); + DocStr(GetSizeMM, "Get the DC size in milimeters.", ""); wxSize GetSizeMM() const; DocDeclAName( void, GetSizeMM( int *OUTPUT, int *OUTPUT ) const, @@ -364,8 +421,13 @@ public: GetLogicalOriginTuple); virtual void SetLogicalOrigin(wxCoord x, wxCoord y); + %extend { + void SetLogicalOriginPoint(const wxPoint& point) { + self->SetLogicalOrigin(point.x, point.y); + } + } - + wxPoint GetDeviceOrigin() const; DocDeclAName( void, GetDeviceOrigin(wxCoord *OUTPUT, wxCoord *OUTPUT) const, @@ -373,6 +435,11 @@ public: GetDeviceOriginTuple); virtual void SetDeviceOrigin(wxCoord x, wxCoord y); + %extend { + void SetDeviceOriginPoint(const wxPoint& point) { + self->SetDeviceOrigin(point.x, point.y); + } + } virtual void SetAxisOrientation(bool xLeftRight, bool yBottomUp); @@ -387,6 +454,12 @@ public: // ------------ virtual void CalcBoundingBox(wxCoord x, wxCoord y); + %extend { + void CalcBoundingBoxPoint(const wxPoint& point) { + self->CalcBoundingBox(point.x, point.y); + } + } + void ResetBoundingBox(); // Get the final bounding box of the PostScript or Metafile picture. @@ -405,6 +478,10 @@ public: %pythoncode { def __nonzero__(self): return self.Ok() }; +#ifdef __WXMSW__ + long GetHDC(); +#endif + %extend { // See drawlist.cpp for impplementaion of these... PyObject* _DrawPointList(PyObject* pyCoords, PyObject* pyPens, PyObject* pyBrushes) @@ -549,6 +626,8 @@ static void wxDC_GetBoundingBox(wxDC* dc, int* x1, int* y1, int* x2, int* y2) { //--------------------------------------------------------------------------- %newgroup +MustHaveApp(wxMemoryDC); + class wxMemoryDC : public wxDC { public: wxMemoryDC(); @@ -560,26 +639,19 @@ public: //--------------------------------------------------------------------------- %newgroup -enum -{ - // this is more efficient and hence default - wxBUFFER_DC_OVERWRITE_BG = 0, - // preserve the old background: more time consuming - wxBUFFER_DC_PRESERVE_BG = 1, +%{ +#include +%} - // flags used by default - wxBUFFER_DC_DEFAULT = wxBUFFER_DC_OVERWRITE_BG -}; +MustHaveApp(wxBufferedDC); class wxBufferedDC : public wxMemoryDC { public: - %pythonAppend wxBufferedDC( wxDC *dc, const wxBitmap &buffer ) + %pythonAppend wxBufferedDC "self._dc = args[0] # save a ref so the other dc will not be deleted before self"; - %pythonAppend wxBufferedDC( wxDC *dc, const wxSize &area, int flags = wxBUFFER_DC_DEFAULT ) - "val._dc = args[0] # save a ref so the other dc will not be deleted before self"; %nokwargs wxBufferedDC; @@ -589,11 +661,19 @@ public: // Construct a wxBufferedDC with an internal buffer of 'area' // (where area is usually something like the size of the window // being buffered) - wxBufferedDC( wxDC *dc, const wxSize &area, int flags = wxBUFFER_DC_DEFAULT ); + wxBufferedDC( wxDC *dc, const wxSize &area ); + // TODO: Keep this one too? - %name(BufferedDCInternalBuffer) wxBufferedDC( wxDC *dc, const wxSize &area, int flags = wxBUFFER_DC_DEFAULT ); + %pythonAppend wxBufferedDC( wxDC *dc, const wxSize &area ) + "val._dc = args[0] # save a ref so the other dc will not be deleted before self"; + %name(BufferedDCInternalBuffer) wxBufferedDC( wxDC *dc, const wxSize &area ); + + + // The buffer is blit to the real DC when the BufferedDC is destroyed. + ~wxBufferedDC(); + // Blits the buffer to the dc, and detaches the dc from // the buffer. Usually called in the dtor or by the dtor // of derived classes if the BufferedDC must blit before @@ -603,16 +683,17 @@ public: }; + +MustHaveApp(wxBufferedPaintDC); + +// Creates a double buffered wxPaintDC, optionally allowing the +// user to specify their own buffer to use. class wxBufferedPaintDC : public wxBufferedDC { public: - %nokwargs wxBufferedPaintDC; - - wxBufferedPaintDC( wxWindow *window, const wxBitmap &buffer ); - - // this ctor creates a bitmap of the size of the window for buffering - wxBufferedPaintDC(wxWindow *window, int flags = wxBUFFER_DC_DEFAULT); + // If no bitmap is supplied by the user, a temporary one will be created. + wxBufferedPaintDC( wxWindow *window, const wxBitmap &buffer = wxNullBitmap ); }; @@ -620,6 +701,8 @@ public: //--------------------------------------------------------------------------- %newgroup +MustHaveApp(wxScreenDC); + class wxScreenDC : public wxDC { public: wxScreenDC(); @@ -632,6 +715,8 @@ public: //--------------------------------------------------------------------------- %newgroup +MustHaveApp(wxClientDC); + class wxClientDC : public wxDC { public: wxClientDC(wxWindow* win); @@ -640,6 +725,8 @@ public: //--------------------------------------------------------------------------- %newgroup +MustHaveApp(wxPaintDC); + class wxPaintDC : public wxDC { public: wxPaintDC(wxWindow* win); @@ -648,6 +735,8 @@ public: //--------------------------------------------------------------------------- %newgroup +MustHaveApp(wxWindowDC); + class wxWindowDC : public wxDC { public: wxWindowDC(wxWindow* win); @@ -656,6 +745,8 @@ public: //--------------------------------------------------------------------------- %newgroup +MustHaveApp(wxMirrorDC); + class wxMirrorDC : public wxDC { public: @@ -675,6 +766,8 @@ public: #include %} +MustHaveApp(wxPostScriptDC); + class wxPostScriptDC : public wxDC { public: wxPostScriptDC(const wxPrintData& printData); @@ -693,7 +786,11 @@ public: %newgroup -#ifdef __WXMSW__ +MustHaveApp(wxMetaFile); +MustHaveApp(wxMetaFileDC); + + +#if defined(__WXMSW__) || defined(__WXMAC__) %{ #include @@ -711,8 +808,10 @@ public: int GetWidth(); int GetHeight(); +#ifdef __WXMSW__ const wxString& GetFileName() const; - +#endif + %pythoncode { def __nonzero__(self): return self.Ok() } }; @@ -765,6 +864,8 @@ public: //--------------------------------------------------------------------------- +MustHaveApp(wxPrinterDC); + #if defined(__WXMSW__) || defined(__WXMAC__) class wxPrinterDC : public wxDC { @@ -807,6 +908,8 @@ public: // compatible with the DC Draw methods in 2.4. See also wxPython/_wx.py. +#if 0 + %define MAKE_OLD_DC_CLASS(classname) %pythoncode { class classname##_old(classname): @@ -844,5 +947,6 @@ MAKE_OLD_DC_CLASS(PostScriptDC); MAKE_OLD_DC_CLASS(MetaFileDC); MAKE_OLD_DC_CLASS(PrinterDC); +#endif //---------------------------------------------------------------------------