]> git.saurik.com Git - wxWidgets.git/blobdiff - src/generic/grid.cpp
Use C locale for numbers in wx(File)Config.
[wxWidgets.git] / src / generic / grid.cpp
index 707ebedabc001cc228d051310fe4da2b1431afeb..315fbda05d02276e0e0a84710e0eab4e697ddd27 100644 (file)
@@ -3765,6 +3765,8 @@ void wxGrid::DoGridDragEvent(wxMouseEvent& event, const wxGridCellCoords& coords
 
     if ( isFirstDrag )
     {
+        wxASSERT_MSG( !m_winCapture, "shouldn't capture the mouse twice" );
+
         m_winCapture = m_gridWin;
         m_winCapture->CaptureMouse();
     }
@@ -3810,6 +3812,29 @@ wxGrid::DoGridCellLeftDown(wxMouseEvent& event,
         }
         else
         {
+            if ( m_selection )
+            {
+                // In row or column selection mode just clicking on the cell
+                // should select the row or column containing it: this is more
+                // convenient for the kinds of controls that use such selection
+                // mode and is compatible with 2.8 behaviour (see #12062).
+                switch ( m_selection->GetSelectionMode() )
+                {
+                    case wxGridSelectCells:
+                    case wxGridSelectRowsOrColumns:
+                        // nothing to do in these cases
+                        break;
+
+                    case wxGridSelectRows:
+                        m_selection->SelectRow(coords.GetRow());
+                        break;
+
+                    case wxGridSelectColumns:
+                        m_selection->SelectCol(coords.GetCol());
+                        break;
+                }
+            }
+
             m_waitForSlowClick = m_currentCellCoords == coords &&
                                         coords != wxGridNoCellCoords;
             SetCurrentCell( coords );
@@ -3944,6 +3969,14 @@ wxGrid::DoGridMouseMoveEvent(wxMouseEvent& WXUNUSED(event),
 
 void wxGrid::ProcessGridCellMouseEvent(wxMouseEvent& event)
 {
+    if ( event.Entering() || event.Leaving() )
+    {
+        // we don't care about these events but we must not reset m_isDragging
+        // if they happen so return before anything else is done
+        event.Skip();
+        return;
+    }
+
     const wxPoint pos = CalcUnscrolledPosition(event.GetPosition());
 
     // coordinates of the cell under mouse
@@ -3969,17 +4002,6 @@ void wxGrid::ProcessGridCellMouseEvent(wxMouseEvent& event)
     m_isDragging = false;
     m_startDragPos = wxDefaultPosition;
 
-    // VZ: if we do this, the mode is reset to WXGRID_CURSOR_SELECT_CELL
-    //     immediately after it becomes WXGRID_CURSOR_RESIZE_ROW/COL under
-    //     wxGTK
-#if 0
-    if ( event.Entering() || event.Leaving() )
-    {
-        ChangeCursorMode(WXGRID_CURSOR_SELECT_CELL);
-        m_gridWin->SetCursor( *wxSTANDARD_CURSOR );
-    }
-#endif // 0
-
     // deal with various button presses
     if ( event.IsButton() )
     {
@@ -5573,6 +5595,11 @@ void wxGrid::DrawColLabel(wxDC& dc, int col)
     }
     else
     {
+        // It is reported that we need to erase the background to avoid display
+        // artefacts, see #12055.
+        wxDCBrushChanger setBrush(dc, m_colWindow->GetBackgroundColour());
+        dc.DrawRectangle(rect);
+
         rend.DrawBorder(*this, dc, rect);
     }
 
@@ -7139,11 +7166,21 @@ bool wxGrid::GetCellOverflow( int row, int col ) const
     return allow;
 }
 
-void wxGrid::GetCellSize( int row, int col, int *num_rows, int *num_cols ) const
+wxGrid::CellSpan
+wxGrid::GetCellSize( int row, int col, int *num_rows, int *num_cols ) const
 {
     wxGridCellAttr *attr = GetCellAttr(row, col);
     attr->GetSize( num_rows, num_cols );
     attr->DecRef();
+
+    if ( *num_rows == 1 && *num_cols == 1 )
+        return CellSpan_None; // just a normal cell
+
+    if ( *num_rows < 0 || *num_cols < 0 )
+        return CellSpan_Inside; // covered by a multi-span cell
+
+    // this cell spans multiple cells to its right/bottom
+    return CellSpan_Main;
 }
 
 wxGridCellRenderer* wxGrid::GetCellRenderer(int row, int col) const
@@ -7802,22 +7839,40 @@ wxGrid::AutoSizeColOrRow(int colOrRow, bool setAsMin, wxGridDirection direction)
     HideCellEditControl();
     SaveEditControlValue();
 
-    // init both of them to avoid compiler warnings, even if we only need one
+    // initialize both of them just to avoid compiler warnings
     int row = -1,
         col = -1;
-    if ( column )
-        col = colOrRow;
-    else
-        row = colOrRow;
 
     wxCoord extent, extentMax = 0;
     int max = column ? m_numRows : m_numCols;
     for ( int rowOrCol = 0; rowOrCol < max; rowOrCol++ )
     {
         if ( column )
+        {
             row = rowOrCol;
+            col = colOrRow;
+        }
         else
+        {
+            row = colOrRow;
             col = rowOrCol;
+        }
+
+        // we need to account for the cells spanning multiple columns/rows:
+        // while they may need a lot of space, they don't need all of it in
+        // this column/row
+        int numRows, numCols;
+        const CellSpan span = GetCellSize(row, col, &numRows, &numCols);
+        if ( span == CellSpan_Inside )
+        {
+            // we need to get the size of the main cell, not of a cell hidden
+            // by it
+            row += numRows;
+            col += numCols;
+
+            // get the size of the main cell too
+            GetCellSize(row, col, &numRows, &numCols);
+        }
 
         wxGridCellAttr *attr = GetCellAttr(row, col);
         wxGridCellRenderer *renderer = attr->GetRenderer(this, row, col);
@@ -7825,6 +7880,19 @@ wxGrid::AutoSizeColOrRow(int colOrRow, bool setAsMin, wxGridDirection direction)
         {
             wxSize size = renderer->GetBestSize(*this, *attr, dc, row, col);
             extent = column ? size.x : size.y;
+
+            if ( span != CellSpan_None )
+            {
+                // we spread the size of a spanning cell over all the cells it
+                // covers evenly -- this is probably not ideal but we can't
+                // really do much better here
+                //
+                // notice that numCols and numRows are never 0 as they
+                // correspond to the size of the main cell of the span and not
+                // of the cell inside it
+                extent /= column ? numCols : numRows;
+            }
+
             if ( extent > extentMax )
                 extentMax = extent;