]> git.saurik.com Git - wxWidgets.git/commitdiff
mouse selection handling fixed
authorKarsten Ballüder <ballueder@usa.net>
Sat, 6 Nov 1999 16:59:44 +0000 (16:59 +0000)
committerKarsten Ballüder <ballueder@usa.net>
Sat, 6 Nov 1999 16:59:44 +0000 (16:59 +0000)
wxGTK private clipboard data format and private selection are broken!

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@4402 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

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

index 7fb9992447328bcc26749777dd688c671a0b0f42..2c514185bfd771bf98e2b7319bd7c71325d5d587 100644 (file)
@@ -1230,7 +1230,7 @@ wxLayoutLine::Layout(wxDC &dc,
    {
       // this might be the case if the cursor is at the end of the
       // line or on a command object:
    {
       // this might be the case if the cursor is at the end of the
       // line or on a command object:
-      if(cursorSize->y < WXLO_MINIMUM_CURSOR_WIDTH)
+      if(cursorSize->x < WXLO_MINIMUM_CURSOR_WIDTH)
       {
          CoordType width, height, descent;
          dc.GetTextExtent(WXLO_CURSORCHAR, &width, &height, &descent);
       {
          CoordType width, height, descent;
          dc.GetTextExtent(WXLO_CURSORCHAR, &width, &height, &descent);
@@ -2479,6 +2479,8 @@ wxLayoutList::DrawCursor(wxDC &dc, bool active, wxPoint const &translate)
 #ifdef WXLAYOUT_USE_CARET
    m_caret->Move(coords);
 #else // !WXLAYOUT_USE_CARET
 #ifdef WXLAYOUT_USE_CARET
    m_caret->Move(coords);
 #else // !WXLAYOUT_USE_CARET
+
+   wxASSERT(m_CursorSize.x >= WXLO_MINIMUM_CURSOR_WIDTH);
    dc.SetBrush(*wxWHITE_BRUSH);
    //FIXME: wxGTK XOR is borken at the moment!!!dc.SetLogicalFunction(wxXOR);
    dc.SetPen(wxPen(*wxBLACK,1,wxSOLID));
    dc.SetBrush(*wxWHITE_BRUSH);
    //FIXME: wxGTK XOR is borken at the moment!!!dc.SetLogicalFunction(wxXOR);
    dc.SetPen(wxPen(*wxBLACK,1,wxSOLID));
@@ -2544,16 +2546,16 @@ wxLayoutList::ContinueSelection(const wxPoint& cposOrig, const wxPoint& spos)
    wxASSERT(m_Selection.m_valid == false);
    WXLO_DEBUG(("Continuing selection at %ld/%ld", cpos.x, cpos.y));
 
    wxASSERT(m_Selection.m_valid == false);
    WXLO_DEBUG(("Continuing selection at %ld/%ld", cpos.x, cpos.y));
 
-      m_Selection.m_ScreenB = spos;
-      m_Selection.m_CursorB = cpos;}
+   m_Selection.m_ScreenB = spos;
+   m_Selection.m_CursorB = cpos;
+}
 
 void
 wxLayoutList::EndSelection(const wxPoint& cposOrig, const wxPoint& spos)
 {
    wxPoint cpos(cposOrig);
 
 void
 wxLayoutList::EndSelection(const wxPoint& cposOrig, const wxPoint& spos)
 {
    wxPoint cpos(cposOrig);
-   if(cpos.x == -1)
-      cpos = m_CursorPos;
-   ContinueSelection(cpos);
+   if(cpos.x == -1) cpos = m_CursorPos;
+   ContinueSelection(cpos, spos);
    WXLO_DEBUG(("Ending selection at %ld/%ld", cpos.x, cpos.y));
    // we always want m_CursorA <= m_CursorB!
    if( m_Selection.m_CursorA > m_Selection.m_CursorB )
    WXLO_DEBUG(("Ending selection at %ld/%ld", cpos.x, cpos.y));
    // we always want m_CursorA <= m_CursorB!
    if( m_Selection.m_CursorA > m_Selection.m_CursorB )
index fac6223d86180f710d3272e6b88a8c8b44b78e22..0ff31fb09f9bb73273896ad4569db73e87bee92b 100644 (file)
@@ -28,7 +28,7 @@
 #   define WXMENU_LAYOUT_LCLICK     1111
 #   define WXMENU_LAYOUT_RCLICK     1112
 #   define WXMENU_LAYOUT_DBLCLICK   1113
 #   define WXMENU_LAYOUT_LCLICK     1111
 #   define WXMENU_LAYOUT_RCLICK     1112
 #   define WXMENU_LAYOUT_DBLCLICK   1113
-#else // for Mahogany only:
+#else // for Mahogany only
 #   include "MObject.h"
 #endif
 
 #   include "MObject.h"
 #endif
 
index 112fc1b21814de1cc1de493c7f3ee14f02e3dfc3..cc968b10d1f364a2486e362371b3da2399497a7c 100644 (file)
 static const int X_SCROLL_PAGE = 10;
 static const int Y_SCROLL_PAGE = 20;
 
 static const int X_SCROLL_PAGE = 10;
 static const int Y_SCROLL_PAGE = 20;
 
+
+
+#define wxUSE_PRIVATE_CLIPBOARD_FORMAT 0
+
 // ----------------------------------------------------------------------------
 // event tables
 // ----------------------------------------------------------------------------
 // ----------------------------------------------------------------------------
 // event tables
 // ----------------------------------------------------------------------------
@@ -394,7 +398,9 @@ wxLayoutWindow::OnMouse(int eventId, wxMouseEvent& event)
    case WXLOWIN_MENU_LUP:
       if ( m_Selecting )
       {
    case WXLOWIN_MENU_LUP:
       if ( m_Selecting )
       {
-         m_llist->EndSelection();
+         // end selection at the cursor position corresponding to the
+         // current mouse position, but don´t move cursor there.
+         m_llist->EndSelection(cursorPos,m_ClickPosition);
          m_Selecting = false;
 
          RequestUpdate();     // TODO: we don't have to redraw everything!
          m_Selecting = false;
 
          RequestUpdate();     // TODO: we don't have to redraw everything!
@@ -457,7 +463,6 @@ wxLayoutWindow::OnChar(wxKeyEvent& event)
    if(keyCode == WXK_F1)
    {
       m_llist->Debug();
    if(keyCode == WXK_F1)
    {
       m_llist->Debug();
-      event.skip();
       return;
    }
 #endif
       return;
    }
 #endif
@@ -571,6 +576,8 @@ wxLayoutWindow::OnChar(wxKeyEvent& event)
             FindAgain();
             break;
          default:
             FindAgain();
             break;
          default:
+            // we don't handle it, maybe an accelerator?
+            event.Skip();
             ;
          }
       else if( IsEditable() )
             ;
          }
       else if( IsEditable() )
@@ -636,7 +643,8 @@ wxLayoutWindow::OnChar(wxKeyEvent& event)
                break;
 #endif
             default:
                break;
 #endif
             default:
-               ;
+            // we don't handle it, maybe an accelerator?
+            event.Skip();
             }
          }
          // ALT only:
             }
          }
          // ALT only:
@@ -650,7 +658,8 @@ wxLayoutWindow::OnChar(wxKeyEvent& event)
                SetDirty();
                break;
             default:
                SetDirty();
                break;
             default:
-               ;
+               // we don't handle it, maybe an accelerator?
+               event.Skip();
             }
          }
          // no control keys:
             }
          }
          // no control keys:
