X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/6a1e8a634a09fa3ff09fe5190429f47e37b1930e..d2e66707deb10dea6f92e3e4092f8a43ef942a5d:/src/generic/grideditors.cpp diff --git a/src/generic/grideditors.cpp b/src/generic/grideditors.cpp index ef818831bb..ac90aa3310 100644 --- a/src/generic/grideditors.cpp +++ b/src/generic/grideditors.cpp @@ -28,12 +28,12 @@ #include "wx/textctrl.h" #include "wx/checkbox.h" #include "wx/combobox.h" - #include "wx/valtext.h" #include "wx/intl.h" #include "wx/math.h" #include "wx/listbox.h" #endif +#include "wx/valnum.h" #include "wx/textfile.h" #include "wx/spinctrl.h" #include "wx/tokenzr.h" @@ -300,13 +300,13 @@ void wxGridCellEditor::Show(bool show, wxGridCellAttr *attr) else { // restore the standard colours fonts - if ( m_colFgOld.Ok() ) + if ( m_colFgOld.IsOk() ) { m_control->SetForegroundColour(m_colFgOld); m_colFgOld = wxNullColour; } - if ( m_colBgOld.Ok() ) + if ( m_colBgOld.IsOk() ) { m_control->SetBackgroundColour(m_colBgOld); m_colBgOld = wxNullColour; @@ -314,7 +314,7 @@ void wxGridCellEditor::Show(bool show, wxGridCellAttr *attr) // Workaround for GTK+1 font setting problem on some platforms #if !defined(__WXGTK__) || defined(__WXGTK20__) - if ( m_fontOld.Ok() ) + if ( m_fontOld.IsOk() ) { m_control->SetFont(m_fontOld); m_fontOld = wxNullFont; @@ -355,7 +355,7 @@ bool wxGridCellEditor::IsAcceptedKey(wxKeyEvent& event) return false; #if wxUSE_UNICODE - if ( event.GetUnicodeKey() == WXK_NONE ) + if ( static_cast(event.GetUnicodeKey()) == WXK_NONE ) return false; #else if ( event.GetKeyCode() > WXK_START ) @@ -547,8 +547,7 @@ void wxGridCellTextEditor::StartingKey(wxKeyEvent& event) // a valid character, so not a whole lot of testing needs to be done. wxTextCtrl* tc = Text(); - wxChar ch; - long pos; + int ch; bool isPrintable; @@ -559,29 +558,28 @@ void wxGridCellTextEditor::StartingKey(wxKeyEvent& event) else #endif // wxUSE_UNICODE { - ch = (wxChar)event.GetKeyCode(); + ch = event.GetKeyCode(); isPrintable = ch >= WXK_SPACE && ch < WXK_START; } switch (ch) { case WXK_DELETE: - // delete the character at the cursor - pos = tc->GetInsertionPoint(); - if (pos < tc->GetLastPosition()) - tc->Remove(pos, pos + 1); + // Delete the initial character when starting to edit with DELETE. + tc->Remove(0, 1); break; case WXK_BACK: - // delete the character before the cursor - pos = tc->GetInsertionPoint(); - if (pos > 0) + // Delete the last character when starting to edit with BACKSPACE. + { + const long pos = tc->GetLastPosition(); tc->Remove(pos - 1, pos); + } break; default: if ( isPrintable ) - tc->WriteText(ch); + tc->WriteText(static_cast(ch)); break; } } @@ -662,7 +660,7 @@ void wxGridCellNumberEditor::Create(wxWindow* parent, wxGridCellTextEditor::Create(parent, id, evtHandler); #if wxUSE_VALIDATORS - Text()->SetValidator(wxTextValidator(wxFILTER_NUMERIC)); + Text()->SetValidator(wxIntegerValidator()); #endif } } @@ -877,7 +875,7 @@ void wxGridCellFloatEditor::Create(wxWindow* parent, wxGridCellTextEditor::Create(parent, id, evtHandler); #if wxUSE_VALIDATORS - Text()->SetValidator(wxTextValidator(wxFILTER_NUMERIC)); + Text()->SetValidator(wxFloatingPointValidator(m_precision)); #endif } @@ -1508,7 +1506,6 @@ void wxGridCellEnumEditor::BeginEdit(int row, int col, wxGrid* grid) } Combo()->SetSelection(m_index); - Combo()->SetInsertionPointEnd(); Combo()->SetFocus(); }