X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/d14a1e28567de23c586bc80017073d0c39f8d18f..2421eb827857325ff4886131c337391365986d6b:/wxPython/src/_dc.i diff --git a/wxPython/src/_dc.i b/wxPython/src/_dc.i index 5c5e193d64..def4b15852 100644 --- a/wxPython/src/_dc.i +++ b/wxPython/src/_dc.i @@ -13,6 +13,7 @@ // Not a %module + //--------------------------------------------------------------------------- %{ @@ -52,7 +53,7 @@ public: -#if 0 // The old way +#if defined(wxUSE_DC_OLD_METHODS) bool FloodFill(wxCoord x, wxCoord y, const wxColour& col, int style = wxFLOOD_SURFACE); //bool GetPixel(wxCoord x, wxCoord y, wxColour *col) const; @@ -75,18 +76,18 @@ public: void DrawCircle(wxCoord x, wxCoord y, wxCoord radius); void DrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height); void DrawIcon(const wxIcon& icon, wxCoord x, wxCoord y); - void DrawBitmap(const wxBitmap &bmp, wxCoord x, wxCoord y, bool useMask = FALSE); + void DrawBitmap(const wxBitmap &bmp, wxCoord x, wxCoord y, bool useMask = False); void DrawText(const wxString& text, wxCoord x, wxCoord y); void DrawRotatedText(const wxString& text, wxCoord x, wxCoord y, double angle); bool Blit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height, wxDC *source, wxCoord xsrc, wxCoord ysrc, - int rop = wxCOPY, bool useMask = FALSE, + int rop = wxCOPY, bool useMask = False, wxCoord xsrcMask = -1, wxCoord ysrcMask = -1); #else // The new way - + %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); @@ -140,8 +141,8 @@ public: %name(DrawIconXY) void DrawIcon(const wxIcon& icon, wxCoord x, wxCoord y); void DrawIcon(const wxIcon& icon, const wxPoint& pt); - %name(DrawBitmapXY) void DrawBitmap(const wxBitmap &bmp, wxCoord x, wxCoord y, bool useMask = FALSE); - void DrawBitmap(const wxBitmap &bmp, const wxPoint& pt, bool useMask = FALSE); + %name(DrawBitmapXY) void DrawBitmap(const wxBitmap &bmp, wxCoord x, wxCoord y, bool useMask = False); + void DrawBitmap(const wxBitmap &bmp, const wxPoint& pt, bool useMask = False); %name(DrawTextXY) void DrawText(const wxString& text, wxCoord x, wxCoord y); void DrawText(const wxString& text, const wxPoint& pt); @@ -149,18 +150,18 @@ public: %name(DrawRotatedTextXY) void DrawRotatedText(const wxString& text, wxCoord x, wxCoord y, double angle); void DrawRotatedText(const wxString& text, const wxPoint& pt, double angle); - + %name(BlitXY) bool Blit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height, wxDC *source, wxCoord xsrc, wxCoord ysrc, - int rop = wxCOPY, bool useMask = FALSE, + int rop = wxCOPY, bool useMask = False, wxCoord xsrcMask = -1, wxCoord ysrcMask = -1); - bool Blit(const wxPoint& destPt, const wxSize& sz, + bool Blit(const wxPoint& destPt, const wxSize& sz, wxDC *source, const wxPoint& srcPt, - int rop = wxCOPY, bool useMask = FALSE, + int rop = wxCOPY, bool useMask = False, const wxPoint& srcPtMask = wxDefaultPosition); #endif - + void DrawLines(int points, wxPoint* points_array, wxCoord xoffset = 0, wxCoord yoffset = 0); void DrawPolygon(int points, wxPoint* points_array, @@ -192,7 +193,7 @@ public: void DrawSpline(int points, wxPoint* points_array); - + // global DC operations // -------------------- @@ -204,7 +205,7 @@ public: virtual void StartPage(); virtual void EndPage(); - + // set objects to use for drawing // ------------------------------ @@ -215,18 +216,21 @@ public: virtual void SetBackgroundMode(int mode); virtual void SetPalette(const wxPalette& palette); - + // clipping region // --------------- - void SetClippingRegion(wxCoord x, wxCoord y, wxCoord width, wxCoord height); - //void SetClippingRegion(const wxPoint& pt, const wxSize& sz) + %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(); - void GetClippingBox(wxCoord *OUTPUT, wxCoord *OUTPUT, wxCoord *OUTPUT, wxCoord *OUTPUT) const; + DocDeclA( + void, GetClippingBox(wxCoord *OUTPUT, wxCoord *OUTPUT, wxCoord *OUTPUT, wxCoord *OUTPUT) const, + "GetClippingBox() -> (x, y, width, height)"); + %extend { wxRect GetClippingRect() { wxRect rect; @@ -234,37 +238,60 @@ public: return rect; } } - - + + // text extent // ----------- virtual wxCoord GetCharHeight() const; virtual wxCoord GetCharWidth() const; - // only works for single line strings - void GetTextExtent(const wxString& string, wxCoord *OUTPUT, wxCoord *OUTPUT); - %name(GetFullTextExtent)void GetTextExtent(const wxString& string, - wxCoord *OUTPUT, wxCoord *OUTPUT, wxCoord *OUTPUT, wxCoord* OUTPUT, - wxFont* font = NULL); + + 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."); + 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.", + GetFullTextExtent); + // works for single as well as multi-line strings - void GetMultiLineTextExtent(const wxString& text, wxCoord *OUTPUT, wxCoord *OUTPUT, wxCoord *OUTPUT, - wxFont *font = NULL); - + DocDeclAStr( + void, GetMultiLineTextExtent(const wxString& text, + 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."); + // size and resolution // ------------------- - // in device units - %name(GetSizeTuple)void GetSize(int* OUTPUT, int* OUTPUT); + DocStr(GetSize, "Get the DC size in device units."); wxSize GetSize(); + DocDeclAName( + void, GetSize( int *OUTPUT, int *OUTPUT ), + "GetSizeTuple() -> (width, height)", + GetSizeTuple); - // in mm - %name(GetSizeMMWH)void GetSizeMM(int* OUTPUT, int* OUTPUT) const; + + DocStr(GetSizeMM, "Get the DC size in milimeters."); wxSize GetSizeMM() const; - + DocDeclAName( + void, GetSizeMM( int *OUTPUT, int *OUTPUT ) const, + "GetSizeMMTuple() -> (width, height)", + GetSizeMMTuple); + + // coordinates conversions // ----------------------- @@ -294,7 +321,7 @@ public: virtual bool Ok() const; - + int GetBackgroundMode() const; const wxBrush& GetBackground() const; @@ -310,19 +337,36 @@ public: int GetMapMode() const; virtual void SetMapMode(int mode); - virtual void GetUserScale(double *OUTPUT, double *OUTPUT) const; + + DocDeclA( + virtual void, GetUserScale(double *OUTPUT, double *OUTPUT) const, + "GetUserScale() -> (xScale, yScale)"); + virtual void SetUserScale(double x, double y); - virtual void GetLogicalScale(double *OUTPUT, double *OUTPUT); + + DocDeclA( + virtual void, GetLogicalScale(double *OUTPUT, double *OUTPUT), + "GetLogicalScale() -> (xScale, yScale)"); + virtual void SetLogicalScale(double x, double y); - %name(GetLogicalOriginTuple) void GetLogicalOrigin(wxCoord *OUTPUT, wxCoord *OUTPUT) const; + wxPoint GetLogicalOrigin() const; + DocDeclAName( + void, GetLogicalOrigin(wxCoord *OUTPUT, wxCoord *OUTPUT) const, + "GetLogicalOriginTuple() -> (x,y)", + GetLogicalOriginTuple); + virtual void SetLogicalOrigin(wxCoord x, wxCoord y); - - %name(GetDeviceOriginTuple) void GetDeviceOrigin(wxCoord *OUTPUT, wxCoord *OUTPUT) const; + wxPoint GetDeviceOrigin() const; + DocDeclAName( + void, GetDeviceOrigin(wxCoord *OUTPUT, wxCoord *OUTPUT) const, + "GetDeviceOriginTuple() -> (x,y)", + GetDeviceOriginTuple); + virtual void SetDeviceOrigin(wxCoord x, wxCoord y); virtual void SetAxisOrientation(bool xLeftRight, bool yBottomUp); @@ -332,7 +376,7 @@ public: virtual void SetOptimization(bool opt); virtual bool GetOptimization(); - + // bounding box // ------------ @@ -347,10 +391,12 @@ public: wxCoord MaxY() const; + DocA(GetBoundingBox, + "GetBoundingBox() -> (x1,y1, x2,y2)"); %extend { void GetBoundingBox(int* OUTPUT, int* OUTPUT, int* OUTPUT, int* OUTPUT); // See below for implementation - } + } %pythoncode { def __nonzero__(self): return self.Ok() }; @@ -441,8 +487,8 @@ public: def DrawPolygonList(self, polygons, pens=None, brushes=None): - ## Note: This does not currently support fill style or offset - ## you can always use the non-List version if need be. + %## Note: This does not currently support fill style or offset + %## you can always use the non-List version if need be. if pens is None: pens = [] elif isinstance(pens, wx.Pen): @@ -459,22 +505,22 @@ public: def DrawTextList(self, textList, coords, foregrounds = None, backgrounds = None, fonts = None): - ## NOTE: this does not currently support changing the font - ## Make sure you set Background mode to wxSolid (DC.SetBackgroundMode) - ## If you want backgounds to do anything. + %## NOTE: this does not currently support changing the font + %## Make sure you set Background mode to wxSolid (DC.SetBackgroundMode) + %## If you want backgounds to do anything. if type(textList) == type(''): textList = [textList] elif len(textList) != len(coords): raise ValueError('textlist and coords must have same length') if foregrounds is None: foregrounds = [] - elif isinstance(foregrounds, wxColour): + elif isinstance(foregrounds, wx.Colour): foregrounds = [foregrounds] elif len(foregrounds) != len(coords): raise ValueError('foregrounds and coords must have same length') if backgrounds is None: backgrounds = [] - elif isinstance(backgrounds, wxColour): + elif isinstance(backgrounds, wx.Colour): backgrounds = [backgrounds] elif len(backgrounds) != len(coords): raise ValueError('backgrounds and coords must have same length') @@ -502,7 +548,7 @@ class wxMemoryDC : public wxDC { public: wxMemoryDC(); %name(MemoryDCFromDC) wxMemoryDC(wxDC* oldDC); - + void SelectObject(const wxBitmap& bitmap); }; @@ -512,9 +558,9 @@ public: class wxBufferedDC : public wxMemoryDC { public: - %addtofunc wxBufferedDC( wxDC *dc, const wxBitmap &buffer ) + %addtofunc wxBufferedDC( wxDC *dc, const wxBitmap &buffer ) "self._dc = args[0] # save a ref so the other dc will not be deleted before self"; - %addtofunc wxBufferedDC( wxDC *dc, const wxSize &area ) + %addtofunc wxBufferedDC( wxDC *dc, const wxSize &area ) "val._dc = args[0] # save a ref so the other dc will not be deleted before self"; // Construct a wxBufferedDC using a user supplied buffer. @@ -585,7 +631,7 @@ class wxMirrorDC : public wxDC public: // constructs a mirror DC associated with the given real DC // - // if mirror parameter is true, all vertical and horizontal coordinates are + // if mirror parameter is True, all vertical and horizontal coordinates are // exchanged, otherwise this class behaves in exactly the same way as a // plain DC // @@ -603,7 +649,7 @@ class wxPostScriptDC : public wxDC { public: wxPostScriptDC(const wxPrintData& printData); // %name(PostScriptDC2)wxPostScriptDC(const wxString& output, -// bool interactive = TRUE, +// bool interactive = True, // wxWindow* parent = NULL); wxPrintData& GetPrintData(); @@ -660,13 +706,13 @@ public: class wxMetaFile : public wxObject { public: wxMetaFile(const wxString&) - { PyErr_SetNone(PyExc_NotImplementedError); } + { wxPyRaiseNotImplemented(); } }; class wxMetaFileDC : public wxClientDC { public: wxMetaFileDC(const wxString&, int, int, const wxString&) - { PyErr_SetNone(PyExc_NotImplementedError); } + { wxPyRaiseNotImplemented(); } }; %} @@ -697,7 +743,7 @@ public: // %name(PrinterDC2) wxPrinterDC(const wxString& driver, // const wxString& device, // const wxString& output, -// bool interactive = TRUE, +// bool interactive = True, // int orientation = wxPORTRAIT); }; @@ -706,22 +752,67 @@ public: class wxPrinterDC : public wxClientDC { public: wxPrinterDC(const wxPrintData&) - { PyErr_SetNone(PyExc_NotImplementedError); } - + { wxPyRaiseNotImplemented(); } + // wxPrinterDC(const wxString&, const wxString&, const wxString&, bool, int) -// { PyErr_SetNone(PyExc_NotImplementedError); } +// { wxPyRaiseNotImplemented(); } }; %} - + class wxPrinterDC : public wxDC { public: wxPrinterDC(const wxPrintData& printData); // %name(PrinterDC2) wxPrinterDC(const wxString& driver, // const wxString& device, // const wxString& output, -// bool interactive = TRUE, +// bool interactive = True, // int orientation = wxPORTRAIT); }; #endif +//--------------------------------------------------------------------------- +//--------------------------------------------------------------------------- + +// Now define some Python classes that rename the Draw methods to be +// compatible with the DC Draw methods in 2.4. See also wxPython/_wx.py. + + +%define MAKE_OLD_DC_CLASS(classname) + %pythoncode { + class classname##_old(classname): + """DC class that has methods with 2.4 compatible parameters.""" + FloodFill = classname.FloodFillXY + GetPixel = classname.GetPixelXY + DrawLine = classname.DrawLineXY + CrossHair = classname.CrossHairXY + DrawArc = classname.DrawArcXY + DrawCheckMark = classname.DrawCheckMarkXY + DrawEllipticArc = classname.DrawEllipticArcXY + DrawPoint = classname.DrawPointXY + DrawRectangle = classname.DrawRectangleXY + DrawRoundedRectangle = classname.DrawRoundedRectangleXY + DrawCircle = classname.DrawCircleXY + DrawEllipse = classname.DrawEllipseXY + DrawIcon = classname.DrawIconXY + DrawBitmap = classname.DrawBitmapXY + DrawText = classname.DrawTextXY + DrawRotatedText = classname.DrawRotatedTextXY + Blit = classname.BlitXY + } +%enddef + +MAKE_OLD_DC_CLASS(DC); +MAKE_OLD_DC_CLASS(MemoryDC); +MAKE_OLD_DC_CLASS(BufferedDC); +MAKE_OLD_DC_CLASS(BufferedPaintDC); +MAKE_OLD_DC_CLASS(ScreenDC); +MAKE_OLD_DC_CLASS(ClientDC); +MAKE_OLD_DC_CLASS(PaintDC); +MAKE_OLD_DC_CLASS(WindowDC); +MAKE_OLD_DC_CLASS(MirrorDC); +MAKE_OLD_DC_CLASS(PostScriptDC); +MAKE_OLD_DC_CLASS(MetaFileDC); +MAKE_OLD_DC_CLASS(PrinterDC); + + //---------------------------------------------------------------------------