#define wxGRID_VALUE_TEXT wxGRID_VALUE_STRING
#define wxGRID_VALUE_LONG wxGRID_VALUE_NUMBER
+// magic constant which tells (to some functions) to automatically calculate
+// the appropriate size
+#define wxGRID_AUTOSIZE (-1)
+
+// many wxGrid methods work either with columns or rows, this enum is used for
+// the parameter indicating which one should it be
+enum wxGridDirection
+{
+ wxGRID_COLUMN,
+ wxGRID_ROW
+};
+
// ----------------------------------------------------------------------------
// forward declarations
// ----------------------------------------------------------------------------
-class WXDLLIMPEXP_ADV wxGrid;
-class WXDLLIMPEXP_ADV wxGridCellAttr;
-class WXDLLIMPEXP_ADV wxGridCellAttrProviderData;
-class WXDLLIMPEXP_ADV wxGridColLabelWindow;
-class WXDLLIMPEXP_ADV wxGridCornerLabelWindow;
-class WXDLLIMPEXP_ADV wxGridRowLabelWindow;
-class WXDLLIMPEXP_ADV wxGridWindow;
-class WXDLLIMPEXP_ADV wxGridTypeRegistry;
-class WXDLLIMPEXP_ADV wxGridSelection;
-
-class WXDLLEXPORT wxCheckBox;
-class WXDLLEXPORT wxComboBox;
-class WXDLLEXPORT wxTextCtrl;
+class WXDLLIMPEXP_FWD_ADV wxGrid;
+class WXDLLIMPEXP_FWD_ADV wxGridCellAttr;
+class WXDLLIMPEXP_FWD_ADV wxGridCellAttrProviderData;
+class WXDLLIMPEXP_FWD_ADV wxGridColLabelWindow;
+class WXDLLIMPEXP_FWD_ADV wxGridCornerLabelWindow;
+class WXDLLIMPEXP_FWD_ADV wxGridRowLabelWindow;
+class WXDLLIMPEXP_FWD_ADV wxGridWindow;
+class WXDLLIMPEXP_FWD_ADV wxGridTypeRegistry;
+class WXDLLIMPEXP_FWD_ADV wxGridSelection;
+
+class WXDLLIMPEXP_FWD_CORE wxCheckBox;
+class WXDLLIMPEXP_FWD_CORE wxComboBox;
+class WXDLLIMPEXP_FWD_CORE wxTextCtrl;
#if wxUSE_SPINCTRL
-class WXDLLEXPORT wxSpinCtrl;
+class WXDLLIMPEXP_FWD_CORE wxSpinCtrl;
#endif
// ----------------------------------------------------------------------------
wxTextCtrl *Text() const { return (wxTextCtrl *)m_control; }
// parts of our virtual functions reused by the derived classes
+ void DoCreate(wxWindow* parent, wxWindowID id, wxEvtHandler* evtHandler,
+ long style = 0);
void DoBeginEdit(const wxString& startValue);
void DoReset(const wxString& startValue);
// setAsMin is true, this optimal width will also be set as minimal width
// for this column
void AutoSizeColumn( int col, bool setAsMin = true )
- { AutoSizeColOrRow(col, setAsMin, true); }
+ { AutoSizeColOrRow(col, setAsMin, wxGRID_COLUMN); }
void AutoSizeRow( int row, bool setAsMin = true )
- { AutoSizeColOrRow(row, setAsMin, false); }
+ { AutoSizeColOrRow(row, setAsMin, wxGRID_ROW); }
// auto size all columns (very ineffective for big grids!)
void AutoSizeColumns( bool setAsMin = true )
// and also set the grid size to just fit its contents
void AutoSize();
+ // Note for both AutoSizeRowLabelSize and AutoSizeColLabelSize:
+ // If col equals to wxGRID_AUTOSIZE value then function autosizes labels column
+ // instead of data column. Note that this operation may be slow for large
+ // tables.
// autosize row height depending on label text
void AutoSizeRowLabelSize( int row );
int SetOrCalcRowSizes(bool calcOnly, bool setAsMin = true);
// common part of AutoSizeColumn/Row()
- void AutoSizeColOrRow(int n, bool setAsMin, bool column /* or row? */);
+ void AutoSizeColOrRow(int n, bool setAsMin, wxGridDirection direction);
+
+ // Calculate the minimum acceptable size for labels area
+ wxCoord CalcColOrRowLabelAreaMinSize(wxGridDirection direction);
// if a column has a minimal width, it will be the value for it in this
// hash table
bool GetModelValues();
bool SetModelValues();
- friend class WXDLLIMPEXP_ADV wxGridSelection;
+ friend class WXDLLIMPEXP_FWD_ADV wxGridSelection;
DECLARE_DYNAMIC_CLASS( wxGrid )
DECLARE_EVENT_TABLE()
DECLARE_NO_COPY_CLASS(wxGrid)
};
+// ----------------------------------------------------------------------------
+// wxGridUpdateLocker prevents updates to a grid during its lifetime
+// ----------------------------------------------------------------------------
+
+class WXDLLIMPEXP_ADV wxGridUpdateLocker
+{
+public:
+ // if the pointer is NULL, Create() can be called later
+ wxGridUpdateLocker(wxGrid *grid = NULL)
+ {
+ Init(grid);
+ }
+
+ // can be called if ctor was used with a NULL pointer, must not be called
+ // more than once
+ void Create(wxGrid *grid)
+ {
+ wxASSERT_MSG( !m_grid, _T("shouldn't be called more than once") );
+
+ Init(grid);
+ }
+
+ ~wxGridUpdateLocker()
+ {
+ if ( m_grid )
+ m_grid->EndBatch();
+ }
+
+private:
+ void Init(wxGrid *grid)
+ {
+ m_grid = grid;
+ if ( m_grid )
+ m_grid->BeginBatch();
+ }
+
+ wxGrid *m_grid;
+
+ DECLARE_NO_COPY_CLASS(wxGridUpdateLocker)
+};
// ----------------------------------------------------------------------------
// Grid event class and event types
return ControlDown();
#endif
}
-
+
virtual wxEvent *Clone() const { return new wxGridSizeEvent(*this); }
protected:
return ControlDown();
#endif
}
-
+
virtual wxEvent *Clone() const { return new wxGridRangeSelectEvent(*this); }
protected:
void SetRow(int row) { m_row = row; }
void SetCol(int col) { m_col = col; }
void SetControl(wxControl* ctrl) { m_ctrl = ctrl; }
-
+
virtual wxEvent *Clone() const { return new wxGridEditorCreatedEvent(*this); }
private:
DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_GRID_EDITOR_HIDDEN, 1594)
DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_GRID_EDITOR_CREATED, 1595)
DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_GRID_CELL_BEGIN_DRAG, 1596)
+ DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_GRID_COL_MOVE, 1597)
END_DECLARE_EVENT_TYPES()
#define EVT_GRID_CMD_LABEL_RIGHT_DCLICK(id, fn) wx__DECLARE_GRIDEVT(LABEL_RIGHT_DCLICK, id, fn)
#define EVT_GRID_CMD_ROW_SIZE(id, fn) wx__DECLARE_GRIDSIZEEVT(ROW_SIZE, id, fn)
#define EVT_GRID_CMD_COL_SIZE(id, fn) wx__DECLARE_GRIDSIZEEVT(COL_SIZE, id, fn)
+#define EVT_GRID_CMD_COL_MOVE(id, fn) wx__DECLARE_GRIDSIZEEVT(COL_MOVE, id, fn)
#define EVT_GRID_CMD_RANGE_SELECT(id, fn) wx__DECLARE_GRIDRANGESELEVT(RANGE_SELECT, id, fn)
#define EVT_GRID_CMD_CELL_CHANGE(id, fn) wx__DECLARE_GRIDEVT(CELL_CHANGE, id, fn)
#define EVT_GRID_CMD_SELECT_CELL(id, fn) wx__DECLARE_GRIDEVT(SELECT_CELL, id, fn)
#define EVT_GRID_LABEL_RIGHT_DCLICK(fn) EVT_GRID_CMD_LABEL_RIGHT_DCLICK(wxID_ANY, fn)
#define EVT_GRID_ROW_SIZE(fn) EVT_GRID_CMD_ROW_SIZE(wxID_ANY, fn)
#define EVT_GRID_COL_SIZE(fn) EVT_GRID_CMD_COL_SIZE(wxID_ANY, fn)
+#define EVT_GRID_COL_MOVE(fn) EVT_GRID_CMD_COL_MOVE(wxID_ANY, fn)
#define EVT_GRID_RANGE_SELECT(fn) EVT_GRID_CMD_RANGE_SELECT(wxID_ANY, fn)
#define EVT_GRID_CELL_CHANGE(fn) EVT_GRID_CMD_CELL_CHANGE(wxID_ANY, fn)
#define EVT_GRID_SELECT_CELL(fn) EVT_GRID_CMD_SELECT_CELL(wxID_ANY, fn)