Refactoring
This commit is contained in:
@@ -2454,7 +2454,7 @@ void wxTextCtrl::UpdateLastVisible()
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
// use (efficient) HitTestLine to find the last visible character
|
// use (efficient) HitTestLine to find the last visible character
|
||||||
wxString text = m_value;//m_value.Mid((size_t)SData().m_colStart /* to the end */);
|
wxString text = m_value;
|
||||||
wxTextCoord col;
|
wxTextCoord col;
|
||||||
switch ( HitTestLine(text, m_rectText.width, &col) )
|
switch ( HitTestLine(text, m_rectText.width, &col) )
|
||||||
{
|
{
|
||||||
|
@@ -38,6 +38,8 @@
|
|||||||
|
|
||||||
static const int TEXT_HEIGHT = 200;
|
static const int TEXT_HEIGHT = 200;
|
||||||
|
|
||||||
|
#define wxHAS_2CHAR_NEWLINES defined(__WXMSW__) && !defined(__WXUNIVERSAL__)
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// test class
|
// test class
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
@@ -437,7 +439,7 @@ void TextCtrlTestCase::ProcessEnter()
|
|||||||
|
|
||||||
void TextCtrlTestCase::Url()
|
void TextCtrlTestCase::Url()
|
||||||
{
|
{
|
||||||
#if wxUSE_UIACTIONSIMULATOR && defined(__WXMSW__) && !defined(__WXUNIVERSAL__)
|
#if wxUSE_UIACTIONSIMULATOR && wxHAS_2CHAR_NEWLINES
|
||||||
// For some unfathomable reason, this test consistently fails when run in
|
// For some unfathomable reason, this test consistently fails when run in
|
||||||
// AppVeyor CI environment, even though it passes locally, so skip it
|
// AppVeyor CI environment, even though it passes locally, so skip it
|
||||||
// there.
|
// there.
|
||||||
@@ -690,7 +692,7 @@ void TextCtrlTestCase::DoPositionToCoordsTestWithStyle(long style)
|
|||||||
const wxPoint pos0 = m_text->PositionToCoords(0);
|
const wxPoint pos0 = m_text->PositionToCoords(0);
|
||||||
if ( pos0 == wxDefaultPosition )
|
if ( pos0 == wxDefaultPosition )
|
||||||
{
|
{
|
||||||
#if ( defined(__WXMSW__) && !defined(__WXUNIVERSAL__) ) || defined(__WXGTK20__)
|
#if ( wxHAS_2CHAR_NEWLINES ) || defined(__WXGTK20__)
|
||||||
CPPUNIT_FAIL( "PositionToCoords() unexpectedly failed." );
|
CPPUNIT_FAIL( "PositionToCoords() unexpectedly failed." );
|
||||||
#endif
|
#endif
|
||||||
return;
|
return;
|
||||||
@@ -793,7 +795,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__) && !defined(__WXUNIVERSAL__)
|
#if wxHAS_2CHAR_NEWLINES
|
||||||
const bool isRichEdit = (style & (wxTE_RICH | wxTE_RICH2)) != 0;
|
const bool isRichEdit = (style & (wxTE_RICH | wxTE_RICH2)) != 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -844,7 +846,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__) && !defined(__WXUNIVERSAL__)
|
#if wxHAS_2CHAR_NEWLINES
|
||||||
// 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 +865,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__) && !defined(__WXUNIVERSAL__)
|
#if wxHAS_2CHAR_NEWLINES
|
||||||
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__) && !defined(__WXUNIVERSAL__)
|
#if wxHAS_2CHAR_NEWLINES
|
||||||
isRichEdit ? coords_2 : coords_2_msw;
|
isRichEdit ? coords_2 : coords_2_msw;
|
||||||
#else
|
#else
|
||||||
coords_2;
|
coords_2;
|
||||||
@@ -892,7 +894,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__) && !defined(__WXUNIVERSAL__)
|
#if wxHAS_2CHAR_NEWLINES
|
||||||
// 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 +915,14 @@ void TextCtrlTestCase::DoPositionToXYMultiLine(long style)
|
|||||||
{ 0, 3 } };
|
{ 0, 3 } };
|
||||||
|
|
||||||
const long &ref_numChars_3 =
|
const long &ref_numChars_3 =
|
||||||
#if defined(__WXMSW__) && !defined(__WXUNIVERSAL__)
|
#if wxHAS_2CHAR_NEWLINES
|
||||||
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__) && !defined(__WXUNIVERSAL__)
|
#if wxHAS_2CHAR_NEWLINES
|
||||||
isRichEdit ? coords_3 : coords_3_msw;
|
isRichEdit ? coords_3 : coords_3_msw;
|
||||||
#else
|
#else
|
||||||
coords_3;
|
coords_3;
|
||||||
@@ -942,7 +944,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__) && !defined(__WXUNIVERSAL__)
|
#if wxHAS_2CHAR_NEWLINES
|
||||||
// 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 +969,14 @@ void TextCtrlTestCase::DoPositionToXYMultiLine(long style)
|
|||||||
{ 0, 5 } };
|
{ 0, 5 } };
|
||||||
|
|
||||||
const long &ref_numChars_4 =
|
const long &ref_numChars_4 =
|
||||||
#if defined(__WXMSW__) && !defined(__WXUNIVERSAL__)
|
#if wxHAS_2CHAR_NEWLINES
|
||||||
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__) && !defined(__WXUNIVERSAL__)
|
#if wxHAS_2CHAR_NEWLINES
|
||||||
isRichEdit ? coords_4 : coords_4_msw;
|
isRichEdit ? coords_4 : coords_4_msw;
|
||||||
#else
|
#else
|
||||||
coords_4;
|
coords_4;
|
||||||
@@ -1015,7 +1017,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__) && !defined(__WXUNIVERSAL__)
|
#if wxHAS_2CHAR_NEWLINES
|
||||||
const bool isRichEdit = (style & (wxTE_RICH | wxTE_RICH2)) != 0;
|
const bool isRichEdit = (style & (wxTE_RICH | wxTE_RICH2)) != 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -1059,7 +1061,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__) && !defined(__WXUNIVERSAL__)
|
#if wxHAS_2CHAR_NEWLINES
|
||||||
// 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 +1076,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__) && !defined(__WXUNIVERSAL__)
|
#if wxHAS_2CHAR_NEWLINES
|
||||||
isRichEdit ? pos_2 : pos_2_msw;
|
isRichEdit ? pos_2 : pos_2_msw;
|
||||||
#else
|
#else
|
||||||
pos_2;
|
pos_2;
|
||||||
@@ -1094,7 +1096,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__) && !defined(__WXUNIVERSAL__)
|
#if wxHAS_2CHAR_NEWLINES
|
||||||
// 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 +1113,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__) && !defined(__WXUNIVERSAL__)
|
#if wxHAS_2CHAR_NEWLINES
|
||||||
isRichEdit ? pos_3 : pos_3_msw;
|
isRichEdit ? pos_3 : pos_3_msw;
|
||||||
#else
|
#else
|
||||||
pos_3;
|
pos_3;
|
||||||
@@ -1131,7 +1133,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__) && !defined(__WXUNIVERSAL__)
|
#if wxHAS_2CHAR_NEWLINES
|
||||||
// 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 +1154,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__) && !defined(__WXUNIVERSAL__)
|
#if wxHAS_2CHAR_NEWLINES
|
||||||
isRichEdit ? pos_4 : pos_4_msw;
|
isRichEdit ? pos_4 : pos_4_msw;
|
||||||
#else
|
#else
|
||||||
pos_4;
|
pos_4;
|
||||||
|
Reference in New Issue
Block a user