mirror of
https://github.com/wxWidgets/Phoenix.git
synced 2026-01-08 13:00:07 +01:00
Add wxBitmap constructor accepting a list of strings of XPM data
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxPython/Phoenix/trunk@72145 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -42,11 +42,42 @@ def run():
|
||||
|
||||
tools.removeVirtuals(c)
|
||||
|
||||
c.find('wxBitmap').findOverload('(const char *const *bits)').ignore()
|
||||
c.find('wxBitmap.bits').type = 'const char*'
|
||||
c.find('wxBitmap.type').default = 'wxBITMAP_TYPE_ANY'
|
||||
c.find('LoadFile.type').default = 'wxBITMAP_TYPE_ANY'
|
||||
|
||||
c.find('wxBitmap').findOverload('(const char *const *bits)').ignore()
|
||||
|
||||
c.addCppCtor('(PyObject* listOfBytes)',
|
||||
doc="Construct a Bitmap from a list of strings formatted as XPM data.",
|
||||
body="""\
|
||||
wxPyThreadBlocker blocker;
|
||||
char** cArray = NULL;
|
||||
int count;
|
||||
char errMsg[] = "Expected a list of bytes objects.";
|
||||
|
||||
if (!PyList_Check(listOfBytes)) {
|
||||
PyErr_SetString(PyExc_TypeError, errMsg);
|
||||
return NULL;
|
||||
}
|
||||
count = PyList_Size(listOfBytes);
|
||||
cArray = new char*[count];
|
||||
|
||||
for(int x=0; x<count; x++) {
|
||||
PyObject* item = PyList_GET_ITEM(listOfBytes, x);
|
||||
if (!PyBytes_Check(item)) {
|
||||
PyErr_SetString(PyExc_TypeError, errMsg);
|
||||
delete [] cArray;
|
||||
return NULL;
|
||||
}
|
||||
cArray[x] = PyBytes_AsString(item);
|
||||
}
|
||||
wxBitmap* bmp = new wxBitmap(cArray);
|
||||
delete [] cArray;
|
||||
return bmp;
|
||||
""")
|
||||
|
||||
|
||||
c.find('SetMask.mask').transfer = True
|
||||
|
||||
c.addCppMethod('void', 'SetMaskColour', '(const wxColour& colour)', """\
|
||||
|
||||
Reference in New Issue
Block a user