///////////////////////////////////////////////////////////////////////////// // Name: _bitmap.i // Purpose: SWIG interface for wxBitmap and wxMask // // Author: Robin Dunn // // Created: 7-July-1997 // RCS-ID: $Id$ // Copyright: (c) 2003 by Total Control Software // Licence: wxWindows license ///////////////////////////////////////////////////////////////////////////// // Not a %module //--------------------------------------------------------------------------- %{ #include static char** ConvertListOfStrings(PyObject* listOfStrings) { char** cArray = NULL; int count; if (!PyList_Check(listOfStrings)) { PyErr_SetString(PyExc_TypeError, "Expected a list of strings."); return NULL; } count = PyList_Size(listOfStrings); cArray = new char*[count]; for(int x=0; xSetHandle((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(); %extend { DocStr(GetSize, "Get the size of the bitmap."); wxSize GetSize() { wxSize size(self->GetWidth(), self->GetHeight()); return size; } } 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); } } 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); #if wxUSE_PALETTE virtual wxPalette *GetPalette() const; virtual void SetPalette(const wxPalette& palette); #endif 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); %extend { DocStr(SetSize, "Set the bitmap size"); void SetSize(const wxSize& size) { self->SetWidth(size.x); self->SetHeight(size.y); } } #ifdef __WXMSW__ bool CopyFromCursor(const wxCursor& cursor); int GetQuality(); void SetQuality(int q); #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: #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 } //--------------------------------------------------------------------------- //---------------------------------------------------------------------------