X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/902725eefee5a402d21d13b2630583ab28ae3931..2296fe5018d42d4e0bf9df07c37d31f60d972b32:/src/generic/grid.cpp diff --git a/src/generic/grid.cpp b/src/generic/grid.cpp index 9768eca985..3e558a168a 100644 --- a/src/generic/grid.cpp +++ b/src/generic/grid.cpp @@ -242,7 +242,8 @@ class wxGridCellEditorEvtHandler : public wxEvtHandler public: wxGridCellEditorEvtHandler(wxGrid* grid, wxGridCellEditor* editor) : m_grid(grid), - m_editor(editor) + m_editor(editor), + m_inSetFocus(false) { } @@ -250,10 +251,16 @@ public: void OnKeyDown(wxKeyEvent& event); void OnChar(wxKeyEvent& event); + void SetInSetFocus(bool inSetFocus) { m_inSetFocus = inSetFocus; } + private: wxGrid* m_grid; wxGridCellEditor* m_editor; + // Work around the fact that a focus kill event can be sent to + // a combobox within a set focus event. + bool m_inSetFocus; + DECLARE_EVENT_TABLE() DECLARE_DYNAMIC_CLASS(wxGridCellEditorEvtHandler) DECLARE_NO_COPY_CLASS(wxGridCellEditorEvtHandler) @@ -1460,6 +1467,14 @@ void wxGridCellChoiceEditor::BeginEdit(int row, int col, wxGrid* grid) wxASSERT_MSG(m_control, wxT("The wxGridCellEditor must be Created first!")); + wxGridCellEditorEvtHandler* evtHandler = NULL; + if (m_control) + evtHandler = wxDynamicCast(m_control->GetEventHandler(), wxGridCellEditorEvtHandler); + + // Don't immediately end if we get a kill focus event within BeginEdit + if (evtHandler) + evtHandler->SetInSetFocus(true); + m_startValue = grid->GetTable()->GetValue(row, col); if (m_allowOthers) @@ -1474,6 +1489,9 @@ void wxGridCellChoiceEditor::BeginEdit(int row, int col, wxGrid* grid) } Combo()->SetInsertionPointEnd(); Combo()->SetFocus(); + + if (evtHandler) + evtHandler->SetInSetFocus(false); } bool wxGridCellChoiceEditor::EndEdit(int row, int col, @@ -1525,6 +1543,10 @@ wxString wxGridCellChoiceEditor::GetValue() const void wxGridCellEditorEvtHandler::OnKillFocus(wxFocusEvent& event) { + // Don't disable the cell if we're just starting to edit it + if (m_inSetFocus) + return; + // accept changes m_grid->DisableCellEditControl(); @@ -1950,21 +1972,19 @@ void wxGridCellFloatRenderer::SetParameters(const wxString& params) { wxLogDebug(_T("Invalid wxGridCellFloatRenderer width parameter string '%s ignored"), params.c_str()); } - } - tmp = params.AfterFirst(_T(',')); - if ( !tmp.empty() ) - { - long precision; + tmp = params.AfterFirst(_T(',')); + if ( !tmp.empty() ) + { + long precision; if ( tmp.ToLong(&precision) ) - { + { SetPrecision((int)precision); - } - else - { + } + else + { wxLogDebug(_T("Invalid wxGridCellFloatRenderer precision parameter string '%s ignored"), params.c_str()); - } - + } } } } @@ -3672,7 +3692,8 @@ void wxGridCornerLabelWindow::OnPaint( wxPaintEvent& WXUNUSED(event) ) int client_width = 0; GetClientSize( &client_width, &client_height ); -#if __WXGTK__ + // VZ: any reason for this ifdef? (FIXME) +#ifdef __WXGTK__ wxRect rect; rect.SetX( 1 ); rect.SetY( 1 ); @@ -3680,7 +3701,7 @@ void wxGridCornerLabelWindow::OnPaint( wxPaintEvent& WXUNUSED(event) ) rect.SetHeight( client_height - 2 ); wxRendererNative::Get().DrawHeaderButton( this, dc, rect, 0 ); -#else +#else // !__WXGTK__ dc.SetPen( wxPen(wxSystemSettings::GetColour(wxSYS_COLOUR_3DDKSHADOW),1, wxSOLID) ); dc.DrawLine( client_width-1, client_height-1, client_width-1, 0 ); dc.DrawLine( client_width-1, client_height-1, 0, client_height-1 ); @@ -3690,7 +3711,7 @@ void wxGridCornerLabelWindow::OnPaint( wxPaintEvent& WXUNUSED(event) ) dc.SetPen( *wxWHITE_PEN ); dc.DrawLine( 1, 1, client_width-1, 1 ); dc.DrawLine( 1, 1, 1, client_height-1 ); -#endif +#endif // __WXGTK__/!__WXGTK__ } @@ -7841,7 +7862,9 @@ void wxGrid::HideCellEditControl() editor->Show( false ); editor->DecRef(); attr->DecRef(); + m_gridWin->SetFocus(); + // refresh whole row to the right wxRect rect( CellToRect(row, col) ); CalcScrolledPosition(rect.x, rect.y, &rect.x, &rect.y );