wxPyOORClientData* data = (wxPyOORClientData*)source->GetClientObject(); \
if (data) { \
target = data->m_obj; \
- Py_INCREF(target); \
+ if (target) \
+ Py_INCREF(target); \
} \
/* Otherwise make a new wrapper for it the old fashioned way and \
give it the OOR treatment */ \
%mutable;
-%rename(GRID_DEFAULT_NUMBER_ROWS) WXGRID_DEFAULT_NUMBER_ROWS;
-%rename(GRID_DEFAULT_NUMBER_COLS) WXGRID_DEFAULT_NUMBER_COLS;
-%rename(GRID_DEFAULT_ROW_HEIGHT) WXGRID_DEFAULT_ROW_HEIGHT;
-%rename(GRID_DEFAULT_COL_WIDTH) WXGRID_DEFAULT_COL_WIDTH;
-%rename(GRID_DEFAULT_COL_LABEL_HEIGHT) WXGRID_DEFAULT_COL_LABEL_HEIGHT;
-%rename(GRID_DEFAULT_ROW_LABEL_WIDTH) WXGRID_DEFAULT_ROW_LABEL_WIDTH;
-%rename(GRID_LABEL_EDGE_ZONE) WXGRID_LABEL_EDGE_ZONE;
-%rename(GRID_MIN_ROW_HEIGHT) WXGRID_MIN_ROW_HEIGHT;
-%rename(GRID_MIN_COL_WIDTH) WXGRID_MIN_COL_WIDTH;
-%rename(GRID_DEFAULT_SCROLLBAR_WIDTH) WXGRID_DEFAULT_SCROLLBAR_WIDTH;
+%{
+#define wxGRID_DEFAULT_NUMBER_ROWS WXGRID_DEFAULT_NUMBER_ROWS
+#define wxGRID_DEFAULT_NUMBER_COLS WXGRID_DEFAULT_NUMBER_COLS
+#define wxGRID_DEFAULT_ROW_HEIGHT WXGRID_DEFAULT_ROW_HEIGHT
+#define wxGRID_DEFAULT_COL_WIDTH WXGRID_DEFAULT_COL_WIDTH
+#define wxGRID_DEFAULT_COL_LABEL_HEIGHT WXGRID_DEFAULT_COL_LABEL_HEIGHT
+#define wxGRID_DEFAULT_ROW_LABEL_WIDTH WXGRID_DEFAULT_ROW_LABEL_WIDTH
+#define wxGRID_LABEL_EDGE_ZONE WXGRID_LABEL_EDGE_ZONE
+#define wxGRID_MIN_ROW_HEIGHT WXGRID_MIN_ROW_HEIGHT
+#define wxGRID_MIN_COL_WIDTH WXGRID_MIN_COL_WIDTH
+#define wxGRID_DEFAULT_SCROLLBAR_WIDTH WXGRID_DEFAULT_SCROLLBAR_WIDTH
+%}
enum {
- WXGRID_DEFAULT_NUMBER_ROWS,
- WXGRID_DEFAULT_NUMBER_COLS,
- WXGRID_DEFAULT_ROW_HEIGHT,
- WXGRID_DEFAULT_COL_WIDTH,
- WXGRID_DEFAULT_COL_LABEL_HEIGHT,
- WXGRID_DEFAULT_ROW_LABEL_WIDTH,
- WXGRID_LABEL_EDGE_ZONE,
- WXGRID_MIN_ROW_HEIGHT,
- WXGRID_MIN_COL_WIDTH,
- WXGRID_DEFAULT_SCROLLBAR_WIDTH
+ wxGRID_DEFAULT_NUMBER_ROWS,
+ wxGRID_DEFAULT_NUMBER_COLS,
+ wxGRID_DEFAULT_ROW_HEIGHT,
+ wxGRID_DEFAULT_COL_WIDTH,
+ wxGRID_DEFAULT_COL_LABEL_HEIGHT,
+ wxGRID_DEFAULT_ROW_LABEL_WIDTH,
+ wxGRID_LABEL_EDGE_ZONE,
+ wxGRID_MIN_ROW_HEIGHT,
+ wxGRID_MIN_COL_WIDTH,
+ wxGRID_DEFAULT_SCROLLBAR_WIDTH
};
public:
%extend {
void _setOORInfo(PyObject* _self) {
- self->SetClientObject(new wxPyOORClientData(_self));
+ if (!self->GetClientObject())
+ self->SetClientObject(new wxPyOORClientData(_self));
}
}
public:
%extend {
void _setOORInfo(PyObject* _self) {
- self->SetClientObject(new wxPyOORClientData(_self));
+ if (!self->GetClientObject())
+ self->SetClientObject(new wxPyOORClientData(_self));
}
}
bool EndEdit(int row, int col, wxGrid* grid) {
- bool rv = False;
+ bool rv = false;
bool blocked = wxPyBeginBlockThreads();
if (wxPyCBH_findCallback(m_myInst, "EndEdit")) {
PyObject* go = wxPyMake_wxObject(grid,false);
%pythonAppend wxGridCellChoiceEditor "self._setOORInfo(self)"
wxGridCellChoiceEditor(int choices = 0,
const wxString* choices_array = NULL,
- bool allowOthers = False);
+ bool allowOthers = false);
virtual wxString GetValue();
};
%extend {
void _setOORInfo(PyObject* _self) {
- self->SetClientObject(new wxPyOORClientData(_self));
+ if (!self->GetClientObject())
+ self->SetClientObject(new wxPyOORClientData(_self));
}
}
%pythonAppend wxGridCellAttr "self._setOORInfo(self)"
wxGridCellAttr(wxGridCellAttr *attrDefault = NULL);
-
+
wxGridCellAttr *Clone() const;
void MergeWith(wxGridCellAttr *mergefrom);
void IncRef();
void SetFont(const wxFont& font);
void SetAlignment(int hAlign, int vAlign);
void SetSize(int num_rows, int num_cols);
- void SetOverflow( bool allow = True );
- void SetReadOnly(bool isReadOnly = True);
+ void SetOverflow( bool allow = true );
+ void SetReadOnly(bool isReadOnly = true);
void SetRenderer(wxGridCellRenderer *renderer);
void SetEditor(wxGridCellEditor* editor);
%extend {
void _setOORInfo(PyObject* _self) {
- self->SetClientObject(new wxPyOORClientData(_self));
+ if (!self->GetClientObject())
+ self->SetClientObject(new wxPyOORClientData(_self));
}
}
%extend {
void _setOORInfo(PyObject* _self) {
- self->SetClientObject(new wxPyOORClientData(_self));
+ if (!self->GetClientObject())
+ self->SetClientObject(new wxPyOORClientData(_self));
}
}
if (source == Py_None) {
**obj = wxGridCellCoords(-1,-1);
- return True;
+ return true;
}
// If source is an object instance then it may already be the right type
if (! wxPyConvertSwigPtr(source, (void **)&ptr, wxT("wxGridCellCoords")))
goto error;
*obj = ptr;
- return True;
+ return true;
}
// otherwise a 2-tuple of integers is expected
else if (PySequence_Check(source) && PyObject_Length(source) == 2) {
**obj = wxGridCellCoords(PyInt_AsLong(o1), PyInt_AsLong(o2));
Py_DECREF(o1);
Py_DECREF(o2);
- return True;
+ return true;
}
error:
PyErr_SetString(PyExc_TypeError, "Expected a 2-tuple of integers or a wxGridCellCoords object.");
- return False;
+ return false;
}
if (wxPySwigInstance_Check(source) &&
wxPyConvertSwigPtr(source, (void **)&ptr, wxT("wxGridCellCoords")))
- return True;
+ return true;
PyErr_Clear();
if (PySequence_Check(source) && PySequence_Length(source) == 2)
- return True;
+ return true;
- return False;
+ return false;
}
%}
{
public:
%pythonAppend wxGrid "self._setOORInfo(self)"
+ %typemap(out) wxGrid*; // turn off this typemap
wxGrid( wxWindow *parent,
wxWindowID id=-1,
%name(PreGrid) wxGrid();
+
+ // Turn it back on again
+ %typemap(out) wxGrid* { $result = wxPyMake_wxObject($1, $owner); }
+
bool Create( wxWindow *parent,
wxWindowID id=-1,
wxGridTableBase * GetTable() const;
- bool SetTable( wxGridTableBase *table, bool takeOwnership=False,
+ bool SetTable( wxGridTableBase *table, bool takeOwnership=false,
WXGRIDSELECTIONMODES selmode =
wxGrid::wxGridSelectCells );
void ClearGrid();
- bool InsertRows( int pos = 0, int numRows = 1, bool updateLabels=True );
- bool AppendRows( int numRows = 1, bool updateLabels=True );
- bool DeleteRows( int pos = 0, int numRows = 1, bool updateLabels=True );
- bool InsertCols( int pos = 0, int numCols = 1, bool updateLabels=True );
- bool AppendCols( int numCols = 1, bool updateLabels=True );
- bool DeleteCols( int pos = 0, int numCols = 1, bool updateLabels=True );
+ bool InsertRows( int pos = 0, int numRows = 1, bool updateLabels=true );
+ bool AppendRows( int numRows = 1, bool updateLabels=true );
+ bool DeleteRows( int pos = 0, int numRows = 1, bool updateLabels=true );
+ bool InsertCols( int pos = 0, int numCols = 1, bool updateLabels=true );
+ bool AppendCols( int numCols = 1, bool updateLabels=true );
+ bool DeleteCols( int pos = 0, int numCols = 1, bool updateLabels=true );
// this function is called when the current cell highlight must be redrawn
bool IsEditable();
void EnableEditing( bool edit );
- void EnableCellEditControl( bool enable = True );
+ void EnableCellEditControl( bool enable = true );
void DisableCellEditControl();
bool CanEnableCellControl() const;
bool IsCellEditControlEnabled() const;
// check to see if a cell is either wholly visible (the default arg) or
// at least partially visible in the grid window
//
- bool IsVisible( int row, int col, bool wholeCellVisible = True );
- // TODO: ??? bool IsVisible( const wxGridCellCoords& coords, bool wholeCellVisible = True );
+ bool IsVisible( int row, int col, bool wholeCellVisible = true );
+ // TODO: ??? bool IsVisible( const wxGridCellCoords& coords, bool wholeCellVisible = true );
void MakeCellVisible( int row, int col );
// TODO: ??? void MakeCellVisible( const wxGridCellCoords& coords );
void SetCellHighlightPenWidth(int width);
void SetCellHighlightROPenWidth(int width);
- void EnableDragRowSize( bool enable = True );
+ void EnableDragRowSize( bool enable = true );
void DisableDragRowSize();
bool CanDragRowSize();
- void EnableDragColSize( bool enable = True );
+ void EnableDragColSize( bool enable = true );
void DisableDragColSize();
bool CanDragColSize();
- void EnableDragGridSize(bool enable = True);
+ void EnableDragGridSize(bool enable = true);
void DisableDragGridSize();
bool CanDragGridSize();
+ void EnableDragCell( bool enable = true );
+ void DisableDragCell();
+ bool CanDragCell();
+
// this sets the specified attribute for all cells in this row/col
void SetAttr(int row, int col, wxGridCellAttr *attr);
void SetRowAttr(int row, wxGridCellAttr *attr);
void SetColAttr(int col, wxGridCellAttr *attr);
+ // returns the attribute we may modify in place: a new one if this cell
+ // doesn't have any yet or the existing one if it does
+ //
+ // DecRef() must be called on the returned pointer, as usual
+ wxGridCellAttr *GetOrCreateCellAttr(int row, int col) const;
+
+
// shortcuts for setting the column parameters
// set the format for the data in the column: default is string
void SetColFormatFloat(int col, int width = -1, int precision = -1);
void SetColFormatCustom(int col, const wxString& typeName);
- void EnableGridLines( bool enable = True );
+ void EnableGridLines( bool enable = true );
bool GridLinesEnabled();
// ------ row and col formatting
void, GetCellSize( int row, int col, int *OUTPUT, int *OUTPUT ),
"GetCellSize(int row, int col) -> (num_rows, num_cols)");
- void SetDefaultRowSize( int height, bool resizeExistingRows = False );
+ void SetDefaultRowSize( int height, bool resizeExistingRows = false );
void SetRowSize( int row, int height );
- void SetDefaultColSize( int width, bool resizeExistingCols = False );
+ void SetDefaultColSize( int width, bool resizeExistingCols = false );
void SetColSize( int col, int width );
// automatically size the column or row to fit to its contents, if
// setAsMin is True, this optimal width will also be set as minimal width
// for this column
- void AutoSizeColumn( int col, bool setAsMin = True );
- void AutoSizeRow( int row, bool setAsMin = True );
+ void AutoSizeColumn( int col, bool setAsMin = true );
+ void AutoSizeRow( int row, bool setAsMin = true );
// auto size all columns (very ineffective for big grids!)
- void AutoSizeColumns( bool setAsMin = True );
- void AutoSizeRows( bool setAsMin = True );
+ void AutoSizeColumns( bool setAsMin = true );
+ void AutoSizeRows( bool setAsMin = true );
// auto size the grid, that is make the columns/rows of the "right" size
// and also set the grid size to just fit its contents
bool IsReadOnly(int row, int col) const;
// make the cell editable/readonly
- void SetReadOnly(int row, int col, bool isReadOnly = True);
+ void SetReadOnly(int row, int col, bool isReadOnly = true);
// ------ selections of blocks of cells
//
- void SelectRow( int row, bool addToSelected = False );
- void SelectCol( int col, bool addToSelected = False );
+ void SelectRow( int row, bool addToSelected = false );
+ void SelectCol( int col, bool addToSelected = false );
void SelectBlock( int topRow, int leftCol, int bottomRow, int rightCol,
- bool addToSelected = False );
+ bool addToSelected = false );
// TODO: ??? void SelectBlock( const wxGridCellCoords& topLeft,
// TODO: ??? const wxGridCellCoords& bottomRight )
wxWindow* GetGridColLabelWindow();
wxWindow* GetGridCornerLabelWindow();
+ // Allow adjustment of scroll increment. The default is (15, 15).
+ void SetScrollLineX(int x);
+ void SetScrollLineY(int y);
+ int GetScrollLineX() const;
+ int GetScrollLineY() const;
+
+ int GetScrollX(int x) const;
+ int GetScrollY(int y) const;
static wxVisualAttributes
GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
{
public:
wxGridEvent(int id, wxEventType type, wxGrid* obj,
- int row=-1, int col=-1, int x=-1, int y=-1, bool sel = True,
- bool control=False, bool shift=False, bool alt=False, bool meta=False);
+ int row=-1, int col=-1, int x=-1, int y=-1, bool sel = true,
+ bool control=false, bool shift=false, bool alt=false, bool meta=false);
virtual int GetRow();
virtual int GetCol();
public:
wxGridSizeEvent(int id, wxEventType type, wxGrid* obj,
int rowOrCol=-1, int x=-1, int y=-1,
- bool control=False, bool shift=False, bool alt=False, bool meta=False);
+ bool control=false, bool shift=false, bool alt=false, bool meta=false);
int GetRowOrCol();
wxPoint GetPosition();
wxGridRangeSelectEvent(int id, wxEventType type, wxGrid* obj,
const wxGridCellCoords& topLeft,
const wxGridCellCoords& bottomRight,
- bool sel = True,
- bool control=False, bool shift=False,
- bool alt=False, bool meta=False);
+ bool sel = true,
+ bool control=false, bool shift=false,
+ bool alt=false, bool meta=false);
wxGridCellCoords GetTopLeftCoords();
wxGridCellCoords GetBottomRightCoords();
%constant wxEventType wxEVT_GRID_EDITOR_SHOWN;
%constant wxEventType wxEVT_GRID_EDITOR_HIDDEN;
%constant wxEventType wxEVT_GRID_EDITOR_CREATED;
+%constant wxEventType wxEVT_GRID_CELL_BEGIN_DRAG;
EVT_GRID_EDITOR_SHOWN = wx.PyEventBinder( wxEVT_GRID_EDITOR_SHOWN )
EVT_GRID_EDITOR_HIDDEN = wx.PyEventBinder( wxEVT_GRID_EDITOR_HIDDEN )
EVT_GRID_EDITOR_CREATED = wx.PyEventBinder( wxEVT_GRID_EDITOR_CREATED )
+EVT_GRID_CELL_BEGIN_DRAG = wx.PyEventBinder( wxEVT_GRID_CELL_BEGIN_DRAG )
%# The same as above but with the ability to specify an identifier
EVT_GRID_CMD_EDITOR_SHOWN = wx.PyEventBinder( wxEVT_GRID_EDITOR_SHOWN, 1 )
EVT_GRID_CMD_EDITOR_HIDDEN = wx.PyEventBinder( wxEVT_GRID_EDITOR_HIDDEN, 1 )
EVT_GRID_CMD_EDITOR_CREATED = wx.PyEventBinder( wxEVT_GRID_EDITOR_CREATED, 1 )
+EVT_GRID_CMD_CELL_BEGIN_DRAG = wx.PyEventBinder( wxEVT_GRID_CELL_BEGIN_DRAG, 1 )
+
}
//---------------------------------------------------------------------------