]> git.saurik.com Git - wxWidgets.git/blobdiff - contrib/src/stc/ScintillaWX.cpp
Don't use a saved label size incase the size changes. Patch from Hong Yuan.
[wxWidgets.git] / contrib / src / stc / ScintillaWX.cpp
index 815180e1b90c619a40aaba16bf2834393f4f3c3d..a27fe5126b5596560b89fa1f094997f5dc41e690 100644 (file)
@@ -79,7 +79,7 @@ wxDragResult  wxSTCDropTarget::OnDragOver(wxCoord x, wxCoord y, wxDragResult def
 void  wxSTCDropTarget::OnLeave() {
     swx->DoDragLeave();
 }
-#endif
+#endif // wxUSE_DRAG_AND_DROP
 
 
 #if wxUSE_POPUPWIN && wxSTC_USE_POPUP
@@ -214,13 +214,15 @@ ScintillaWX::ScintillaWX(wxStyledTextCtrl* win) {
 #endif
 #if wxUSE_DRAG_AND_DROP
     startDragTimer = new wxStartDragTimer(this);
-#endif
+#endif // wxUSE_DRAG_AND_DROP
 }
 
 
 ScintillaWX::~ScintillaWX() {
+#if wxUSE_DRAG_AND_DROP
     delete startDragTimer;
-    Finalise();    
+#endif // wxUSE_DRAG_AND_DROP
+    Finalise();
 }
 
 //----------------------------------------------------------------------
@@ -233,7 +235,7 @@ void ScintillaWX::Initialise() {
     dropTarget = new wxSTCDropTarget;
     dropTarget->SetScintilla(this);
     stc->SetDropTarget(dropTarget);
-#endif
+#endif // wxUSE_DRAG_AND_DROP
 #ifdef __WXMAC__
     vs.extraFontFlag = false;  // UseAntiAliasing
 #else
@@ -255,11 +257,12 @@ void ScintillaWX::StartDrag() {
     // We defer the starting of the DnD, otherwise the LeftUp of a normal
     // click could be lost and the STC will think it is doing a DnD when the
     // user just wanted a normal click.
-    startDragTimer->Start(100, true);
-#endif
+    startDragTimer->Start(200, true);
+#endif // wxUSE_DRAG_AND_DROP
 }
 
 void ScintillaWX::DoStartDrag() {
+#if wxUSE_DRAG_AND_DROP
     wxString dragText = stc2wx(drag.s, drag.len);
 
     // Send an event to allow the drag text to be changed
@@ -272,7 +275,7 @@ void ScintillaWX::DoStartDrag() {
     stc->GetEventHandler()->ProcessEvent(evt);
     dragText = evt.GetDragText();
 
-    if (dragText.Length()) {
+    if (dragText.length()) {
         wxDropSource        source(stc);
         wxTextDataObject    data(dragText);
         wxDragResult        result;
@@ -285,6 +288,7 @@ void ScintillaWX::DoStartDrag() {
         inDragDrop = false;
         SetDragPosition(invalidPosition);
     }
+#endif // wxUSE_DRAG_AND_DROP
 }
 
 
@@ -324,16 +328,17 @@ void ScintillaWX::SetTicking(bool on) {
 
 void ScintillaWX::SetMouseCapture(bool on) {
     if (mouseDownCaptures) {
-        if (on && !capturedMouse)
+        if (on && !stc->HasCapture())
             stc->CaptureMouse();
-        else if (!on && capturedMouse && stc->HasCapture())
+        else if (!on && stc->HasCapture())
             stc->ReleaseMouse();
-        capturedMouse = on;
+        capturedMouse = stc->HasCapture();
     }
 }
 
 
 bool ScintillaWX::HaveMouseCapture() {
+    capturedMouse = stc->HasCapture();
     return capturedMouse;
 }
 
@@ -479,7 +484,10 @@ void ScintillaWX::Paste() {
     if (gotData) {
         wxString   text = wxTextBuffer::Translate(data.GetText(),
                                                   wxConvertEOLMode(pdoc->eolMode));
+  data.SetText(wxEmptyString); // free the data object content
         wxWX2MBbuf buf = (wxWX2MBbuf)wx2stc(text);
+  text = wxEmptyString; // free text
+
         int        len = strlen(buf);
         pdoc->InsertString(currentPos, buf, len);
         SetEmptySelection(currentPos + len);
@@ -823,13 +831,15 @@ void ScintillaWX::DoLeftButtonDown(Point pt, unsigned int curTime, bool shift, b
 }
 
 void ScintillaWX::DoLeftButtonUp(Point pt, unsigned int curTime, bool ctrl) {
+    ButtonUp(pt, curTime, ctrl);
 #if wxUSE_DRAG_AND_DROP
     if (startDragTimer->IsRunning()) {
         startDragTimer->Stop();
-        SetEmptySelection(PositionFromLocation(pt));        
+        SetDragPosition(invalidPosition);
+        SetEmptySelection(PositionFromLocation(pt));
+        ShowCaretAtCurrentPosition();
     }
-#endif
-    ButtonUp(pt, curTime, ctrl);
+#endif // wxUSE_DRAG_AND_DROP
 }
 
 void ScintillaWX::DoLeftButtonMove(Point pt) {
@@ -903,10 +913,10 @@ int  ScintillaWX::DoKeyDown(const wxKeyEvent& evt, bool* consumed)
     case WXK_RIGHT:             key = SCK_RIGHT;    break;
     case WXK_HOME:              key = SCK_HOME;     break;
     case WXK_END:               key = SCK_END;      break;
-    case WXK_PAGEUP:            // fall through
-    case WXK_PRIOR:             key = SCK_PRIOR;    break;
-    case WXK_PAGEDOWN:          // fall through
-    case WXK_NEXT:              key = SCK_NEXT;     break;
+    case WXK_PAGEUP:            key = SCK_PRIOR;    break;
+    case WXK_PAGEDOWN:          key = SCK_NEXT;     break;
+    case WXK_NUMPAD_PAGEUP:     key = SCK_PRIOR;    break;
+    case WXK_NUMPAD_PAGEDOWN:   key = SCK_NEXT;     break;
     case WXK_DELETE:            key = SCK_DELETE;   break;
     case WXK_INSERT:            key = SCK_INSERT;   break;
     case WXK_ESCAPE:            key = SCK_ESCAPE;   break;
@@ -1031,7 +1041,7 @@ wxDragResult ScintillaWX::DoDragOver(wxCoord x, wxCoord y, wxDragResult def) {
 void ScintillaWX::DoDragLeave() {
     SetDragPosition(invalidPosition);
 }
-#endif
+#endif // wxUSE_DRAG_AND_DROP
 //----------------------------------------------------------------------
 
 // Force the whole window to be repainted