From a29a241fd60b5df7506e2dd4d8b89eb483da90e8 Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Tue, 23 Oct 2001 22:12:50 +0000 Subject: [PATCH] Added DnD related events to wxSTC git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@12156 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- contrib/include/wx/stc/stc.h | 57 +++++--- contrib/src/stc/ScintillaWX.cpp | 71 ++++++++-- contrib/src/stc/stc.cpp | 16 ++- contrib/src/stc/stc.cpp.in | 16 ++- contrib/src/stc/stc.h.in | 57 +++++--- include/wx/stc/stc.h | 57 +++++--- src/stc/ScintillaWX.cpp | 71 ++++++++-- src/stc/stc.cpp | 16 ++- src/stc/stc.cpp.in | 16 ++- src/stc/stc.h.in | 57 +++++--- wxPython/contrib/stc/stc_.cpp | 204 ++++++++++++++++++++++++++++ wxPython/contrib/stc/stc_.i | 8 ++ wxPython/contrib/stc/stc_.py | 29 ++++ wxPython/demo/data/stc.h.html | 107 +++++++++++---- wxPython/demo/wxStyledTextCtrl_1.py | 46 ++++++- wxPython/demo/wxStyledTextCtrl_2.py | 2 +- 16 files changed, 691 insertions(+), 139 deletions(-) diff --git a/contrib/include/wx/stc/stc.h b/contrib/include/wx/stc/stc.h index 99553d810b..a5586bdfc5 100644 --- a/contrib/include/wx/stc/stc.h +++ b/contrib/include/wx/stc/stc.h @@ -22,6 +22,7 @@ #include +#include //---------------------------------------------------------------------- // BEGIN generated section. The following code is automatically generated @@ -1621,6 +1622,7 @@ private: void NotifyChange(); void NotifyParent(SCNotification* scn); + private: DECLARE_EVENT_TABLE() DECLARE_CLASS(wxStyledTextCtrl) @@ -1642,23 +1644,26 @@ public: wxStyledTextEvent(wxEventType commandType=0, int id=0); ~wxStyledTextEvent() {} - void SetPosition(int pos) { m_position = pos; } - void SetKey(int k) { m_key = k; } - void SetModifiers(int m) { m_modifiers = m; } - void SetModificationType(int t) { m_modificationType = t; } - void SetText(const char* t) { m_text = t; } - void SetLength(int len) { m_length = len; } - void SetLinesAdded(int num) { m_linesAdded = num; } - void SetLine(int val) { m_line = val; } - void SetFoldLevelNow(int val) { m_foldLevelNow = val; } - void SetFoldLevelPrev(int val) { m_foldLevelPrev = val; } - void SetMargin(int val) { m_margin = val; } - void SetMessage(int val) { m_message = val; } - void SetWParam(int val) { m_wParam = val; } - void SetLParam(int val) { m_lParam = val; } - void SetListType(int val) { m_listType = val; } - void SetX(int val) { m_x = val; } - void SetY(int val) { m_y = val; } + void SetPosition(int pos) { m_position = pos; } + void SetKey(int k) { m_key = k; } + void SetModifiers(int m) { m_modifiers = m; } + void SetModificationType(int t) { m_modificationType = t; } + void SetText(const char* t) { m_text = t; } + void SetLength(int len) { m_length = len; } + void SetLinesAdded(int num) { m_linesAdded = num; } + void SetLine(int val) { m_line = val; } + void SetFoldLevelNow(int val) { m_foldLevelNow = val; } + void SetFoldLevelPrev(int val) { m_foldLevelPrev = val; } + void SetMargin(int val) { m_margin = val; } + void SetMessage(int val) { m_message = val; } + void SetWParam(int val) { m_wParam = val; } + void SetLParam(int val) { m_lParam = val; } + void SetListType(int val) { m_listType = val; } + void SetX(int val) { m_x = val; } + void SetY(int val) { m_y = val; } + void SetDragText(const wxString& val) { m_dragText = val; } + void SetDragAllowMove(bool val) { m_dragAllowMove = val; } + void SetDragResult(wxDragResult val) { m_dragResult = val; } int GetPosition() const { return m_position; } int GetKey() const { return m_key; } @@ -1677,6 +1682,9 @@ public: int GetListType() const { return m_listType; } int GetX() const { return m_x; } int GetY() const { return m_y; } + wxString GetDragText() { return m_dragText; } + bool GetDragAllowMove() { return m_dragAllowMove; } + wxDragResult GetDragResult() { return m_dragResult; } bool GetShift() const; bool GetControl() const; @@ -1709,6 +1717,11 @@ private: int m_listType; int m_x; int m_y; + + wxString m_dragText; // wxEVT_STC_START_DRAG, wxEVT_STC_DO_DROP + bool m_dragAllowMove; // wxEVT_STC_START_DRAG + + wxDragResult m_dragResult; // wxEVT_STC_DRAG_OVER,wxEVT_STC_DO_DROP #endif }; @@ -1733,6 +1746,9 @@ BEGIN_DECLARE_EVENT_TYPES() DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_URIDROPPED, 1666) DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_DWELLSTART, 1667) DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_DWELLEND, 1668) + DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_START_DRAG, 1669) + DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_DRAG_OVER, 1670) + DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_DO_DROP, 1671) END_DECLARE_EVENT_TYPES() #else enum { @@ -1755,6 +1771,9 @@ END_DECLARE_EVENT_TYPES() wxEVT_STC_URIDROPPED, wxEVT_STC_DWELLSTART, wxEVT_STC_DWELLEND, + wxEVT_STC_START_DRAG, + wxEVT_STC_DRAG_OVER, + wxEVT_STC_DO_DROP, }; #endif @@ -1782,7 +1801,9 @@ typedef void (wxEvtHandler::*wxStyledTextEventFunction)(wxStyledTextEvent&); #define EVT_STC_URIDROPPED(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_URIDROPPED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ), #define EVT_STC_DWELLSTART(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_DWELLSTART, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ), #define EVT_STC_DWELLEND(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_DWELLEND, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ), - +#define EVT_STC_START_DRAG(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_START_DRAG, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ), +#define EVT_STC_DRAG_OVER(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_DRAG_OVER, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ), +#define EVT_STC_DO_DROP(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_DO_DROP, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ), #endif diff --git a/contrib/src/stc/ScintillaWX.cpp b/contrib/src/stc/ScintillaWX.cpp index d5f2648dd1..023a0f92d0 100644 --- a/contrib/src/stc/ScintillaWX.cpp +++ b/contrib/src/stc/ScintillaWX.cpp @@ -121,17 +121,31 @@ void ScintillaWX::Finalise() { void ScintillaWX::StartDrag() { - wxDropSource source(wMain.GetID()); - wxTextDataObject data(wxString(drag.s, drag.len)); - wxDragResult result; - - dropWentOutside = true; - source.SetData(data); - result = source.DoDragDrop(TRUE); - if (result == wxDragMove && dropWentOutside) - ClearSelection(); - inDragDrop = FALSE; - SetDragPosition(invalidPosition); + wxString dragText(drag.s, drag.len); + + // Send an event to allow the drag text to be changed + wxStyledTextEvent evt(wxEVT_STC_START_DRAG, stc->GetId()); + evt.SetEventObject(stc); + evt.SetDragText(dragText); + evt.SetDragAllowMove(TRUE); + evt.SetPosition(wxMin(stc->GetSelectionStart(), + stc->GetSelectionEnd())); + stc->GetEventHandler()->ProcessEvent(evt); + dragText = evt.GetDragText(); + + if (dragText.Length()) { + wxDropSource source(wMain.GetID()); + wxTextDataObject data(dragText); + wxDragResult result; + + source.SetData(data); + dropWentOutside = TRUE; + result = source.DoDragDrop(evt.GetDragAllowMove()); + if (result == wxDragMove && dropWentOutside) + ClearSelection(); + inDragDrop = FALSE; + SetDragPosition(invalidPosition); + } } @@ -489,9 +503,26 @@ void ScintillaWX::DoOnListBox() { bool ScintillaWX::DoDropText(long x, long y, const wxString& data) { SetDragPosition(invalidPosition); - int movePos = PositionFromLocation(Point(x,y)); - DropAt(movePos, data, dragResult == wxDragMove, FALSE); // TODO: rectangular? - return TRUE; + + // Send an event to allow the drag details to be changed + wxStyledTextEvent evt(wxEVT_STC_DO_DROP, stc->GetId()); + evt.SetEventObject(stc); + evt.SetDragResult(dragResult); + evt.SetX(x); + evt.SetY(y); + evt.SetPosition(PositionFromLocation(Point(x,y))); + evt.SetDragText(data); + stc->GetEventHandler()->ProcessEvent(evt); + + dragResult = evt.GetDragResult(); + if (dragResult == wxDragMove || dragResult == wxDragCopy) { + DropAt(evt.GetPosition(), + evt.GetDragText(), + dragResult == wxDragMove, + FALSE); // TODO: rectangular? + return TRUE; + } + return FALSE; } @@ -503,7 +534,17 @@ wxDragResult ScintillaWX::DoDragEnter(wxCoord x, wxCoord y, wxDragResult def) { wxDragResult ScintillaWX::DoDragOver(wxCoord x, wxCoord y, wxDragResult def) { SetDragPosition(PositionFromLocation(Point(x, y))); - dragResult = def; + + // Send an event to allow the drag result to be changed + wxStyledTextEvent evt(wxEVT_STC_DRAG_OVER, stc->GetId()); + evt.SetEventObject(stc); + evt.SetDragResult(def); + evt.SetX(x); + evt.SetY(y); + evt.SetPosition(PositionFromLocation(Point(x,y))); + stc->GetEventHandler()->ProcessEvent(evt); + + dragResult = evt.GetDragResult(); return dragResult; } diff --git a/contrib/src/stc/stc.cpp b/contrib/src/stc/stc.cpp index 99645adb29..10e29c82ef 100644 --- a/contrib/src/stc/stc.cpp +++ b/contrib/src/stc/stc.cpp @@ -93,8 +93,9 @@ DEFINE_EVENT_TYPE( wxEVT_STC_USERLISTSELECTION ) DEFINE_EVENT_TYPE( wxEVT_STC_URIDROPPED ) DEFINE_EVENT_TYPE( wxEVT_STC_DWELLSTART ) DEFINE_EVENT_TYPE( wxEVT_STC_DWELLEND ) - - +DEFINE_EVENT_TYPE( wxEVT_STC_START_DRAG ) +DEFINE_EVENT_TYPE( wxEVT_STC_DRAG_OVER ) +DEFINE_EVENT_TYPE( wxEVT_STC_DO_DROP ) BEGIN_EVENT_TABLE(wxStyledTextCtrl, wxControl) @@ -1914,6 +1915,7 @@ void wxStyledTextCtrl::OnListBox(wxCommandEvent& evt) { void wxStyledTextCtrl::NotifyChange() { wxStyledTextEvent evt(wxEVT_STC_CHANGE, GetId()); + evt.SetEventObject(this); GetEventHandler()->ProcessEvent(evt); } @@ -1921,6 +1923,7 @@ void wxStyledTextCtrl::NotifyParent(SCNotification* _scn) { SCNotification& scn = *_scn; wxStyledTextEvent evt(0, GetId()); + evt.SetEventObject(this); evt.SetPosition(scn.position); evt.SetKey(scn.ch); evt.SetModifiers(scn.modifiers); @@ -2026,7 +2029,6 @@ void wxStyledTextCtrl::NotifyParent(SCNotification* _scn) { } - //---------------------------------------------------------------------- //---------------------------------------------------------------------- //---------------------------------------------------------------------- @@ -2050,6 +2052,8 @@ wxStyledTextEvent::wxStyledTextEvent(wxEventType commandType, int id) m_listType = 0; m_x = 0; m_y = 0; + m_dragAllowMove = FALSE; + m_dragResult = wxDragNone; } bool wxStyledTextEvent::GetShift() const { return (m_modifiers & SCI_SHIFT) != 0; } @@ -2081,8 +2085,14 @@ void wxStyledTextEvent::CopyObject(wxObject& obj) const { o->m_x = m_x; o->m_y = m_y; + o->m_dragText = m_dragText; + o->m_dragAllowMove =m_dragAllowMove; + o->m_dragResult = m_dragResult; } //---------------------------------------------------------------------- //---------------------------------------------------------------------- + + + diff --git a/contrib/src/stc/stc.cpp.in b/contrib/src/stc/stc.cpp.in index 3a415e1f85..77ecc6b3c6 100644 --- a/contrib/src/stc/stc.cpp.in +++ b/contrib/src/stc/stc.cpp.in @@ -93,8 +93,9 @@ DEFINE_EVENT_TYPE( wxEVT_STC_USERLISTSELECTION ) DEFINE_EVENT_TYPE( wxEVT_STC_URIDROPPED ) DEFINE_EVENT_TYPE( wxEVT_STC_DWELLSTART ) DEFINE_EVENT_TYPE( wxEVT_STC_DWELLEND ) - - +DEFINE_EVENT_TYPE( wxEVT_STC_START_DRAG ) +DEFINE_EVENT_TYPE( wxEVT_STC_DRAG_OVER ) +DEFINE_EVENT_TYPE( wxEVT_STC_DO_DROP ) BEGIN_EVENT_TABLE(wxStyledTextCtrl, wxControl) @@ -458,6 +459,7 @@ void wxStyledTextCtrl::OnListBox(wxCommandEvent& evt) { void wxStyledTextCtrl::NotifyChange() { wxStyledTextEvent evt(wxEVT_STC_CHANGE, GetId()); + evt.SetEventObject(this); GetEventHandler()->ProcessEvent(evt); } @@ -465,6 +467,7 @@ void wxStyledTextCtrl::NotifyParent(SCNotification* _scn) { SCNotification& scn = *_scn; wxStyledTextEvent evt(0, GetId()); + evt.SetEventObject(this); evt.SetPosition(scn.position); evt.SetKey(scn.ch); evt.SetModifiers(scn.modifiers); @@ -570,7 +573,6 @@ void wxStyledTextCtrl::NotifyParent(SCNotification* _scn) { } - //---------------------------------------------------------------------- //---------------------------------------------------------------------- //---------------------------------------------------------------------- @@ -594,6 +596,8 @@ wxStyledTextEvent::wxStyledTextEvent(wxEventType commandType, int id) m_listType = 0; m_x = 0; m_y = 0; + m_dragAllowMove = FALSE; + m_dragResult = wxDragNone; } bool wxStyledTextEvent::GetShift() const { return (m_modifiers & SCI_SHIFT) != 0; } @@ -625,8 +629,14 @@ void wxStyledTextEvent::CopyObject(wxObject& obj) const { o->m_x = m_x; o->m_y = m_y; + o->m_dragText = m_dragText; + o->m_dragAllowMove =m_dragAllowMove; + o->m_dragResult = m_dragResult; } //---------------------------------------------------------------------- //---------------------------------------------------------------------- + + + diff --git a/contrib/src/stc/stc.h.in b/contrib/src/stc/stc.h.in index 09712a1e8b..13ca81ae90 100644 --- a/contrib/src/stc/stc.h.in +++ b/contrib/src/stc/stc.h.in @@ -22,6 +22,7 @@ #include +#include //---------------------------------------------------------------------- // BEGIN generated section. The following code is automatically generated @@ -175,6 +176,7 @@ private: void NotifyChange(); void NotifyParent(SCNotification* scn); + private: DECLARE_EVENT_TABLE() DECLARE_CLASS(wxStyledTextCtrl) @@ -196,23 +198,26 @@ public: wxStyledTextEvent(wxEventType commandType=0, int id=0); ~wxStyledTextEvent() {} - void SetPosition(int pos) { m_position = pos; } - void SetKey(int k) { m_key = k; } - void SetModifiers(int m) { m_modifiers = m; } - void SetModificationType(int t) { m_modificationType = t; } - void SetText(const char* t) { m_text = t; } - void SetLength(int len) { m_length = len; } - void SetLinesAdded(int num) { m_linesAdded = num; } - void SetLine(int val) { m_line = val; } - void SetFoldLevelNow(int val) { m_foldLevelNow = val; } - void SetFoldLevelPrev(int val) { m_foldLevelPrev = val; } - void SetMargin(int val) { m_margin = val; } - void SetMessage(int val) { m_message = val; } - void SetWParam(int val) { m_wParam = val; } - void SetLParam(int val) { m_lParam = val; } - void SetListType(int val) { m_listType = val; } - void SetX(int val) { m_x = val; } - void SetY(int val) { m_y = val; } + void SetPosition(int pos) { m_position = pos; } + void SetKey(int k) { m_key = k; } + void SetModifiers(int m) { m_modifiers = m; } + void SetModificationType(int t) { m_modificationType = t; } + void SetText(const char* t) { m_text = t; } + void SetLength(int len) { m_length = len; } + void SetLinesAdded(int num) { m_linesAdded = num; } + void SetLine(int val) { m_line = val; } + void SetFoldLevelNow(int val) { m_foldLevelNow = val; } + void SetFoldLevelPrev(int val) { m_foldLevelPrev = val; } + void SetMargin(int val) { m_margin = val; } + void SetMessage(int val) { m_message = val; } + void SetWParam(int val) { m_wParam = val; } + void SetLParam(int val) { m_lParam = val; } + void SetListType(int val) { m_listType = val; } + void SetX(int val) { m_x = val; } + void SetY(int val) { m_y = val; } + void SetDragText(const wxString& val) { m_dragText = val; } + void SetDragAllowMove(bool val) { m_dragAllowMove = val; } + void SetDragResult(wxDragResult val) { m_dragResult = val; } int GetPosition() const { return m_position; } int GetKey() const { return m_key; } @@ -231,6 +236,9 @@ public: int GetListType() const { return m_listType; } int GetX() const { return m_x; } int GetY() const { return m_y; } + wxString GetDragText() { return m_dragText; } + bool GetDragAllowMove() { return m_dragAllowMove; } + wxDragResult GetDragResult() { return m_dragResult; } bool GetShift() const; bool GetControl() const; @@ -263,6 +271,11 @@ private: int m_listType; int m_x; int m_y; + + wxString m_dragText; // wxEVT_STC_START_DRAG, wxEVT_STC_DO_DROP + bool m_dragAllowMove; // wxEVT_STC_START_DRAG + + wxDragResult m_dragResult; // wxEVT_STC_DRAG_OVER,wxEVT_STC_DO_DROP #endif }; @@ -287,6 +300,9 @@ BEGIN_DECLARE_EVENT_TYPES() DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_URIDROPPED, 1666) DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_DWELLSTART, 1667) DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_DWELLEND, 1668) + DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_START_DRAG, 1669) + DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_DRAG_OVER, 1670) + DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_DO_DROP, 1671) END_DECLARE_EVENT_TYPES() #else enum { @@ -309,6 +325,9 @@ END_DECLARE_EVENT_TYPES() wxEVT_STC_URIDROPPED, wxEVT_STC_DWELLSTART, wxEVT_STC_DWELLEND, + wxEVT_STC_START_DRAG, + wxEVT_STC_DRAG_OVER, + wxEVT_STC_DO_DROP, }; #endif @@ -336,7 +355,9 @@ typedef void (wxEvtHandler::*wxStyledTextEventFunction)(wxStyledTextEvent&); #define EVT_STC_URIDROPPED(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_URIDROPPED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ), #define EVT_STC_DWELLSTART(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_DWELLSTART, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ), #define EVT_STC_DWELLEND(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_DWELLEND, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ), - +#define EVT_STC_START_DRAG(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_START_DRAG, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ), +#define EVT_STC_DRAG_OVER(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_DRAG_OVER, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ), +#define EVT_STC_DO_DROP(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_DO_DROP, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ), #endif diff --git a/include/wx/stc/stc.h b/include/wx/stc/stc.h index 99553d810b..a5586bdfc5 100644 --- a/include/wx/stc/stc.h +++ b/include/wx/stc/stc.h @@ -22,6 +22,7 @@ #include +#include //---------------------------------------------------------------------- // BEGIN generated section. The following code is automatically generated @@ -1621,6 +1622,7 @@ private: void NotifyChange(); void NotifyParent(SCNotification* scn); + private: DECLARE_EVENT_TABLE() DECLARE_CLASS(wxStyledTextCtrl) @@ -1642,23 +1644,26 @@ public: wxStyledTextEvent(wxEventType commandType=0, int id=0); ~wxStyledTextEvent() {} - void SetPosition(int pos) { m_position = pos; } - void SetKey(int k) { m_key = k; } - void SetModifiers(int m) { m_modifiers = m; } - void SetModificationType(int t) { m_modificationType = t; } - void SetText(const char* t) { m_text = t; } - void SetLength(int len) { m_length = len; } - void SetLinesAdded(int num) { m_linesAdded = num; } - void SetLine(int val) { m_line = val; } - void SetFoldLevelNow(int val) { m_foldLevelNow = val; } - void SetFoldLevelPrev(int val) { m_foldLevelPrev = val; } - void SetMargin(int val) { m_margin = val; } - void SetMessage(int val) { m_message = val; } - void SetWParam(int val) { m_wParam = val; } - void SetLParam(int val) { m_lParam = val; } - void SetListType(int val) { m_listType = val; } - void SetX(int val) { m_x = val; } - void SetY(int val) { m_y = val; } + void SetPosition(int pos) { m_position = pos; } + void SetKey(int k) { m_key = k; } + void SetModifiers(int m) { m_modifiers = m; } + void SetModificationType(int t) { m_modificationType = t; } + void SetText(const char* t) { m_text = t; } + void SetLength(int len) { m_length = len; } + void SetLinesAdded(int num) { m_linesAdded = num; } + void SetLine(int val) { m_line = val; } + void SetFoldLevelNow(int val) { m_foldLevelNow = val; } + void SetFoldLevelPrev(int val) { m_foldLevelPrev = val; } + void SetMargin(int val) { m_margin = val; } + void SetMessage(int val) { m_message = val; } + void SetWParam(int val) { m_wParam = val; } + void SetLParam(int val) { m_lParam = val; } + void SetListType(int val) { m_listType = val; } + void SetX(int val) { m_x = val; } + void SetY(int val) { m_y = val; } + void SetDragText(const wxString& val) { m_dragText = val; } + void SetDragAllowMove(bool val) { m_dragAllowMove = val; } + void SetDragResult(wxDragResult val) { m_dragResult = val; } int GetPosition() const { return m_position; } int GetKey() const { return m_key; } @@ -1677,6 +1682,9 @@ public: int GetListType() const { return m_listType; } int GetX() const { return m_x; } int GetY() const { return m_y; } + wxString GetDragText() { return m_dragText; } + bool GetDragAllowMove() { return m_dragAllowMove; } + wxDragResult GetDragResult() { return m_dragResult; } bool GetShift() const; bool GetControl() const; @@ -1709,6 +1717,11 @@ private: int m_listType; int m_x; int m_y; + + wxString m_dragText; // wxEVT_STC_START_DRAG, wxEVT_STC_DO_DROP + bool m_dragAllowMove; // wxEVT_STC_START_DRAG + + wxDragResult m_dragResult; // wxEVT_STC_DRAG_OVER,wxEVT_STC_DO_DROP #endif }; @@ -1733,6 +1746,9 @@ BEGIN_DECLARE_EVENT_TYPES() DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_URIDROPPED, 1666) DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_DWELLSTART, 1667) DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_DWELLEND, 1668) + DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_START_DRAG, 1669) + DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_DRAG_OVER, 1670) + DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_DO_DROP, 1671) END_DECLARE_EVENT_TYPES() #else enum { @@ -1755,6 +1771,9 @@ END_DECLARE_EVENT_TYPES() wxEVT_STC_URIDROPPED, wxEVT_STC_DWELLSTART, wxEVT_STC_DWELLEND, + wxEVT_STC_START_DRAG, + wxEVT_STC_DRAG_OVER, + wxEVT_STC_DO_DROP, }; #endif @@ -1782,7 +1801,9 @@ typedef void (wxEvtHandler::*wxStyledTextEventFunction)(wxStyledTextEvent&); #define EVT_STC_URIDROPPED(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_URIDROPPED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ), #define EVT_STC_DWELLSTART(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_DWELLSTART, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ), #define EVT_STC_DWELLEND(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_DWELLEND, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ), - +#define EVT_STC_START_DRAG(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_START_DRAG, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ), +#define EVT_STC_DRAG_OVER(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_DRAG_OVER, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ), +#define EVT_STC_DO_DROP(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_DO_DROP, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ), #endif diff --git a/src/stc/ScintillaWX.cpp b/src/stc/ScintillaWX.cpp index d5f2648dd1..023a0f92d0 100644 --- a/src/stc/ScintillaWX.cpp +++ b/src/stc/ScintillaWX.cpp @@ -121,17 +121,31 @@ void ScintillaWX::Finalise() { void ScintillaWX::StartDrag() { - wxDropSource source(wMain.GetID()); - wxTextDataObject data(wxString(drag.s, drag.len)); - wxDragResult result; - - dropWentOutside = true; - source.SetData(data); - result = source.DoDragDrop(TRUE); - if (result == wxDragMove && dropWentOutside) - ClearSelection(); - inDragDrop = FALSE; - SetDragPosition(invalidPosition); + wxString dragText(drag.s, drag.len); + + // Send an event to allow the drag text to be changed + wxStyledTextEvent evt(wxEVT_STC_START_DRAG, stc->GetId()); + evt.SetEventObject(stc); + evt.SetDragText(dragText); + evt.SetDragAllowMove(TRUE); + evt.SetPosition(wxMin(stc->GetSelectionStart(), + stc->GetSelectionEnd())); + stc->GetEventHandler()->ProcessEvent(evt); + dragText = evt.GetDragText(); + + if (dragText.Length()) { + wxDropSource source(wMain.GetID()); + wxTextDataObject data(dragText); + wxDragResult result; + + source.SetData(data); + dropWentOutside = TRUE; + result = source.DoDragDrop(evt.GetDragAllowMove()); + if (result == wxDragMove && dropWentOutside) + ClearSelection(); + inDragDrop = FALSE; + SetDragPosition(invalidPosition); + } } @@ -489,9 +503,26 @@ void ScintillaWX::DoOnListBox() { bool ScintillaWX::DoDropText(long x, long y, const wxString& data) { SetDragPosition(invalidPosition); - int movePos = PositionFromLocation(Point(x,y)); - DropAt(movePos, data, dragResult == wxDragMove, FALSE); // TODO: rectangular? - return TRUE; + + // Send an event to allow the drag details to be changed + wxStyledTextEvent evt(wxEVT_STC_DO_DROP, stc->GetId()); + evt.SetEventObject(stc); + evt.SetDragResult(dragResult); + evt.SetX(x); + evt.SetY(y); + evt.SetPosition(PositionFromLocation(Point(x,y))); + evt.SetDragText(data); + stc->GetEventHandler()->ProcessEvent(evt); + + dragResult = evt.GetDragResult(); + if (dragResult == wxDragMove || dragResult == wxDragCopy) { + DropAt(evt.GetPosition(), + evt.GetDragText(), + dragResult == wxDragMove, + FALSE); // TODO: rectangular? + return TRUE; + } + return FALSE; } @@ -503,7 +534,17 @@ wxDragResult ScintillaWX::DoDragEnter(wxCoord x, wxCoord y, wxDragResult def) { wxDragResult ScintillaWX::DoDragOver(wxCoord x, wxCoord y, wxDragResult def) { SetDragPosition(PositionFromLocation(Point(x, y))); - dragResult = def; + + // Send an event to allow the drag result to be changed + wxStyledTextEvent evt(wxEVT_STC_DRAG_OVER, stc->GetId()); + evt.SetEventObject(stc); + evt.SetDragResult(def); + evt.SetX(x); + evt.SetY(y); + evt.SetPosition(PositionFromLocation(Point(x,y))); + stc->GetEventHandler()->ProcessEvent(evt); + + dragResult = evt.GetDragResult(); return dragResult; } diff --git a/src/stc/stc.cpp b/src/stc/stc.cpp index 99645adb29..10e29c82ef 100644 --- a/src/stc/stc.cpp +++ b/src/stc/stc.cpp @@ -93,8 +93,9 @@ DEFINE_EVENT_TYPE( wxEVT_STC_USERLISTSELECTION ) DEFINE_EVENT_TYPE( wxEVT_STC_URIDROPPED ) DEFINE_EVENT_TYPE( wxEVT_STC_DWELLSTART ) DEFINE_EVENT_TYPE( wxEVT_STC_DWELLEND ) - - +DEFINE_EVENT_TYPE( wxEVT_STC_START_DRAG ) +DEFINE_EVENT_TYPE( wxEVT_STC_DRAG_OVER ) +DEFINE_EVENT_TYPE( wxEVT_STC_DO_DROP ) BEGIN_EVENT_TABLE(wxStyledTextCtrl, wxControl) @@ -1914,6 +1915,7 @@ void wxStyledTextCtrl::OnListBox(wxCommandEvent& evt) { void wxStyledTextCtrl::NotifyChange() { wxStyledTextEvent evt(wxEVT_STC_CHANGE, GetId()); + evt.SetEventObject(this); GetEventHandler()->ProcessEvent(evt); } @@ -1921,6 +1923,7 @@ void wxStyledTextCtrl::NotifyParent(SCNotification* _scn) { SCNotification& scn = *_scn; wxStyledTextEvent evt(0, GetId()); + evt.SetEventObject(this); evt.SetPosition(scn.position); evt.SetKey(scn.ch); evt.SetModifiers(scn.modifiers); @@ -2026,7 +2029,6 @@ void wxStyledTextCtrl::NotifyParent(SCNotification* _scn) { } - //---------------------------------------------------------------------- //---------------------------------------------------------------------- //---------------------------------------------------------------------- @@ -2050,6 +2052,8 @@ wxStyledTextEvent::wxStyledTextEvent(wxEventType commandType, int id) m_listType = 0; m_x = 0; m_y = 0; + m_dragAllowMove = FALSE; + m_dragResult = wxDragNone; } bool wxStyledTextEvent::GetShift() const { return (m_modifiers & SCI_SHIFT) != 0; } @@ -2081,8 +2085,14 @@ void wxStyledTextEvent::CopyObject(wxObject& obj) const { o->m_x = m_x; o->m_y = m_y; + o->m_dragText = m_dragText; + o->m_dragAllowMove =m_dragAllowMove; + o->m_dragResult = m_dragResult; } //---------------------------------------------------------------------- //---------------------------------------------------------------------- + + + diff --git a/src/stc/stc.cpp.in b/src/stc/stc.cpp.in index 3a415e1f85..77ecc6b3c6 100644 --- a/src/stc/stc.cpp.in +++ b/src/stc/stc.cpp.in @@ -93,8 +93,9 @@ DEFINE_EVENT_TYPE( wxEVT_STC_USERLISTSELECTION ) DEFINE_EVENT_TYPE( wxEVT_STC_URIDROPPED ) DEFINE_EVENT_TYPE( wxEVT_STC_DWELLSTART ) DEFINE_EVENT_TYPE( wxEVT_STC_DWELLEND ) - - +DEFINE_EVENT_TYPE( wxEVT_STC_START_DRAG ) +DEFINE_EVENT_TYPE( wxEVT_STC_DRAG_OVER ) +DEFINE_EVENT_TYPE( wxEVT_STC_DO_DROP ) BEGIN_EVENT_TABLE(wxStyledTextCtrl, wxControl) @@ -458,6 +459,7 @@ void wxStyledTextCtrl::OnListBox(wxCommandEvent& evt) { void wxStyledTextCtrl::NotifyChange() { wxStyledTextEvent evt(wxEVT_STC_CHANGE, GetId()); + evt.SetEventObject(this); GetEventHandler()->ProcessEvent(evt); } @@ -465,6 +467,7 @@ void wxStyledTextCtrl::NotifyParent(SCNotification* _scn) { SCNotification& scn = *_scn; wxStyledTextEvent evt(0, GetId()); + evt.SetEventObject(this); evt.SetPosition(scn.position); evt.SetKey(scn.ch); evt.SetModifiers(scn.modifiers); @@ -570,7 +573,6 @@ void wxStyledTextCtrl::NotifyParent(SCNotification* _scn) { } - //---------------------------------------------------------------------- //---------------------------------------------------------------------- //---------------------------------------------------------------------- @@ -594,6 +596,8 @@ wxStyledTextEvent::wxStyledTextEvent(wxEventType commandType, int id) m_listType = 0; m_x = 0; m_y = 0; + m_dragAllowMove = FALSE; + m_dragResult = wxDragNone; } bool wxStyledTextEvent::GetShift() const { return (m_modifiers & SCI_SHIFT) != 0; } @@ -625,8 +629,14 @@ void wxStyledTextEvent::CopyObject(wxObject& obj) const { o->m_x = m_x; o->m_y = m_y; + o->m_dragText = m_dragText; + o->m_dragAllowMove =m_dragAllowMove; + o->m_dragResult = m_dragResult; } //---------------------------------------------------------------------- //---------------------------------------------------------------------- + + + diff --git a/src/stc/stc.h.in b/src/stc/stc.h.in index 09712a1e8b..13ca81ae90 100644 --- a/src/stc/stc.h.in +++ b/src/stc/stc.h.in @@ -22,6 +22,7 @@ #include +#include //---------------------------------------------------------------------- // BEGIN generated section. The following code is automatically generated @@ -175,6 +176,7 @@ private: void NotifyChange(); void NotifyParent(SCNotification* scn); + private: DECLARE_EVENT_TABLE() DECLARE_CLASS(wxStyledTextCtrl) @@ -196,23 +198,26 @@ public: wxStyledTextEvent(wxEventType commandType=0, int id=0); ~wxStyledTextEvent() {} - void SetPosition(int pos) { m_position = pos; } - void SetKey(int k) { m_key = k; } - void SetModifiers(int m) { m_modifiers = m; } - void SetModificationType(int t) { m_modificationType = t; } - void SetText(const char* t) { m_text = t; } - void SetLength(int len) { m_length = len; } - void SetLinesAdded(int num) { m_linesAdded = num; } - void SetLine(int val) { m_line = val; } - void SetFoldLevelNow(int val) { m_foldLevelNow = val; } - void SetFoldLevelPrev(int val) { m_foldLevelPrev = val; } - void SetMargin(int val) { m_margin = val; } - void SetMessage(int val) { m_message = val; } - void SetWParam(int val) { m_wParam = val; } - void SetLParam(int val) { m_lParam = val; } - void SetListType(int val) { m_listType = val; } - void SetX(int val) { m_x = val; } - void SetY(int val) { m_y = val; } + void SetPosition(int pos) { m_position = pos; } + void SetKey(int k) { m_key = k; } + void SetModifiers(int m) { m_modifiers = m; } + void SetModificationType(int t) { m_modificationType = t; } + void SetText(const char* t) { m_text = t; } + void SetLength(int len) { m_length = len; } + void SetLinesAdded(int num) { m_linesAdded = num; } + void SetLine(int val) { m_line = val; } + void SetFoldLevelNow(int val) { m_foldLevelNow = val; } + void SetFoldLevelPrev(int val) { m_foldLevelPrev = val; } + void SetMargin(int val) { m_margin = val; } + void SetMessage(int val) { m_message = val; } + void SetWParam(int val) { m_wParam = val; } + void SetLParam(int val) { m_lParam = val; } + void SetListType(int val) { m_listType = val; } + void SetX(int val) { m_x = val; } + void SetY(int val) { m_y = val; } + void SetDragText(const wxString& val) { m_dragText = val; } + void SetDragAllowMove(bool val) { m_dragAllowMove = val; } + void SetDragResult(wxDragResult val) { m_dragResult = val; } int GetPosition() const { return m_position; } int GetKey() const { return m_key; } @@ -231,6 +236,9 @@ public: int GetListType() const { return m_listType; } int GetX() const { return m_x; } int GetY() const { return m_y; } + wxString GetDragText() { return m_dragText; } + bool GetDragAllowMove() { return m_dragAllowMove; } + wxDragResult GetDragResult() { return m_dragResult; } bool GetShift() const; bool GetControl() const; @@ -263,6 +271,11 @@ private: int m_listType; int m_x; int m_y; + + wxString m_dragText; // wxEVT_STC_START_DRAG, wxEVT_STC_DO_DROP + bool m_dragAllowMove; // wxEVT_STC_START_DRAG + + wxDragResult m_dragResult; // wxEVT_STC_DRAG_OVER,wxEVT_STC_DO_DROP #endif }; @@ -287,6 +300,9 @@ BEGIN_DECLARE_EVENT_TYPES() DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_URIDROPPED, 1666) DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_DWELLSTART, 1667) DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_DWELLEND, 1668) + DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_START_DRAG, 1669) + DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_DRAG_OVER, 1670) + DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_DO_DROP, 1671) END_DECLARE_EVENT_TYPES() #else enum { @@ -309,6 +325,9 @@ END_DECLARE_EVENT_TYPES() wxEVT_STC_URIDROPPED, wxEVT_STC_DWELLSTART, wxEVT_STC_DWELLEND, + wxEVT_STC_START_DRAG, + wxEVT_STC_DRAG_OVER, + wxEVT_STC_DO_DROP, }; #endif @@ -336,7 +355,9 @@ typedef void (wxEvtHandler::*wxStyledTextEventFunction)(wxStyledTextEvent&); #define EVT_STC_URIDROPPED(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_URIDROPPED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ), #define EVT_STC_DWELLSTART(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_DWELLSTART, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ), #define EVT_STC_DWELLEND(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_DWELLEND, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ), - +#define EVT_STC_START_DRAG(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_START_DRAG, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ), +#define EVT_STC_DRAG_OVER(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_DRAG_OVER, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ), +#define EVT_STC_DO_DROP(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_DO_DROP, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ), #endif diff --git a/wxPython/contrib/stc/stc_.cpp b/wxPython/contrib/stc/stc_.cpp index e3c1b1e79c..3635bb3071 100644 --- a/wxPython/contrib/stc/stc_.cpp +++ b/wxPython/contrib/stc/stc_.cpp @@ -9215,6 +9215,115 @@ static PyObject *_wrap_wxStyledTextEvent_SetY(PyObject *self, PyObject *args, Py return _resultobj; } +#define wxStyledTextEvent_SetDragText(_swigobj,_swigarg0) (_swigobj->SetDragText(_swigarg0)) +static PyObject *_wrap_wxStyledTextEvent_SetDragText(PyObject *self, PyObject *args, PyObject *kwargs) { + PyObject * _resultobj; + wxStyledTextEvent * _arg0; + wxString * _arg1; + PyObject * _argo0 = 0; + PyObject * _obj1 = 0; + char *_kwnames[] = { "self","val", NULL }; + + self = self; + if(!PyArg_ParseTupleAndKeywords(args,kwargs,"OO:wxStyledTextEvent_SetDragText",_kwnames,&_argo0,&_obj1)) + return NULL; + if (_argo0) { + if (_argo0 == Py_None) { _arg0 = NULL; } + else if (SWIG_GetPtrObj(_argo0,(void **) &_arg0,"_wxStyledTextEvent_p")) { + PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of wxStyledTextEvent_SetDragText. Expected _wxStyledTextEvent_p."); + return NULL; + } + } +{ +#if PYTHON_API_VERSION >= 1009 + char* tmpPtr; int tmpSize; + if (!PyString_Check(_obj1) && !PyUnicode_Check(_obj1)) { + PyErr_SetString(PyExc_TypeError, wxStringErrorMsg); + return NULL; + } + if (PyString_AsStringAndSize(_obj1, &tmpPtr, &tmpSize) == -1) + return NULL; + _arg1 = new wxString(tmpPtr, tmpSize); +#else + if (!PyString_Check(_obj1)) { + PyErr_SetString(PyExc_TypeError, wxStringErrorMsg); + return NULL; + } + _arg1 = new wxString(PyString_AS_STRING(_obj1), PyString_GET_SIZE(_obj1)); +#endif +} +{ + wxPy_BEGIN_ALLOW_THREADS; + wxStyledTextEvent_SetDragText(_arg0,*_arg1); + + wxPy_END_ALLOW_THREADS; +} Py_INCREF(Py_None); + _resultobj = Py_None; +{ + if (_obj1) + delete _arg1; +} + return _resultobj; +} + +#define wxStyledTextEvent_SetDragAllowMove(_swigobj,_swigarg0) (_swigobj->SetDragAllowMove(_swigarg0)) +static PyObject *_wrap_wxStyledTextEvent_SetDragAllowMove(PyObject *self, PyObject *args, PyObject *kwargs) { + PyObject * _resultobj; + wxStyledTextEvent * _arg0; + bool _arg1; + PyObject * _argo0 = 0; + int tempbool1; + char *_kwnames[] = { "self","val", NULL }; + + self = self; + if(!PyArg_ParseTupleAndKeywords(args,kwargs,"Oi:wxStyledTextEvent_SetDragAllowMove",_kwnames,&_argo0,&tempbool1)) + return NULL; + if (_argo0) { + if (_argo0 == Py_None) { _arg0 = NULL; } + else if (SWIG_GetPtrObj(_argo0,(void **) &_arg0,"_wxStyledTextEvent_p")) { + PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of wxStyledTextEvent_SetDragAllowMove. Expected _wxStyledTextEvent_p."); + return NULL; + } + } + _arg1 = (bool ) tempbool1; +{ + wxPy_BEGIN_ALLOW_THREADS; + wxStyledTextEvent_SetDragAllowMove(_arg0,_arg1); + + wxPy_END_ALLOW_THREADS; +} Py_INCREF(Py_None); + _resultobj = Py_None; + return _resultobj; +} + +#define wxStyledTextEvent_SetDragResult(_swigobj,_swigarg0) (_swigobj->SetDragResult(_swigarg0)) +static PyObject *_wrap_wxStyledTextEvent_SetDragResult(PyObject *self, PyObject *args, PyObject *kwargs) { + PyObject * _resultobj; + wxStyledTextEvent * _arg0; + wxDragResult _arg1; + PyObject * _argo0 = 0; + char *_kwnames[] = { "self","val", NULL }; + + self = self; + if(!PyArg_ParseTupleAndKeywords(args,kwargs,"Oi:wxStyledTextEvent_SetDragResult",_kwnames,&_argo0,&_arg1)) + return NULL; + if (_argo0) { + if (_argo0 == Py_None) { _arg0 = NULL; } + else if (SWIG_GetPtrObj(_argo0,(void **) &_arg0,"_wxStyledTextEvent_p")) { + PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of wxStyledTextEvent_SetDragResult. Expected _wxStyledTextEvent_p."); + return NULL; + } + } +{ + wxPy_BEGIN_ALLOW_THREADS; + wxStyledTextEvent_SetDragResult(_arg0,_arg1); + + wxPy_END_ALLOW_THREADS; +} Py_INCREF(Py_None); + _resultobj = Py_None; + return _resultobj; +} + #define wxStyledTextEvent_GetPosition(_swigobj) (_swigobj->GetPosition()) static PyObject *_wrap_wxStyledTextEvent_GetPosition(PyObject *self, PyObject *args, PyObject *kwargs) { PyObject * _resultobj; @@ -9679,6 +9788,92 @@ static PyObject *_wrap_wxStyledTextEvent_GetY(PyObject *self, PyObject *args, Py return _resultobj; } +#define wxStyledTextEvent_GetDragText(_swigobj) (_swigobj->GetDragText()) +static PyObject *_wrap_wxStyledTextEvent_GetDragText(PyObject *self, PyObject *args, PyObject *kwargs) { + PyObject * _resultobj; + wxString * _result; + wxStyledTextEvent * _arg0; + PyObject * _argo0 = 0; + char *_kwnames[] = { "self", NULL }; + + self = self; + if(!PyArg_ParseTupleAndKeywords(args,kwargs,"O:wxStyledTextEvent_GetDragText",_kwnames,&_argo0)) + return NULL; + if (_argo0) { + if (_argo0 == Py_None) { _arg0 = NULL; } + else if (SWIG_GetPtrObj(_argo0,(void **) &_arg0,"_wxStyledTextEvent_p")) { + PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of wxStyledTextEvent_GetDragText. Expected _wxStyledTextEvent_p."); + return NULL; + } + } +{ + wxPy_BEGIN_ALLOW_THREADS; + _result = new wxString (wxStyledTextEvent_GetDragText(_arg0)); + + wxPy_END_ALLOW_THREADS; +}{ + _resultobj = PyString_FromStringAndSize(_result->c_str(), _result->Len()); +} +{ + delete _result; +} + return _resultobj; +} + +#define wxStyledTextEvent_GetDragAllowMove(_swigobj) (_swigobj->GetDragAllowMove()) +static PyObject *_wrap_wxStyledTextEvent_GetDragAllowMove(PyObject *self, PyObject *args, PyObject *kwargs) { + PyObject * _resultobj; + bool _result; + wxStyledTextEvent * _arg0; + PyObject * _argo0 = 0; + char *_kwnames[] = { "self", NULL }; + + self = self; + if(!PyArg_ParseTupleAndKeywords(args,kwargs,"O:wxStyledTextEvent_GetDragAllowMove",_kwnames,&_argo0)) + return NULL; + if (_argo0) { + if (_argo0 == Py_None) { _arg0 = NULL; } + else if (SWIG_GetPtrObj(_argo0,(void **) &_arg0,"_wxStyledTextEvent_p")) { + PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of wxStyledTextEvent_GetDragAllowMove. Expected _wxStyledTextEvent_p."); + return NULL; + } + } +{ + wxPy_BEGIN_ALLOW_THREADS; + _result = (bool )wxStyledTextEvent_GetDragAllowMove(_arg0); + + wxPy_END_ALLOW_THREADS; +} _resultobj = Py_BuildValue("i",_result); + return _resultobj; +} + +#define wxStyledTextEvent_GetDragResult(_swigobj) (_swigobj->GetDragResult()) +static PyObject *_wrap_wxStyledTextEvent_GetDragResult(PyObject *self, PyObject *args, PyObject *kwargs) { + PyObject * _resultobj; + wxDragResult _result; + wxStyledTextEvent * _arg0; + PyObject * _argo0 = 0; + char *_kwnames[] = { "self", NULL }; + + self = self; + if(!PyArg_ParseTupleAndKeywords(args,kwargs,"O:wxStyledTextEvent_GetDragResult",_kwnames,&_argo0)) + return NULL; + if (_argo0) { + if (_argo0 == Py_None) { _arg0 = NULL; } + else if (SWIG_GetPtrObj(_argo0,(void **) &_arg0,"_wxStyledTextEvent_p")) { + PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of wxStyledTextEvent_GetDragResult. Expected _wxStyledTextEvent_p."); + return NULL; + } + } +{ + wxPy_BEGIN_ALLOW_THREADS; + _result = (wxDragResult )wxStyledTextEvent_GetDragResult(_arg0); + + wxPy_END_ALLOW_THREADS; +} _resultobj = Py_BuildValue("i",_result); + return _resultobj; +} + #define wxStyledTextEvent_GetShift(_swigobj) (_swigobj->GetShift()) static PyObject *_wrap_wxStyledTextEvent_GetShift(PyObject *self, PyObject *args, PyObject *kwargs) { PyObject * _resultobj; @@ -9801,6 +9996,9 @@ static PyMethodDef stc_cMethods[] = { { "wxStyledTextEvent_GetAlt", (PyCFunction) _wrap_wxStyledTextEvent_GetAlt, METH_VARARGS | METH_KEYWORDS }, { "wxStyledTextEvent_GetControl", (PyCFunction) _wrap_wxStyledTextEvent_GetControl, METH_VARARGS | METH_KEYWORDS }, { "wxStyledTextEvent_GetShift", (PyCFunction) _wrap_wxStyledTextEvent_GetShift, METH_VARARGS | METH_KEYWORDS }, + { "wxStyledTextEvent_GetDragResult", (PyCFunction) _wrap_wxStyledTextEvent_GetDragResult, METH_VARARGS | METH_KEYWORDS }, + { "wxStyledTextEvent_GetDragAllowMove", (PyCFunction) _wrap_wxStyledTextEvent_GetDragAllowMove, METH_VARARGS | METH_KEYWORDS }, + { "wxStyledTextEvent_GetDragText", (PyCFunction) _wrap_wxStyledTextEvent_GetDragText, METH_VARARGS | METH_KEYWORDS }, { "wxStyledTextEvent_GetY", (PyCFunction) _wrap_wxStyledTextEvent_GetY, METH_VARARGS | METH_KEYWORDS }, { "wxStyledTextEvent_GetX", (PyCFunction) _wrap_wxStyledTextEvent_GetX, METH_VARARGS | METH_KEYWORDS }, { "wxStyledTextEvent_GetListType", (PyCFunction) _wrap_wxStyledTextEvent_GetListType, METH_VARARGS | METH_KEYWORDS }, @@ -9818,6 +10016,9 @@ static PyMethodDef stc_cMethods[] = { { "wxStyledTextEvent_GetModifiers", (PyCFunction) _wrap_wxStyledTextEvent_GetModifiers, METH_VARARGS | METH_KEYWORDS }, { "wxStyledTextEvent_GetKey", (PyCFunction) _wrap_wxStyledTextEvent_GetKey, METH_VARARGS | METH_KEYWORDS }, { "wxStyledTextEvent_GetPosition", (PyCFunction) _wrap_wxStyledTextEvent_GetPosition, METH_VARARGS | METH_KEYWORDS }, + { "wxStyledTextEvent_SetDragResult", (PyCFunction) _wrap_wxStyledTextEvent_SetDragResult, METH_VARARGS | METH_KEYWORDS }, + { "wxStyledTextEvent_SetDragAllowMove", (PyCFunction) _wrap_wxStyledTextEvent_SetDragAllowMove, METH_VARARGS | METH_KEYWORDS }, + { "wxStyledTextEvent_SetDragText", (PyCFunction) _wrap_wxStyledTextEvent_SetDragText, METH_VARARGS | METH_KEYWORDS }, { "wxStyledTextEvent_SetY", (PyCFunction) _wrap_wxStyledTextEvent_SetY, METH_VARARGS | METH_KEYWORDS }, { "wxStyledTextEvent_SetX", (PyCFunction) _wrap_wxStyledTextEvent_SetX, METH_VARARGS | METH_KEYWORDS }, { "wxStyledTextEvent_SetListType", (PyCFunction) _wrap_wxStyledTextEvent_SetListType, METH_VARARGS | METH_KEYWORDS }, @@ -10755,6 +10956,9 @@ SWIGEXPORT(void) initstc_c() { PyDict_SetItemString(d,"wxEVT_STC_URIDROPPED", PyInt_FromLong((long) wxEVT_STC_URIDROPPED)); PyDict_SetItemString(d,"wxEVT_STC_DWELLSTART", PyInt_FromLong((long) wxEVT_STC_DWELLSTART)); PyDict_SetItemString(d,"wxEVT_STC_DWELLEND", PyInt_FromLong((long) wxEVT_STC_DWELLEND)); + PyDict_SetItemString(d,"wxEVT_STC_START_DRAG", PyInt_FromLong((long) wxEVT_STC_START_DRAG)); + PyDict_SetItemString(d,"wxEVT_STC_DRAG_OVER", PyInt_FromLong((long) wxEVT_STC_DRAG_OVER)); + PyDict_SetItemString(d,"wxEVT_STC_DO_DROP", PyInt_FromLong((long) wxEVT_STC_DO_DROP)); wxClassInfo::CleanUpClasses(); diff --git a/wxPython/contrib/stc/stc_.i b/wxPython/contrib/stc/stc_.i index 74a4694c58..fa4936e84c 100644 --- a/wxPython/contrib/stc/stc_.i +++ b/wxPython/contrib/stc/stc_.i @@ -96,6 +96,14 @@ def EVT_STC_DWELLSTART(win, id, func): def EVT_STC_DWELLEND(win, id, func): win.Connect(id, -1, wxEVT_STC_DWELLEND, func) +def EVT_STC_START_DRAG(win, id, func): + win.Connect(id, -1, wxEVT_STC_START_DRAG, func) + +def EVT_STC_DRAG_OVER(win, id, func): + win.Connect(id, -1, wxEVT_STC_DRAG_OVER, func) + +def EVT_STC_DO_DROP(win, id, func): + win.Connect(id, -1, wxEVT_STC_DO_DROP, func) " diff --git a/wxPython/contrib/stc/stc_.py b/wxPython/contrib/stc/stc_.py index 7fd978d5a0..f2434e5541 100644 --- a/wxPython/contrib/stc/stc_.py +++ b/wxPython/contrib/stc/stc_.py @@ -98,6 +98,14 @@ def EVT_STC_DWELLSTART(win, id, func): def EVT_STC_DWELLEND(win, id, func): win.Connect(id, -1, wxEVT_STC_DWELLEND, func) +def EVT_STC_START_DRAG(win, id, func): + win.Connect(id, -1, wxEVT_STC_START_DRAG, func) + +def EVT_STC_DRAG_OVER(win, id, func): + win.Connect(id, -1, wxEVT_STC_DRAG_OVER, func) + +def EVT_STC_DO_DROP(win, id, func): + win.Connect(id, -1, wxEVT_STC_DO_DROP, func) class wxStyledTextCtrlPtr(wxControlPtr): @@ -994,6 +1002,15 @@ class wxStyledTextEventPtr(wxCommandEventPtr): def SetY(self, *_args, **_kwargs): val = apply(stc_c.wxStyledTextEvent_SetY,(self,) + _args, _kwargs) return val + def SetDragText(self, *_args, **_kwargs): + val = apply(stc_c.wxStyledTextEvent_SetDragText,(self,) + _args, _kwargs) + return val + def SetDragAllowMove(self, *_args, **_kwargs): + val = apply(stc_c.wxStyledTextEvent_SetDragAllowMove,(self,) + _args, _kwargs) + return val + def SetDragResult(self, *_args, **_kwargs): + val = apply(stc_c.wxStyledTextEvent_SetDragResult,(self,) + _args, _kwargs) + return val def GetPosition(self, *_args, **_kwargs): val = apply(stc_c.wxStyledTextEvent_GetPosition,(self,) + _args, _kwargs) return val @@ -1045,6 +1062,15 @@ class wxStyledTextEventPtr(wxCommandEventPtr): def GetY(self, *_args, **_kwargs): val = apply(stc_c.wxStyledTextEvent_GetY,(self,) + _args, _kwargs) return val + def GetDragText(self, *_args, **_kwargs): + val = apply(stc_c.wxStyledTextEvent_GetDragText,(self,) + _args, _kwargs) + return val + def GetDragAllowMove(self, *_args, **_kwargs): + val = apply(stc_c.wxStyledTextEvent_GetDragAllowMove,(self,) + _args, _kwargs) + return val + def GetDragResult(self, *_args, **_kwargs): + val = apply(stc_c.wxStyledTextEvent_GetDragResult,(self,) + _args, _kwargs) + return val def GetShift(self, *_args, **_kwargs): val = apply(stc_c.wxStyledTextEvent_GetShift,(self,) + _args, _kwargs) return val @@ -1593,6 +1619,9 @@ wxEVT_STC_USERLISTSELECTION = stc_c.wxEVT_STC_USERLISTSELECTION wxEVT_STC_URIDROPPED = stc_c.wxEVT_STC_URIDROPPED wxEVT_STC_DWELLSTART = stc_c.wxEVT_STC_DWELLSTART wxEVT_STC_DWELLEND = stc_c.wxEVT_STC_DWELLEND +wxEVT_STC_START_DRAG = stc_c.wxEVT_STC_START_DRAG +wxEVT_STC_DRAG_OVER = stc_c.wxEVT_STC_DRAG_OVER +wxEVT_STC_DO_DROP = stc_c.wxEVT_STC_DO_DROP #-------------- USER INCLUDE ----------------------- diff --git a/wxPython/demo/data/stc.h.html b/wxPython/demo/data/stc.h.html index 81c8e33053..3ca2d5fbd2 100644 --- a/wxPython/demo/data/stc.h.html +++ b/wxPython/demo/data/stc.h.html @@ -28,6 +28,7 @@ #include <wx/wx.h> +#include <wx/dnd.h> //---------------------------------------------------------------------- // BEGIN generated section. The following code is automatically generated @@ -78,6 +79,7 @@ #define wxSTC_MARK_CIRCLEPLUSCONNECTED 19 #define wxSTC_MARK_CIRCLEMINUS 20 #define wxSTC_MARK_CIRCLEMINUSCONNECTED 21 +#define wxSTC_MARK_CHARACTER 10000 // Markers used for outlining column #define wxSTC_MARKNUM_FOLDEREND 25 @@ -89,12 +91,16 @@ #define wxSTC_MARKNUM_FOLDEROPEN 31 #define wxSTC_MARGIN_SYMBOL 0 #define wxSTC_MARGIN_NUMBER 1 + +// Styles in range 32..37 are predefined for parts of the UI and are not used as normal styles. +// Styles 38 and 39 are for future use. #define wxSTC_STYLE_DEFAULT 32 #define wxSTC_STYLE_LINENUMBER 33 #define wxSTC_STYLE_BRACELIGHT 34 #define wxSTC_STYLE_BRACEBAD 35 #define wxSTC_STYLE_CONTROLCHAR 36 #define wxSTC_STYLE_INDENTGUIDE 37 +#define wxSTC_STYLE_LASTPREDEFINED 39 #define wxSTC_STYLE_MAX 127 // Character set identifiers are used in StyleSetCharacterSet. @@ -301,6 +307,7 @@ #define wxSTC_LEX_EIFFEL 23 #define wxSTC_LEX_EIFFELKW 24 #define wxSTC_LEX_TCL 25 +#define wxSTC_LEX_NNCRONTAB 26 // When a lexer specifies its language as SCLEX_AUTOMATIC it receives a // value assigned in sequence from SCLEX_AUTOMATIC+1. @@ -340,6 +347,8 @@ #define wxSTC_C_REGEX 14 #define wxSTC_C_COMMENTLINEDOC 15 #define wxSTC_C_WORD2 16 +#define wxSTC_C_COMMENTDOCKEYWORD 17 +#define wxSTC_C_COMMENTDOCKEYWORDERROR 18 // Lexical states for SCLEX_HTML, SCLEX_XML #define wxSTC_H_DEFAULT 0 @@ -371,7 +380,17 @@ #define wxSTC_H_XCCOMMENT 20 // SGML -#define wxSTC_H_SGML 21 +#define wxSTC_H_SGML_DEFAULT 21 +#define wxSTC_H_SGML_COMMAND 22 +#define wxSTC_H_SGML_1ST_PARAM 23 +#define wxSTC_H_SGML_DOUBLESTRING 24 +#define wxSTC_H_SGML_SIMPLESTRING 25 +#define wxSTC_H_SGML_ERROR 26 +#define wxSTC_H_SGML_SPECIAL 27 +#define wxSTC_H_SGML_ENTITY 28 +#define wxSTC_H_SGML_COMMENT 29 +#define wxSTC_H_SGML_1ST_PARAM_COMMENT 30 +#define wxSTC_H_SGML_BLOCK_DEFAULT 31 // Embedded Javascript #define wxSTC_HJ_START 40 @@ -610,6 +629,19 @@ #define wxSTC_EIFFEL_IDENTIFIER 7 #define wxSTC_EIFFEL_STRINGEOL 8 +// Lexical states for the SCLEX_NNCRONTAB (nnCron crontab Lexer) +#define wxSTC_NNCRONTAB_DEFAULT 0 +#define wxSTC_NNCRONTAB_COMMENT 1 +#define wxSTC_NNCRONTAB_TASK 2 +#define wxSTC_NNCRONTAB_SECTION 3 +#define wxSTC_NNCRONTAB_KEYWORD 4 +#define wxSTC_NNCRONTAB_MODIFIER 5 +#define wxSTC_NNCRONTAB_ASTERISK 6 +#define wxSTC_NNCRONTAB_NUMBER 7 +#define wxSTC_NNCRONTAB_STRING 8 +#define wxSTC_NNCRONTAB_ENVIRONMENT 9 +#define wxSTC_NNCRONTAB_IDENTIFIER 10 + // END of generated section //---------------------------------------------------------------------- // Others @@ -637,6 +669,8 @@ const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = 0, const char* name = "styledtext"); + %pragma(python) addtomethod = "__init__:self._setOORInfo(self)" + #else wxStyledTextCtrl(wxWindow *parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition, @@ -740,7 +774,11 @@ // Retrieve the text of the line containing the caret. // Returns the index of the caret on the line. - wxString GetCurLine(int* OUTPUT=NULL); + #ifdef SWIG + wxString GetCurLine(int* OUTPUT); +#else + wxString GetCurLine(int* linePos=NULL); +#endif // Retrieve the position of the last correctly styled character. int GetEndStyled(); @@ -1223,10 +1261,12 @@ int GetTargetEnd(); // Replace the target text with the argument text. + // Text is counted so it can contain nulls. // Returns the length of the replacement text. int ReplaceTarget(const wxString& text); // Replace the target text with the argument text after \d processing. + // Text is counted so it can contain nulls. // Looks for \d where d is between 1 and 9 and replaces these with the strings // matched in the last search operation which were surrounded by \( and \). // Returns the length of the replacement text including any change @@ -1234,7 +1274,7 @@ int ReplaceTargetRE(const wxString& text); // Search for a counted string in the target and set the target to the found - // range. + // range. Text is counted so it can contain nulls. // Returns length of range or -1 for failure in which case target is not moved. int SearchInTarget(const wxString& text); @@ -1423,10 +1463,10 @@ int GetModEventMask(); // Change internal focus flag - void SetFocus(bool focus); + void SetSTCFocus(bool focus); // Get internal focus flag - bool GetFocus(); + bool GetSTCFocus(); // Change error status - 0 = OK void SetStatus(int statusCode); @@ -1588,6 +1628,7 @@ void NotifyChange(); void NotifyParent(SCNotification* scn); + private: DECLARE_EVENT_TABLE() DECLARE_CLASS(wxStyledTextCtrl) @@ -1595,6 +1636,7 @@ ScintillaWX* m_swx; wxStopWatch m_stopWatch; + bool m_lastKeyDownConsumed; friend class ScintillaWX; friend class Platform; @@ -1608,23 +1650,26 @@ wxStyledTextEvent(wxEventType commandType=0, int id=0); ~wxStyledTextEvent() {} - void SetPosition(int pos) { m_position = pos; } - void SetKey(int k) { m_key = k; } - void SetModifiers(int m) { m_modifiers = m; } - void SetModificationType(int t) { m_modificationType = t; } - void SetText(const char* t) { m_text = t; } - void SetLength(int len) { m_length = len; } - void SetLinesAdded(int num) { m_linesAdded = num; } - void SetLine(int val) { m_line = val; } - void SetFoldLevelNow(int val) { m_foldLevelNow = val; } - void SetFoldLevelPrev(int val) { m_foldLevelPrev = val; } - void SetMargin(int val) { m_margin = val; } - void SetMessage(int val) { m_message = val; } - void SetWParam(int val) { m_wParam = val; } - void SetLParam(int val) { m_lParam = val; } - void SetListType(int val) { m_listType = val; } - void SetX(int val) { m_x = val; } - void SetY(int val) { m_y = val; } + void SetPosition(int pos) { m_position = pos; } + void SetKey(int k) { m_key = k; } + void SetModifiers(int m) { m_modifiers = m; } + void SetModificationType(int t) { m_modificationType = t; } + void SetText(const char* t) { m_text = t; } + void SetLength(int len) { m_length = len; } + void SetLinesAdded(int num) { m_linesAdded = num; } + void SetLine(int val) { m_line = val; } + void SetFoldLevelNow(int val) { m_foldLevelNow = val; } + void SetFoldLevelPrev(int val) { m_foldLevelPrev = val; } + void SetMargin(int val) { m_margin = val; } + void SetMessage(int val) { m_message = val; } + void SetWParam(int val) { m_wParam = val; } + void SetLParam(int val) { m_lParam = val; } + void SetListType(int val) { m_listType = val; } + void SetX(int val) { m_x = val; } + void SetY(int val) { m_y = val; } + void SetDragText(const wxString& val) { m_dragText = val; } + void SetDragAllowMove(bool val) { m_dragAllowMove = val; } + void SetDragResult(wxDragResult val) { m_dragResult = val; } int GetPosition() const { return m_position; } int GetKey() const { return m_key; } @@ -1643,6 +1688,9 @@ int GetListType() const { return m_listType; } int GetX() const { return m_x; } int GetY() const { return m_y; } + wxString GetDragText() { return m_dragText; } + bool GetDragAllowMove() { return m_dragAllowMove; } + wxDragResult GetDragResult() { return m_dragResult; } bool GetShift() const; bool GetControl() const; @@ -1675,6 +1723,11 @@ int m_listType; int m_x; int m_y; + + wxString m_dragText; // wxEVT_STC_START_DRAG, wxEVT_STC_DO_DROP + bool m_dragAllowMove; // wxEVT_STC_START_DRAG + + wxDragResult m_dragResult; // wxEVT_STC_DRAG_OVER,wxEVT_STC_DO_DROP #endif }; @@ -1699,6 +1752,9 @@ BEGIN_DECLARE_EVENT_TYPES() DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_URIDROPPED, 1666) DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_DWELLSTART, 1667) DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_DWELLEND, 1668) + DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_START_DRAG, 1669) + DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_DRAG_OVER, 1670) + DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_DO_DROP, 1671) END_DECLARE_EVENT_TYPES() #else enum { @@ -1721,6 +1777,9 @@ END_DECLARE_EVENT_TYPES() wxEVT_STC_URIDROPPED, wxEVT_STC_DWELLSTART, wxEVT_STC_DWELLEND, + wxEVT_STC_START_DRAG, + wxEVT_STC_DRAG_OVER, + wxEVT_STC_DO_DROP, }; #endif @@ -1748,7 +1807,9 @@ END_DECLARE_EVENT_TYPES() #define EVT_STC_URIDROPPED(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_URIDROPPED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ), #define EVT_STC_DWELLSTART(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_DWELLSTART, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ), #define EVT_STC_DWELLEND(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_DWELLEND, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ), - +#define EVT_STC_START_DRAG(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_START_DRAG, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ), +#define EVT_STC_DRAG_OVER(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_DRAG_OVER, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ), +#define EVT_STC_DO_DROP(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_DO_DROP, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ), #endif diff --git a/wxPython/demo/wxStyledTextCtrl_1.py b/wxPython/demo/wxStyledTextCtrl_1.py index e3421d4727..c641f2d9fa 100644 --- a/wxPython/demo/wxStyledTextCtrl_1.py +++ b/wxPython/demo/wxStyledTextCtrl_1.py @@ -4,6 +4,9 @@ from wxPython.stc import * #---------------------------------------------------------------------- +debug = 1 + + demoText = """\ This editor is provided by a class named wxStyledTextCtrl. As @@ -52,9 +55,48 @@ class MySTC(wxStyledTextCtrl): wxStyledTextCtrl.__init__(self, parent, ID) self.log = log + EVT_STC_DO_DROP(self, ID, self.OnDoDrop) + EVT_STC_DRAG_OVER(self, ID, self.OnDragOver) + EVT_STC_START_DRAG(self, ID, self.OnStartDrag) EVT_STC_MODIFIED(self, ID, self.OnModified) + def OnStartDrag(self, evt): + self.log.write("OnStartDrag: %d, %s\n" + % (evt.GetDragAllowMove(), evt.GetDragText())) + + if debug and evt.GetPosition() < 250: + evt.SetDragAllowMove(false) # you can prevent moving of text (only copy) + evt.SetDragText("DRAGGED TEXT") # you can change what is dragged + #evt.SetDragText("") # or prevent the drag with empty text + + + def OnDragOver(self, evt): + self.log.write("OnDragOver: x,y=(%d, %d) pos: %d DragResult: %d\n" + % (evt.GetX(), evt.GetY(), evt.GetPosition(), evt.GetDragResult())) + + if debug and evt.GetPosition() < 250: + evt.SetDragResult(wxDragNone) # prevent dropping at the begining of the buffer + + + def OnDoDrop(self, evt): + self.log.write("OnDoDrop: x,y=(%d, %d) pos: %d DragResult: %d\n" + "\ttext: %s\n" + % (evt.GetX(), evt.GetY(), evt.GetPosition(), evt.GetDragResult(), + evt.GetDragText())) + + if debug and evt.GetPosition() < 500: + evt.SetDragText("DROPPED TEXT") # Can change text if needed + ##evt.SetDragResult(wxDragNone) # Can also change the drag operation, but it + # is probably better to do it in OnDragOver so + # there is visual feedback + + ##evt.SetPosition(25) # Can also change position, but I'm not sure why + # you would want to... + + + + def OnModified(self, evt): self.log.write("""OnModified Mod type: %s @@ -67,6 +109,7 @@ class MySTC(wxStyledTextCtrl): evt.GetLength(), evt.GetText() )) + def transModType(self, modType): st = "" table = [(wxSTC_MOD_INSERTTEXT, "InsertText"), @@ -93,6 +136,7 @@ class MySTC(wxStyledTextCtrl): + #---------------------------------------------------------------------- _USE_PANEL = 1 @@ -168,7 +212,7 @@ def runTest(frame, nb, log): ed.SetStyling(10, wxSTC_INDIC2_MASK | wxSTC_INDIC1_MASK) # some test stuff... - if 1: + if debug: print "GetTextLength(): ", ed.GetTextLength(), len(ed.GetText()) print "GetText(): ", repr(ed.GetText()) print diff --git a/wxPython/demo/wxStyledTextCtrl_2.py b/wxPython/demo/wxStyledTextCtrl_2.py index aefd323557..51a14386bd 100644 --- a/wxPython/demo/wxStyledTextCtrl_2.py +++ b/wxPython/demo/wxStyledTextCtrl_2.py @@ -116,7 +116,7 @@ class PythonSTC(wxStyledTextCtrl): self.SetCaretForeground("BLUE") - EVT_KEY_UP(self, self.OnKeyPressed) + EVT_KEY_DOWN(self, self.OnKeyPressed) def OnKeyPressed(self, event): -- 2.45.2