From 0c6099b79e8f38a6dd53f96e6d55cb5a81f568f7 Mon Sep 17 00:00:00 2001 From: Ryan Norton Date: Sat, 6 Nov 2004 07:09:35 +0000 Subject: [PATCH] Revert files to previous version that were affected by wxIsXXX((wxChar)X) change. Note - passing a negative value to those c lib functions is undefined, and could return true on platforms using a lookup table, for example (might crash also?), which is what will happen when casting to char to ansii mode and a char is above 127 git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@30319 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- samples/treectrl/treetest.cpp | 227 +++++++++++++++++----------------- src/common/menucmn.cpp | 4 +- src/common/valtext.cpp | 6 +- src/generic/grid.cpp | 25 ++-- 4 files changed, 131 insertions(+), 131 deletions(-) diff --git a/samples/treectrl/treetest.cpp b/samples/treectrl/treetest.cpp index 8d4c5f7085..d140808b4d 100644 --- a/samples/treectrl/treetest.cpp +++ b/samples/treectrl/treetest.cpp @@ -411,7 +411,7 @@ void MyFrame::OnRename(wxCommandEvent& WXUNUSED(event)) static wxString s_text; s_text = wxGetTextFromUser(wxT("New name: "), wxT("Tree sample question"), s_text, this); - if ( !s_text.empty() ) + if ( !s_text.IsEmpty() ) { m_treeCtrl->SetItemText(item, s_text); } @@ -906,120 +906,121 @@ TREE_EVENT_HANDLER(OnSelChanging) void LogKeyEvent(const wxChar *name, const wxKeyEvent& event) { wxString key; - int keycode = event.GetKeyCode(); - - switch ( keycode ) + long keycode = event.GetKeyCode(); { - case WXK_BACK: key = wxT("BACK"); break; - case WXK_TAB: key = wxT("TAB"); break; - case WXK_RETURN: key = wxT("RETURN"); break; - case WXK_ESCAPE: key = wxT("ESCAPE"); break; - case WXK_SPACE: key = wxT("SPACE"); break; - case WXK_DELETE: key = wxT("DELETE"); break; - case WXK_START: key = wxT("START"); break; - case WXK_LBUTTON: key = wxT("LBUTTON"); break; - case WXK_RBUTTON: key = wxT("RBUTTON"); break; - case WXK_CANCEL: key = wxT("CANCEL"); break; - case WXK_MBUTTON: key = wxT("MBUTTON"); break; - case WXK_CLEAR: key = wxT("CLEAR"); break; - case WXK_SHIFT: key = wxT("SHIFT"); break; - case WXK_ALT: key = wxT("ALT"); break; - case WXK_CONTROL: key = wxT("CONTROL"); break; - case WXK_MENU: key = wxT("MENU"); break; - case WXK_PAUSE: key = wxT("PAUSE"); break; - case WXK_CAPITAL: key = wxT("CAPITAL"); break; - case WXK_PRIOR: key = wxT("PRIOR"); break; - case WXK_NEXT: key = wxT("NEXT"); break; - case WXK_END: key = wxT("END"); break; - case WXK_HOME: key = wxT("HOME"); break; - case WXK_LEFT: key = wxT("LEFT"); break; - case WXK_UP: key = wxT("UP"); break; - case WXK_RIGHT: key = wxT("RIGHT"); break; - case WXK_DOWN: key = wxT("DOWN"); break; - case WXK_SELECT: key = wxT("SELECT"); break; - case WXK_PRINT: key = wxT("PRINT"); break; - case WXK_EXECUTE: key = wxT("EXECUTE"); break; - case WXK_SNAPSHOT: key = wxT("SNAPSHOT"); break; - case WXK_INSERT: key = wxT("INSERT"); break; - case WXK_HELP: key = wxT("HELP"); break; - case WXK_NUMPAD0: key = wxT("NUMPAD0"); break; - case WXK_NUMPAD1: key = wxT("NUMPAD1"); break; - case WXK_NUMPAD2: key = wxT("NUMPAD2"); break; - case WXK_NUMPAD3: key = wxT("NUMPAD3"); break; - case WXK_NUMPAD4: key = wxT("NUMPAD4"); break; - case WXK_NUMPAD5: key = wxT("NUMPAD5"); break; - case WXK_NUMPAD6: key = wxT("NUMPAD6"); break; - case WXK_NUMPAD7: key = wxT("NUMPAD7"); break; - case WXK_NUMPAD8: key = wxT("NUMPAD8"); break; - case WXK_NUMPAD9: key = wxT("NUMPAD9"); break; - case WXK_MULTIPLY: key = wxT("MULTIPLY"); break; - case WXK_ADD: key = wxT("ADD"); break; - case WXK_SEPARATOR: key = wxT("SEPARATOR"); break; - case WXK_SUBTRACT: key = wxT("SUBTRACT"); break; - case WXK_DECIMAL: key = wxT("DECIMAL"); break; - case WXK_DIVIDE: key = wxT("DIVIDE"); break; - case WXK_F1: key = wxT("F1"); break; - case WXK_F2: key = wxT("F2"); break; - case WXK_F3: key = wxT("F3"); break; - case WXK_F4: key = wxT("F4"); break; - case WXK_F5: key = wxT("F5"); break; - case WXK_F6: key = wxT("F6"); break; - case WXK_F7: key = wxT("F7"); break; - case WXK_F8: key = wxT("F8"); break; - case WXK_F9: key = wxT("F9"); break; - case WXK_F10: key = wxT("F10"); break; - case WXK_F11: key = wxT("F11"); break; - case WXK_F12: key = wxT("F12"); break; - case WXK_F13: key = wxT("F13"); break; - case WXK_F14: key = wxT("F14"); break; - case WXK_F15: key = wxT("F15"); break; - case WXK_F16: key = wxT("F16"); break; - case WXK_F17: key = wxT("F17"); break; - case WXK_F18: key = wxT("F18"); break; - case WXK_F19: key = wxT("F19"); break; - case WXK_F20: key = wxT("F20"); break; - case WXK_F21: key = wxT("F21"); break; - case WXK_F22: key = wxT("F22"); break; - case WXK_F23: key = wxT("F23"); break; - case WXK_F24: key = wxT("F24"); break; - case WXK_NUMLOCK: key = wxT("NUMLOCK"); break; - case WXK_SCROLL: key = wxT("SCROLL"); break; - case WXK_PAGEUP: key = wxT("PAGEUP"); break; - case WXK_PAGEDOWN: key = wxT("PAGEDOWN"); break; - case WXK_NUMPAD_SPACE: key = wxT("NUMPAD_SPACE"); break; - case WXK_NUMPAD_TAB: key = wxT("NUMPAD_TAB"); break; - case WXK_NUMPAD_ENTER: key = wxT("NUMPAD_ENTER"); break; - case WXK_NUMPAD_F1: key = wxT("NUMPAD_F1"); break; - case WXK_NUMPAD_F2: key = wxT("NUMPAD_F2"); break; - case WXK_NUMPAD_F3: key = wxT("NUMPAD_F3"); break; - case WXK_NUMPAD_F4: key = wxT("NUMPAD_F4"); break; - case WXK_NUMPAD_HOME: key = wxT("NUMPAD_HOME"); break; - case WXK_NUMPAD_LEFT: key = wxT("NUMPAD_LEFT"); break; - case WXK_NUMPAD_UP: key = wxT("NUMPAD_UP"); break; - case WXK_NUMPAD_RIGHT: key = wxT("NUMPAD_RIGHT"); break; - case WXK_NUMPAD_DOWN: key = wxT("NUMPAD_DOWN"); break; - case WXK_NUMPAD_PRIOR: key = wxT("NUMPAD_PRIOR"); break; - case WXK_NUMPAD_PAGEUP: key = wxT("NUMPAD_PAGEUP"); break; - case WXK_NUMPAD_PAGEDOWN: key = wxT("NUMPAD_PAGEDOWN"); break; - case WXK_NUMPAD_END: key = wxT("NUMPAD_END"); break; - case WXK_NUMPAD_BEGIN: key = wxT("NUMPAD_BEGIN"); break; - case WXK_NUMPAD_INSERT: key = wxT("NUMPAD_INSERT"); break; - case WXK_NUMPAD_DELETE: key = wxT("NUMPAD_DELETE"); break; - case WXK_NUMPAD_EQUAL: key = wxT("NUMPAD_EQUAL"); break; - case WXK_NUMPAD_MULTIPLY: key = wxT("NUMPAD_MULTIPLY"); break; - case WXK_NUMPAD_ADD: key = wxT("NUMPAD_ADD"); break; - case WXK_NUMPAD_SEPARATOR: key = wxT("NUMPAD_SEPARATOR"); break; - case WXK_NUMPAD_SUBTRACT: key = wxT("NUMPAD_SUBTRACT"); break; - case WXK_NUMPAD_DECIMAL: key = wxT("NUMPAD_DECIMAL"); break; - - default: + switch ( keycode ) { - if ( wxIsprint((wxChar)keycode) ) - key.Printf(wxT("'%c'"), (char)keycode); - else if ( keycode > 0 && keycode < 27 ) - key.Printf(_("Ctrl-%c"), wxT('A') + keycode - 1); - else - key.Printf(wxT("unknown (%d)"), keycode); + case WXK_BACK: key = wxT("BACK"); break; + case WXK_TAB: key = wxT("TAB"); break; + case WXK_RETURN: key = wxT("RETURN"); break; + case WXK_ESCAPE: key = wxT("ESCAPE"); break; + case WXK_SPACE: key = wxT("SPACE"); break; + case WXK_DELETE: key = wxT("DELETE"); break; + case WXK_START: key = wxT("START"); break; + case WXK_LBUTTON: key = wxT("LBUTTON"); break; + case WXK_RBUTTON: key = wxT("RBUTTON"); break; + case WXK_CANCEL: key = wxT("CANCEL"); break; + case WXK_MBUTTON: key = wxT("MBUTTON"); break; + case WXK_CLEAR: key = wxT("CLEAR"); break; + case WXK_SHIFT: key = wxT("SHIFT"); break; + case WXK_ALT: key = wxT("ALT"); break; + case WXK_CONTROL: key = wxT("CONTROL"); break; + case WXK_MENU: key = wxT("MENU"); break; + case WXK_PAUSE: key = wxT("PAUSE"); break; + case WXK_CAPITAL: key = wxT("CAPITAL"); break; + case WXK_PRIOR: key = wxT("PRIOR"); break; + case WXK_NEXT: key = wxT("NEXT"); break; + case WXK_END: key = wxT("END"); break; + case WXK_HOME: key = wxT("HOME"); break; + case WXK_LEFT: key = wxT("LEFT"); break; + case WXK_UP: key = wxT("UP"); break; + case WXK_RIGHT: key = wxT("RIGHT"); break; + case WXK_DOWN: key = wxT("DOWN"); break; + case WXK_SELECT: key = wxT("SELECT"); break; + case WXK_PRINT: key = wxT("PRINT"); break; + case WXK_EXECUTE: key = wxT("EXECUTE"); break; + case WXK_SNAPSHOT: key = wxT("SNAPSHOT"); break; + case WXK_INSERT: key = wxT("INSERT"); break; + case WXK_HELP: key = wxT("HELP"); break; + case WXK_NUMPAD0: key = wxT("NUMPAD0"); break; + case WXK_NUMPAD1: key = wxT("NUMPAD1"); break; + case WXK_NUMPAD2: key = wxT("NUMPAD2"); break; + case WXK_NUMPAD3: key = wxT("NUMPAD3"); break; + case WXK_NUMPAD4: key = wxT("NUMPAD4"); break; + case WXK_NUMPAD5: key = wxT("NUMPAD5"); break; + case WXK_NUMPAD6: key = wxT("NUMPAD6"); break; + case WXK_NUMPAD7: key = wxT("NUMPAD7"); break; + case WXK_NUMPAD8: key = wxT("NUMPAD8"); break; + case WXK_NUMPAD9: key = wxT("NUMPAD9"); break; + case WXK_MULTIPLY: key = wxT("MULTIPLY"); break; + case WXK_ADD: key = wxT("ADD"); break; + case WXK_SEPARATOR: key = wxT("SEPARATOR"); break; + case WXK_SUBTRACT: key = wxT("SUBTRACT"); break; + case WXK_DECIMAL: key = wxT("DECIMAL"); break; + case WXK_DIVIDE: key = wxT("DIVIDE"); break; + case WXK_F1: key = wxT("F1"); break; + case WXK_F2: key = wxT("F2"); break; + case WXK_F3: key = wxT("F3"); break; + case WXK_F4: key = wxT("F4"); break; + case WXK_F5: key = wxT("F5"); break; + case WXK_F6: key = wxT("F6"); break; + case WXK_F7: key = wxT("F7"); break; + case WXK_F8: key = wxT("F8"); break; + case WXK_F9: key = wxT("F9"); break; + case WXK_F10: key = wxT("F10"); break; + case WXK_F11: key = wxT("F11"); break; + case WXK_F12: key = wxT("F12"); break; + case WXK_F13: key = wxT("F13"); break; + case WXK_F14: key = wxT("F14"); break; + case WXK_F15: key = wxT("F15"); break; + case WXK_F16: key = wxT("F16"); break; + case WXK_F17: key = wxT("F17"); break; + case WXK_F18: key = wxT("F18"); break; + case WXK_F19: key = wxT("F19"); break; + case WXK_F20: key = wxT("F20"); break; + case WXK_F21: key = wxT("F21"); break; + case WXK_F22: key = wxT("F22"); break; + case WXK_F23: key = wxT("F23"); break; + case WXK_F24: key = wxT("F24"); break; + case WXK_NUMLOCK: key = wxT("NUMLOCK"); break; + case WXK_SCROLL: key = wxT("SCROLL"); break; + case WXK_PAGEUP: key = wxT("PAGEUP"); break; + case WXK_PAGEDOWN: key = wxT("PAGEDOWN"); break; + case WXK_NUMPAD_SPACE: key = wxT("NUMPAD_SPACE"); break; + case WXK_NUMPAD_TAB: key = wxT("NUMPAD_TAB"); break; + case WXK_NUMPAD_ENTER: key = wxT("NUMPAD_ENTER"); break; + case WXK_NUMPAD_F1: key = wxT("NUMPAD_F1"); break; + case WXK_NUMPAD_F2: key = wxT("NUMPAD_F2"); break; + case WXK_NUMPAD_F3: key = wxT("NUMPAD_F3"); break; + case WXK_NUMPAD_F4: key = wxT("NUMPAD_F4"); break; + case WXK_NUMPAD_HOME: key = wxT("NUMPAD_HOME"); break; + case WXK_NUMPAD_LEFT: key = wxT("NUMPAD_LEFT"); break; + case WXK_NUMPAD_UP: key = wxT("NUMPAD_UP"); break; + case WXK_NUMPAD_RIGHT: key = wxT("NUMPAD_RIGHT"); break; + case WXK_NUMPAD_DOWN: key = wxT("NUMPAD_DOWN"); break; + case WXK_NUMPAD_PRIOR: key = wxT("NUMPAD_PRIOR"); break; + case WXK_NUMPAD_PAGEUP: key = wxT("NUMPAD_PAGEUP"); break; + case WXK_NUMPAD_PAGEDOWN: key = wxT("NUMPAD_PAGEDOWN"); break; + case WXK_NUMPAD_END: key = wxT("NUMPAD_END"); break; + case WXK_NUMPAD_BEGIN: key = wxT("NUMPAD_BEGIN"); break; + case WXK_NUMPAD_INSERT: key = wxT("NUMPAD_INSERT"); break; + case WXK_NUMPAD_DELETE: key = wxT("NUMPAD_DELETE"); break; + case WXK_NUMPAD_EQUAL: key = wxT("NUMPAD_EQUAL"); break; + case WXK_NUMPAD_MULTIPLY: key = wxT("NUMPAD_MULTIPLY"); break; + case WXK_NUMPAD_ADD: key = wxT("NUMPAD_ADD"); break; + case WXK_NUMPAD_SEPARATOR: key = wxT("NUMPAD_SEPARATOR"); break; + case WXK_NUMPAD_SUBTRACT: key = wxT("NUMPAD_SUBTRACT"); break; + case WXK_NUMPAD_DECIMAL: key = wxT("NUMPAD_DECIMAL"); break; + + default: + { + if ( wxIsprint((int)keycode) ) + key.Printf(wxT("'%c'"), (char)keycode); + else if ( keycode > 0 && keycode < 27 ) + key.Printf(_("Ctrl-%c"), wxT('A') + keycode - 1); + else + key.Printf(wxT("unknown (%ld)"), keycode); + } } } diff --git a/src/common/menucmn.cpp b/src/common/menucmn.cpp index befcfd613d..0f49207fd0 100644 --- a/src/common/menucmn.cpp +++ b/src/common/menucmn.cpp @@ -141,7 +141,7 @@ wxAcceleratorEntry *wxGetAccelFromString(const wxString& label) } } - if ( current.empty() ) { + if ( current.IsEmpty() ) { wxLogDebug(wxT("No accel key found, accel string ignored.")); } else { @@ -262,7 +262,7 @@ void wxMenuItemBase::SetAccel(wxAcceleratorEntry *accel) // we should process them here default: - if ( wxIsalnum((wxChar)code) ) + if ( wxIsalnum(code) ) { text << (wxChar)code; diff --git a/src/common/valtext.cpp b/src/common/valtext.cpp index 7534652aba..bd3d8a0c75 100644 --- a/src/common/valtext.cpp +++ b/src/common/valtext.cpp @@ -243,9 +243,9 @@ void wxTextValidator::OnChar(wxKeyEvent& event) ((m_validatorStyle & wxFILTER_INCLUDE_CHAR_LIST) && !IsInCharIncludeList(wxString((wxChar) keyCode, 1))) || ((m_validatorStyle & wxFILTER_EXCLUDE_CHAR_LIST) && !IsNotInCharExcludeList(wxString((wxChar) keyCode, 1))) || ((m_validatorStyle & wxFILTER_ASCII) && !isascii(keyCode)) || - ((m_validatorStyle & wxFILTER_ALPHA) && !wxIsalpha((wxChar)keyCode)) || - ((m_validatorStyle & wxFILTER_ALPHANUMERIC) && !wxIsalnum((wxChar)keyCode)) || - ((m_validatorStyle & wxFILTER_NUMERIC) && !wxIsdigit((wxChar)keyCode) + ((m_validatorStyle & wxFILTER_ALPHA) && !wxIsalpha(keyCode)) || + ((m_validatorStyle & wxFILTER_ALPHANUMERIC) && !wxIsalnum(keyCode)) || + ((m_validatorStyle & wxFILTER_NUMERIC) && !wxIsdigit(keyCode) && keyCode != '.' && keyCode != ',' && keyCode != '-') ) ) diff --git a/src/generic/grid.cpp b/src/generic/grid.cpp index 6c6ba9d2c9..9d0e0a9f69 100644 --- a/src/generic/grid.cpp +++ b/src/generic/grid.cpp @@ -502,7 +502,7 @@ void wxGridCellEditor::Show(bool show, wxGridCellAttr *attr) m_colBgOld = m_control->GetBackgroundColour(); m_control->SetBackgroundColour(attr->GetBackgroundColour()); - // Workaround for GTK+1 font setting problem on some platforms + // Workaround for GTK+1 font setting problem on some platforms #if !defined(__WXGTK__) || defined(__WXGTK20__) m_fontOld = m_control->GetFont(); m_control->SetFont(attr->GetFont()); @@ -525,8 +525,7 @@ void wxGridCellEditor::Show(bool show, wxGridCellAttr *attr) m_control->SetBackgroundColour(m_colBgOld); m_colBgOld = wxNullColour; } - - // Workaround for GTK+1 font setting problem on some platforms + // Workaround for GTK+1 font setting problem on some platforms #if !defined(__WXGTK__) || defined(__WXGTK20__) if ( m_fontOld.Ok() ) { @@ -729,7 +728,7 @@ bool wxGridCellTextEditor::IsAcceptedKey(wxKeyEvent& event) default: // accept 8 bit chars too if isprint() agrees - if ( (keycode < 255) && (wxIsprint((wxChar)keycode)) ) + if ( (keycode < 255) && (wxIsprint(keycode)) ) return true; } } @@ -836,7 +835,7 @@ void wxGridCellNumberEditor::BeginEdit(int row, int col, wxGrid* grid) { m_valueOld = 0; wxString sValue = table->GetValue(row, col); - if (! sValue.ToLong(&m_valueOld) && ! sValue.empty()) + if (! sValue.ToLong(&m_valueOld) && ! sValue.IsEmpty()) { wxFAIL_MSG( _T("this cell doesn't have numeric value") ); return; @@ -871,7 +870,7 @@ bool wxGridCellNumberEditor::EndEdit(int row, int col, else { text = Text()->GetValue(); - changed = (text.empty() || text.ToLong(&value)) && (value != m_valueOld); + changed = (text.IsEmpty() || text.ToLong(&value)) && (value != m_valueOld); } if ( changed ) @@ -923,7 +922,7 @@ bool wxGridCellNumberEditor::IsAcceptedKey(wxKeyEvent& event) return true; default: - if ( (keycode < 128) && wxIsdigit((wxChar)keycode) ) + if ( (keycode < 128) && wxIsdigit(keycode) ) return true; } } @@ -936,7 +935,7 @@ void wxGridCellNumberEditor::StartingKey(wxKeyEvent& event) if ( !HasRange() ) { int keycode = event.GetKeyCode(); - if ( wxIsdigit((wxChar)keycode) || keycode == '+' || keycode == '-' + if ( wxIsdigit(keycode) || keycode == '+' || keycode == '-' || keycode == WXK_NUMPAD0 || keycode == WXK_NUMPAD1 || keycode == WXK_NUMPAD2 @@ -1040,7 +1039,7 @@ void wxGridCellFloatEditor::BeginEdit(int row, int col, wxGrid* grid) { m_valueOld = 0.0; wxString sValue = table->GetValue(row, col); - if (! sValue.ToDouble(&m_valueOld) && ! sValue.empty()) + if (! sValue.ToDouble(&m_valueOld) && ! sValue.IsEmpty()) { wxFAIL_MSG( _T("this cell doesn't have float value") ); return; @@ -1056,7 +1055,7 @@ bool wxGridCellFloatEditor::EndEdit(int row, int col, double value = 0.0; wxString text(Text()->GetValue()); - if ( (text.empty() || text.ToDouble(&value)) && (value != m_valueOld) ) + if ( (text.IsEmpty() || text.ToDouble(&value)) && (value != m_valueOld) ) { if (grid->GetTable()->CanSetValueAs(row, col, wxGRID_VALUE_FLOAT)) grid->GetTable()->SetValueAsDouble(row, col, value); @@ -1082,7 +1081,7 @@ void wxGridCellFloatEditor::StartingKey(wxKeyEvent& event) wxString strbuf(tmpbuf, *wxConvCurrent); bool is_decimal_point = ( strbuf == wxLocale::GetInfo(wxLOCALE_DECIMAL_POINT, wxLOCALE_CAT_NUMBER) ); - if ( wxIsdigit((wxChar)keycode) || keycode == '+' || keycode == '-' + if ( wxIsdigit(keycode) || keycode == '+' || keycode == '-' || is_decimal_point || keycode == WXK_NUMPAD0 || keycode == WXK_NUMPAD1 @@ -1189,11 +1188,11 @@ bool wxGridCellFloatEditor::IsAcceptedKey(wxKeyEvent& event) tmpbuf[0] = (char) keycode; tmpbuf[1] = '\0'; wxString strbuf(tmpbuf, *wxConvCurrent); - bool is_decimal_point = + bool is_decimal_point = ( strbuf == wxLocale::GetInfo(wxLOCALE_DECIMAL_POINT, wxLOCALE_CAT_NUMBER) ); if ( (keycode < 128) && - (wxIsdigit((wxChar)keycode) || tolower(keycode) == 'e' || + (wxIsdigit(keycode) || tolower(keycode) == 'e' || is_decimal_point || keycode == '+' || keycode == '-') ) return true; } -- 2.45.2