@@ -715,10 +724,16 @@ wxLayoutWindow::OnChar(wxKeyEvent& event)
                   m_llist->Insert((char)keyCode);
                   SetDirty();
                }
                   m_llist->Insert((char)keyCode);
                   SetDirty();
                }
+               else
+                  // we don't handle it, maybe an accelerator?
+                  event.Skip();
                break;
             }
          }
       }// if(IsEditable())
                break;
             }
          }
       }// if(IsEditable())
+      else
+         // we don't handle it, maybe an accelerator?
+         event.Skip();
    }// first switch()
 
    if ( m_Selecting )
    }// first switch()
 
    if ( m_Selecting )
@@ -729,7 +744,6 @@ wxLayoutWindow::OnChar(wxKeyEvent& event)
    ScrollToCursor();
    // refresh the screen
    RequestUpdate(m_llist->GetUpdateRect());
    ScrollToCursor();
    // refresh the screen
    RequestUpdate(m_llist->GetUpdateRect());
-   event.Skip();
 }
 
 void
 }
 
 void
@@ -1068,6 +1082,7 @@ wxLayoutWindow::ResizeScrollbars(bool exact)
 }
 
 // ----------------------------------------------------------------------------
 }
 
 // ----------------------------------------------------------------------------
+//
 // clipboard operations
 //
 // ----------------------------------------------------------------------------
 // clipboard operations
 //
 // ----------------------------------------------------------------------------
