1. fix for custom event handler in wxScrollWindow which was eating events

2. fix for (initial) selection anchor position in wxTextCtrl


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/wxUNIVERSAL@8659 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2000-10-30 21:15:15 +00:00
parent 9686c81605
commit f6c8b8f53d
5 changed files with 33 additions and 23 deletions

7
TODO
View File

@@ -8,8 +8,11 @@ samples:
wxTextCtrl
* display corrupted when typing text in quickly
* text ctrl display pb when text is truncated
* display corrupted when typing text in quickly (single line)
? text ctrl display pb when text is truncated
* too much is refreshed when double clicking (word select)
!! own ScrollWindow() for horz scrolling as we must always scroll by char!
All

View File

@@ -384,7 +384,7 @@ MyUnivFrame::MyUnivFrame(const wxString& title)
new wxTextCtrl(this, -1, _T("Hello, Universe!"),
wxPoint(550, 150), wxDefaultSize);
#else // TEST_TEXT_ONLY
#if 1
#if 0
wxTextCtrl *text = new wxTextCtrl(this, -1, _T("Hello, Universe!"),
wxPoint(10, 40));
text->SetFont(wxFont(24, wxFONTFAMILY_DEFAULT,

View File

@@ -80,25 +80,22 @@ public:
case wxEVT_SCROLLWIN_THUMBTRACK:
case wxEVT_SCROLLWIN_THUMBRELEASE:
m_scrollHelper->HandleOnScroll((wxScrollWinEvent&)event);
break;
return TRUE;
case wxEVT_PAINT:
m_scrollHelper->HandleOnPaint((wxPaintEvent&)event);
break;
return TRUE;
case wxEVT_SIZE:
m_scrollHelper->HandleOnSize((wxSizeEvent&)event);
break;
return FALSE;
case wxEVT_CHAR:
m_scrollHelper->HandleOnChar((wxKeyEvent&)event);
break;
default:
return FALSE;
return !event.GetSkipped();
}
return TRUE;
return FALSE;
}
private:

View File

@@ -356,7 +356,7 @@ void wxTextCtrl::Replace(long from, long to, const wxString& text)
_T("can't have more than one line in this wxTextCtrl"));
// update the current position
SetInsertionPoint(from + text.length());
DoSetInsertionPoint(from + text.length());
// and the selection (do it after setting the cursor to have correct value
// for selection anchor)
@@ -631,7 +631,7 @@ void wxTextCtrl::Replace(long from, long to, const wxString& text)
// update the current position: note that we always put the cursor at the
// end of the replacement text
SetInsertionPoint(from + text.length());
DoSetInsertionPoint(from + text.length());
// and the selection (do it after setting the cursor to have correct value
// for selection anchor)
@@ -681,16 +681,24 @@ void wxTextCtrl::SetInsertionPoint(long pos)
{
DoSetInsertionPoint(pos);
}
ClearSelection();
}
void wxTextCtrl::InitInsertionPoint()
{
// so far always put it in the beginning
DoSetInsertionPoint(0);
// this will also set the selection anchor correctly
ClearSelection();
}
void wxTextCtrl::DoSetInsertionPoint(long pos)
{
wxASSERT_MSG( pos >= 0 && pos <= GetLastPosition(),
_T("DoSetInsertionPoint() can only be called with valid pos") );
m_curPos = pos;
PositionToXY(m_curPos, &m_curCol, &m_curRow);
@@ -1133,7 +1141,7 @@ void wxTextCtrl::ShowPosition(long pos)
{
// scroll down: the current item should appear at the
// bottom of the view
Scroll(0, m_curRow - (yEnd - yStart));
Scroll(0, m_curRow - (yEnd - yStart) + 1);
}
}
}
@@ -1329,7 +1337,7 @@ wxSize wxTextCtrl::DoGetBestClientSize() const
int wChar = GetCharWidth(),
hChar = GetCharHeight();
int widthMin = wxMin(10*wChar, 100);
int widthMin = wxMax(10*wChar, 100);
if ( w < widthMin )
w = widthMin;
if ( h < hChar )
@@ -2222,14 +2230,12 @@ void wxTextCtrl::DoDraw(wxControlRenderer *renderer)
rectTextArea.y += pt.y;
rgnUpdate.Intersect(rectTextArea);
#if 0
// even though the drawing is already clipped to the update region, we must
// explicitly clip it to the rect we will use as otherwise parts of letters
// might be drawn outside of it (if even a small part of a charater is
// inside, HitTest() will return its column and DrawText() can't draw only
// the part of the character, of course)
dc.SetClippingRegion(m_rectText);
#endif // 0
// adjust for scrolling
DoPrepareDC(dc);
@@ -2315,9 +2321,13 @@ void wxTextCtrl::ShowCaret(bool show)
wxCaret *caret = GetCaret();
if ( caret )
{
// position it correctly
caret->Move(m_rectText.x + GetCaretPosition() - m_ofsHorz,
m_rectText.y + m_curRow*GetCharHeight());
// position it correctly (taking scrolling into account)
wxCoord xCaret, yCaret;
CalcUnscrolledPosition(m_rectText.x + GetCaretPosition() - m_ofsHorz,
m_rectText.y + m_curRow*GetCharHeight(),
&xCaret,
&yCaret);
caret->Move(xCaret, yCaret);
// and show it there
caret->Show(show);
@@ -2468,7 +2478,7 @@ bool wxTextCtrl::PerformAction(const wxControlAction& actionOrig,
else // cursor movement command
{
// just go there
SetInsertionPoint(newPos);
DoSetInsertionPoint(newPos);
if ( sel )
{

View File

@@ -1736,7 +1736,7 @@ wxRect wxWin32Renderer::GetTextTotalArea(const wxTextCtrl *text,
{
// this is what Windows does
wxRect rectTotal = rect;
rectTotal.Inflate(1);
rectTotal.Inflate(10);
rectTotal.height++;
return rectTotal;
@@ -1748,7 +1748,7 @@ wxRect wxWin32Renderer::GetTextClientArea(const wxTextCtrl *text,
// undo GetTextTotalArea()
wxRect rectText = rect;
rectText.height--;
rectText.Inflate(-1);
rectText.Inflate(-10);
return rectText;
}