X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/db2c04684d8fabf332db5e1c237f53408983fe3c..e911dd0a5abd10c32d6cce4cff44e1cb06c3036b:/src/generic/grid.cpp diff --git a/src/generic/grid.cpp b/src/generic/grid.cpp index 5701bbef22..494b74f2cc 100644 --- a/src/generic/grid.cpp +++ b/src/generic/grid.cpp @@ -72,8 +72,8 @@ const char wxGridNameStr[] = "grid"; // Required for wxIs... functions #include -WX_DECLARE_HASH_SET_WITH_DECL(int, wxIntegerHash, wxIntegerEqual, - wxGridFixedIndicesSet, class WXDLLIMPEXP_ADV); +WX_DECLARE_HASH_SET_WITH_DECL_PTR(int, ::wxIntegerHash, ::wxIntegerEqual, + wxGridFixedIndicesSet, class WXDLLIMPEXP_ADV); // ---------------------------------------------------------------------------- @@ -419,7 +419,7 @@ void wxGridCellAttr::SetSize(int num_rows, int num_cols) wxASSERT_MSG( (!((num_rows > 0) && (num_cols <= 0)) || !((num_rows <= 0) && (num_cols > 0)) || !((num_rows == 0) && (num_cols == 0))), - wxT("wxGridCellAttr::SetSize only takes two postive values or negative/zero values")); + wxT("wxGridCellAttr::SetSize only takes two positive values or negative/zero values")); m_sizeRows = num_rows; m_sizeCols = num_cols; @@ -1534,9 +1534,9 @@ bool wxGridStringTable::DeleteCols( size_t pos, size_t numCols ) // m_colLabels stores just as many elements as it needs, e.g. if only // the label of the first column had been set it would have only one // element and not numCols, so account for it - int nToRm = m_colLabels.size() - colID; - if ( nToRm > 0 ) - m_colLabels.RemoveAt( colID, nToRm ); + int numRemaining = m_colLabels.size() - colID; + if (numRemaining > 0) + m_colLabels.RemoveAt( colID, wxMin(numCols, numRemaining) ); } if ( numCols >= curNumCols ) @@ -3069,7 +3069,7 @@ void wxGrid::ProcessRowLabelMouseEvent( wxMouseEvent& event ) ChangeCursorMode(WXGRID_CURSOR_SELECT_CELL, GetColLabelWindow()); m_dragLastPos = -1; } - else // not on row separator or it's not resizeable + else // not on row separator or it's not resizable { row = YToRow(y); if ( row >=0 && @@ -3648,13 +3648,15 @@ void wxGrid::ChangeCursorMode(CursorMode mode, // grid mouse event processing // ---------------------------------------------------------------------------- -void +bool wxGrid::DoGridCellDrag(wxMouseEvent& event, const wxGridCellCoords& coords, bool isFirstDrag) { + bool performDefault = true ; + if ( coords == wxGridNoCellCoords ) - return; // we're outside any valid cell + return performDefault; // we're outside any valid cell // Hide the edit control, so it won't interfere with drag-shrinking. if ( IsCellEditControlShown() ) @@ -3665,7 +3667,7 @@ wxGrid::DoGridCellDrag(wxMouseEvent& event, switch ( event.GetModifiers() ) { - case wxMOD_CMD: + case wxMOD_CONTROL: if ( m_selectedBlockCorner == wxGridNoCellCoords) m_selectedBlockCorner = coords; UpdateBlockBeingSelected(m_selectedBlockCorner, coords); @@ -3679,8 +3681,11 @@ wxGrid::DoGridCellDrag(wxMouseEvent& event, if ( m_selectedBlockCorner == wxGridNoCellCoords) m_selectedBlockCorner = coords; - SendEvent(wxEVT_GRID_CELL_BEGIN_DRAG, coords, event); - return; + // if event is handled by user code, no further processing + if ( SendEvent(wxEVT_GRID_CELL_BEGIN_DRAG, coords, event) != 0 ) + performDefault = false; + + return performDefault; } } @@ -3691,6 +3696,8 @@ wxGrid::DoGridCellDrag(wxMouseEvent& event, // we don't handle the other key modifiers event.Skip(); } + + return performDefault; } void wxGrid::DoGridLineDrag(wxMouseEvent& event, const wxGridOperations& oper) @@ -3743,7 +3750,9 @@ void wxGrid::DoGridDragEvent(wxMouseEvent& event, const wxGridCellCoords& coords switch ( m_cursorMode ) { case WXGRID_CURSOR_SELECT_CELL: - DoGridCellDrag(event, coords, isFirstDrag); + // no further handling if handled by user + if ( DoGridCellDrag(event, coords, isFirstDrag) == false ) + return; break; case WXGRID_CURSOR_RESIZE_ROW: @@ -4397,6 +4406,14 @@ wxGrid::SendEvent(const wxEventType type, mouseEv.GetY() + GetColLabelSize(), false, mouseEv); + + if ( type == wxEVT_GRID_CELL_BEGIN_DRAG ) + { + // by default the dragging is not supported, the user code must + // explicitly allow the event for it to take place + gridEvt.Veto(); + } + claimed = GetEventHandler()->ProcessEvent(gridEvt); vetoed = !gridEvt.IsAllowed(); } @@ -6918,7 +6935,7 @@ void wxGrid::SetCellHighlightPenWidth(int width) m_cellHighlightPenWidth = width; // Just redrawing the cell highlight is not enough since that won't - // make any visible change if the the thickness is getting smaller. + // make any visible change if the thickness is getting smaller. int row = m_currentCellCoords.GetRow(); int col = m_currentCellCoords.GetCol(); if ( row == -1 || col == -1 || GetColWidth(col) <= 0 || GetRowHeight(row) <= 0 ) @@ -6936,7 +6953,7 @@ void wxGrid::SetCellHighlightROPenWidth(int width) m_cellHighlightROPenWidth = width; // Just redrawing the cell highlight is not enough since that won't - // make any visible change if the the thickness is getting smaller. + // make any visible change if the thickness is getting smaller. int row = m_currentCellCoords.GetRow(); int col = m_currentCellCoords.GetCol(); if ( row == -1 || col == -1 || @@ -7665,7 +7682,7 @@ void wxGrid::SetRowSize( int row, int height ) } // See comment in SetColSize - if ( height < GetRowMinimalAcceptableHeight()) + if ( height > 0 && height < GetRowMinimalAcceptableHeight()) return; if ( m_rowHeights.IsEmpty() ) @@ -7684,7 +7701,10 @@ void wxGrid::SetRowSize( int row, int height ) } if ( !GetBatchCount() ) + { CalcDimensions(); + Refresh(); + } } void wxGrid::SetDefaultColSize( int width, bool resizeExistingCols ) @@ -8152,10 +8172,12 @@ void wxGrid::Fit() AutoSize(); } +#if WXWIN_COMPATIBILITY_2_8 wxPen& wxGrid::GetDividerPen() const { return wxNullPen; } +#endif // WXWIN_COMPATIBILITY_2_8 // ---------------------------------------------------------------------------- // cell value accessor functions