]> git.saurik.com Git - wxWidgets.git/blobdiff - src/generic/grid.cpp
Reverted part of rev 1.92. It causes probelms on Windows when
[wxWidgets.git] / src / generic / grid.cpp
index 2bebd87e647be872aa978bca20da554372042dc0..284143a62ecf731a087cd51ffeb3b060eb629a88 100644 (file)
@@ -4418,8 +4418,8 @@ void wxGrid::Init()
 
     m_currentCellCoords = wxGridNoCellCoords;
 
 
     m_currentCellCoords = wxGridNoCellCoords;
 
-    m_selectingTopLeft = wxGridNoCellCoords;
-    m_selectingBottomRight = wxGridNoCellCoords;
+    ClearSelection();
+
     m_selectionBackground = wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT);
     m_selectionForeground = wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHTTEXT);
 
     m_selectionBackground = wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT);
     m_selectionForeground = wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHTTEXT);
 
@@ -5598,23 +5598,26 @@ void wxGrid::ProcessColLabelMouseEvent( wxMouseEvent& event )
         switch ( m_cursorMode )
         {
             case WXGRID_CURSOR_RESIZE_COL:
         switch ( m_cursorMode )
         {
             case WXGRID_CURSOR_RESIZE_COL:
-            {
                 DoEndDragResizeCol();
 
                 // Note: we are ending the event *after* doing
                 // default processing in this case
                 //
                 SendEvent( wxEVT_GRID_COL_SIZE, -1, m_dragRowOrCol, event );
                 DoEndDragResizeCol();
 
                 // Note: we are ending the event *after* doing
                 // default processing in this case
                 //
                 SendEvent( wxEVT_GRID_COL_SIZE, -1, m_dragRowOrCol, event );
-            }
-            break;
+                break;
 
             case WXGRID_CURSOR_MOVE_COL:
 
             case WXGRID_CURSOR_MOVE_COL:
-            {
                 DoEndDragMoveCol();
 
                 SendEvent( wxEVT_GRID_COL_MOVE, -1, m_dragRowOrCol, event );
                 DoEndDragMoveCol();
 
                 SendEvent( wxEVT_GRID_COL_MOVE, -1, m_dragRowOrCol, event );
-            }
-            break;
+                break;
+
+            case WXGRID_CURSOR_SELECT_COL:
+            case WXGRID_CURSOR_SELECT_CELL:
+            case WXGRID_CURSOR_RESIZE_ROW:
+            case WXGRID_CURSOR_SELECT_ROW:
+                // nothing to do (?)
+                break;
         }
 
         ChangeCursorMode(WXGRID_CURSOR_SELECT_CELL, m_colLabelWin);
         }
 
         ChangeCursorMode(WXGRID_CURSOR_SELECT_CELL, m_colLabelWin);
@@ -6615,6 +6618,32 @@ int wxGrid::SendEvent( const wxEventType type,
        claimed = GetEventHandler()->ProcessEvent(gridEvt);
        vetoed = !gridEvt.IsAllowed();
    }
        claimed = GetEventHandler()->ProcessEvent(gridEvt);
        vetoed = !gridEvt.IsAllowed();
    }
+   else if ( type == wxEVT_GRID_LABEL_LEFT_CLICK ||
+             type == wxEVT_GRID_LABEL_LEFT_DCLICK ||
+             type == wxEVT_GRID_LABEL_RIGHT_CLICK ||
+             type == wxEVT_GRID_LABEL_RIGHT_DCLICK )
+   {
+       wxPoint pos = mouseEv.GetPosition();
+
+       if ( mouseEv.GetEventObject() == GetGridRowLabelWindow() )
+           pos.y += GetColLabelSize();
+       if ( mouseEv.GetEventObject() == GetGridColLabelWindow() )
+           pos.x += GetRowLabelSize();
+       
+       wxGridEvent gridEvt( GetId(),
+               type,
+               this,
+               row, col,
+               pos.x,
+               pos.y,
+               false,
+               mouseEv.ControlDown(),
+               mouseEv.ShiftDown(),
+               mouseEv.AltDown(),
+               mouseEv.MetaDown() );
+       claimed = GetEventHandler()->ProcessEvent(gridEvt);
+       vetoed = !gridEvt.IsAllowed();
+   }
    else
    {
        wxGridEvent gridEvt( GetId(),
    else
    {
        wxGridEvent gridEvt( GetId(),
@@ -8170,13 +8199,6 @@ void wxGrid::ShowCellEditControl()
                 m_currentCellCoords.SetCol( col );
             }
 
                 m_currentCellCoords.SetCol( col );
             }
 
-            // convert to scrolled coords
-            CalcScrolledPosition( rect.x, rect.y, &rect.x, &rect.y );
-
-            int nXMove = 0;
-            if (rect.x < 0)
-                nXMove = rect.x;
-
             // erase the highlight and the cell contents because the editor
             // might not cover the entire cell
             wxClientDC dc( m_gridWin );
             // erase the highlight and the cell contents because the editor
             // might not cover the entire cell
             wxClientDC dc( m_gridWin );
@@ -8185,6 +8207,13 @@ void wxGrid::ShowCellEditControl()
             dc.SetPen(*wxTRANSPARENT_PEN);
             dc.DrawRectangle(rect);
 
             dc.SetPen(*wxTRANSPARENT_PEN);
             dc.DrawRectangle(rect);
 
+            // convert to scrolled coords
+            CalcScrolledPosition( rect.x, rect.y, &rect.x, &rect.y );
+
+            int nXMove = 0;
+            if (rect.x < 0)
+                nXMove = rect.x;
+
             // cell is shifted by one pixel
             // However, don't allow x or y to become negative
             // since the SetSize() method interprets that as
             // cell is shifted by one pixel
             // However, don't allow x or y to become negative
             // since the SetSize() method interprets that as
@@ -10790,8 +10819,9 @@ wxArrayInt wxGrid::GetSelectedCols() const
 
 void wxGrid::ClearSelection()
 {
 
 void wxGrid::ClearSelection()
 {
-    m_selectingTopLeft = wxGridNoCellCoords;
-    m_selectingBottomRight = wxGridNoCellCoords;
+    m_selectingTopLeft =
+    m_selectingBottomRight =
+    m_selectingKeyboard = wxGridNoCellCoords;
     if ( m_selection )
         m_selection->ClearSelection();
 }
     if ( m_selection )
         m_selection->ClearSelection();
 }