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
This commit is contained in:
Michael Bedward
2000-02-22 03:51:43 +00:00
parent 40c7018756
commit 6e8524b11b
2 changed files with 35 additions and 6 deletions

View File

@@ -839,6 +839,13 @@ public:
void SetRowLabelValue( int row, const wxString& ); void SetRowLabelValue( int row, const wxString& );
void SetColLabelValue( int col, const wxString& ); void SetColLabelValue( int col, const wxString& );
void SetGridLineColour( const wxColour& ); 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 // this sets the specified attribute for all cells in this row/col
void SetRowAttr(int row, wxGridCellAttr *attr); void SetRowAttr(int row, wxGridCellAttr *attr);
@@ -1319,6 +1326,8 @@ protected:
wxWindow *m_winCapture; // the window which captured the mouse wxWindow *m_winCapture; // the window which captured the mouse
CursorMode m_cursorMode; CursorMode m_cursorMode;
bool m_canDragRowSize;
bool m_canDragColSize;
int m_dragLastPos; int m_dragLastPos;
int m_dragRowOrCol; int m_dragRowOrCol;
bool m_isDragging; bool m_isDragging;

View File

@@ -2398,6 +2398,8 @@ void wxGrid::Init()
m_cursorMode = WXGRID_CURSOR_SELECT_CELL; m_cursorMode = WXGRID_CURSOR_SELECT_CELL;
m_winCapture = (wxWindow *)NULL; m_winCapture = (wxWindow *)NULL;
m_canDragRowSize = TRUE;
m_canDragColSize = TRUE;
m_dragLastPos = -1; m_dragLastPos = -1;
m_dragRowOrCol = -1; m_dragRowOrCol = -1;
m_isDragging = FALSE; m_isDragging = FALSE;
@@ -2974,7 +2976,8 @@ void wxGrid::ProcessRowLabelMouseEvent( wxMouseEvent& event )
{ {
// starting to drag-resize a row // 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 ) if ( m_cursorMode == WXGRID_CURSOR_SELECT_CELL )
{ {
// don't capture the mouse yet // 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 ) else if ( m_cursorMode != WXGRID_CURSOR_SELECT_CELL )
@@ -3139,7 +3143,8 @@ void wxGrid::ProcessColLabelMouseEvent( wxMouseEvent& event )
{ {
// starting to drag-resize a col // 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 ) if ( m_cursorMode == WXGRID_CURSOR_SELECT_CELL )
{ {
// don't capture the cursor yet // 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 ) else if ( m_cursorMode != WXGRID_CURSOR_SELECT_CELL )
@@ -3590,7 +3596,8 @@ void wxGrid::ProcessGridCellMouseEvent( wxMouseEvent& event )
if ( m_cursorMode == WXGRID_CURSOR_SELECT_CELL ) if ( m_cursorMode == WXGRID_CURSOR_SELECT_CELL )
{ {
ChangeCursorMode(WXGRID_CURSOR_RESIZE_ROW); if ( CanDragRowSize() )
ChangeCursorMode(WXGRID_CURSOR_RESIZE_ROW);
} }
return; return;
@@ -3602,7 +3609,8 @@ void wxGrid::ProcessGridCellMouseEvent( wxMouseEvent& event )
if ( m_cursorMode == WXGRID_CURSOR_SELECT_CELL ) if ( m_cursorMode == WXGRID_CURSOR_SELECT_CELL )
{ {
ChangeCursorMode(WXGRID_CURSOR_RESIZE_COL); if ( CanDragColSize() )
ChangeCursorMode(WXGRID_CURSOR_RESIZE_COL);
} }
return; return;
@@ -6221,6 +6229,18 @@ wxGridCellRenderer* wxGrid::GetDefaultRendererForType(const wxString& typeName)
// row/col size // 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 ) void wxGrid::SetDefaultRowSize( int height, bool resizeExistingRows )
{ {
m_defaultRowHeight = wxMax( height, WXGRID_MIN_ROW_HEIGHT ); m_defaultRowHeight = wxMax( height, WXGRID_MIN_ROW_HEIGHT );