Allow comparrisons with None

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@25857 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robin Dunn
2004-02-19 02:33:28 +00:00
parent 112ae51d19
commit 22faec7d06
16 changed files with 258 additions and 234 deletions

View File

@@ -1392,42 +1392,6 @@ public:
//---------------------------------------------------------------------------
class wxGridCellCoords
{
public:
wxGridCellCoords( int r=-1, int c=-1 );
~wxGridCellCoords();
int GetRow() const;
void SetRow( int n );
int GetCol() const;
void SetCol( int n );
void Set( int row, int col );
bool operator==( const wxGridCellCoords& other ) const;
bool operator!=( const wxGridCellCoords& other ) const;
%extend {
PyObject* asTuple() {
PyObject* tup = PyTuple_New(2);
PyTuple_SET_ITEM(tup, 0, PyInt_FromLong(self->GetRow()));
PyTuple_SET_ITEM(tup, 1, PyInt_FromLong(self->GetCol()));
return tup;
}
}
%pythoncode {
def __str__(self): return str(self.asTuple())
def __repr__(self): return 'wxGridCellCoords'+str(self.asTuple())
def __len__(self): return len(self.asTuple())
def __getitem__(self, index): return self.asTuple()[index]
def __setitem__(self, index, val):
if index == 0: self.SetRow(val)
elif index == 1: self.SetCol(val)
else: raise IndexError
}
};
// Typemap to allow conversion of sequence objects to wxGridCellCoords...
%typemap(in) wxGridCellCoords& (wxGridCellCoords temp) {
$1 = &temp;
@@ -1442,6 +1406,11 @@ public:
%{
bool wxGridCellCoords_helper(PyObject* source, wxGridCellCoords** obj) {
if (source == Py_None) {
**obj = wxGridCellCoords(-1,-1);
return True;
}
// If source is an object instance then it may already be the right type
if (wxPySwigInstance_Check(source)) {
wxGridCellCoords* ptr;
@@ -1515,6 +1484,47 @@ PyObject* wxGridCellCoordsArray_helper(const wxGridCellCoordsArray& source)
}
%}
class wxGridCellCoords
{
public:
wxGridCellCoords( int r=-1, int c=-1 );
~wxGridCellCoords();
int GetRow() const;
void SetRow( int n );
int GetCol() const;
void SetCol( int n );
void Set( int row, int col );
bool operator==( const wxGridCellCoords& other ) const;
bool operator!=( const wxGridCellCoords& other ) const;
%extend {
PyObject* asTuple() {
PyObject* tup = PyTuple_New(2);
PyTuple_SET_ITEM(tup, 0, PyInt_FromLong(self->GetRow()));
PyTuple_SET_ITEM(tup, 1, PyInt_FromLong(self->GetCol()));
return tup;
}
}
%pythoncode {
def __str__(self): return str(self.asTuple())
def __repr__(self): return 'wxGridCellCoords'+str(self.asTuple())
def __len__(self): return len(self.asTuple())
def __getitem__(self, index): return self.asTuple()[index]
def __setitem__(self, index, val):
if index == 0: self.SetRow(val)
elif index == 1: self.SetCol(val)
else: raise IndexError
}
};
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// The grid itself