From 062bc6fcfe6f31999d86e909751d92c52cade36f Mon Sep 17 00:00:00 2001 From: cxl Date: Sat, 19 Jan 2013 13:35:32 +0000 Subject: [PATCH] 'Drag And Drop' violates read-only state for source with DND_MOVE git-svn-id: svn://ultimatepp.org/upp/trunk@5721 f0d560ea-af0d-0410-9eb7-867de7ffcac7 --- uppsrc/CtrlCore/GtkX11Util.cpp | 10 ++++++---- uppsrc/CtrlLib/DocEdit.cpp | 8 +++++--- uppsrc/CtrlLib/EditField.cpp | 8 +++++--- uppsrc/CtrlLib/LineEdit.cpp | 8 +++++--- uppsrc/RichEdit/Clip.cpp | 8 +++++--- 5 files changed, 26 insertions(+), 16 deletions(-) diff --git a/uppsrc/CtrlCore/GtkX11Util.cpp b/uppsrc/CtrlCore/GtkX11Util.cpp index 40f1fad87..caad91c03 100644 --- a/uppsrc/CtrlCore/GtkX11Util.cpp +++ b/uppsrc/CtrlCore/GtkX11Util.cpp @@ -4,10 +4,11 @@ NAMESPACE_UPP -#define Time XTime -#define Font XFont -#define Display XDisplay -#define Picture XPicture +#define Time XTime +#define Font XFont +#define Display XDisplay +#define Picture XPicture +#define CurrentTime XCurrentTime #include @@ -15,6 +16,7 @@ NAMESPACE_UPP #undef Time #undef Font #undef Display +#undef CurrentTime XDisplay *Xdisplay() { diff --git a/uppsrc/CtrlLib/DocEdit.cpp b/uppsrc/CtrlLib/DocEdit.cpp index 0c25a4e53..d70eeb631 100644 --- a/uppsrc/CtrlLib/DocEdit.cpp +++ b/uppsrc/CtrlLib/DocEdit.cpp @@ -516,7 +516,8 @@ void DocEdit::DragAndDrop(Point p, PasteClip& d) WString txt = GetWString(d); if(GetSelection(sell, selh)) { if(c >= sell && c < selh) { - RemoveSelection(); + if(!IsReadOnly()) + RemoveSelection(); if(IsDragAndDropSource()) d.SetAction(DND_COPY); c = sell; @@ -525,7 +526,8 @@ void DocEdit::DragAndDrop(Point p, PasteClip& d) if(d.GetAction() == DND_MOVE && IsDragAndDropSource()) { if(c > sell) c -= selh - sell; - RemoveSelection(); + if(!IsReadOnly()) + RemoveSelection(); d.SetAction(DND_COPY); } } @@ -586,7 +588,7 @@ void DocEdit::LeftDrag(Point p, dword flags) iw.Alpha().DrawRect(ssz, Black()); DrawTLText(iw.Alpha(), 0, 0, ssz.cx, sample, StdFont(), White()); NextUndo(); - if(DoDragAndDrop(ClipFmtsText(), iw) == DND_MOVE) { + if(DoDragAndDrop(ClipFmtsText(), iw) == DND_MOVE && !IsReadOnly()) { RemoveSelection(); Action(); } diff --git a/uppsrc/CtrlLib/EditField.cpp b/uppsrc/CtrlLib/EditField.cpp index 0f8a4baf8..9afa75949 100644 --- a/uppsrc/CtrlLib/EditField.cpp +++ b/uppsrc/CtrlLib/EditField.cpp @@ -679,7 +679,8 @@ void EditField::DragAndDrop(Point p, PasteClip& d) WString txt = GetWString(d); if(GetSelection(sell, selh)) { if(c >= sell && c < selh) { - RemoveSelection(); + if(!IsReadOnly()) + RemoveSelection(); if(IsDragAndDropSource()) d.SetAction(DND_COPY); c = sell; @@ -688,7 +689,8 @@ void EditField::DragAndDrop(Point p, PasteClip& d) if(d.GetAction() == DND_MOVE && IsDragAndDropSource()) { if(c > sell) c -= selh - sell; - RemoveSelection(); + if(!IsReadOnly()) + RemoveSelection(); d.SetAction(DND_COPY); } } @@ -754,7 +756,7 @@ void EditField::LeftDrag(Point p, dword flags) Append(data, sel); bool oks = keep_selection; keep_selection = true; - if(DoDragAndDrop(data, iw) == DND_MOVE) { + if(DoDragAndDrop(data, iw) == DND_MOVE && !IsReadOnly()) { CancelSelection(); SaveUndo(); Remove(sell, selh - sell); diff --git a/uppsrc/CtrlLib/LineEdit.cpp b/uppsrc/CtrlLib/LineEdit.cpp index c273dcf12..1fd387c5b 100644 --- a/uppsrc/CtrlLib/LineEdit.cpp +++ b/uppsrc/CtrlLib/LineEdit.cpp @@ -793,7 +793,8 @@ void LineEdit::DragAndDrop(Point p, PasteClip& d) WString text = GetWString(d); if(GetSelection(sell, selh)) { if(c >= sell && c < selh) { - RemoveSelection(); + if(!IsReadOnly()) + RemoveSelection(); if(IsDragAndDropSource()) d.SetAction(DND_COPY); c = sell; @@ -802,7 +803,8 @@ void LineEdit::DragAndDrop(Point p, PasteClip& d) if(d.GetAction() == DND_MOVE && IsDragAndDropSource()) { if(c > sell) c -= selh - sell; - RemoveSelection(); + if(!IsReadOnly()) + RemoveSelection(); d.SetAction(DND_COPY); } } @@ -868,7 +870,7 @@ void LineEdit::LeftDrag(Point p, dword flags) iw.Alpha().DrawRect(sz, Black()); DrawTLText(iw.Alpha(), 0, 0, 9999, sample, Courier(10), White()); NextUndo(); - if(DoDragAndDrop(ClipFmtsText(), iw) == DND_MOVE) { + if(DoDragAndDrop(ClipFmtsText(), iw) == DND_MOVE && !IsReadOnly()) { RemoveSelection(); Action(); } diff --git a/uppsrc/RichEdit/Clip.cpp b/uppsrc/RichEdit/Clip.cpp index e4d0f0147..b2a685430 100644 --- a/uppsrc/RichEdit/Clip.cpp +++ b/uppsrc/RichEdit/Clip.cpp @@ -103,7 +103,8 @@ void RichEdit::DragAndDrop(Point p, PasteClip& d) int a = sb; int c = dropcursor; if(InSelection(c)) { - RemoveSelection(); + if(!IsReadOnly()) + RemoveSelection(); if(IsDragAndDropSource()) d.SetAction(DND_COPY); } @@ -111,7 +112,8 @@ void RichEdit::DragAndDrop(Point p, PasteClip& d) if(GetSelection(sell, selh) && d.GetAction() == DND_MOVE && IsDragAndDropSource()) { if(c > sell) c -= selh - sell; - RemoveSelection(); + if(!IsReadOnly()) + RemoveSelection(); d.SetAction(DND_COPY); } Move(c); @@ -244,7 +246,7 @@ void RichEdit::LeftDrag(Point p, dword flags) sample.Paint(iw, 0, 0, 128); NextUndo(); if(DoDragAndDrop(String().Cat() << "text/QTF;" RTFS ";" << ClipFmtsText(), - ColorMask(iw, White)) == DND_MOVE) { + ColorMask(iw, White)) == DND_MOVE && !IsReadOnly()) { RemoveSelection(); Action(); }