Fixed bug that caused wrong block of cells to be selected if the
mouse was dragged out of the grid cell area. Cell text values now echo changes in top edit control if in-place editing is disabled. Changed highlight scheme again so that a border is drawn around the current cell whether in-place editing is on or off. Hopefully this is less confusing. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@4207 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
ad9bb75ff2
commit
52068ea5ff
@ -287,7 +287,7 @@ class wxGrid : public wxPanel
|
||||
{
|
||||
DECLARE_DYNAMIC_CLASS( wxGrid )
|
||||
|
||||
private:
|
||||
protected:
|
||||
bool m_created;
|
||||
|
||||
wxGridTableBase *m_table;
|
||||
@ -459,14 +459,21 @@ class wxGrid : public wxPanel
|
||||
void DrawGridLines( wxDC& dc );
|
||||
void DrawCells( wxDC& dc );
|
||||
void DrawCellBackground( wxDC& dc, const wxRect&, int row, int col );
|
||||
void DrawCellValue( wxDC& dc, const wxRect&, int row, int col );
|
||||
|
||||
// this one is useful when you just need to draw one or a few
|
||||
void DrawCellValue( wxDC& dc, const wxRect&, int row, int col,
|
||||
const wxString& value = wxEmptyString, bool useValueArg = FALSE );
|
||||
|
||||
// this updates the displayed cell text value but not the underlying
|
||||
// table cell value (it is used to echo text being entered into
|
||||
// the top edit control when in-place editing is turned off)
|
||||
//
|
||||
void DrawCellValue( const wxGridCellCoords& coords, const wxString& value );
|
||||
|
||||
// these are useful when you just need to draw one or a few
|
||||
// cells
|
||||
void DrawCell( int row, int col );
|
||||
void DrawCell( const wxGridCellCoords& coords )
|
||||
{ DrawCell( coords.GetRow(), coords.GetCol() ); }
|
||||
|
||||
|
||||
void DrawCellHighlight( wxDC& dc, int row, int col );
|
||||
void DrawCellHighlight( wxDC& dc, wxGridCellCoords& coords )
|
||||
{ DrawCellHighlight( dc, coords.GetRow(), coords.GetCol() ); }
|
||||
@ -896,7 +903,7 @@ class WXDLLEXPORT wxGridEvent : public wxNotifyEvent
|
||||
{
|
||||
DECLARE_DYNAMIC_CLASS(wxGridEvent)
|
||||
|
||||
private:
|
||||
protected:
|
||||
int m_row;
|
||||
int m_col;
|
||||
int m_x;
|
||||
@ -931,7 +938,7 @@ class WXDLLEXPORT wxGridSizeEvent : public wxNotifyEvent
|
||||
{
|
||||
DECLARE_DYNAMIC_CLASS(wxGridSizeEvent)
|
||||
|
||||
private:
|
||||
protected:
|
||||
int m_rowOrCol;
|
||||
int m_x;
|
||||
int m_y;
|
||||
@ -964,7 +971,7 @@ class WXDLLEXPORT wxGridRangeSelectEvent : public wxNotifyEvent
|
||||
{
|
||||
DECLARE_DYNAMIC_CLASS(wxGridRangeSelectEvent)
|
||||
|
||||
private:
|
||||
protected:
|
||||
wxGridCellCoords m_topLeft;
|
||||
wxGridCellCoords m_bottomRight;
|
||||
bool m_control;
|
||||
|
@ -1294,9 +1294,29 @@ void wxGrid::OnMouse( wxMouseEvent& ev )
|
||||
{
|
||||
SelectBlock( cellCoords, cellCoords );
|
||||
}
|
||||
else if ( !IsInSelection( cellCoords ) )
|
||||
else
|
||||
{
|
||||
SelectBlock( m_currentCellCoords, cellCoords );
|
||||
// check for the mouse being outside the cell area
|
||||
// (we still want to let the user grow the selected block)
|
||||
//
|
||||
if ( cellCoords.GetCol() == -1 )
|
||||
{
|
||||
if ( x >= m_right )
|
||||
cellCoords.SetCol( m_numCols-1 );
|
||||
else
|
||||
cellCoords.SetCol( m_scrollPosX );
|
||||
}
|
||||
|
||||
if ( cellCoords.GetRow() == -1 )
|
||||
{
|
||||
if ( y >= m_bottom )
|
||||
cellCoords.SetRow( m_numRows-1 );
|
||||
else
|
||||
cellCoords.SetRow( m_scrollPosY );
|
||||
}
|
||||
|
||||
if ( !IsInSelection( cellCoords ) )
|
||||
SelectBlock( m_currentCellCoords, cellCoords );
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1913,20 +1933,38 @@ void wxGrid::OnText( wxKeyEvent& ev )
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if ( ctrl == m_topEditCtrl &&
|
||||
IsCellEditControlEnabled() )
|
||||
else if ( ctrl == m_topEditCtrl )
|
||||
{
|
||||
switch ( m_editCtrlType )
|
||||
if ( IsCellEditControlEnabled() )
|
||||
{
|
||||
case wxGRID_TEXTCTRL:
|
||||
((wxTextCtrl *)m_cellEditCtrl)->
|
||||
SetValue(((wxTextCtrl *)ctrl)->GetValue());
|
||||
break;
|
||||
|
||||
case wxGRID_COMBOBOX:
|
||||
((wxComboBox *)m_cellEditCtrl)->
|
||||
SetValue(((wxComboBox *)ctrl)->GetValue());
|
||||
break;
|
||||
switch ( m_editCtrlType )
|
||||
{
|
||||
case wxGRID_TEXTCTRL:
|
||||
((wxTextCtrl *)m_cellEditCtrl)->
|
||||
SetValue(((wxTextCtrl *)ctrl)->GetValue());
|
||||
break;
|
||||
|
||||
case wxGRID_COMBOBOX:
|
||||
((wxComboBox *)m_cellEditCtrl)->
|
||||
SetValue(((wxComboBox *)ctrl)->GetValue());
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// in the case when in-place editing is turned off we just want to
|
||||
// echo the text changes in the cell but not yet update the grid table
|
||||
//
|
||||
switch ( m_editCtrlType )
|
||||
{
|
||||
case wxGRID_TEXTCTRL:
|
||||
DrawCellValue( m_currentCellCoords, ((wxTextCtrl *)ctrl)->GetValue() );
|
||||
break;
|
||||
|
||||
case wxGRID_COMBOBOX:
|
||||
DrawCellValue( m_currentCellCoords, ((wxComboBox *)ctrl)->GetValue() );
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2993,7 +3031,11 @@ void wxGrid::DrawCellBackground( wxDC& dc, const wxRect& rect, int row, int col
|
||||
}
|
||||
|
||||
|
||||
void wxGrid::DrawCellValue( wxDC& dc, const wxRect& rect, int row, int col )
|
||||
// This draws a text value in the given cell. If useValueArg is FALSE
|
||||
// (the default) then the grid table value will be used
|
||||
//
|
||||
void wxGrid::DrawCellValue( wxDC& dc, const wxRect& rect, int row, int col,
|
||||
const wxString& value, bool useValueArg )
|
||||
{
|
||||
wxRect rect2;
|
||||
rect2 = rect;
|
||||
@ -3020,7 +3062,37 @@ void wxGrid::DrawCellValue( wxDC& dc, const wxRect& rect, int row, int col )
|
||||
|
||||
int hAlign, vAlign;
|
||||
GetCellAlignment( row, col, &hAlign, &vAlign );
|
||||
DrawTextRectangle( dc, GetCellValue( row, col ), rect2, hAlign, vAlign );
|
||||
|
||||
if ( useValueArg )
|
||||
{
|
||||
DrawTextRectangle( dc, value, rect2, hAlign, vAlign );
|
||||
}
|
||||
else
|
||||
{
|
||||
DrawTextRectangle( dc, GetCellValue( row, col ), rect2, hAlign, vAlign );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// this is used to echo text being entered into the top edit control when
|
||||
// in-place editing is turned off
|
||||
//
|
||||
void wxGrid::DrawCellValue( const wxGridCellCoords& coords, const wxString& value )
|
||||
{
|
||||
if ( IsVisible( coords ) )
|
||||
{
|
||||
int row = coords.GetRow();
|
||||
int col = coords.GetCol();
|
||||
wxRect rect;
|
||||
rect.x = m_colRights[ col ] - m_colWidths[ col ];
|
||||
rect.y = m_rowBottoms[ row ] - m_rowHeights[ row ];
|
||||
rect.width = m_colWidths[ col ];
|
||||
rect.height = m_rowHeights[ row ];
|
||||
|
||||
wxClientDC dc( this );
|
||||
DrawCellBackground( dc, rect, row, col );
|
||||
DrawCellValue( dc, rect, row, col, value, TRUE );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -3083,8 +3155,7 @@ void wxGrid::DrawCell( int row, int col )
|
||||
//
|
||||
void wxGrid::HideCurrentCellHighlight( wxDC& dc )
|
||||
{
|
||||
if ( !m_cellEditCtrlEnabled &&
|
||||
m_currentCellHighlighted &&
|
||||
if ( m_currentCellHighlighted &&
|
||||
m_currentCellCoords != wxGridNoCellCoords )
|
||||
{
|
||||
DrawCellHighlight( dc, m_currentCellCoords );
|
||||
@ -3097,8 +3168,7 @@ void wxGrid::HideCurrentCellHighlight( wxDC& dc )
|
||||
//
|
||||
void wxGrid::ShowCurrentCellHighlight( wxDC& dc )
|
||||
{
|
||||
if ( !m_cellEditCtrlEnabled &&
|
||||
!m_currentCellHighlighted &&
|
||||
if ( !m_currentCellHighlighted &&
|
||||
m_currentCellCoords != wxGridNoCellCoords )
|
||||
{
|
||||
DrawCellHighlight( dc, m_currentCellCoords );
|
||||
|
Loading…
Reference in New Issue
Block a user