mirror of
https://github.com/cookiengineer/audacity
synced 2025-11-23 17:30:17 +01:00
From: martin@steghoefer.eu [patches 0017 and 0018] Fix compilation problem with wxWidgets 3.0:
0017: Encapsulation of reference type returned by wxString::operator[] 0018: Interface change for classes deriving from wxGridTableBase 0017 ---- The NumericTextCtrl relies on the fact that the value returned by wxString::operator[] is a "wxChar&". However, in wxWidgets 3.0 it is a wxUniCharRef (encapsulation of a reference to characters, to improve unicode handling). wxString::reference provides the correct type in both wx2.8 and wx3.0 and can be used as writable reference in both cases. However, for the case of an update of the reference itself (instead of the value), there is no common syntax. In this case the character position within the string has to be used as reference. 0018 ---- With wx3.0, different methods have to be implemented (EndEdit with new signature and ApplyEdit) than with wx2.8 (only EndEdit with old signature). Now both versions are implemented in parallel in the classes TimeEditor and ChoiceEditor (one version essentially being a wrapper of the other one). Note: Superseding the previous solution of the issue (committed in r13403) by one that avoids code duplication. This should avoid problems with missed changes in code that isn't used with the wxWidgets version that the developer tests with (like just happened in r13557).
This commit is contained in:
@@ -1594,15 +1594,15 @@ void NumericTextCtrl::OnKeyDown(wxKeyEvent &event)
|
||||
// Convert numeric keypad entries.
|
||||
if ((keyCode >= WXK_NUMPAD0) && (keyCode <= WXK_NUMPAD9)) keyCode -= WXK_NUMPAD0 - '0';
|
||||
|
||||
wxChar *theDigit = &mValueString[mDigits[mFocusedDigit].pos];
|
||||
if (keyCode >= '0' && keyCode <= '9') {
|
||||
if (*theDigit == wxChar('-')) {
|
||||
int digitPosition = mDigits[mFocusedDigit].pos;
|
||||
if (mValueString[digitPosition] == wxChar('-')) {
|
||||
mValue = 0;
|
||||
ValueToControls();
|
||||
// Beware relocation of the string
|
||||
theDigit = &mValueString[mDigits[mFocusedDigit].pos];
|
||||
digitPosition = mDigits[mFocusedDigit].pos;
|
||||
}
|
||||
*theDigit = wxChar(keyCode);
|
||||
mValueString[digitPosition] = wxChar(keyCode);
|
||||
ControlsToValue();
|
||||
ValueToControls();
|
||||
mFocusedDigit = (mFocusedDigit + 1) % (mDigits.GetCount());
|
||||
@@ -1614,9 +1614,9 @@ void NumericTextCtrl::OnKeyDown(wxKeyEvent &event)
|
||||
mFocusedDigit--;
|
||||
mFocusedDigit += mDigits.GetCount();
|
||||
mFocusedDigit %= mDigits.GetCount();
|
||||
theDigit = &mValueString[mDigits[mFocusedDigit].pos];
|
||||
if (*theDigit != wxChar('-'))
|
||||
*theDigit = '0';
|
||||
wxString::reference theDigit = mValueString[mDigits[mFocusedDigit].pos];
|
||||
if (theDigit != wxChar('-'))
|
||||
theDigit = '0';
|
||||
ControlsToValue();
|
||||
ValueToControls();
|
||||
Updated();
|
||||
|
||||
Reference in New Issue
Block a user