]> git.saurik.com Git - wxWidgets.git/commitdiff
minor changes (fixing crash on mouse click)
authorVadim Zeitlin <vadim@wxwidgets.org>
Fri, 11 Jun 1999 11:14:47 +0000 (11:14 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Fri, 11 Jun 1999 11:14:47 +0000 (11:14 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@2760 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

samples/richedit/wxllist.cpp
samples/richedit/wxlwindow.cpp
samples/richedit/wxlwindow.h

index 7ae280d6d8bdaaa2fa95bafacae97e811abe58e9..f6b6032c9cc2e63fffa75440edd588c6a92de1c6 100644 (file)
@@ -1852,8 +1852,11 @@ wxLayoutList::MoveCursorWord(int n, bool untilNext)
             }
             else // backwards
             {
-               if ( isspace(*p) )
+               // in these 2 cases we took 1 char too much
+               if ( (p < start) || isspace(*p) )
+               {
                   p++;
+               }
             }
 
             n > 0 ? n-- : n++;
@@ -1964,7 +1967,7 @@ wxLayoutList::LineBreak(void)
    if(prev)
       height += prev->GetHeight();
    height += m_CursorLine->GetHeight();
-   
+
    m_movedCursor = true;
 
    SetUpdateRect(position);
@@ -2172,7 +2175,8 @@ wxLayoutList::Layout(wxDC &dc, CoordType bottom, bool forceAll,
             if(cpos && line ->GetLineNumber() == cpos->y)
             {
                *cpos = m_CursorScreenPos;
-               *csize = m_CursorSize;
+               if ( csize )
+                  *csize = m_CursorSize;
             }
          }
          else
index d8389b7f8df7da7bc23275836702a54a57e85579..6b154206c22c8280a5e8deb3648434dcb4e6259c 100644 (file)
@@ -210,6 +210,14 @@ wxLayoutWindow::Clear(int family,
    DoPaint((wxRect *)NULL);
 }
 
+void wxLayoutWindow::Refresh(bool eraseBackground, const wxRect *rect)
+{
+   wxScrolledWindow::Refresh(eraseBackground, rect);
+
+   ResizeScrollbars();
+   ScrollToCursor();
+}
+
 void
 wxLayoutWindow::OnMouse(int eventId, wxMouseEvent& event)
 {
@@ -288,7 +296,16 @@ wxLayoutWindow::OnMouse(int eventId, wxMouseEvent& event)
       case WXLOWIN_MENU_LDOWN:
          {
              // 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
              if ( m_llist->HasSelection() )
index edf9de631e80337cde91f90d6b1db79ff6ddc6aa..c936477bfee8ca56f3a9e9139c514638fd0f8832 100644 (file)
@@ -68,6 +68,11 @@ public:
               int underline=0,
               wxColour *fg=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.
        @param bitmap a pointer to a wxBitmap or NULL to remove it
    */