Some mouse events need to be handled even when outside the grid.
Added flag and accessors to enable/disable the dragging of the grid lines. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@6229 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
		@@ -958,7 +958,6 @@ public:
 | 
			
		||||
 | 
			
		||||
    void ShowCellEditControl();
 | 
			
		||||
    void HideCellEditControl();
 | 
			
		||||
    void SetEditControlValue( const wxString& s = wxEmptyString );
 | 
			
		||||
    void SaveEditControlValue();
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@@ -1041,6 +1040,10 @@ public:
 | 
			
		||||
    void     EnableDragColSize( bool enable = TRUE );
 | 
			
		||||
    void     DisableDragColSize() { EnableDragColSize( FALSE ); }
 | 
			
		||||
    bool     CanDragColSize() { return m_canDragColSize; }
 | 
			
		||||
    void     EnableDragGridSize(bool enable = TRUE);
 | 
			
		||||
    void     DisableDragGridSize() { EnableDragGridSize(FALSE); }
 | 
			
		||||
    bool     CanDragGridSize() { return m_canDragGridSize; }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    // this sets the specified attribute for all cells in this row/col
 | 
			
		||||
    void     SetRowAttr(int row, wxGridCellAttr *attr);
 | 
			
		||||
@@ -1530,6 +1533,7 @@ protected:
 | 
			
		||||
 | 
			
		||||
    bool    m_canDragRowSize;
 | 
			
		||||
    bool    m_canDragColSize;
 | 
			
		||||
    bool    m_canDragGridSize;
 | 
			
		||||
    int     m_dragLastPos;
 | 
			
		||||
    int     m_dragRowOrCol;
 | 
			
		||||
    bool    m_isDragging;
 | 
			
		||||
 
 | 
			
		||||
@@ -70,6 +70,7 @@ BEGIN_EVENT_TABLE( GridFrame, wxFrame )
 | 
			
		||||
    EVT_MENU( ID_TOGGLEEDIT, GridFrame::ToggleEditing )
 | 
			
		||||
    EVT_MENU( ID_TOGGLEROWSIZING, GridFrame::ToggleRowSizing )
 | 
			
		||||
    EVT_MENU( ID_TOGGLECOLSIZING, GridFrame::ToggleColSizing )
 | 
			
		||||
    EVT_MENU( ID_TOGGLEGRIDSIZING, GridFrame::ToggleGridSizing )
 | 
			
		||||
    EVT_MENU( ID_SETLABELCOLOUR, GridFrame::SetLabelColour )
 | 
			
		||||
    EVT_MENU( ID_SETLABELTEXTCOLOUR, GridFrame::SetLabelTextColour )
 | 
			
		||||
    EVT_MENU( ID_ROWLABELHORIZALIGN, GridFrame::SetRowLabelHorizAlignment )
 | 
			
		||||
@@ -124,6 +125,7 @@ GridFrame::GridFrame()
 | 
			
		||||
    viewMenu->Append( ID_TOGGLEEDIT,  "&Editable", "", TRUE );
 | 
			
		||||
    viewMenu->Append( ID_TOGGLEROWSIZING, "Ro&w drag-resize", "", TRUE );
 | 
			
		||||
    viewMenu->Append( ID_TOGGLECOLSIZING, "C&ol drag-resize", "", TRUE );
 | 
			
		||||
    viewMenu->Append( ID_TOGGLEGRIDSIZING, "&Grid drag-resize", "", TRUE );
 | 
			
		||||
 | 
			
		||||
    wxMenu *rowLabelMenu = new wxMenu;
 | 
			
		||||
 | 
			
		||||
