#if wxUSE_GRID
+#include "wx/hashmap.h"
+
#include "wx/scrolwin.h"
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_FWD_CORE wxSpinCtrl;
#endif
+class wxGridFixedIndicesSet;
+
class wxGridOperations;
class wxGridRowOperations;
class wxGridColumnOperations;
// class is not documented and is not public at all
// ----------------------------------------------------------------------------
-class WXDLLIMPEXP_ADV wxGridCellWorker : public wxClientDataContainer
+class WXDLLIMPEXP_ADV wxGridCellWorker : public wxClientDataContainer, public wxRefCounter
{
public:
- wxGridCellWorker() { m_nRef = 1; }
-
- // this class is ref counted: it is created with ref count of 1, so
- // calling DecRef() once will delete it. Calling IncRef() allows to lock
- // it until the matching DecRef() is called
- void IncRef() { m_nRef++; }
- void DecRef() { if ( --m_nRef == 0 ) delete this; }
+ wxGridCellWorker() { }
// interpret renderer parameters: arbitrary string whose interpretatin is
// left to the derived classes
virtual ~wxGridCellWorker();
private:
- size_t m_nRef;
-
// suppress the stupid gcc warning about the class having private dtor and
// no friends
friend class wxGridCellWorkerDummyFriend;
// class may be returned by wxGridTable::GetAttr().
// ----------------------------------------------------------------------------
-class WXDLLIMPEXP_ADV wxGridCellAttr : public wxClientDataContainer
+class WXDLLIMPEXP_ADV wxGridCellAttr : public wxClientDataContainer, public wxRefCounter
{
public:
enum wxAttrKind
wxGridCellAttr *Clone() const;
void MergeWith(wxGridCellAttr *mergefrom);
- // this class is ref counted: it is created with ref count of 1, so
- // calling DecRef() once will delete it. Calling IncRef() allows to lock
- // it until the matching DecRef() is called
- void IncRef() { m_nRef++; }
- void DecRef() { if ( --m_nRef == 0 ) delete this; }
-
// setters
void SetTextColour(const wxColour& colText) { m_colText = colText; }
void SetBackgroundColour(const wxColour& colBack) { m_colBack = colBack; }
void Init(wxGridCellAttr *attrDefault = NULL);
- // the ref count - when it goes to 0, we die
- size_t m_nRef;
-
wxColour m_colText,
m_colBack;
wxFont m_font;
public:
wxGridStringTable();
wxGridStringTable( int numRows, int numCols );
- virtual ~wxGridStringTable();
// these are pure virtual in wxGridTableBase
//
- int GetNumberRows();
- int GetNumberCols();
- wxString GetValue( int row, int col );
- void SetValue( int row, int col, const wxString& s );
+ virtual int GetNumberRows() { return m_data.size(); }
+ virtual int GetNumberCols() { return m_numCols; }
+ virtual wxString GetValue( int row, int col );
+ virtual void SetValue( int row, int col, const wxString& s );
// overridden functions from wxGridTableBase
//
private:
wxGridStringArray m_data;
+ // notice that while we don't need to store the number of our rows as it's
+ // always equal to the size of m_data array, we do need to store the number
+ // of our columns as we can't retrieve it from m_data when the number of
+ // rows is 0 (see #10818)
+ int m_numCols;
+
// These only get used if you set your own labels, otherwise the
// GetRow/ColLabelValue functions return wxGridTableBase defaults
//
// their non default size for those which don't have the default size.
// ----------------------------------------------------------------------------
-// Hashmap to store postions as the keys and sizes as the values
+// hash map to store positions as the keys and sizes as the values
WX_DECLARE_HASH_MAP_WITH_DECL( unsigned, int, wxIntegerHash, wxIntegerEqual,
wxUnsignedToIntHashMap, class WXDLLIMPEXP_ADV );
void SetCellHighlightPenWidth(int width);
void SetCellHighlightROPenWidth(int width);
+
+ // interactive grid mouse operations control
+ // -----------------------------------------
+
+ // functions globally enabling row/column interactive resizing (enabled by
+ // default)
void EnableDragRowSize( bool enable = true );
void DisableDragRowSize() { EnableDragRowSize( false ); }
- bool CanDragRowSize() const { return m_canDragRowSize; }
+
void EnableDragColSize( bool enable = true );
void DisableDragColSize() { EnableDragColSize( false ); }
- bool CanDragColSize() const { return m_canDragColSize; }
+
+ // if interactive resizing is enabled, some rows/columns can still have
+ // fixed size
+ void DisableRowResize(int row) { DoDisableLineResize(row, m_setFixedRows); }
+ void DisableColResize(int col) { DoDisableLineResize(col, m_setFixedCols); }
+
+ // these functions return whether the given row/column can be
+ // effectively resized: for this interactive resizing must be enabled
+ // and this index must not have been passed to DisableRow/ColResize()
+ bool CanDragRowSize(int row) const
+ { return m_canDragRowSize && DoCanResizeLine(row, m_setFixedRows); }
+ bool CanDragColSize(int col) const
+ { return m_canDragColSize && DoCanResizeLine(col, m_setFixedCols); }
+
+ // interactive column reordering (disabled by default)
void EnableDragColMove( bool enable = true );
void DisableDragColMove() { EnableDragColMove( false ); }
bool CanDragColMove() const { return m_canDragColMove; }
+
+ // interactive resizing of grid cells (enabled by default)
void EnableDragGridSize(bool enable = true);
void DisableDragGridSize() { EnableDragGridSize(false); }
bool CanDragGridSize() const { return m_canDragGridSize; }
+ // interactive dragging of cells (disabled by default)
void EnableDragCell( bool enable = true );
void DisableDragCell() { EnableDragCell( false ); }
bool CanDragCell() const { return m_canDragCell; }
wxGRID_CHECKBOX,
wxGRID_CHOICE,
wxGRID_COMBOBOX };
+
+ wxDEPRECATED_INLINE(bool CanDragRowSize() const, return m_canDragRowSize; )
+ wxDEPRECATED_INLINE(bool CanDragColSize() const, return m_canDragColSize; )
#endif // WXWIN_COMPATIBILITY_2_8
// it was processed (but not vetoed) and 0 if it wasn't processed
int SendEvent(const wxEventType evtType,
int row, int col,
- wxMouseEvent& e);
+ const wxMouseEvent& e);
int SendEvent(const wxEventType evtType,
const wxGridCellCoords& coords,
- wxMouseEvent& e)
+ const wxMouseEvent& e)
{ return SendEvent(evtType, coords.GetRow(), coords.GetCol(), e); }
int SendEvent(const wxEventType evtType,
int row, int col,
int SendEvent(const wxEventType evtType, const wxString& s = wxString())
{ return SendEvent(evtType, m_currentCellCoords, s); }
+ // send wxEVT_GRID_{ROW,COL}_SIZE
+ void SendGridSizeEvent(wxEventType type,
+ int row, int col,
+ const wxMouseEvent& mouseEv);
+
void OnPaint( wxPaintEvent& );
void OnSize( wxSizeEvent& );
void OnKeyDown( wxKeyEvent& );
void DoUpdateResizeColWidth(int w);
void DoStartMoveCol(int col);
- void DoEndDragResizeRow();
- void DoEndDragResizeCol(wxMouseEvent *event = NULL);
+ void DoEndDragResizeRow(const wxMouseEvent& event);
+ void DoEndDragResizeCol(const wxMouseEvent& event);
void DoEndMoveCol(int pos);
// common implementations of methods defined for both rows and columns
void DeselectLine(int line, const wxGridOperations& oper);
- void DoEndDragResizeLine(const wxGridOperations& oper);
+ bool DoEndDragResizeLine(const wxGridOperations& oper);
int PosToLinePos(int pos, bool clipToMinMax,
const wxGridOperations& oper) const;
int PosToLine(int pos, bool clipToMinMax,
bool DoAppendLines(bool (wxGridTableBase::*funcAppend)(size_t),
int num, bool updateLabels);
- // Common part of Set{Col,Row}Sizes
+ // common part of Set{Col,Row}Sizes
void DoSetSizes(const wxGridSizesInfo& sizeInfo,
const wxGridOperations& oper);
+ // common part of Disable{Row,Col}Resize and CanDrag{Row,Col}Size
+ void DoDisableLineResize(int line, wxGridFixedIndicesSet *& setFixed);
+ bool DoCanResizeLine(int line, const wxGridFixedIndicesSet *setFixed) const;
+
+
+
+ // these sets contain the indices of fixed, i.e. non-resizable
+ // interactively, grid rows or columns and are NULL if there are no fixed
+ // elements (which is the default)
+ wxGridFixedIndicesSet *m_setFixedRows,
+ *m_setFixedCols;
+
DECLARE_DYNAMIC_CLASS( wxGrid )
DECLARE_EVENT_TABLE()
wxDECLARE_NO_COPY_CLASS(wxGrid);