1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: SWIG interface for wxBitmap and wxMask
7 // Created: 7-July-1997
9 // Copyright: (c) 2003 by Total Control Software
10 // Licence: wxWindows license
11 /////////////////////////////////////////////////////////////////////////////
16 //---------------------------------------------------------------------------
21 static char** ConvertListOfStrings(PyObject* listOfStrings) {
25 if (!PyList_Check(listOfStrings)) {
26 PyErr_SetString(PyExc_TypeError, "Expected a list of strings.");
29 count = PyList_Size(listOfStrings);
30 cArray = new char*[count];
32 for(int x=0; x<count; x++) {
33 // TODO: Need some validation and error checking here
34 cArray[x] = PyString_AsString(PyList_GET_ITEM(listOfStrings, x));
41 //---------------------------------------------------------------------------
43 // TODO: When the API stabalizes and is available on other platforms, add
44 // wrappers for the new wxBitmap, wxRawBitmap, wxDIB stuff...
47 class wxBitmap : public wxGDIObject
50 wxBitmap(const wxString& name, wxBitmapType type=wxBITMAP_TYPE_ANY);
53 // alternate constructors
54 %name(EmptyBitmap) wxBitmap(int width, int height, int depth=-1);
55 %name(BitmapFromIcon) wxBitmap(const wxIcon& icon);
56 %name(BitmapFromImage) wxBitmap(const wxImage& image, int depth=-1);
58 %name(BitmapFromXPMData) wxBitmap(PyObject* listOfStrings) {
62 cArray = ConvertListOfStrings(listOfStrings);
65 bmp = new wxBitmap(cArray);
70 %name(BitmapFromBits) wxBitmap(PyObject* bits, int width, int height, int depth = 1 ) {
73 PyString_AsStringAndSize(bits, &buf, &length);
74 return new wxBitmap(buf, width, height, depth);
80 void SetPalette(wxPalette& palette);
86 void SetHandle(long handle);
95 virtual wxImage ConvertToImage() const;
97 virtual wxMask* GetMask() const;
98 virtual void SetMask(wxMask* mask);
100 void SetMaskColour(const wxColour& colour) {
101 wxMask *mask = new wxMask(*self, colour);
105 // def SetMaskColour(self, colour):
106 // mask = wxMaskColour(self, colour)
107 // self.SetMask(mask)
109 virtual wxBitmap GetSubBitmap(const wxRect& rect) const;
111 virtual bool SaveFile(const wxString &name, wxBitmapType type,
112 wxPalette *palette = (wxPalette *)NULL);
113 virtual bool LoadFile(const wxString &name, wxBitmapType type);
117 virtual wxPalette *GetPalette() const;
118 virtual void SetPalette(const wxPalette& palette);
121 // copies the contents and mask of the given (colour) icon to the bitmap
122 virtual bool CopyFromIcon(const wxIcon& icon);
124 virtual void SetHeight(int height);
125 virtual void SetWidth(int width);
126 virtual void SetDepth(int depth);
129 bool CopyFromCursor(const wxCursor& cursor);
131 void SetQuality(int q);
134 %pythoncode { def __nonzero__(self): return self.Ok() }
138 //---------------------------------------------------------------------------
140 class wxMask : public wxObject {
142 wxMask(const wxBitmap& bitmap);
143 %name(MaskColour) wxMask(const wxBitmap& bitmap, const wxColour& colour);
149 //---------------------------------------------------------------------------
150 //---------------------------------------------------------------------------