From: Michael Bedward Date: Tue, 22 Feb 2000 03:51:43 +0000 (+0000) Subject: Added functions to enable/disable drag-resizing of rows and cols. X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/6e8524b11b0854a2ae816c80f843a27bd7534b7f Added functions to enable/disable drag-resizing of rows and cols. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@6198 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/include/wx/generic/grid.h b/include/wx/generic/grid.h index bc92de5093..9df770ec8e 100644 --- a/include/wx/generic/grid.h +++ b/include/wx/generic/grid.h @@ -839,6 +839,13 @@ public: void SetRowLabelValue( int row, const wxString& ); void SetColLabelValue( int col, const wxString& ); void SetGridLineColour( const wxColour& ); + + void EnableDragRowSize( bool enable = TRUE ); + void DisableDragRowSize() { EnableDragRowSize( FALSE ); } + bool CanDragRowSize() { return m_canDragRowSize; } + void EnableDragColSize( bool enable = TRUE ); + void DisableDragColSize() { EnableDragColSize( FALSE ); } + bool CanDragColSize() { return m_canDragColSize; } // this sets the specified attribute for all cells in this row/col void SetRowAttr(int row, wxGridCellAttr *attr); @@ -1319,6 +1326,8 @@ protected: wxWindow *m_winCapture; // the window which captured the mouse CursorMode m_cursorMode; + bool m_canDragRowSize; + bool m_canDragColSize; int m_dragLastPos; int m_dragRowOrCol; bool m_isDragging; diff --git a/src/generic/grid.cpp b/src/generic/grid.cpp index 664efa84d4..7ae17f89a4 100644 --- a/src/generic/grid.cpp +++ b/src/generic/grid.cpp @@ -2398,6 +2398,8 @@ void wxGrid::Init() m_cursorMode = WXGRID_CURSOR_SELECT_CELL; m_winCapture = (wxWindow *)NULL; + m_canDragRowSize = TRUE; + m_canDragColSize = TRUE; m_dragLastPos = -1; m_dragRowOrCol = -1; m_isDragging = FALSE; @@ -2974,7 +2976,8 @@ void wxGrid::ProcessRowLabelMouseEvent( wxMouseEvent& event ) { // starting to drag-resize a row // - ChangeCursorMode(WXGRID_CURSOR_RESIZE_ROW, m_rowLabelWin); + if ( CanDragRowSize() ) + ChangeCursorMode(WXGRID_CURSOR_RESIZE_ROW, m_rowLabelWin); } } @@ -3044,7 +3047,8 @@ void wxGrid::ProcessRowLabelMouseEvent( wxMouseEvent& event ) if ( m_cursorMode == WXGRID_CURSOR_SELECT_CELL ) { // don't capture the mouse yet - ChangeCursorMode(WXGRID_CURSOR_RESIZE_ROW, m_rowLabelWin, FALSE); + if ( CanDragRowSize() ) + ChangeCursorMode(WXGRID_CURSOR_RESIZE_ROW, m_rowLabelWin, FALSE); } } else if ( m_cursorMode != WXGRID_CURSOR_SELECT_CELL ) @@ -3139,7 +3143,8 @@ void wxGrid::ProcessColLabelMouseEvent( wxMouseEvent& event ) { // starting to drag-resize a col // - ChangeCursorMode(WXGRID_CURSOR_RESIZE_COL, m_colLabelWin); + if ( CanDragColSize() ) + ChangeCursorMode(WXGRID_CURSOR_RESIZE_COL, m_colLabelWin); } } @@ -3209,7 +3214,8 @@ void wxGrid::ProcessColLabelMouseEvent( wxMouseEvent& event ) if ( m_cursorMode == WXGRID_CURSOR_SELECT_CELL ) { // don't capture the cursor yet - ChangeCursorMode(WXGRID_CURSOR_RESIZE_COL, m_colLabelWin, FALSE); + if ( CanDragColSize() ) + ChangeCursorMode(WXGRID_CURSOR_RESIZE_COL, m_colLabelWin, FALSE); } } else if ( m_cursorMode != WXGRID_CURSOR_SELECT_CELL ) @@ -3590,7 +3596,8 @@ void wxGrid::ProcessGridCellMouseEvent( wxMouseEvent& event ) if ( m_cursorMode == WXGRID_CURSOR_SELECT_CELL ) { - ChangeCursorMode(WXGRID_CURSOR_RESIZE_ROW); + if ( CanDragRowSize() ) + ChangeCursorMode(WXGRID_CURSOR_RESIZE_ROW); } return; @@ -3602,7 +3609,8 @@ void wxGrid::ProcessGridCellMouseEvent( wxMouseEvent& event ) if ( m_cursorMode == WXGRID_CURSOR_SELECT_CELL ) { - ChangeCursorMode(WXGRID_CURSOR_RESIZE_COL); + if ( CanDragColSize() ) + ChangeCursorMode(WXGRID_CURSOR_RESIZE_COL); } return; @@ -6221,6 +6229,18 @@ wxGridCellRenderer* wxGrid::GetDefaultRendererForType(const wxString& typeName) // row/col size // ---------------------------------------------------------------------------- +void wxGrid::EnableDragRowSize( bool enable ) +{ + m_canDragRowSize = enable; +} + + +void wxGrid::EnableDragColSize( bool enable ) +{ + m_canDragColSize = enable; +} + + void wxGrid::SetDefaultRowSize( int height, bool resizeExistingRows ) { m_defaultRowHeight = wxMax( height, WXGRID_MIN_ROW_HEIGHT );