minor changes (fixing crash on mouse click)

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@2760 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
1999-06-11 11:14:47 +00:00
parent 55021f25ff
commit 02fe546f1f
3 changed files with 30 additions and 4 deletions

View File

@@ -1852,8 +1852,11 @@ wxLayoutList::MoveCursorWord(int n, bool untilNext)
} }
else // backwards else // backwards
{ {
if ( isspace(*p) ) // in these 2 cases we took 1 char too much
if ( (p < start) || isspace(*p) )
{
p++; p++;
}
} }
n > 0 ? n-- : n++; n > 0 ? n-- : n++;
@@ -1964,7 +1967,7 @@ wxLayoutList::LineBreak(void)
if(prev) if(prev)
height += prev->GetHeight(); height += prev->GetHeight();
height += m_CursorLine->GetHeight(); height += m_CursorLine->GetHeight();
m_movedCursor = true; m_movedCursor = true;
SetUpdateRect(position); SetUpdateRect(position);
@@ -2172,7 +2175,8 @@ wxLayoutList::Layout(wxDC &dc, CoordType bottom, bool forceAll,
if(cpos && line ->GetLineNumber() == cpos->y) if(cpos && line ->GetLineNumber() == cpos->y)
{ {
*cpos = m_CursorScreenPos; *cpos = m_CursorScreenPos;
*csize = m_CursorSize; if ( csize )
*csize = m_CursorSize;
} }
} }
else else

View File

@@ -210,6 +210,14 @@ wxLayoutWindow::Clear(int family,
DoPaint((wxRect *)NULL); DoPaint((wxRect *)NULL);
} }
void wxLayoutWindow::Refresh(bool eraseBackground, const wxRect *rect)
{
wxScrolledWindow::Refresh(eraseBackground, rect);
ResizeScrollbars();
ScrollToCursor();
}
void void
wxLayoutWindow::OnMouse(int eventId, wxMouseEvent& event) wxLayoutWindow::OnMouse(int eventId, wxMouseEvent& event)
{ {
@@ -288,7 +296,16 @@ wxLayoutWindow::OnMouse(int eventId, wxMouseEvent& event)
case WXLOWIN_MENU_LDOWN: case WXLOWIN_MENU_LDOWN:
{ {
// always move cursor to mouse click: // always move cursor to mouse click:
m_llist->MoveCursorTo(cursorPos); if ( obj )
{
// we have found the real position
m_llist->MoveCursorTo(cursorPos);
}
else
{
// click beyond the end of the text
m_llist->MoveCursorTo(m_llist->GetSize());
}
// clicking a mouse removes the selection // clicking a mouse removes the selection
if ( m_llist->HasSelection() ) if ( m_llist->HasSelection() )

View File

@@ -68,6 +68,11 @@ public:
int underline=0, int underline=0,
wxColour *fg=NULL, wxColour *fg=NULL,
wxColour *bg=NULL); wxColour *bg=NULL);
/// override base class virtual to also refresh the scrollbar position
virtual void Refresh(bool eraseBackground = TRUE,
const wxRect *rect = (const wxRect *)NULL);
/** Sets a background image, only used on screen, not on printouts. /** Sets a background image, only used on screen, not on printouts.
@param bitmap a pointer to a wxBitmap or NULL to remove it @param bitmap a pointer to a wxBitmap or NULL to remove it
*/ */