@@ -261,6 +263,7 @@ void GridFrame::SetDefaults()
 | 
			
		||||
    GetMenuBar()->Check( ID_TOGGLEEDIT, TRUE );
 | 
			
		||||
    GetMenuBar()->Check( ID_TOGGLEROWSIZING, TRUE );
 | 
			
		||||
    GetMenuBar()->Check( ID_TOGGLECOLSIZING, TRUE );
 | 
			
		||||
    GetMenuBar()->Check( ID_TOGGLEGRIDSIZING, TRUE );
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@@ -310,6 +313,12 @@ void GridFrame::ToggleColSizing( wxCommandEvent& WXUNUSED(ev) )
 | 
			
		||||
        GetMenuBar()->IsChecked( ID_TOGGLECOLSIZING ) );
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void GridFrame::ToggleGridSizing( wxCommandEvent& WXUNUSED(ev) )
 | 
			
		||||
{
 | 
			
		||||
    grid->EnableDragGridSize(
 | 
			
		||||
        GetMenuBar()->IsChecked( ID_TOGGLEGRIDSIZING ) );
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
void GridFrame::SetLabelColour( wxCommandEvent& WXUNUSED(ev) )
 | 
			
		||||
{
 | 
			
		||||
 
 | 
			
		||||
@@ -39,6 +39,7 @@ class GridFrame : public wxFrame
 | 
			
		||||
    void ToggleEditing( wxCommandEvent& );
 | 
			
		||||
    void ToggleRowSizing( wxCommandEvent& );
 | 
			
		||||
    void ToggleColSizing( wxCommandEvent& );
 | 
			
		||||
    void ToggleGridSizing( wxCommandEvent& );
 | 
			
		||||
    void SetLabelColour( wxCommandEvent& );
 | 
			
		||||
    void SetLabelTextColour( wxCommandEvent& );
 | 
			
		||||
    void SetRowLabelHorizAlignment( wxCommandEvent& );
 | 
			
		||||
@@ -83,6 +84,7 @@ public:
 | 
			
		||||
        ID_TOGGLEEDIT,
 | 
			
		||||
        ID_TOGGLEROWSIZING,
 | 
			
		||||
        ID_TOGGLECOLSIZING,
 | 
			
		||||
        ID_TOGGLEGRIDSIZING,
 | 
			
		||||
        ID_SETLABELCOLOUR,
 | 
			
		||||
        ID_SETLABELTEXTCOLOUR,
 | 
			
		||||
        ID_ROWLABELALIGN,
 | 
			
		||||
 
 | 
			
		||||
@@ -2868,6 +2868,7 @@ void wxGrid::Init()
 | 
			
		||||
    m_winCapture = (wxWindow *)NULL;
 | 
			
		||||
    m_canDragRowSize = TRUE;
 | 
			
		||||
    m_canDragColSize = TRUE;
 | 
			
		||||
    m_canDragGridSize = TRUE;
 | 
			
		||||
    m_dragLastPos  = -1;
 | 
			
		||||
    m_dragRowOrCol = -1;
 | 
			
		||||
    m_isDragging = FALSE;
 | 
			
		||||
@@ -3895,9 +3896,13 @@ void wxGrid::ProcessGridCellMouseEvent( wxMouseEvent& event )
 | 
			
		||||
    m_isDragging = FALSE;
 | 
			
		||||
    m_startDragPos = wxDefaultPosition;
 | 
			
		||||
 | 
			
		||||
//      if ( coords == wxGridNoCellCoords && m_cursorMode != WXGRID_CURSOR_SELECT_CELL )
 | 
			
		||||
//      {
 | 
			
		||||
//          ChangeCursorMode(WXGRID_CURSOR_SELECT_CELL);
 | 
			
		||||
//      }
 | 
			
		||||
 | 
			
		||||
    if ( coords != wxGridNoCellCoords )
 | 
			
		||||
    {
 | 
			
		||||
//      if ( coords != wxGridNoCellCoords )
 | 
			
		||||
//      {
 | 
			
		||||
        // 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
 | 
			
		||||
@@ -3912,7 +3917,7 @@ void wxGrid::ProcessGridCellMouseEvent( wxMouseEvent& event )
 | 
			
		||||
 | 
			
		||||
        // ------------ Left button pressed
 | 
			
		||||
        //
 | 
			
		||||
        if ( event.LeftDown() )
 | 
			
		||||
        if ( event.LeftDown() && coords != wxGridNoCellCoords )
 | 
			
		||||
        {
 | 
			
		||||
            DisableCellEditControl();
 | 
			
		||||
            if ( event.ShiftDown() )
 | 
			
		||||
@@ -3955,7 +3960,7 @@ void wxGrid::ProcessGridCellMouseEvent( wxMouseEvent& event )
 | 
			
		||||
 | 
			
		||||
        // ------------ Left double click
 | 
			
		||||
        //
 | 
			
		||||
        else if ( event.LeftDClick() )
 | 
			
		||||
        else if ( event.LeftDClick() && coords != wxGridNoCellCoords )
 | 
			
		||||
        {
 | 
			
		||||
            DisableCellEditControl();
 | 
			
		||||
            if ( XToEdgeOfCol(x) < 0  &&  YToEdgeOfRow(y) < 0 )
 | 
			
		||||
@@ -4015,7 +4020,7 @@ void wxGrid::ProcessGridCellMouseEvent( wxMouseEvent& event )
 | 
			
		||||
 | 
			
		||||
        // ------------ Right button down
 | 
			
		||||
        //
 | 
			
		||||
        else if ( event.RightDown() )
 | 
			
		||||
        else if ( event.RightDown() && coords != wxGridNoCellCoords )
 | 
			
		||||
        {
 | 
			
		||||
            DisableCellEditControl();
 | 
			
		||||
            if ( !SendEvent( wxEVT_GRID_CELL_RIGHT_CLICK,
 | 
			
		||||
@@ -4030,7 +4035,7 @@ void wxGrid::ProcessGridCellMouseEvent( wxMouseEvent& event )
 | 
			
		||||
 | 
			
		||||
        // ------------ Right double click
 | 
			
		||||
        //
 | 
			
		||||
        else if ( event.RightDClick() )
 | 
			
		||||
        else if ( event.RightDClick() && coords != wxGridNoCellCoords )
 | 
			
		||||
        {
 | 
			
		||||
            DisableCellEditControl();
 | 
			
		||||
            if ( !SendEvent( wxEVT_GRID_CELL_RIGHT_DCLICK,
 | 
			
		||||
@@ -4064,7 +4069,7 @@ void wxGrid::ProcessGridCellMouseEvent( wxMouseEvent& event )
 | 
			
		||||
 | 
			
		||||
                if ( m_cursorMode == WXGRID_CURSOR_SELECT_CELL )
 | 
			
		||||
                {
 | 
			
		||||
                    if ( CanDragRowSize() )
 | 
			
		||||
                    if ( CanDragRowSize() && CanDragGridSize() )
 | 
			
		||||
                        ChangeCursorMode(WXGRID_CURSOR_RESIZE_ROW);
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
@@ -4077,7 +4082,7 @@ void wxGrid::ProcessGridCellMouseEvent( wxMouseEvent& event )
 | 
			
		||||
 | 
			
		||||
                if ( m_cursorMode == WXGRID_CURSOR_SELECT_CELL )
 | 
			
		||||
                {
 | 
			
		||||
                    if ( CanDragColSize() )
 | 
			
		||||
                    if ( CanDragColSize() && CanDragGridSize() )
 | 
			
		||||
                        ChangeCursorMode(WXGRID_CURSOR_RESIZE_COL);
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
@@ -4091,7 +4096,6 @@ void wxGrid::ProcessGridCellMouseEvent( wxMouseEvent& event )
 | 
			
		||||
                ChangeCursorMode(WXGRID_CURSOR_SELECT_CELL);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@@ -4210,8 +4214,10 @@ void wxGrid::ClearGrid()
 | 
			
		||||
{
 | 
			
		||||
    if ( m_table )
 | 
			
		||||
    {
 | 
			
		||||
        if (IsCellEditControlEnabled())
 | 
			
		||||
            DisableCellEditControl();
 | 
			
		||||
 | 
			
		||||
        m_table->Clear();
 | 
			
		||||
        SetEditControlValue();
 | 
			
		||||
        if ( !GetBatchCount() ) m_gridWin->Refresh();
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -4260,7 +4266,6 @@ bool wxGrid::InsertRows( int pos, int numRows, bool WXUNUSED(updateLabels) )
 | 
			
		||||
            if ( !GetBatchCount() ) Refresh();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        SetEditControlValue();
 | 
			
		||||
        return ok;
 | 
			
		||||
    }
 | 
			
		||||
    else
 | 
			
		||||
@@ -4368,7 +4373,6 @@ bool wxGrid::InsertCols( int pos, int numCols, bool WXUNUSED(updateLabels) )
 | 
			
		||||
            if ( !GetBatchCount() ) Refresh();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        SetEditControlValue();
 | 
			
		||||
        return ok;
 | 
			
		||||
    }
 | 
			
		||||
    else
 | 
			
		||||
@@ -4537,7 +4541,6 @@ void wxGrid::OnPaint( wxPaintEvent& WXUNUSED(event) )
 | 
			
		||||
         m_numRows && m_numCols )
 | 
			
		||||
    {
 | 
			
		||||
        m_currentCellCoords.Set(0, 0);
 | 
			
		||||
        SetEditControlValue();
 | 
			
		||||
        ShowCellEditControl();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -4736,9 +4739,6 @@ void wxGrid::SetCurrentCell( const wxGridCellCoords& coords )
 | 
			
		||||
         m_currentCellCoords != wxGridNoCellCoords )
 | 
			
		||||
    {
 | 
			
		||||
        HideCellEditControl();
 | 
			
		||||
        // RD:  Does disabling this cause any problems?  It's called again
 | 
			
		||||
        //      in DisableCellEditControl...
 | 
			
		||||
        // SaveEditControlValue();
 | 
			
		||||
        DisableCellEditControl();
 | 
			
		||||
 | 
			
		||||
        // Clear the old current cell highlight
 | 
			
		||||
@@ -4752,8 +4752,6 @@ void wxGrid::SetCurrentCell( const wxGridCellCoords& coords )
 | 
			
		||||
 | 
			
		||||
    m_currentCellCoords = coords;
 | 
			
		||||
 | 
			
		||||
    SetEditControlValue();
 | 
			
		||||
 | 
			
		||||
    if ( m_displayed )
 | 
			
		||||
    {
 | 
			
		||||
        wxClientDC dc(m_gridWin);
 | 
			
		||||
@@ -5302,7 +5300,6 @@ void wxGrid::EnableCellEditControl( bool enable )
 | 
			
		||||
            // do it before ShowCellEditControl()
 | 
			
		||||
            m_cellEditCtrlEnabled = enable;
 | 
			
		||||
 | 
			
		||||
            SetEditControlValue();
 | 
			
		||||
            ShowCellEditControl();
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
@@ -5404,12 +5401,6 @@ void wxGrid::HideCellEditControl()
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
void wxGrid::SetEditControlValue( const wxString& value )
 | 
			
		||||
{
 | 
			
		||||
    // RD: The new Editors get the value from the table themselves now.  This
 | 
			
		||||
    // method can probably be removed...
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
void wxGrid::SaveEditControlValue()
 | 
			
		||||
{
 | 
			
		||||
@@ -6684,6 +6675,11 @@ void wxGrid::EnableDragColSize( bool enable )
 | 
			
		||||
    m_canDragColSize = enable;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void wxGrid::EnableDragGridSize( bool enable )
 | 
			
		||||
{
 | 
			
		||||
    m_canDragGridSize = enable;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
void wxGrid::SetDefaultRowSize( int height, bool resizeExistingRows )
 | 
			
		||||
{
 | 
			
		||||
@@ -6839,15 +6835,13 @@ void wxGrid::SetCellValue( int row, int col, const wxString& s )
 | 
			
		||||
            DrawCell( dc, wxGridCellCoords(row, col) );
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
#if 0  // TODO: edit in place
 | 
			
		||||
 | 
			
		||||
        if ( m_currentCellCoords.GetRow() == row &&
 | 
			
		||||
             m_currentCellCoords.GetCol() == col )
 | 
			
		||||
             m_currentCellCoords.GetCol() == col &&
 | 
			
		||||
             IsCellEditControlEnabled())
 | 
			
		||||
        {
 | 
			
		||||
            SetEditControlValue( s );
 | 
			
		||||
            HideCellEditControl();
 | 
			
		||||
            ShowCellEditControl(); // will reread data from table
 | 
			
		||||
        }
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user