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:
Robin Dunn 2000-02-23 19:27:08 +00:00
parent fc3398f8e0
commit a5777624e2

View File

@ -634,11 +634,14 @@ void wxGridCellNumberEditor::BeginEdit(int row, int col, wxGrid* grid)
m_valueOld = table->GetValueAsLong(row, col);
}
else
{
wxString sValue = table->GetValue(row, col);
if (! sValue.ToLong(&m_valueOld))
{
wxFAIL_MSG( _T("this cell doesn't have numeric value") );
return;
}
}
if ( HasRange() )
{
@ -668,7 +671,10 @@ bool wxGridCellNumberEditor::EndEdit(int row, int col,
if ( changed )
{
if (grid->GetTable()->CanSetValueAs(row, col, wxGRID_VALUE_NUMBER))
grid->GetTable()->SetValueAsLong(row, col, value);
else
grid->GetTable()->SetValue(row, col, wxString::Format("%ld", value));
}
return changed;
@ -727,11 +733,14 @@ void wxGridCellFloatEditor::BeginEdit(int row, int col, wxGrid* grid)
m_valueOld = table->GetValueAsDouble(row, col);
}
else
{
wxString sValue = table->GetValue(row, col);
if (! sValue.ToDouble(&m_valueOld))
{
wxFAIL_MSG( _T("this cell doesn't have float value") );
return;
}
}
DoBeginEdit(GetString());
}
@ -742,7 +751,10 @@ bool wxGridCellFloatEditor::EndEdit(int row, int col,
double value;
if ( Text()->GetValue().ToDouble(&value) && (value != m_valueOld) )
{
if (grid->GetTable()->CanSetValueAs(row, col, wxGRID_VALUE_FLOAT))
grid->GetTable()->SetValueAsDouble(row, col, value);
else
grid->GetTable()->SetValue(row, col, wxString::Format("%f", value));
return TRUE;
}
@ -898,11 +910,16 @@ void wxGridCellChoiceEditor::Create(wxWindow* parent,
wxGridCellEditor::Create(parent, id, evtHandler);
}
void wxGridCellChoiceEditor::PaintBackground(const wxRect& WXUNUSED(rectCell),
wxGridCellAttr * WXUNUSED(attr))
void wxGridCellChoiceEditor::PaintBackground(const wxRect& rectCell,
wxGridCellAttr * attr)
{
// as we fill the entire client area, don't do anything here to minimize
// 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)
@ -2586,10 +2603,10 @@ void wxGridWindow::OnPaint( wxPaintEvent &WXUNUSED(event) )
wxRegion reg = GetUpdateRegion();
m_owner->CalcCellsExposed( reg );
m_owner->DrawGridCellArea( dc );
m_owner->DrawGridSpace( dc );
#if WXGRID_DRAW_LINES
m_owner->DrawAllGridLines( dc, reg );
#endif
m_owner->DrawGridSpace( dc );
m_owner->DrawHighlight( dc );
}
@ -3803,7 +3820,10 @@ void wxGrid::ProcessGridCellMouseEvent( wxMouseEvent& event )
// Hide the edit control, so it
// won't interfer with drag-shrinking.
if ( IsCellEditControlEnabled() )
{
HideCellEditControl();
SaveEditControlValue();
}
// Have we captured the mouse yet?
if (! m_winCapture)
@ -3873,13 +3893,6 @@ 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 )
// {
// 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
@ -3896,7 +3909,6 @@ void wxGrid::ProcessGridCellMouseEvent( wxMouseEvent& event )
//
if ( event.LeftDown() && coords != wxGridNoCellCoords )
{
DisableCellEditControl();
if ( event.ShiftDown() )
{
SelectBlock( m_currentCellCoords, coords );
@ -3909,6 +3921,7 @@ void wxGrid::ProcessGridCellMouseEvent( wxMouseEvent& event )
coords.GetCol(),
event ) )
{
DisableCellEditControl();
MakeCellVisible( coords );
// 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 )
{
DisableCellEditControl();
if ( XToEdgeOfCol(x) < 0 && YToEdgeOfRow(y) < 0 )
{
SendEvent( wxEVT_GRID_CELL_LEFT_DCLICK,
@ -4091,6 +4105,7 @@ void wxGrid::DoEndDragResizeRow()
dc.SetLogicalFunction( wxINVERT );
dc.DrawLine( left, m_dragLastPos, left+cw, m_dragLastPos );
HideCellEditControl();
SaveEditControlValue();
int rowTop = GetRowTop(m_dragRowOrCol);
SetRowSize( m_dragRowOrCol,
@ -4129,6 +4144,7 @@ void wxGrid::DoEndDragResizeCol()
dc.SetLogicalFunction( wxINVERT );
dc.DrawLine( m_dragLastPos, top, m_dragLastPos, top+ch );
HideCellEditControl();
SaveEditControlValue();
int colLeft = GetColLeft(m_dragRowOrCol);
SetColSize( m_dragRowOrCol,
@ -4826,11 +4842,11 @@ void wxGrid::DrawGridSpace( wxDC& dc )
dc.SetPen( *wxTRANSPARENT_PEN );
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 );
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) );
}
}