X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/3f2965162ce86e5b669cd85d1bce98b6a232d020..e1ee679c2e3f48bc4f2607e35033ed5505ed6665:/src/generic/grid.cpp diff --git a/src/generic/grid.cpp b/src/generic/grid.cpp index 8850bc7742..c8e79066cd 100644 --- a/src/generic/grid.cpp +++ b/src/generic/grid.cpp @@ -602,6 +602,8 @@ void wxGridTextCtrl::OnKeyDown( wxKeyEvent& ev ) case WXK_DOWN: case WXK_LEFT: case WXK_RIGHT: + case WXK_PRIOR: + case WXK_NEXT: case WXK_RETURN: if ( m_isCellControl ) { @@ -805,10 +807,9 @@ void wxGrid::Init() wxGRID_CELLCTRL, "", wxPoint(1,1), - wxSize(1,1), - wxNO_BORDER + wxSize(1,1) #ifdef __WXMSW__ - | wxTE_MULTILINE | wxTE_NO_VSCROLL + , wxTE_MULTILINE | wxTE_NO_VSCROLL #endif ); @@ -1133,8 +1134,8 @@ bool wxGrid::SendEvent( const wxEventType type, int row, int col, wxMouseEvent& mouseEv ) { - if ( type == EVT_WXGRID_ROW_SIZE || - type == EVT_WXGRID_COL_SIZE ) + if ( type == EVT_GRID_ROW_SIZE || + type == EVT_GRID_COL_SIZE ) { int rowOrCol = (row == -1 ? col : row); @@ -1150,7 +1151,7 @@ bool wxGrid::SendEvent( const wxEventType type, return GetEventHandler()->ProcessEvent(gridEvt); } - else if ( type == EVT_WXGRID_RANGE_SELECT ) + else if ( type == EVT_GRID_RANGE_SELECT ) { wxGridRangeSelectEvent gridEvt( GetId(), type, @@ -1187,8 +1188,8 @@ bool wxGrid::SendEvent( const wxEventType type, bool wxGrid::SendEvent( const wxEventType type, int row, int col ) { - if ( type == EVT_WXGRID_ROW_SIZE || - type == EVT_WXGRID_COL_SIZE ) + if ( type == EVT_GRID_ROW_SIZE || + type == EVT_GRID_COL_SIZE ) { int rowOrCol = (row == -1 ? col : row); @@ -1380,7 +1381,7 @@ void wxGrid::OnMouse( wxMouseEvent& ev ) if ( YToEdgeOfRow(y) < 0 ) { row = YToRow(y); - if ( !SendEvent( EVT_WXGRID_LABEL_LEFT_CLICK, row, col, ev ) ) + if ( !SendEvent( EVT_GRID_LABEL_LEFT_CLICK, row, col, ev ) ) { SelectRow( row, ev.ShiftDown() ); m_cursorMode = WXGRID_CURSOR_SELECT_ROW; @@ -1398,7 +1399,7 @@ void wxGrid::OnMouse( wxMouseEvent& ev ) if ( XToEdgeOfCol(x) < 0 ) { col = XToCol(x); - if ( !SendEvent( EVT_WXGRID_LABEL_LEFT_CLICK, row, col, ev ) ) + if ( !SendEvent( EVT_GRID_LABEL_LEFT_CLICK, row, col, ev ) ) { SelectCol( col, ev.ShiftDown() ); m_cursorMode = WXGRID_CURSOR_SELECT_COL; @@ -1411,7 +1412,7 @@ void wxGrid::OnMouse( wxMouseEvent& ev ) { // leave both row and col as -1 // - if ( !SendEvent( EVT_WXGRID_LABEL_LEFT_CLICK, row, col, ev ) ) + if ( !SendEvent( EVT_GRID_LABEL_LEFT_CLICK, row, col, ev ) ) { SelectAll(); } @@ -1421,7 +1422,7 @@ void wxGrid::OnMouse( wxMouseEvent& ev ) case WXGRID_CELL: { XYToCell( x, y, cellCoords ); - if ( !SendEvent( EVT_WXGRID_CELL_LEFT_CLICK, + if ( !SendEvent( EVT_GRID_CELL_LEFT_CLICK, cellCoords.GetRow(), cellCoords.GetCol(), ev ) ) @@ -1460,7 +1461,7 @@ void wxGrid::OnMouse( wxMouseEvent& ev ) if ( YToEdgeOfRow(y) < 0 ) { row = YToRow(y); - SendEvent( EVT_WXGRID_LABEL_LEFT_DCLICK, row, col, ev ); + SendEvent( EVT_GRID_LABEL_LEFT_DCLICK, row, col, ev ); } } break; @@ -1474,7 +1475,7 @@ void wxGrid::OnMouse( wxMouseEvent& ev ) if ( XToEdgeOfCol(x) < 0 ) { col = XToCol(x); - SendEvent( EVT_WXGRID_LABEL_LEFT_DCLICK, row, col, ev ); + SendEvent( EVT_GRID_LABEL_LEFT_DCLICK, row, col, ev ); } } break; @@ -1483,14 +1484,14 @@ void wxGrid::OnMouse( wxMouseEvent& ev ) { // leave both row and col as -1 // - SendEvent( EVT_WXGRID_LABEL_LEFT_DCLICK, row, col, ev ); + SendEvent( EVT_GRID_LABEL_LEFT_DCLICK, row, col, ev ); } break; case WXGRID_CELL: { XYToCell( x, y, cellCoords ); - SendEvent( EVT_WXGRID_CELL_LEFT_DCLICK, + SendEvent( EVT_GRID_CELL_LEFT_DCLICK, cellCoords.GetRow(), cellCoords.GetCol(), ev ); @@ -1535,7 +1536,7 @@ void wxGrid::OnMouse( wxMouseEvent& ev ) // Note: we are ending the event *after* doing // default processing in this case // - SendEvent( EVT_WXGRID_ROW_SIZE, m_dragRowOrCol, -1, ev ); + SendEvent( EVT_GRID_ROW_SIZE, m_dragRowOrCol, -1, ev ); } } break; @@ -1563,7 +1564,7 @@ void wxGrid::OnMouse( wxMouseEvent& ev ) // Note: we are ending the event *after* doing // default processing in this case // - SendEvent( EVT_WXGRID_COL_SIZE, -1, m_dragRowOrCol, ev ); + SendEvent( EVT_GRID_COL_SIZE, -1, m_dragRowOrCol, ev ); } } break; @@ -1575,7 +1576,7 @@ void wxGrid::OnMouse( wxMouseEvent& ev ) // Note: we are ending the event *after* doing // default processing in this case // - SendEvent( EVT_WXGRID_RANGE_SELECT, -1, -1, ev ); + SendEvent( EVT_GRID_RANGE_SELECT, -1, -1, ev ); } } break; @@ -1599,7 +1600,7 @@ void wxGrid::OnMouse( wxMouseEvent& ev ) case WXGRID_ROWLABEL: { row = YToRow(y); - if ( !SendEvent( EVT_WXGRID_LABEL_RIGHT_CLICK, row, col, ev ) ) + if ( !SendEvent( EVT_GRID_LABEL_RIGHT_CLICK, row, col, ev ) ) { // TODO: default processing ? } @@ -1609,7 +1610,7 @@ void wxGrid::OnMouse( wxMouseEvent& ev ) case WXGRID_COLLABEL: { col = XToCol(x); - if ( !SendEvent( EVT_WXGRID_LABEL_RIGHT_CLICK, row, col, ev ) ) + if ( !SendEvent( EVT_GRID_LABEL_RIGHT_CLICK, row, col, ev ) ) { // TODO: default processing ? } @@ -1620,7 +1621,7 @@ void wxGrid::OnMouse( wxMouseEvent& ev ) { // leave both row and col as -1 // - if ( !SendEvent( EVT_WXGRID_LABEL_RIGHT_CLICK, row, col, ev ) ) + if ( !SendEvent( EVT_GRID_LABEL_RIGHT_CLICK, row, col, ev ) ) { // TODO: default processing ? } @@ -1630,7 +1631,7 @@ void wxGrid::OnMouse( wxMouseEvent& ev ) case WXGRID_CELL: { XYToCell( x, y, cellCoords ); - if ( !SendEvent( EVT_WXGRID_CELL_RIGHT_CLICK, + if ( !SendEvent( EVT_GRID_CELL_RIGHT_CLICK, cellCoords.GetRow(), cellCoords.GetCol(), ev ) ) @@ -1663,14 +1664,14 @@ void wxGrid::OnMouse( wxMouseEvent& ev ) case WXGRID_ROWLABEL: { row = YToRow(y); - SendEvent( EVT_WXGRID_LABEL_RIGHT_DCLICK, row, col, ev ); + SendEvent( EVT_GRID_LABEL_RIGHT_DCLICK, row, col, ev ); } break; case WXGRID_COLLABEL: { col = XToCol(x); - SendEvent( EVT_WXGRID_LABEL_RIGHT_DCLICK, row, col, ev ); + SendEvent( EVT_GRID_LABEL_RIGHT_DCLICK, row, col, ev ); } break; @@ -1678,14 +1679,14 @@ void wxGrid::OnMouse( wxMouseEvent& ev ) { // leave both row and col as -1 // - SendEvent( EVT_WXGRID_LABEL_RIGHT_DCLICK, row, col, ev ); + SendEvent( EVT_GRID_LABEL_RIGHT_DCLICK, row, col, ev ); } break; case WXGRID_CELL: { XYToCell( x, y, cellCoords ); - SendEvent( EVT_WXGRID_CELL_RIGHT_DCLICK, + SendEvent( EVT_GRID_CELL_RIGHT_DCLICK, cellCoords.GetRow(), cellCoords.GetCol(), ev ); @@ -1964,6 +1965,12 @@ void wxGrid::OnGridScroll( wxScrollEvent& ev ) void wxGrid::SelectCell( const wxGridCellCoords& coords ) { + if ( SendEvent( EVT_GRID_SELECT_CELL, coords.GetRow(), coords.GetCol() ) ) + { + // the event has been intercepted - do nothing + return; + } + wxClientDC dc( this ); if ( m_currentCellCoords != wxGridNoCellCoords ) @@ -2153,7 +2160,7 @@ void wxGrid::SaveEditControlValue() if ( valueChanged ) { - SendEvent( EVT_WXGRID_CELL_CHANGE, + SendEvent( EVT_GRID_CELL_CHANGE, m_currentCellCoords.GetRow(), m_currentCellCoords.GetCol() ); } @@ -3035,13 +3042,13 @@ void wxGrid::DrawCellHighlight( wxDC& dc, int row, int col ) y = m_rowBottoms[row] - m_rowHeights[row]; if ( y >= ch ) return; - dc.SetLogicalFunction( wxXOR ); + dc.SetLogicalFunction( wxINVERT ); dc.SetPen( wxPen(GetCellHighlightColour(), 2, wxSOLID) ); dc.SetBrush( *wxTRANSPARENT_BRUSH ); - dc.DrawRectangle( x, y, - m_colWidths[col] + 2, - m_rowHeights[row] + 2 ); + dc.DrawRectangle( x-2, y-2, + m_colWidths[col] + 6, + m_rowHeights[row] + 6 ); dc.SetLogicalFunction( wxCOPY ); } @@ -3076,7 +3083,8 @@ void wxGrid::DrawCell( int row, int col ) // void wxGrid::HideCurrentCellHighlight( wxDC& dc ) { - if ( m_currentCellHighlighted && + if ( !m_cellEditCtrlEnabled && + m_currentCellHighlighted && m_currentCellCoords != wxGridNoCellCoords ) { DrawCellHighlight( dc, m_currentCellCoords ); @@ -3089,7 +3097,8 @@ void wxGrid::HideCurrentCellHighlight( wxDC& dc ) // void wxGrid::ShowCurrentCellHighlight( wxDC& dc ) { - if ( !m_currentCellHighlighted && + if ( !m_cellEditCtrlEnabled && + !m_currentCellHighlighted && m_currentCellCoords != wxGridNoCellCoords ) { DrawCellHighlight( dc, m_currentCellCoords ); @@ -3587,6 +3596,9 @@ void wxGrid::EnableCellEditControl( bool enable ) if ( m_cellEditCtrl && enable != m_cellEditCtrlEnabled ) { + wxClientDC dc( this ); + + HideCurrentCellHighlight( dc ); HideCellEditControl(); SaveEditControlValue(); @@ -3594,6 +3606,7 @@ void wxGrid::EnableCellEditControl( bool enable ) SetEditControlValue(); ShowCellEditControl(); + ShowCurrentCellHighlight( dc ); } } @@ -3863,7 +3876,7 @@ void wxGrid::SetRowSize( int row, int height ) // Note: we are ending the event *after* doing // default processing in this case // - SendEvent( EVT_WXGRID_ROW_SIZE, + SendEvent( EVT_GRID_ROW_SIZE, row, -1 ); } else @@ -3902,7 +3915,7 @@ void wxGrid::SetColSize( int col, int width ) // Note: we are ending the event *after* doing // default processing in this case // - SendEvent( EVT_WXGRID_COL_SIZE, + SendEvent( EVT_GRID_COL_SIZE, -1, col ); } else @@ -4141,7 +4154,7 @@ void wxGrid::SelectRow( int row, bool addToSelected ) } wxGridRangeSelectEvent gridEvt( GetId(), - EVT_WXGRID_RANGE_SELECT, + EVT_GRID_RANGE_SELECT, this, m_selectedTopLeft, m_selectedBottomRight ); @@ -4178,7 +4191,7 @@ void wxGrid::SelectCol( int col, bool addToSelected ) } wxGridRangeSelectEvent gridEvt( GetId(), - EVT_WXGRID_RANGE_SELECT, + EVT_GRID_RANGE_SELECT, this, m_selectedTopLeft, m_selectedBottomRight ); @@ -4220,7 +4233,7 @@ void wxGrid::SelectBlock( int topRow, int leftCol, int bottomRow, int rightCol ) if ( !m_isDragging ) { wxGridRangeSelectEvent gridEvt( GetId(), - EVT_WXGRID_RANGE_SELECT, + EVT_GRID_RANGE_SELECT, this, m_selectedTopLeft, m_selectedBottomRight );