Added GetSelectedCells, GetSelectionBlockTopLeft,
GetSelectionBlockBottomRight, GetSelectedRows, GetSelectedCols nethods to wxGrid. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_4_BRANCH@17596 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -1403,8 +1403,17 @@ public:
|
||||
return *self != other;
|
||||
}
|
||||
}
|
||||
%pragma(python) addtoclass = "def __str__(self): return str(self.asTuple())"
|
||||
%pragma(python) addtoclass = "def __repr__(self): return str(self.asTuple())"
|
||||
%pragma(python) addtoclass = "
|
||||
def __str__(self): return str(self.asTuple())
|
||||
def __repr__(self): return 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...
|
||||
@@ -1440,6 +1449,32 @@ bool wxGridCellCoords_helper(PyObject* source, wxGridCellCoords** obj) {
|
||||
}
|
||||
%}
|
||||
|
||||
|
||||
|
||||
// Typemap to convert an array of cells coords to a list of tuples...
|
||||
%typemap(python, out) wxGridCellCoordsArray& {
|
||||
$target = wxGridCellCoordsArray_helper($source);
|
||||
}
|
||||
|
||||
|
||||
// ...and the helper function for the above typemap.
|
||||
%{
|
||||
PyObject* wxGridCellCoordsArray_helper(const wxGridCellCoordsArray* source)
|
||||
{
|
||||
PyObject* list = PyList_New(0);
|
||||
size_t idx;
|
||||
for (idx = 0; idx < source->GetCount(); idx += 1) {
|
||||
wxGridCellCoords& coord = source->Item(idx);
|
||||
PyObject* tup = PyTuple_New(2);
|
||||
PyTuple_SET_ITEM(tup, 0, PyInt_FromLong(coord.GetRow()));
|
||||
PyTuple_SET_ITEM(tup, 1, PyInt_FromLong(coord.GetCol()));
|
||||
PyList_Append(list, tup);
|
||||
Py_DECREF(tup);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
%}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//---------------------------------------------------------------------------
|
||||
// The grid itself
|
||||
@@ -1763,12 +1798,11 @@ public:
|
||||
bool IsInSelection( int row, int col );
|
||||
// TODO: ??? bool IsInSelection( const wxGridCellCoords& coords )
|
||||
|
||||
// TODO: These need typemaps
|
||||
// wxGridCellCoordsArray GetSelectedCells() const;
|
||||
// wxGridCellCoordsArray GetSelectionBlockTopLeft() const;
|
||||
// wxGridCellCoordsArray GetSelectionBlockBottomRight() const;
|
||||
// wxArrayInt GetSelectedRows() const;
|
||||
// wxArrayInt GetSelectedCols() const;
|
||||
wxGridCellCoordsArray& GetSelectedCells() const;
|
||||
wxGridCellCoordsArray& GetSelectionBlockTopLeft() const;
|
||||
wxGridCellCoordsArray& GetSelectionBlockBottomRight() const;
|
||||
wxArrayInt& GetSelectedRows() const;
|
||||
wxArrayInt& GetSelectedCols() const;
|
||||
|
||||
|
||||
// This function returns the rectangle that encloses the block of cells
|
||||
|
@@ -308,6 +308,18 @@ $function
|
||||
}
|
||||
|
||||
|
||||
// Typemap to convert an array of ints to a list
|
||||
%typemap(python, out) wxArrayInt& {
|
||||
$target = PyList_New(0);
|
||||
size_t idx;
|
||||
for (idx = 0; idx < $source->GetCount(); idx += 1) {
|
||||
PyObject* val = PyInt_FromLong($source->Item(idx));
|
||||
PyList_Append($target, val);
|
||||
Py_DECREF(val);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Map T_OUTPUTs for floats to return ints.
|
||||
|
||||
|
Reference in New Issue
Block a user