From b8d9ac9a32e1fb8d24d240195b597b69a2c8f5bd Mon Sep 17 00:00:00 2001 From: Kvaz1r Date: Sat, 7 Aug 2021 11:03:03 +0300 Subject: [PATCH] Revert MSW-specific changes for wxTextCtrl tests in wxUniv --- src/univ/textctrl.cpp | 21 +------------------- tests/controls/textctrltest.cpp | 34 ++++++++++++++++----------------- 2 files changed, 18 insertions(+), 37 deletions(-) diff --git a/src/univ/textctrl.cpp b/src/univ/textctrl.cpp index 75a3831abf..11f1613340 100644 --- a/src/univ/textctrl.cpp +++ b/src/univ/textctrl.cpp @@ -1192,13 +1192,6 @@ void wxTextCtrl::Replace(wxTextPos from, wxTextPos to, const wxString& text) // update the (cached) last position first as refresh functions use it m_posLast += text.length() - to + from; -#if defined(__WXMSW__) - // Take into account that every new line mark occupies - // two characters, not one. - if ( !HasFlag(wxTE_RICH | wxTE_RICH2) ) - m_posLast += nReplaceCount - 1; -#endif // WXMSW - // we may optimize refresh if the number of rows didn't change - but if // it did we have to refresh everything below the part we chanegd as // well as it might have moved @@ -1740,10 +1733,6 @@ wxTextPos wxTextCtrl::XYToPosition(wxTextCoord x, wxTextCoord y) const // start of the next one are different pos += GetLines()[nLine].length() + 1; -#if defined(__WXMSW__) - if( !HasFlag(wxTE_RICH | wxTE_RICH2) && nLine + 1 != nLineCount) - pos += 1; -#endif // WXMSW } // out of the line @@ -1778,21 +1767,13 @@ bool wxTextCtrl::PositionToXY(wxTextPos pos, // +1 is because the start of the next line is one // position after the end of this one wxTextPos posNew = posCur + GetLines()[nLine].length() + 1; -#if defined(__WXMSW__) - if( !HasFlag(wxTE_RICH | wxTE_RICH2) && nLine + 1 != nLineCount) - posNew += 1; -#endif // WXMSW + if ( posNew > pos ) { // we've found the line, now just calc the column if ( x ) *x = pos - posCur; -#if defined(__WXMSW__) - if ( !HasFlag(wxTE_RICH | wxTE_RICH2) && x && nLine + 1 != nLineCount && posNew - 1 == pos) - *x = pos - posCur - 1; -#endif // WXMSW - if ( y ) *y = nLine; diff --git a/tests/controls/textctrltest.cpp b/tests/controls/textctrltest.cpp index 7d13969d61..5196b6d08d 100644 --- a/tests/controls/textctrltest.cpp +++ b/tests/controls/textctrltest.cpp @@ -793,7 +793,7 @@ void TextCtrlTestCase::DoPositionToXYMultiLine(long style) delete m_text; CreateText(style|wxTE_MULTILINE|wxTE_DONTWRAP); -#if defined(__WXMSW__) +#if defined(__WXMSW__) && !defined(__WXUNIVERSAL__) const bool isRichEdit = (style & (wxTE_RICH | wxTE_RICH2)) != 0; #endif @@ -844,7 +844,7 @@ void TextCtrlTestCase::DoPositionToXYMultiLine(long style) text = wxS("123\nab\nX"); m_text->SetValue(text); -#if defined(__WXMSW__) +#if defined(__WXMSW__) && !defined(__WXUNIVERSAL__) // Take into account that every new line mark occupies // two characters, not one. const long numChars_msw_2 = 8 + 2; @@ -863,14 +863,14 @@ void TextCtrlTestCase::DoPositionToXYMultiLine(long style) { 0, 2 }, { 1, 2 } }; const long &ref_numChars_2 = -#if defined(__WXMSW__) +#if defined(__WXMSW__) && !defined(__WXUNIVERSAL__) isRichEdit ? numChars_2 : numChars_msw_2; #else numChars_2; #endif XYPos *ref_coords_2 = -#if defined(__WXMSW__) +#if defined(__WXMSW__) && !defined(__WXUNIVERSAL__) isRichEdit ? coords_2 : coords_2_msw; #else coords_2; @@ -892,7 +892,7 @@ void TextCtrlTestCase::DoPositionToXYMultiLine(long style) text = wxS("\n\n\n"); m_text->SetValue(text); -#if defined(__WXMSW__) +#if defined(__WXMSW__) && !defined(__WXUNIVERSAL__) // Take into account that every new line mark occupies // two characters, not one. const long numChars_msw_3 = 3 + 3; @@ -913,14 +913,14 @@ void TextCtrlTestCase::DoPositionToXYMultiLine(long style) { 0, 3 } }; const long &ref_numChars_3 = -#if defined(__WXMSW__) +#if defined(__WXMSW__) && !defined(__WXUNIVERSAL__) isRichEdit ? numChars_3 : numChars_msw_3; #else numChars_3; #endif XYPos *ref_coords_3 = -#if defined(__WXMSW__) +#if defined(__WXMSW__) && !defined(__WXUNIVERSAL__) isRichEdit ? coords_3 : coords_3_msw; #else coords_3; @@ -942,7 +942,7 @@ void TextCtrlTestCase::DoPositionToXYMultiLine(long style) text = wxS("123\na\n\nX\n\n"); m_text->SetValue(text); -#if defined(__WXMSW__) +#if defined(__WXMSW__) && !defined(__WXUNIVERSAL__) // Take into account that every new line mark occupies // two characters, not one. const long numChars_msw_4 = 10 + 5; @@ -967,14 +967,14 @@ void TextCtrlTestCase::DoPositionToXYMultiLine(long style) { 0, 5 } }; const long &ref_numChars_4 = -#if defined(__WXMSW__) +#if defined(__WXMSW__) && !defined(__WXUNIVERSAL__) isRichEdit ? numChars_4 : numChars_msw_4; #else numChars_4; #endif XYPos *ref_coords_4 = -#if defined(__WXMSW__) +#if defined(__WXMSW__) && !defined(__WXUNIVERSAL__) isRichEdit ? coords_4 : coords_4_msw; #else coords_4; @@ -1015,7 +1015,7 @@ void TextCtrlTestCase::DoXYToPositionMultiLine(long style) delete m_text; CreateText(style|wxTE_MULTILINE|wxTE_DONTWRAP); -#if defined(__WXMSW__) +#if defined(__WXMSW__) && !defined(__WXUNIVERSAL__) const bool isRichEdit = (style & (wxTE_RICH | wxTE_RICH2)) != 0; #endif @@ -1059,7 +1059,7 @@ void TextCtrlTestCase::DoXYToPositionMultiLine(long style) const long maxLineLength_2 = 4; const long numLines_2 = 3; CPPUNIT_ASSERT_EQUAL( numLines_2, m_text->GetNumberOfLines() ); -#if defined(__WXMSW__) +#if defined(__WXMSW__) && !defined(__WXUNIVERSAL__) // Note: New lines are occupied by two characters. long pos_2_msw[numLines_2 + 1][maxLineLength_2 + 1] = { { 0, 1, 2, 3, -1 }, // New line occupies positions 3, 4 @@ -1074,7 +1074,7 @@ void TextCtrlTestCase::DoXYToPositionMultiLine(long style) { -1, -1, -1, -1, -1 } }; long (&ref_pos_2)[numLines_2 + 1][maxLineLength_2 + 1] = -#if defined(__WXMSW__) +#if defined(__WXMSW__) && !defined(__WXUNIVERSAL__) isRichEdit ? pos_2 : pos_2_msw; #else pos_2; @@ -1094,7 +1094,7 @@ void TextCtrlTestCase::DoXYToPositionMultiLine(long style) const long maxLineLength_3 = 1; const long numLines_3 = 4; CPPUNIT_ASSERT_EQUAL( numLines_3, m_text->GetNumberOfLines() ); -#if defined(__WXMSW__) +#if defined(__WXMSW__) && !defined(__WXUNIVERSAL__) // Note: New lines are occupied by two characters. long pos_3_msw[numLines_3 + 1][maxLineLength_3 + 1] = { { 0, -1 }, // New line occupies positions 0, 1 @@ -1111,7 +1111,7 @@ void TextCtrlTestCase::DoXYToPositionMultiLine(long style) { -1, -1 } }; long (&ref_pos_3)[numLines_3 + 1][maxLineLength_3 + 1] = -#if defined(__WXMSW__) +#if defined(__WXMSW__) && !defined(__WXUNIVERSAL__) isRichEdit ? pos_3 : pos_3_msw; #else pos_3; @@ -1131,7 +1131,7 @@ void TextCtrlTestCase::DoXYToPositionMultiLine(long style) const long maxLineLength_4 = 4; const long numLines_4 = 6; CPPUNIT_ASSERT_EQUAL( numLines_4, m_text->GetNumberOfLines() ); -#if defined(__WXMSW__) +#if defined(__WXMSW__) && !defined(__WXUNIVERSAL__) // Note: New lines are occupied by two characters. long pos_4_msw[numLines_4 + 1][maxLineLength_4 + 1] = { { 0, 1, 2, 3, -1 }, // New line occupies positions 3, 4 @@ -1152,7 +1152,7 @@ void TextCtrlTestCase::DoXYToPositionMultiLine(long style) { -1, -1, -1, -1, -1 } }; long (&ref_pos_4)[numLines_4 + 1][maxLineLength_4 + 1] = -#if defined(__WXMSW__) +#if defined(__WXMSW__) && !defined(__WXUNIVERSAL__) isRichEdit ? pos_4 : pos_4_msw; #else pos_4;