@@ -1086,7 +1101,7 @@ wxLayoutWindow::Paste(bool primary)
       wxLayoutDataObject wxldo;
       if (wxTheClipboard->IsSupported( wxldo.GetFormat() ))
       {
       wxLayoutDataObject wxldo;
       if (wxTheClipboard->IsSupported( wxldo.GetFormat() ))
       {
-         wxTheClipboard->GetData(&wxldo);
+         wxTheClipboard->GetData(wxldo);
          {
          }
          //FIXME: missing functionality  m_llist->Insert(wxldo.GetList());
          {
          }
          //FIXME: missing functionality  m_llist->Insert(wxldo.GetList());
@@ -1094,16 +1109,14 @@ wxLayoutWindow::Paste(bool primary)
       else
 #endif
       {
       else
 #endif
       {
-#if 0 //RE_ENABLE FIXME!!
          wxTextDataObject data;
          wxTextDataObject data;
-         if (wxTheClipboard->IsSupported( data.GetFormat() ))
+         if (wxTheClipboard->IsSupported( data.GetFormat() )
+             && wxTheClipboard->GetData(data) )
          {
          {
-            wxTheClipboard->GetData(&data);
             wxString text = data.GetText();
             wxLayoutImportText( m_llist, text);
             SetDirty();
          }
             wxString text = data.GetText();
             wxLayoutImportText( m_llist, text);
             SetDirty();
          }
-#endif
       }
       wxTheClipboard->Close();
    }
       }
       wxTheClipboard->Close();
    }
@@ -1120,7 +1133,6 @@ wxLayoutWindow::Copy(bool invalidate)
       m_llist->EndSelection();
    }
 
       m_llist->EndSelection();
    }
 
-#if 0 //FIXME CLIPBOARD
    wxLayoutDataObject wldo;
    wxLayoutList *llist = m_llist->GetSelection(&wldo, invalidate);
    if(! llist)
    wxLayoutDataObject wldo;
    wxLayoutList *llist = m_llist->GetSelection(&wldo, invalidate);
    if(! llist)
@@ -1147,7 +1159,6 @@ wxLayoutWindow::Copy(bool invalidate)
          text = text.Mid(0,len-1);
    }
 
          text = text.Mid(0,len-1);
    }
 
-
    if (wxTheClipboard->Open())
    {
       wxTextDataObject *data = new wxTextDataObject( text );
    if (wxTheClipboard->Open())
    {
       wxTextDataObject *data = new wxTextDataObject( text );
@@ -1158,7 +1169,6 @@ wxLayoutWindow::Copy(bool invalidate)
       wxTheClipboard->Close();
       return rc;
    }
       wxTheClipboard->Close();
       return rc;
    }
-#endif //FIXME CLIPBOARD
    
    return FALSE;
 }
    
    return FALSE;
 }
@@ -1180,12 +1190,12 @@ wxLayoutWindow::Cut(void)
 // searching
 // ----------------------------------------------------------------------------
 
 // searching
 // ----------------------------------------------------------------------------
 
-#ifdef M_BASEDIR
 bool
 wxLayoutWindow::Find(const wxString &needle,
                      wxPoint * fromWhere,
                      const wxString &configPath)
 {
 bool
 wxLayoutWindow::Find(const wxString &needle,
                      wxPoint * fromWhere,
                      const wxString &configPath)
 {
+#ifdef M_BASEDIR
    wxPoint found;
    
    if(needle.Length() == 0)
    wxPoint found;
    
    if(needle.Length() == 0)
@@ -1217,6 +1227,7 @@ wxLayoutWindow::Find(const wxString &needle,
       RequestUpdate();
       return true;
    }
       RequestUpdate();
       return true;
    }
+#endif
    return false;
 }
 
    return false;
 }
 
@@ -1227,7 +1238,6 @@ wxLayoutWindow::FindAgain(void)
    bool rc = Find(m_FindString);
    return rc;
 }
    bool rc = Find(m_FindString);
    return rc;
 }
-#endif
 
 // ----------------------------------------------------------------------------
 // popup menu stuff
 
 // ----------------------------------------------------------------------------
 // popup menu stuff
index 5453903a235d8fc1e53d102bb1996a9fa83f8a3f..4ad20e8fce12d9e711ce27f7589e65adf388fcde 100644 (file)
@@ -23,8 +23,6 @@
 #endif
 
 
 #endif
 
 
-#define wxUSE_PRIVATE_CLIPBOARD_FORMAT 0
-
 enum
 {
    WXLOWIN_MENU_LARGER = WXLOWIN_MENU_FIRST,
 enum
 {
    WXLOWIN_MENU_LARGER = WXLOWIN_MENU_FIRST,
@@ -106,15 +104,12 @@ public:
    bool Cut(void);
    //@}
 
    bool Cut(void);
    //@}
 
-#ifdef M_BASEDIR
    /// find string in buffer
    bool Find(const wxString &needle,
              wxPoint * fromWhere = NULL,
              const wxString &configPath = "MsgViewFindString");
    /// find the same string again
    bool FindAgain(void);
    /// find string in buffer
    bool Find(const wxString &needle,
              wxPoint * fromWhere = NULL,
              const wxString &configPath = "MsgViewFindString");
    /// find the same string again
    bool FindAgain(void);
-#endif
-   
 
    void EnablePopup(bool enable = true) { m_DoPopupMenu = enable; }
 
 
    void EnablePopup(bool enable = true) { m_DoPopupMenu = enable; }