Fixed wxImage GetData and SetData to properly use String objects for

data transfer.

Added access methods to wxGridEvent.


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@3244 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robin Dunn 1999-08-03 06:44:28 +00:00
parent 849949b13f
commit 1dc2f8658b
7 changed files with 975 additions and 6630 deletions

View File

@ -93,6 +93,10 @@ Added a helper function named wxPyTypeCast that can convert shadow
objects of one type into shadow objects of another type. (Like doing
a down-cast.) See the implementation in wx.py for some docs.
Fixed wxImage GetData and SetData to properly use String objects for
data transfer.
Added access methods to wxGridEvent.

View File

@ -102,8 +102,27 @@ public:
int GetWidth();
int GetHeight();
unsigned char *GetData();
void SetData( unsigned char *data );
//unsigned char *GetData();
//void SetData( unsigned char *data );
%addmethods {
PyObject* GetData() {
unsigned char* data = self->GetData();
int len = self->GetWidth() * self->GetHeight() * 3;
return PyString_FromStringAndSize((char*)data, len);
}
void SetData(PyObject* data) {
unsigned char* dataPtr;
if (! PyString_Check(data)) {
PyErr_SetString(PyExc_TypeError, "Expected string object");
return /* NULL */ ;
}
dataPtr = (unsigned char*)PyString_AsString(data);
self->SetData(dataPtr);
}
}
void SetMaskColour( unsigned char r, unsigned char g, unsigned char b );
unsigned char GetMaskRed();

File diff suppressed because it is too large Load Diff

View File

