horz scrolling in etxt ctrl works better
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/wxUNIVERSAL@8704 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
11
TODO
11
TODO
@@ -1,3 +1,9 @@
|
|||||||
|
----------------------------------------------------------------------------
|
||||||
|
TEST
|
||||||
|
----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
how Paste/Cut work with undo/redo in wxTextCtrl?
|
||||||
|
|
||||||
----------------------------------------------------------------------------
|
----------------------------------------------------------------------------
|
||||||
TODO
|
TODO
|
||||||
----------------------------------------------------------------------------
|
----------------------------------------------------------------------------
|
||||||
@@ -8,12 +14,11 @@ samples:
|
|||||||
|
|
||||||
wxTextCtrl
|
wxTextCtrl
|
||||||
|
|
||||||
* display corrupted when typing text in quickly (single line)
|
*! display corrupted when typing text in quickly (caret problem?)
|
||||||
|
* scrollbars don't disappear after deleting long line
|
||||||
? text ctrl display pb when text is truncated
|
? text ctrl display pb when text is truncated
|
||||||
* too much is refreshed when double clicking (word select)
|
* too much is refreshed when double clicking (word select)
|
||||||
|
|
||||||
!! own ScrollWindow() for horz scrolling as we must always scroll by char!
|
|
||||||
|
|
||||||
All
|
All
|
||||||
|
|
||||||
! wxThemeSettings
|
! wxThemeSettings
|
||||||
|
@@ -389,8 +389,6 @@ MyUnivFrame::MyUnivFrame(const wxString& title)
|
|||||||
#if 0
|
#if 0
|
||||||
wxTextCtrl *text = new wxTextCtrl(this, -1, _T("Hello, Universe!"),
|
wxTextCtrl *text = new wxTextCtrl(this, -1, _T("Hello, Universe!"),
|
||||||
wxPoint(10, 40));
|
wxPoint(10, 40));
|
||||||
text->SetFont(wxFont(24, wxFONTFAMILY_DEFAULT,
|
|
||||||
wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL));
|
|
||||||
wxSize sizeText = text->GetBestSize();
|
wxSize sizeText = text->GetBestSize();
|
||||||
sizeText.x = 200;
|
sizeText.x = 200;
|
||||||
text->SetSize(sizeText);
|
text->SetSize(sizeText);
|
||||||
@@ -408,6 +406,8 @@ MyUnivFrame::MyUnivFrame(const wxString& title)
|
|||||||
TestTextCtrlReplace(text, "first\nsecond\n\nthird line");
|
TestTextCtrlReplace(text, "first\nsecond\n\nthird line");
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
text->SetFont(wxFont(24, wxFONTFAMILY_DEFAULT,
|
||||||
|
wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL));
|
||||||
text->SetFocus();
|
text->SetFocus();
|
||||||
//text->SetEditable(FALSE);
|
//text->SetEditable(FALSE);
|
||||||
#endif // !TEST_TEXT_ONLY/TEST_TEXT_ONLY
|
#endif // !TEST_TEXT_ONLY/TEST_TEXT_ONLY
|
||||||
|
@@ -1303,18 +1303,19 @@ void wxTextCtrl::ShowPosition(long pos)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wxRect rectText = GetRealTextArea();
|
||||||
|
|
||||||
|
// scroll the position vertically into view: if it is currently above
|
||||||
|
// it, make it the first one, otherwise the last one
|
||||||
if ( m_scrollRangeY )
|
if ( m_scrollRangeY )
|
||||||
{
|
{
|
||||||
// scroll the position vertically into view: if it is currently
|
|
||||||
// above it, make it the first one, otherwise the last one
|
|
||||||
if ( row < yStart )
|
if ( row < yStart )
|
||||||
{
|
{
|
||||||
Scroll(0, row);
|
Scroll(0, row);
|
||||||
}
|
}
|
||||||
else
|
else // we are currently in or below the view area
|
||||||
{
|
{
|
||||||
int yEnd = yStart +
|
int yEnd = yStart + rectText.height / GetCharHeight() - 1;
|
||||||
GetRealTextArea().height / GetCharHeight() - 1;
|
|
||||||
if ( yEnd < row )
|
if ( yEnd < row )
|
||||||
{
|
{
|
||||||
// scroll down: the current item should appear at the
|
// scroll down: the current item should appear at the
|
||||||
@@ -1324,9 +1325,34 @@ void wxTextCtrl::ShowPosition(long pos)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// scroll the position horizontally into view
|
||||||
if ( m_scrollRangeX )
|
if ( m_scrollRangeX )
|
||||||
{
|
{
|
||||||
// TODO
|
// unlike for the rows, xStart doesn't correspond to the starting
|
||||||
|
// column as they all have different widths, so we need to
|
||||||
|
// translate everything to pixels
|
||||||
|
|
||||||
|
// we want the text between posLeft and posRight be entirely inside
|
||||||
|
// the view (i.e. the current character)
|
||||||
|
wxString line = GetLineText(row);
|
||||||
|
wxCoord posLeft = GetTextWidth(line.Left(col));
|
||||||
|
|
||||||
|
// make xStart the first visible pixel (and not position)
|
||||||
|
int wChar = GetCharWidth();
|
||||||
|
xStart *= GetCharWidth();
|
||||||
|
|
||||||
|
if ( posLeft < xStart )
|
||||||
|
{
|
||||||
|
Scroll(posLeft / wChar, row);
|
||||||
|
}
|
||||||
|
else // maybe we're beyond the right border of the view?
|
||||||
|
{
|
||||||
|
wxCoord posRight = posLeft + GetTextWidth(line[(size_t)col]);
|
||||||
|
if ( posRight > xStart + rectText.width )
|
||||||
|
{
|
||||||
|
Scroll(posRight / wChar, row);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//else: multiline but no scrollbars, hence nothing to do
|
//else: multiline but no scrollbars, hence nothing to do
|
||||||
@@ -2502,11 +2528,17 @@ void wxTextCtrl::DoDrawTextInRect(wxDC& dc, const wxRect& rectUpdate)
|
|||||||
|
|
||||||
if ( colEnd > m_colLastVisible )
|
if ( colEnd > m_colLastVisible )
|
||||||
colEnd = m_colLastVisible;
|
colEnd = m_colLastVisible;
|
||||||
|
|
||||||
|
// we don't draw the last character because it may be shown only
|
||||||
|
// partially in single line mode (in multi line we can't avoid
|
||||||
|
// showing parts of characters anyhow)
|
||||||
|
if ( colEnd > colStart )
|
||||||
|
colEnd--;
|
||||||
}
|
}
|
||||||
|
|
||||||
// extract the part of line we need to redraw
|
// extract the part of line we need to redraw
|
||||||
wxString textLine = GetLineText(line);
|
wxString textLine = GetLineText(line);
|
||||||
wxString text = textLine.Mid(colStart, colEnd - colStart);
|
wxString text = textLine.Mid(colStart, colEnd - colStart + 1);
|
||||||
|
|
||||||
// now deal with the selection
|
// now deal with the selection
|
||||||
int selStart, selEnd;
|
int selStart, selEnd;
|
||||||
|
Reference in New Issue
Block a user