]> git.saurik.com Git - wxWidgets.git/blob - wxPython/src/_bitmap.i
Fixes for later WinCE versions
[wxWidgets.git] / wxPython / src / _bitmap.i
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: _bitmap.i
3 // Purpose: SWIG interface for wxBitmap and wxMask
4 //
5 // Author: Robin Dunn
6 //
7 // Created: 7-July-1997
8 // RCS-ID: $Id$
9 // Copyright: (c) 2003 by Total Control Software
10 // Licence: wxWindows license
11 /////////////////////////////////////////////////////////////////////////////
12
13 // Not a %module
14
15
16 //---------------------------------------------------------------------------
17
18 %{
19 #include <wx/image.h>
20
21 static char** ConvertListOfStrings(PyObject* listOfStrings) {
22 char** cArray = NULL;
23 int count;
24
25 if (!PyList_Check(listOfStrings)) {
26 PyErr_SetString(PyExc_TypeError, "Expected a list of strings.");
27 return NULL;
28 }
29 count = PyList_Size(listOfStrings);
30 cArray = new char*[count];
31
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));
35 }
36 return cArray;
37 }
38
39 %}
40
41 //---------------------------------------------------------------------------
42
43 // TODO: When the API stabalizes and is available on other platforms, add
44 // wrappers for the new wxBitmap, wxRawBitmap, wxDIB stuff...
45
46
47 class wxBitmap : public wxGDIObject
48 {
49 public:
50 wxBitmap(const wxString& name, wxBitmapType type=wxBITMAP_TYPE_ANY);
51 ~wxBitmap();
52
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);
57 %extend {
58 %name(BitmapFromXPMData) wxBitmap(PyObject* listOfStrings) {
59 char** cArray = NULL;
60 wxBitmap* bmp;
61
62 cArray = ConvertListOfStrings(listOfStrings);
63 if (! cArray)
64 return NULL;
65 bmp = new wxBitmap(cArray);
66 delete [] cArray;
67 return bmp;
68 }
69
70 %name(BitmapFromBits) wxBitmap(PyObject* bits, int width, int height, int depth = 1 ) {
71 char* buf;
72 int length;
73 PyString_AsStringAndSize(bits, &buf, &length);
74 return new wxBitmap(buf, width, height, depth);
75 }
76 }
77
78
79 #ifdef __WXMSW__
80 void SetPalette(wxPalette& palette);
81 #endif
82
83 // wxGDIImage methods
84 #ifdef __WXMSW__
85 long GetHandle();
86 void SetHandle(long handle);
87 #endif
88
89 bool Ok();
90
91 int GetWidth();
92 int GetHeight();
93 int GetDepth();
94
95 virtual wxImage ConvertToImage() const;
96
97 virtual wxMask* GetMask() const;
98 virtual void SetMask(wxMask* mask);
99 %extend {
100 void SetMaskColour(const wxColour& colour) {
101 wxMask *mask = new wxMask(*self, colour);
102 self->SetMask(mask);
103 }
104 }
105 // def SetMaskColour(self, colour):
106 // mask = wxMaskColour(self, colour)
107 // self.SetMask(mask)
108
109 virtual wxBitmap GetSubBitmap(const wxRect& rect) const;
110
111 virtual bool SaveFile(const wxString &name, wxBitmapType type,
112 wxPalette *palette = (wxPalette *)NULL);
113 virtual bool LoadFile(const wxString &name, wxBitmapType type);
114
115
116 #if wxUSE_PALETTE
117 virtual wxPalette *GetPalette() const;
118 virtual void SetPalette(const wxPalette& palette);
119 #endif
120
121 // copies the contents and mask of the given (colour) icon to the bitmap
122 virtual bool CopyFromIcon(const wxIcon& icon);
123
124 virtual void SetHeight(int height);
125 virtual void SetWidth(int width);
126 virtual void SetDepth(int depth);
127
128 #ifdef __WXMSW__
129 bool CopyFromCursor(const wxCursor& cursor);
130 int GetQuality();
131 void SetQuality(int q);
132 #endif
133
134 %pythoncode { def __nonzero__(self): return self.Ok() }
135 };
136
137
138 //---------------------------------------------------------------------------
139
140 class wxMask : public wxObject {
141 public:
142 wxMask(const wxBitmap& bitmap);
143 %name(MaskColour) wxMask(const wxBitmap& bitmap, const wxColour& colour);
144
145 //~wxMask();
146
147 };
148
149 //---------------------------------------------------------------------------
150 //---------------------------------------------------------------------------