fallback to string changes for number and float editors
Fixes for DrawGridSpace (it needed moved over/up by one pixel, at least for MSW) Editor left active when resizing rows/cols git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@6248 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -634,11 +634,14 @@ void wxGridCellNumberEditor::BeginEdit(int row, int col, wxGrid* grid)
|
|||||||
m_valueOld = table->GetValueAsLong(row, col);
|
m_valueOld = table->GetValueAsLong(row, col);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
wxString sValue = table->GetValue(row, col);
|
||||||
|
if (! sValue.ToLong(&m_valueOld))
|
||||||
{
|
{
|
||||||
wxFAIL_MSG( _T("this cell doesn't have numeric value") );
|
wxFAIL_MSG( _T("this cell doesn't have numeric value") );
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ( HasRange() )
|
if ( HasRange() )
|
||||||
{
|
{
|
||||||
@@ -668,7 +671,10 @@ bool wxGridCellNumberEditor::EndEdit(int row, int col,
|
|||||||
|
|
||||||
if ( changed )
|
if ( changed )
|
||||||
{
|
{
|
||||||
|
if (grid->GetTable()->CanSetValueAs(row, col, wxGRID_VALUE_NUMBER))
|
||||||
grid->GetTable()->SetValueAsLong(row, col, value);
|
grid->GetTable()->SetValueAsLong(row, col, value);
|
||||||
|
else
|
||||||
|
grid->GetTable()->SetValue(row, col, wxString::Format("%ld", value));
|
||||||
}
|
}
|
||||||
|
|
||||||
return changed;
|
return changed;
|
||||||
@@ -727,11 +733,14 @@ void wxGridCellFloatEditor::BeginEdit(int row, int col, wxGrid* grid)
|
|||||||
m_valueOld = table->GetValueAsDouble(row, col);
|
m_valueOld = table->GetValueAsDouble(row, col);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
wxString sValue = table->GetValue(row, col);
|
||||||
|
if (! sValue.ToDouble(&m_valueOld))
|
||||||
{
|
{
|
||||||
wxFAIL_MSG( _T("this cell doesn't have float value") );
|
wxFAIL_MSG( _T("this cell doesn't have float value") );
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
DoBeginEdit(GetString());
|
DoBeginEdit(GetString());
|
||||||
}
|
}
|
||||||
@@ -742,7 +751,10 @@ bool wxGridCellFloatEditor::EndEdit(int row, int col,
|
|||||||
double value;
|
double value;
|
||||||
if ( Text()->GetValue().ToDouble(&value) && (value != m_valueOld) )
|
if ( Text()->GetValue().ToDouble(&value) && (value != m_valueOld) )
|
||||||
{
|
{
|
||||||
|
if (grid->GetTable()->CanSetValueAs(row, col, wxGRID_VALUE_FLOAT))
|
||||||
grid->GetTable()->SetValueAsDouble(row, col, value);
|
grid->GetTable()->SetValueAsDouble(row, col, value);
|
||||||
|
else
|
||||||
|
grid->GetTable()->SetValue(row, col, wxString::Format("%f", value));
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
@@ -898,11 +910,16 @@ void wxGridCellChoiceEditor::Create(wxWindow* parent,
|
|||||||
wxGridCellEditor::Create(parent, id, evtHandler);
|
wxGridCellEditor::Create(parent, id, evtHandler);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxGridCellChoiceEditor::PaintBackground(const wxRect& WXUNUSED(rectCell),
|
void wxGridCellChoiceEditor::PaintBackground(const wxRect& rectCell,
|
||||||
wxGridCellAttr * WXUNUSED(attr))
|
wxGridCellAttr * attr)
|
||||||
{
|
{
|
||||||
// as we fill the entire client area, don't do anything here to minimize
|
// as we fill the entire client area, don't do anything here to minimize
|
||||||
// flicker
|
// flicker
|
||||||
|
|
||||||
|
// TODO: It doesn't actually fill the client area since the height of a
|
||||||
|
// combo always defaults to the standard... Until someone has time to
|
||||||
|
// figure out the right rectangle to paint, just do it the normal way...
|
||||||
|
wxGridCellEditor::PaintBackground(rectCell, attr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxGridCellChoiceEditor::BeginEdit(int row, int col, wxGrid* grid)
|
void wxGridCellChoiceEditor::BeginEdit(int row, int col, wxGrid* grid)
|
||||||
@@ -2586,10 +2603,10 @@ void wxGridWindow::OnPaint( wxPaintEvent &WXUNUSED(event) )
|
|||||||
wxRegion reg = GetUpdateRegion();
|
wxRegion reg = GetUpdateRegion();
|
||||||
m_owner->CalcCellsExposed( reg );
|
m_owner->CalcCellsExposed( reg );
|
||||||
m_owner->DrawGridCellArea( dc );
|
m_owner->DrawGridCellArea( dc );
|
||||||
m_owner->DrawGridSpace( dc );
|
|
||||||
#if WXGRID_DRAW_LINES
|
#if WXGRID_DRAW_LINES
|
||||||
m_owner->DrawAllGridLines( dc, reg );
|
m_owner->DrawAllGridLines( dc, reg );
|
||||||
#endif
|
#endif
|
||||||
|
m_owner->DrawGridSpace( dc );
|
||||||
m_owner->DrawHighlight( dc );
|
m_owner->DrawHighlight( dc );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3803,7 +3820,10 @@ void wxGrid::ProcessGridCellMouseEvent( wxMouseEvent& event )
|
|||||||
// Hide the edit control, so it
|
// Hide the edit control, so it
|
||||||
// won't interfer with drag-shrinking.
|
// won't interfer with drag-shrinking.
|
||||||
if ( IsCellEditControlEnabled() )
|
if ( IsCellEditControlEnabled() )
|
||||||
|
{
|
||||||
HideCellEditControl();
|
HideCellEditControl();
|
||||||
|
SaveEditControlValue();
|
||||||
|
}
|
||||||
|
|
||||||
// Have we captured the mouse yet?
|
// Have we captured the mouse yet?
|
||||||
if (! m_winCapture)
|
if (! m_winCapture)
|
||||||
@@ -3873,13 +3893,6 @@ void wxGrid::ProcessGridCellMouseEvent( wxMouseEvent& event )
|
|||||||
m_isDragging = FALSE;
|
m_isDragging = FALSE;
|
||||||
m_startDragPos = wxDefaultPosition;
|
m_startDragPos = wxDefaultPosition;
|
||||||
|
|
||||||
// if ( coords == wxGridNoCellCoords && m_cursorMode != WXGRID_CURSOR_SELECT_CELL )
|
|
||||||
// {
|
|
||||||
// ChangeCursorMode(WXGRID_CURSOR_SELECT_CELL);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// if ( coords != wxGridNoCellCoords )
|
|
||||||
// {
|
|
||||||
// VZ: if we do this, the mode is reset to WXGRID_CURSOR_SELECT_CELL
|
// VZ: if we do this, the mode is reset to WXGRID_CURSOR_SELECT_CELL
|
||||||
// immediately after it becomes WXGRID_CURSOR_RESIZE_ROW/COL under
|
// immediately after it becomes WXGRID_CURSOR_RESIZE_ROW/COL under
|
||||||
// wxGTK
|
// wxGTK
|
||||||
@@ -3896,7 +3909,6 @@ void wxGrid::ProcessGridCellMouseEvent( wxMouseEvent& event )
|
|||||||
//
|
//
|
||||||
if ( event.LeftDown() && coords != wxGridNoCellCoords )
|
if ( event.LeftDown() && coords != wxGridNoCellCoords )
|
||||||
{
|
{
|
||||||
DisableCellEditControl();
|
|
||||||
if ( event.ShiftDown() )
|
if ( event.ShiftDown() )
|
||||||
{
|
{
|
||||||
SelectBlock( m_currentCellCoords, coords );
|
SelectBlock( m_currentCellCoords, coords );
|
||||||
@@ -3909,6 +3921,7 @@ void wxGrid::ProcessGridCellMouseEvent( wxMouseEvent& event )
|
|||||||
coords.GetCol(),
|
coords.GetCol(),
|
||||||
event ) )
|
event ) )
|
||||||
{
|
{
|
||||||
|
DisableCellEditControl();
|
||||||
MakeCellVisible( coords );
|
MakeCellVisible( coords );
|
||||||
|
|
||||||
// if this is the second click on this cell then start
|
// if this is the second click on this cell then start
|
||||||
@@ -3940,6 +3953,7 @@ void wxGrid::ProcessGridCellMouseEvent( wxMouseEvent& event )
|
|||||||
else if ( event.LeftDClick() && coords != wxGridNoCellCoords )
|
else if ( event.LeftDClick() && coords != wxGridNoCellCoords )
|
||||||
{
|
{
|
||||||
DisableCellEditControl();
|
DisableCellEditControl();
|
||||||
|
|
||||||
if ( XToEdgeOfCol(x) < 0 && YToEdgeOfRow(y) < 0 )
|
if ( XToEdgeOfCol(x) < 0 && YToEdgeOfRow(y) < 0 )
|
||||||
{
|
{
|
||||||
SendEvent( wxEVT_GRID_CELL_LEFT_DCLICK,
|
SendEvent( wxEVT_GRID_CELL_LEFT_DCLICK,
|
||||||
@@ -4091,6 +4105,7 @@ void wxGrid::DoEndDragResizeRow()
|
|||||||
dc.SetLogicalFunction( wxINVERT );
|
dc.SetLogicalFunction( wxINVERT );
|
||||||
dc.DrawLine( left, m_dragLastPos, left+cw, m_dragLastPos );
|
dc.DrawLine( left, m_dragLastPos, left+cw, m_dragLastPos );
|
||||||
HideCellEditControl();
|
HideCellEditControl();
|
||||||
|
SaveEditControlValue();
|
||||||
|
|
||||||
int rowTop = GetRowTop(m_dragRowOrCol);
|
int rowTop = GetRowTop(m_dragRowOrCol);
|
||||||
SetRowSize( m_dragRowOrCol,
|
SetRowSize( m_dragRowOrCol,
|
||||||
@@ -4129,6 +4144,7 @@ void wxGrid::DoEndDragResizeCol()
|
|||||||
dc.SetLogicalFunction( wxINVERT );
|
dc.SetLogicalFunction( wxINVERT );
|
||||||
dc.DrawLine( m_dragLastPos, top, m_dragLastPos, top+ch );
|
dc.DrawLine( m_dragLastPos, top, m_dragLastPos, top+ch );
|
||||||
HideCellEditControl();
|
HideCellEditControl();
|
||||||
|
SaveEditControlValue();
|
||||||
|
|
||||||
int colLeft = GetColLeft(m_dragRowOrCol);
|
int colLeft = GetColLeft(m_dragRowOrCol);
|
||||||
SetColSize( m_dragRowOrCol,
|
SetColSize( m_dragRowOrCol,
|
||||||
@@ -4826,11 +4842,11 @@ void wxGrid::DrawGridSpace( wxDC& dc )
|
|||||||
dc.SetPen( *wxTRANSPARENT_PEN );
|
dc.SetPen( *wxTRANSPARENT_PEN );
|
||||||
|
|
||||||
if ( right > GetColRight(m_numCols-1) )
|
if ( right > GetColRight(m_numCols-1) )
|
||||||
dc.DrawRectangle( GetColRight(m_numCols-1)+1, top,
|
dc.DrawRectangle( GetColRight(m_numCols-1), top,
|
||||||
right - GetColRight(m_numCols-1), ch );
|
right - GetColRight(m_numCols-1), ch );
|
||||||
|
|
||||||
if ( bottom > GetRowBottom(m_numRows-1) )
|
if ( bottom > GetRowBottom(m_numRows-1) )
|
||||||
dc.DrawRectangle( left, GetRowBottom(m_numRows-1)+1,
|
dc.DrawRectangle( left, GetRowBottom(m_numRows-1),
|
||||||
cw, bottom - GetRowBottom(m_numRows-1) );
|
cw, bottom - GetRowBottom(m_numRows-1) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user