@ -1207,13 +1207,16 @@ static PyObject *_wrap_wxImage_GetHeight(PyObject *self, PyObject *args) {
return _resultobj;
}
#define wxImage_GetData(_swigobj) (_swigobj->GetData())
static PyObject * wxImage_GetData(wxImage *self) {
unsigned char* data = self->GetData();
int len = self->GetWidth() * self->GetHeight() * 3;
return PyString_FromStringAndSize((char*)data, len);
}
static PyObject *_wrap_wxImage_GetData(PyObject *self, PyObject *args) {
PyObject * _resultobj;
unsigned char * _result;
PyObject * _result;
wxImage * _arg0;
char * _argc0 = 0;
char _ptemp[128];
self = self;
if(!PyArg_ParseTuple(args,"s:wxImage_GetData",&_argc0))
@ -1226,24 +1229,34 @@ static PyObject *_wrap_wxImage_GetData(PyObject *self, PyObject *args) {
}
{
wxPy_BEGIN_ALLOW_THREADS;
_result = (unsigned char *)wxImage_GetData(_arg0);
_result = (PyObject *)wxImage_GetData(_arg0);
wxPy_END_ALLOW_THREADS;
} SWIG_MakePtr(_ptemp, (char *) _result,"_unsigned_char_p");
_resultobj = Py_BuildValue("s",_ptemp);
}{
_resultobj = _result;
}
return _resultobj;
}
#define wxImage_SetData(_swigobj,_swigarg0) (_swigobj->SetData(_swigarg0))
static void wxImage_SetData(wxImage *self,PyObject * data) {
unsigned char* dataPtr;
if (! PyString_Check(data)) {
PyErr_SetString(PyExc_TypeError, "Expected string object");
return /* NULL */ ;
}
dataPtr = (unsigned char*)PyString_AsString(data);
self->SetData(dataPtr);
}
static PyObject *_wrap_wxImage_SetData(PyObject *self, PyObject *args) {
PyObject * _resultobj;
wxImage * _arg0;
unsigned char * _arg1;
PyObject * _arg1;
char * _argc0 = 0;
char * _argc1 = 0;
PyObject * _obj1 = 0;
self = self;
if(!PyArg_ParseTuple(args,"ss:wxImage_SetData",&_argc0,&_argc1))
if(!PyArg_ParseTuple(args,"sO:wxImage_SetData",&_argc0,&_obj1))
return NULL;
if (_argc0) {
if (SWIG_GetPtr(_argc0,(void **) &_arg0,"_wxImage_p")) {
@ -1251,12 +1264,9 @@ static PyObject *_wrap_wxImage_SetData(PyObject *self, PyObject *args) {
return NULL;
}
}
if (_argc1) {
if (SWIG_GetPtr(_argc1,(void **) &_arg1,"_unsigned_char_p")) {
PyErr_SetString(PyExc_TypeError,"Type error in argument 2 of wxImage_SetData. Expected _unsigned_char_p.");
return NULL;
}
}
{
_arg1 = _obj1;
}
{
wxPy_BEGIN_ALLOW_THREADS;
wxImage_SetData(_arg0,_arg1);

View File

@ -2958,6 +2958,160 @@ static PyObject *_wrap_wxGridEvent_m_cell_get(PyObject *self, PyObject *args) {
return _resultobj;
}
#define wxGridEvent_GetRow(_swigobj) (_swigobj->GetRow())
static PyObject *_wrap_wxGridEvent_GetRow(PyObject *self, PyObject *args) {
PyObject * _resultobj;
int _result;
wxGridEvent * _arg0;
char * _argc0 = 0;
self = self;
if(!PyArg_ParseTuple(args,"s:wxGridEvent_GetRow",&_argc0))
return NULL;
if (_argc0) {
if (SWIG_GetPtr(_argc0,(void **) &_arg0,"_wxGridEvent_p")) {
PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of wxGridEvent_GetRow. Expected _wxGridEvent_p.");
return NULL;
}
}
{
wxPy_BEGIN_ALLOW_THREADS;
_result = (int )wxGridEvent_GetRow(_arg0);
wxPy_END_ALLOW_THREADS;
} _resultobj = Py_BuildValue("i",_result);
return _resultobj;
}
#define wxGridEvent_GetCol(_swigobj) (_swigobj->GetCol())
static PyObject *_wrap_wxGridEvent_GetCol(PyObject *self, PyObject *args) {
PyObject * _resultobj;
int _result;
wxGridEvent * _arg0;
char * _argc0 = 0;
self = self;
if(!PyArg_ParseTuple(args,"s:wxGridEvent_GetCol",&_argc0))
return NULL;
if (_argc0) {
if (SWIG_GetPtr(_argc0,(void **) &_arg0,"_wxGridEvent_p")) {
PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of wxGridEvent_GetCol. Expected _wxGridEvent_p.");
return NULL;
}
}
{
wxPy_BEGIN_ALLOW_THREADS;
_result = (int )wxGridEvent_GetCol(_arg0);
wxPy_END_ALLOW_THREADS;
} _resultobj = Py_BuildValue("i",_result);
return _resultobj;
}
#define wxGridEvent_GetPosition(_swigobj) (_swigobj->GetPosition())
static PyObject *_wrap_wxGridEvent_GetPosition(PyObject *self, PyObject *args) {
PyObject * _resultobj;
wxPoint * _result;
wxGridEvent * _arg0;
char * _argc0 = 0;
char _ptemp[128];
self = self;
if(!PyArg_ParseTuple(args,"s:wxGridEvent_GetPosition",&_argc0))
return NULL;
if (_argc0) {
if (SWIG_GetPtr(_argc0,(void **) &_arg0,"_wxGridEvent_p")) {
PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of wxGridEvent_GetPosition. Expected _wxGridEvent_p.");
return NULL;
}
}
{
wxPy_BEGIN_ALLOW_THREADS;
_result = new wxPoint (wxGridEvent_GetPosition(_arg0));
wxPy_END_ALLOW_THREADS;
} SWIG_MakePtr(_ptemp, (void *) _result,"_wxPoint_p");
_resultobj = Py_BuildValue("s",_ptemp);
return _resultobj;
}
#define wxGridEvent_ControlDown(_swigobj) (_swigobj->ControlDown())
static PyObject *_wrap_wxGridEvent_ControlDown(PyObject *self, PyObject *args) {
PyObject * _resultobj;
bool _result;
wxGridEvent * _arg0;
char * _argc0 = 0;
self = self;
if(!PyArg_ParseTuple(args,"s:wxGridEvent_ControlDown",&_argc0))
return NULL;
if (_argc0) {
if (SWIG_GetPtr(_argc0,(void **) &_arg0,"_wxGridEvent_p")) {
PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of wxGridEvent_ControlDown. Expected _wxGridEvent_p.");
return NULL;
}
}
{
wxPy_BEGIN_ALLOW_THREADS;
_result = (bool )wxGridEvent_ControlDown(_arg0);
wxPy_END_ALLOW_THREADS;
} _resultobj = Py_BuildValue("i",_result);
return _resultobj;
}
#define wxGridEvent_ShiftDown(_swigobj) (_swigobj->ShiftDown())
static PyObject *_wrap_wxGridEvent_ShiftDown(PyObject *self, PyObject *args) {
PyObject * _resultobj;
bool _result;
wxGridEvent * _arg0;
char * _argc0 = 0;
self = self;
if(!PyArg_ParseTuple(args,"s:wxGridEvent_ShiftDown",&_argc0))
return NULL;
if (_argc0) {
if (SWIG_GetPtr(_argc0,(void **) &_arg0,"_wxGridEvent_p")) {
PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of wxGridEvent_ShiftDown. Expected _wxGridEvent_p.");
return NULL;
}
}
{
wxPy_BEGIN_ALLOW_THREADS;
_result = (bool )wxGridEvent_ShiftDown(_arg0);
wxPy_END_ALLOW_THREADS;
} _resultobj = Py_BuildValue("i",_result);
return _resultobj;
}
#define wxGridEvent_GetCell(_swigobj) (_swigobj->GetCell())
static PyObject *_wrap_wxGridEvent_GetCell(PyObject *self, PyObject *args) {
PyObject * _resultobj;
wxGridCell * _result;
wxGridEvent * _arg0;
char * _argc0 = 0;
char _ptemp[128];
self = self;
if(!PyArg_ParseTuple(args,"s:wxGridEvent_GetCell",&_argc0))
return NULL;
if (_argc0) {
if (SWIG_GetPtr(_argc0,(void **) &_arg0,"_wxGridEvent_p")) {
PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of wxGridEvent_GetCell. Expected _wxGridEvent_p.");
return NULL;
}
}
{
wxPy_BEGIN_ALLOW_THREADS;
_result = (wxGridCell *)wxGridEvent_GetCell(_arg0);
wxPy_END_ALLOW_THREADS;
} SWIG_MakePtr(_ptemp, (char *) _result,"_wxGridCell_p");
_resultobj = Py_BuildValue("s",_ptemp);
return _resultobj;
}
static void *SwigwxNotebookEventTowxNotifyEvent(void *ptr) {
wxNotebookEvent *src;
wxNotifyEvent *dest;
@ -4585,6 +4739,12 @@ static PyMethodDef windows2cMethods[] = {
{ "wxNotebookEvent_SetOldSelection", _wrap_wxNotebookEvent_SetOldSelection, 1 },
{ "wxNotebookEvent_GetOldSelection", _wrap_wxNotebookEvent_GetOldSelection, 1 },
{ "wxNotebookEvent_GetSelection", _wrap_wxNotebookEvent_GetSelection, 1 },
{ "wxGridEvent_GetCell", _wrap_wxGridEvent_GetCell, 1 },
{ "wxGridEvent_ShiftDown", _wrap_wxGridEvent_ShiftDown, 1 },
{ "wxGridEvent_ControlDown", _wrap_wxGridEvent_ControlDown, 1 },
{ "wxGridEvent_GetPosition", _wrap_wxGridEvent_GetPosition, 1 },
{ "wxGridEvent_GetCol", _wrap_wxGridEvent_GetCol, 1 },
{ "wxGridEvent_GetRow", _wrap_wxGridEvent_GetRow, 1 },
{ "wxGridEvent_m_cell_get", _wrap_wxGridEvent_m_cell_get, 1 },
{ "wxGridEvent_m_cell_set", _wrap_wxGridEvent_m_cell_set, 1 },
{ "wxGridEvent_m_shift_get", _wrap_wxGridEvent_m_shift_get, 1 },

View File

@ -322,6 +322,27 @@ class wxGridEventPtr(wxEventPtr):
def __init__(self,this):
self.this = this
self.thisown = 0
def GetRow(self):
val = windows2c.wxGridEvent_GetRow(self.this)
return val
def GetCol(self):
val = windows2c.wxGridEvent_GetCol(self.this)
return val
def GetPosition(self):
val = windows2c.wxGridEvent_GetPosition(self.this)
val = wxPointPtr(val)
val.thisown = 1
return val
def ControlDown(self):
val = windows2c.wxGridEvent_ControlDown(self.this)
return val
def ShiftDown(self):
val = windows2c.wxGridEvent_ShiftDown(self.this)
return val
def GetCell(self):
val = windows2c.wxGridEvent_GetCell(self.this)
val = wxGridCellPtr(val)
return val
def __setattr__(self,name,value):
if name == "m_row" :
windows2c.wxGridEvent_m_row_set(self.this,value)

View File

@ -219,6 +219,13 @@ public:
bool m_control;
bool m_shift;
wxGridCell* m_cell;
int GetRow();
int GetCol();
wxPoint GetPosition();
bool ControlDown();
bool ShiftDown();
wxGridCell* GetCell();
};