Revert MSW-specific changes for wxTextCtrl tests in wxUniv

This commit is contained in:
Kvaz1r
2021-08-07 11:03:03 +03:00
parent e3acc50fbc
commit b8d9ac9a32
2 changed files with 18 additions and 37 deletions

View File

@@ -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 // update the (cached) last position first as refresh functions use it
m_posLast += text.length() - to + from; 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 // 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 // it did we have to refresh everything below the part we chanegd as
// well as it might have moved // 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 // start of the next one are different
pos += GetLines()[nLine].length() + 1; 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 // out of the line
@@ -1778,21 +1767,13 @@ bool wxTextCtrl::PositionToXY(wxTextPos pos,
// +1 is because the start of the next line is one // +1 is because the start of the next line is one
// position after the end of this one // position after the end of this one
wxTextPos posNew = posCur + GetLines()[nLine].length() + 1; 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 ) if ( posNew > pos )
{ {
// we've found the line, now just calc the column // we've found the line, now just calc the column
if ( x ) if ( x )
*x = pos - posCur; *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 ) if ( y )
*y = nLine; *y = nLine;

View File

@@ -793,7 +793,7 @@ void TextCtrlTestCase::DoPositionToXYMultiLine(long style)
delete m_text; delete m_text;
CreateText(style|wxTE_MULTILINE|wxTE_DONTWRAP); CreateText(style|wxTE_MULTILINE|wxTE_DONTWRAP);
#if defined(__WXMSW__) #if defined(__WXMSW__) && !defined(__WXUNIVERSAL__)
const bool isRichEdit = (style & (wxTE_RICH | wxTE_RICH2)) != 0; const bool isRichEdit = (style & (wxTE_RICH | wxTE_RICH2)) != 0;
#endif #endif
@@ -844,7 +844,7 @@ void TextCtrlTestCase::DoPositionToXYMultiLine(long style)
text = wxS("123\nab\nX"); text = wxS("123\nab\nX");
m_text->SetValue(text); m_text->SetValue(text);
#if defined(__WXMSW__) #if defined(__WXMSW__) && !defined(__WXUNIVERSAL__)
// Take into account that every new line mark occupies // Take into account that every new line mark occupies
// two characters, not one. // two characters, not one.
const long numChars_msw_2 = 8 + 2; const long numChars_msw_2 = 8 + 2;
@@ -863,14 +863,14 @@ void TextCtrlTestCase::DoPositionToXYMultiLine(long style)
{ 0, 2 }, { 1, 2 } }; { 0, 2 }, { 1, 2 } };
const long &ref_numChars_2 = const long &ref_numChars_2 =
#if defined(__WXMSW__) #if defined(__WXMSW__) && !defined(__WXUNIVERSAL__)
isRichEdit ? numChars_2 : numChars_msw_2; isRichEdit ? numChars_2 : numChars_msw_2;
#else #else
numChars_2; numChars_2;
#endif #endif
XYPos *ref_coords_2 = XYPos *ref_coords_2 =
#if defined(__WXMSW__) #if defined(__WXMSW__) && !defined(__WXUNIVERSAL__)
isRichEdit ? coords_2 : coords_2_msw; isRichEdit ? coords_2 : coords_2_msw;
#else #else
coords_2; coords_2;
@@ -892,7 +892,7 @@ void TextCtrlTestCase::DoPositionToXYMultiLine(long style)
text = wxS("\n\n\n"); text = wxS("\n\n\n");
m_text->SetValue(text); m_text->SetValue(text);
#if defined(__WXMSW__) #if defined(__WXMSW__) && !defined(__WXUNIVERSAL__)
// Take into account that every new line mark occupies // Take into account that every new line mark occupies
// two characters, not one. // two characters, not one.
const long numChars_msw_3 = 3 + 3; const long numChars_msw_3 = 3 + 3;
@@ -913,14 +913,14 @@ void TextCtrlTestCase::DoPositionToXYMultiLine(long style)
{ 0, 3 } }; { 0, 3 } };
const long &ref_numChars_3 = const long &ref_numChars_3 =
#if defined(__WXMSW__) #if defined(__WXMSW__) && !defined(__WXUNIVERSAL__)
isRichEdit ? numChars_3 : numChars_msw_3; isRichEdit ? numChars_3 : numChars_msw_3;
#else #else
numChars_3; numChars_3;
#endif #endif
XYPos *ref_coords_3 = XYPos *ref_coords_3 =
#if defined(__WXMSW__) #if defined(__WXMSW__) && !defined(__WXUNIVERSAL__)
isRichEdit ? coords_3 : coords_3_msw; isRichEdit ? coords_3 : coords_3_msw;
#else #else
coords_3; coords_3;
@@ -942,7 +942,7 @@ void TextCtrlTestCase::DoPositionToXYMultiLine(long style)
text = wxS("123\na\n\nX\n\n"); text = wxS("123\na\n\nX\n\n");
m_text->SetValue(text); m_text->SetValue(text);
#if defined(__WXMSW__) #if defined(__WXMSW__) && !defined(__WXUNIVERSAL__)
// Take into account that every new line mark occupies // Take into account that every new line mark occupies
// two characters, not one. // two characters, not one.
const long numChars_msw_4 = 10 + 5; const long numChars_msw_4 = 10 + 5;
@@ -967,14 +967,14 @@ void TextCtrlTestCase::DoPositionToXYMultiLine(long style)
{ 0, 5 } }; { 0, 5 } };
const long &ref_numChars_4 = const long &ref_numChars_4 =
#if defined(__WXMSW__) #if defined(__WXMSW__) && !defined(__WXUNIVERSAL__)
isRichEdit ? numChars_4 : numChars_msw_4; isRichEdit ? numChars_4 : numChars_msw_4;
#else #else
numChars_4; numChars_4;
#endif #endif
XYPos *ref_coords_4 = XYPos *ref_coords_4 =
#if defined(__WXMSW__) #if defined(__WXMSW__) && !defined(__WXUNIVERSAL__)
isRichEdit ? coords_4 : coords_4_msw; isRichEdit ? coords_4 : coords_4_msw;
#else #else
coords_4; coords_4;
@@ -1015,7 +1015,7 @@ void TextCtrlTestCase::DoXYToPositionMultiLine(long style)
delete m_text; delete m_text;
CreateText(style|wxTE_MULTILINE|wxTE_DONTWRAP); CreateText(style|wxTE_MULTILINE|wxTE_DONTWRAP);
#if defined(__WXMSW__) #if defined(__WXMSW__) && !defined(__WXUNIVERSAL__)
const bool isRichEdit = (style & (wxTE_RICH | wxTE_RICH2)) != 0; const bool isRichEdit = (style & (wxTE_RICH | wxTE_RICH2)) != 0;
#endif #endif
@@ -1059,7 +1059,7 @@ void TextCtrlTestCase::DoXYToPositionMultiLine(long style)
const long maxLineLength_2 = 4; const long maxLineLength_2 = 4;
const long numLines_2 = 3; const long numLines_2 = 3;
CPPUNIT_ASSERT_EQUAL( numLines_2, m_text->GetNumberOfLines() ); CPPUNIT_ASSERT_EQUAL( numLines_2, m_text->GetNumberOfLines() );
#if defined(__WXMSW__) #if defined(__WXMSW__) && !defined(__WXUNIVERSAL__)
// Note: New lines are occupied by two characters. // Note: New lines are occupied by two characters.
long pos_2_msw[numLines_2 + 1][maxLineLength_2 + 1] = long pos_2_msw[numLines_2 + 1][maxLineLength_2 + 1] =
{ { 0, 1, 2, 3, -1 }, // New line occupies positions 3, 4 { { 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 } }; { -1, -1, -1, -1, -1 } };
long (&ref_pos_2)[numLines_2 + 1][maxLineLength_2 + 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; isRichEdit ? pos_2 : pos_2_msw;
#else #else
pos_2; pos_2;
@@ -1094,7 +1094,7 @@ void TextCtrlTestCase::DoXYToPositionMultiLine(long style)
const long maxLineLength_3 = 1; const long maxLineLength_3 = 1;
const long numLines_3 = 4; const long numLines_3 = 4;
CPPUNIT_ASSERT_EQUAL( numLines_3, m_text->GetNumberOfLines() ); CPPUNIT_ASSERT_EQUAL( numLines_3, m_text->GetNumberOfLines() );
#if defined(__WXMSW__) #if defined(__WXMSW__) && !defined(__WXUNIVERSAL__)
// Note: New lines are occupied by two characters. // Note: New lines are occupied by two characters.
long pos_3_msw[numLines_3 + 1][maxLineLength_3 + 1] = long pos_3_msw[numLines_3 + 1][maxLineLength_3 + 1] =
{ { 0, -1 }, // New line occupies positions 0, 1 { { 0, -1 }, // New line occupies positions 0, 1
@@ -1111,7 +1111,7 @@ void TextCtrlTestCase::DoXYToPositionMultiLine(long style)
{ -1, -1 } }; { -1, -1 } };
long (&ref_pos_3)[numLines_3 + 1][maxLineLength_3 + 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; isRichEdit ? pos_3 : pos_3_msw;
#else #else
pos_3; pos_3;
@@ -1131,7 +1131,7 @@ void TextCtrlTestCase::DoXYToPositionMultiLine(long style)
const long maxLineLength_4 = 4; const long maxLineLength_4 = 4;
const long numLines_4 = 6; const long numLines_4 = 6;
CPPUNIT_ASSERT_EQUAL( numLines_4, m_text->GetNumberOfLines() ); CPPUNIT_ASSERT_EQUAL( numLines_4, m_text->GetNumberOfLines() );
#if defined(__WXMSW__) #if defined(__WXMSW__) && !defined(__WXUNIVERSAL__)
// Note: New lines are occupied by two characters. // Note: New lines are occupied by two characters.
long pos_4_msw[numLines_4 + 1][maxLineLength_4 + 1] = long pos_4_msw[numLines_4 + 1][maxLineLength_4 + 1] =
{ { 0, 1, 2, 3, -1 }, // New line occupies positions 3, 4 { { 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 } }; { -1, -1, -1, -1, -1 } };
long (&ref_pos_4)[numLines_4 + 1][maxLineLength_4 + 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; isRichEdit ? pos_4 : pos_4_msw;
#else #else
pos_4; pos_4;