X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/6f58f3d7e0ed959dd6a568a70161ec14ec524feb..refs/heads/master:/src/generic/grid.cpp diff --git a/src/generic/grid.cpp b/src/generic/grid.cpp index 6bd231ea0b..31f9297c63 100644 --- a/src/generic/grid.cpp +++ b/src/generic/grid.cpp @@ -4,7 +4,6 @@ // Author: Michael Bedward (based on code by Julian Smart, Robin Dunn) // Modified by: Robin Dunn, Vadim Zeitlin, Santiago Palacios // Created: 1/08/1999 -// RCS-ID: $Id$ // Copyright: (c) Michael Bedward (mbedward@ozemail.com.au) // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -2159,6 +2158,7 @@ BEGIN_EVENT_TABLE( wxGrid, wxScrolledWindow ) EVT_KEY_UP( wxGrid::OnKeyUp ) EVT_CHAR ( wxGrid::OnChar ) EVT_ERASE_BACKGROUND( wxGrid::OnEraseBackground ) + EVT_COMMAND(wxID_ANY, wxEVT_GRID_HIDE_EDITOR, wxGrid::OnHideEditor ) END_EVENT_TABLE() bool wxGrid::Create(wxWindow *parent, wxWindowID id, @@ -2944,8 +2944,6 @@ bool wxGrid::Redimension( wxGridTableMessage& msg ) int numCols = msg.GetCommandInt(); int oldNumCols = m_numCols; m_numCols += numCols; - if ( m_useNativeHeader ) - GetGridColHeader()->SetColumnCount(m_numCols); if ( !m_colAt.IsEmpty() ) { @@ -2977,6 +2975,12 @@ bool wxGrid::Redimension( wxGridTableMessage& msg ) } } + // Notice that this must be called after updating m_colWidths above + // as the native grid control will check whether the new columns + // are shown which results in accessing m_colWidths array. + if ( m_useNativeHeader ) + GetGridColHeader()->SetColumnCount(m_numCols); + if ( m_currentCellCoords == wxGridNoCellCoords ) { // if we have just inserted cols into an empty grid the current @@ -3262,10 +3266,7 @@ void wxGrid::ProcessRowLabelMouseEvent( wxMouseEvent& event ) if ( event.Dragging() ) { if (!m_isDragging) - { m_isDragging = true; - m_rowLabelWin->CaptureMouse(); - } if ( event.LeftIsDown() ) { @@ -3315,11 +3316,7 @@ void wxGrid::ProcessRowLabelMouseEvent( wxMouseEvent& event ) return; if (m_isDragging) - { - if (m_rowLabelWin->HasCapture()) - m_rowLabelWin->ReleaseMouse(); m_isDragging = false; - } // ------------ Entering or leaving the window // @@ -3546,7 +3543,6 @@ void wxGrid::ProcessColLabelMouseEvent( wxMouseEvent& event ) if (!m_isDragging) { m_isDragging = true; - GetColLabelWindow()->CaptureMouse(); if ( m_cursorMode == WXGRID_CURSOR_MOVE_COL && col != -1 ) DoStartMoveCol(col); @@ -3637,11 +3633,7 @@ void wxGrid::ProcessColLabelMouseEvent( wxMouseEvent& event ) return; if (m_isDragging) - { - if (GetColLabelWindow()->HasCapture()) - GetColLabelWindow()->ReleaseMouse(); m_isDragging = false; - } // ------------ Entering or leaving the window // @@ -6553,6 +6545,11 @@ void wxGrid::SaveEditControlValue() } } +void wxGrid::OnHideEditor(wxCommandEvent& WXUNUSED(event)) +{ + DisableCellEditControl(); +} + // // ------ Grid location functions // Note that all of these functions work with the logical coordinates of @@ -8163,12 +8160,9 @@ void wxGrid::SetRowSize( int row, int height ) return; // The value of -1 is special and means to fit the height to the row label. - if ( height == -1 ) + // As with the columns, ignore attempts to auto-size the hidden rows. + if ( height == -1 && GetRowHeight(row) != 0 ) { - // As with the columns, ignore attempts to auto-size the hidden rows. - if ( GetRowHeight(row) == 0 ) - return; - long w, h; wxArrayString lines; wxClientDC dc(m_rowLabelWin); @@ -8239,14 +8233,13 @@ void wxGrid::SetColSize( int col, int width ) return; // The value of -1 is special and means to fit the width to the column label. - if ( width == -1 ) + // + // Notice that we currently don't support auto-sizing hidden columns (we + // could, but it's not clear whether this is really needed and it would + // make the code more complex), and for them passing -1 simply means to + // show the column back using its old size. + if ( width == -1 && GetColWidth(col) != 0 ) { - // We currently don't support auto-sizing hidden columns. We could, but - // it's not clear whether this is really needed and it would make the - // code more complex. - if ( GetColWidth(col) == 0 ) - return; - long w, h; wxArrayString lines; wxClientDC dc(m_colWindow); @@ -8405,11 +8398,17 @@ wxGrid::AutoSizeColOrRow(int colOrRow, bool setAsMin, wxGridDirection direction) { if ( column ) { + if ( !IsRowShown(rowOrCol) ) + continue; + row = rowOrCol; col = colOrRow; } else { + if ( !IsColShown(rowOrCol) ) + continue; + row = colOrRow; col = rowOrCol; }