X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/d14a1e28567de23c586bc80017073d0c39f8d18f..4263de1e0586d20cb49d0dde23f0d227c5ef25cb:/wxPython/src/_bitmap.i?ds=sidebyside diff --git a/wxPython/src/_bitmap.i b/wxPython/src/_bitmap.i index ce0bbd9a0d..8f9213ea36 100644 --- a/wxPython/src/_bitmap.i +++ b/wxPython/src/_bitmap.i @@ -47,14 +47,36 @@ class wxBitmap : public wxGDIObject { public: - wxBitmap(const wxString& name, wxBitmapType type=wxBITMAP_TYPE_ANY); + DocCtorStr( + wxBitmap(const wxString& name, wxBitmapType type=wxBITMAP_TYPE_ANY), + "Loads a bitmap from a file."); + ~wxBitmap(); - // alternate constructors - %name(EmptyBitmap) wxBitmap(int width, int height, int depth=-1); - %name(BitmapFromIcon) wxBitmap(const wxIcon& icon); - %name(BitmapFromImage) wxBitmap(const wxImage& image, int depth=-1); + DocCtorStrName( + wxBitmap(int width, int height, int depth=-1), + "Creates a new bitmap of the given size. A depth of -1 indicates the depth of\n" + "the current screen or visual. Some platforms only support 1 for monochrome and\n" + "-1 for the current colour setting.", + EmptyBitmap); + + DocCtorStrName( + wxBitmap(const wxIcon& icon), + "Create a new bitmap from an Icon object.", + BitmapFromIcon); + + DocCtorStrName( + wxBitmap(const wxImage& image, int depth=-1), + "Creates bitmap object from the image. This has to be done to actually display\n" + "an image as you cannot draw an image directly on a window. The resulting\n" + "bitmap will use the provided colour depth (or that of the current system if\n" + "depth is -1) which entails that a colour reduction has to take place.", + BitmapFromImage); + + %extend { + DocStr(wxBitmap(PyObject* listOfStrings), + "Construct a Bitmap from a list of strings formatted as XPM data."); %name(BitmapFromXPMData) wxBitmap(PyObject* listOfStrings) { char** cArray = NULL; wxBitmap* bmp; @@ -67,7 +89,12 @@ public: return bmp; } - %name(BitmapFromBits) wxBitmap(PyObject* bits, int width, int height, int depth = 1 ) { + DocStr(wxBitmap(PyObject* bits, int width, int height, int depth=1 ), + "Creates a bitmap from an array of bits. You should only use this function for\n" + "monochrome bitmaps (depth 1) in portable programs: in this case the bits\n" + "parameter should contain an XBM image. For other bit depths, the behaviour is\n" + "platform dependent."); + %name(BitmapFromBits) wxBitmap(PyObject* bits, int width, int height, int depth=1 ) { char* buf; int length; PyString_AsStringAndSize(bits, &buf, &length); @@ -83,33 +110,58 @@ public: // wxGDIImage methods #ifdef __WXMSW__ long GetHandle(); - void SetHandle(long handle); + %extend { + void SetHandle(long handle) { self->SetHandle((WXHANDLE)handle); } + } #endif bool Ok(); + DocStr(GetWidth, "Gets the width of the bitmap in pixels."); int GetWidth(); + + DocStr(GetHeight, "Gets the height of the bitmap in pixels."); int GetHeight(); + + DocStr(GetDepth, + "Gets the colour depth of the bitmap. A value of 1 indicates a\n" + "monochrome bitmap."); int GetDepth(); + DocStr(ConvertToImage, + "Creates a platform-independent image from a platform-dependent bitmap. This\n" + "preserves mask information so that bitmaps and images can be converted back\n" + "and forth without loss in that respect."); virtual wxImage ConvertToImage() const; + DocStr(GetMask, + "Gets the associated mask (if any) which may have been loaded from a file\n" + "or explpicitly set for the bitmap."); virtual wxMask* GetMask() const; + + DocStr(SetMask, + "Sets the mask for this bitmap."); virtual void SetMask(wxMask* mask); + %extend { + DocStr(SetMaskColour, + "Create a Mask based on a specified colour in the Bitmap."); void SetMaskColour(const wxColour& colour) { wxMask *mask = new wxMask(*self, colour); self->SetMask(mask); } } -// def SetMaskColour(self, colour): -// mask = wxMaskColour(self, colour) -// self.SetMask(mask) + DocStr(GetSubBitmap, + "Returns a sub bitmap of the current one as long as the rect belongs entirely\n" + "to the bitmap. This function preserves bit depth and mask information."); virtual wxBitmap GetSubBitmap(const wxRect& rect) const; + DocStr(SaveFile, "Saves a bitmap in the named file."); virtual bool SaveFile(const wxString &name, wxBitmapType type, wxPalette *palette = (wxPalette *)NULL); + + DocStr(LoadFile, "Loads a bitmap from a file"); virtual bool LoadFile(const wxString &name, wxBitmapType type); @@ -118,13 +170,19 @@ public: virtual void SetPalette(const wxPalette& palette); #endif - // copies the contents and mask of the given (colour) icon to the bitmap - virtual bool CopyFromIcon(const wxIcon& icon); + virtual bool CopyFromIcon(const wxIcon& icon); + + DocStr(SetHeight, "Set the height property (does not affect the bitmap data).") virtual void SetHeight(int height); + + DocStr(SetWidth, "Set the width property (does not affect the bitmap data).") virtual void SetWidth(int width); + + DocStr(SetDepth, "Set the depth property (does not affect the bitmap data).") virtual void SetDepth(int depth); + #ifdef __WXMSW__ bool CopyFromCursor(const wxCursor& cursor); int GetQuality(); @@ -132,19 +190,47 @@ public: #endif %pythoncode { def __nonzero__(self): return self.Ok() } + + %extend { + bool __eq__(const wxBitmap* other) { return other ? (*self == *other) : False; } + bool __ne__(const wxBitmap* other) { return other ? (*self != *other) : True; } + } }; //--------------------------------------------------------------------------- +DocStr(wxMask, + "This class encapsulates a monochrome mask bitmap, where the masked area is\n" + "black and the unmasked area is white. When associated with a bitmap and drawn\n" + "in a device context, the unmasked area of the bitmap will be drawn, and the\n" + "masked area will not be drawn."); + class wxMask : public wxObject { public: - wxMask(const wxBitmap& bitmap); - %name(MaskColour) wxMask(const wxBitmap& bitmap, const wxColour& colour); +#if 0 + DocCtorStr( + wxMask(const wxBitmap& bitmap), + "Constructs a mask from a monochrome bitmap."); +#endif + + DocStr(wxMask, + "Constructs a mask from a bitmap and a colour in that bitmap that indicates\n" + "the transparent portions of the mask, by default BLACK is used."); + + %extend { + wxMask(const wxBitmap& bitmap, const wxColour& colour = wxNullColour) { + if ( !colour.Ok() ) + return new wxMask(bitmap, *wxBLACK); + else + return new wxMask(bitmap, colour); + } + } //~wxMask(); - }; +%pythoncode { MaskColour = Mask } + //--------------------------------------------------------------------------- //---------------------------------------------------------------------------