Fix wxSTC compilation without wxUSE_DRAG_AND_DROP after r65827.

Correct the changes of r65827 to also compile with wxUSE_DRAG_AND_DROP==0
(especially important for the ports without dnd support such as wxX11 and
wxDFB).

Also do the changes in the correct files, i.e. src/stc/stc.{h,cpp}.in and not
in the generated files themselves to prevent them from being overwritten the
next time gen_iface.py is ran.

Finally keep backwards compatibility as SetDragAllowMove(bool) is a public
method so preserve its old semantics and add a new SetDragFlags() instead of
silently breaking the existing code using SetDragAllowMove().

See #11709.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@65840 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin 2010-10-17 18:17:30 +00:00
parent 5f8bf0ee6f
commit 35f8d83dbb
5 changed files with 48 additions and 26 deletions

View File

@ -4325,10 +4325,20 @@ public:
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(int val) { m_dragAllowMove = val; }
#ifdef STC_USE_DND
void SetDragText(const wxString& val) { m_dragText = val; }
void SetDragFlags(int flags) { m_dragFlags = flags; }
void SetDragResult(wxDragResult val) { m_dragResult = val; }
// This method is kept mainly for backwards compatibility, use
// SetDragFlags() in the new code.
void SetDragAllowMove(bool allow)
{
if ( allow )
m_dragFlags |= wxDrag_AllowMove;
else
m_dragFlags &= ~(wxDrag_AllowMove | wxDrag_DefaultMove);
}
#endif
int GetPosition() const { return m_position; }
@ -4348,10 +4358,12 @@ public:
int GetListType() const { return m_listType; }
int GetX() const { return m_x; }
int GetY() const { return m_y; }
wxString GetDragText() { return m_dragText; }
int GetDragAllowMove() { return m_dragAllowMove; }
#ifdef STC_USE_DND
wxString GetDragText() { return m_dragText; }
int GetDragFlags() { return m_dragFlags; }
wxDragResult GetDragResult() { return m_dragResult; }
bool GetDragAllowMove() { return (GetDragFlags() & wxDrag_AllowMove) != 0; }
#endif
bool GetShift() const;
@ -4386,11 +4398,10 @@ private:
int m_x;
int m_y;
wxString m_dragText; // wxEVT_STC_START_DRAG, wxEVT_STC_DO_DROP
int m_dragAllowMove; // wxEVT_STC_START_DRAG
#if wxUSE_DRAG_AND_DROP
wxDragResult m_dragResult; // wxEVT_STC_DRAG_OVER,wxEVT_STC_DO_DROP
wxString m_dragText; // wxEVT_STC_START_DRAG, wxEVT_STC_DO_DROP
int m_dragFlags; // wxEVT_STC_START_DRAG
wxDragResult m_dragResult; // wxEVT_STC_DRAG_OVER,wxEVT_STC_DO_DROP
#endif
#endif
};

View File

@ -283,7 +283,7 @@ void ScintillaWX::StartDrag() {
wxStyledTextEvent evt(wxEVT_STC_START_DRAG, stc->GetId());
evt.SetEventObject(stc);
evt.SetDragText(dragText);
evt.SetDragAllowMove(wxDrag_DefaultMove);
evt.SetDragFlags(wxDrag_DefaultMove);
evt.SetPosition(wxMin(stc->GetSelectionStart(),
stc->GetSelectionEnd()));
stc->GetEventHandler()->ProcessEvent(evt);
@ -297,7 +297,7 @@ void ScintillaWX::StartDrag() {
source.SetData(data);
dropWentOutside = true;
inDragDrop = ddDragging;
result = source.DoDragDrop(evt.GetDragAllowMove());
result = source.DoDragDrop(evt.GetDragFlags());
if (result == wxDragMove && dropWentOutside)
ClearSelection();
inDragDrop = ddNone;

View File

@ -595,7 +595,7 @@ void wxStyledTextCtrl::MarkerDefineBitmap(int markerNumber, const wxBitmap& bmp)
buff[len] = 0;
SendMsg(2049, markerNumber, (sptr_t)buff);
delete [] buff;
}
// Add a set of markers to a line.
@ -1190,7 +1190,7 @@ void wxStyledTextCtrl::RegisterImage(int type, const wxBitmap& bmp) {
buff[len] = 0;
SendMsg(2405, type, (sptr_t)buff);
delete [] buff;
}
// Clear all the registered images.
@ -4573,8 +4573,8 @@ wxStyledTextEvent::wxStyledTextEvent(wxEventType commandType, int id)
m_listType = 0;
m_x = 0;
m_y = 0;
m_dragAllowMove = wxDrag_CopyOnly;
#if wxUSE_DRAG_AND_DROP
m_dragFlags = wxDrag_CopyOnly;
m_dragResult = wxDragNone;
#endif
}
@ -4608,9 +4608,9 @@ wxStyledTextEvent::wxStyledTextEvent(const wxStyledTextEvent& event):
m_x = event.m_x;
m_y = event.m_y;
m_dragText = event.m_dragText;
m_dragAllowMove =event.m_dragAllowMove;
#if wxUSE_DRAG_AND_DROP
m_dragText = event.m_dragText;
m_dragFlags = event.m_dragFlags;
m_dragResult = event.m_dragResult;
#endif
}

View File

@ -1073,8 +1073,8 @@ wxStyledTextEvent::wxStyledTextEvent(wxEventType commandType, int id)
m_listType = 0;
m_x = 0;
m_y = 0;
m_dragAllowMove = false;
#if wxUSE_DRAG_AND_DROP
m_dragFlags = wxDrag_CopyOnly;
m_dragResult = wxDragNone;
#endif
}
@ -1108,9 +1108,9 @@ wxStyledTextEvent::wxStyledTextEvent(const wxStyledTextEvent& event):
m_x = event.m_x;
m_y = event.m_y;
m_dragText = event.m_dragText;
m_dragAllowMove =event.m_dragAllowMove;
#if wxUSE_DRAG_AND_DROP
m_dragText = event.m_dragText;
m_dragFlags = event.m_dragFlags;
m_dragResult = event.m_dragResult;
#endif
}

View File

@ -523,10 +523,20 @@ public:
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; }
#ifdef STC_USE_DND
void SetDragText(const wxString& val) { m_dragText = val; }
void SetDragFlags(int flags) { m_dragFlags = flags; }
void SetDragResult(wxDragResult val) { m_dragResult = val; }
// This method is kept mainly for backwards compatibility, use
// SetDragFlags() in the new code.
void SetDragAllowMove(bool allow)
{
if ( allow )
m_dragFlags |= wxDrag_AllowMove;
else
m_dragFlags &= ~(wxDrag_AllowMove | wxDrag_DefaultMove);
}
#endif
int GetPosition() const { return m_position; }
@ -546,10 +556,12 @@ 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; }
#ifdef STC_USE_DND
wxString GetDragText() { return m_dragText; }
int GetDragFlags() { return m_dragFlags; }
wxDragResult GetDragResult() { return m_dragResult; }
bool GetDragAllowMove() { return (GetDragFlags() & wxDrag_AllowMove) != 0; }
#endif
bool GetShift() const;
@ -584,11 +596,10 @@ private:
int m_x;
int m_y;
wxString m_dragText; // wxEVT_STC_START_DRAG, wxEVT_STC_DO_DROP
bool m_dragAllowMove; // wxEVT_STC_START_DRAG
#if wxUSE_DRAG_AND_DROP
wxDragResult m_dragResult; // wxEVT_STC_DRAG_OVER,wxEVT_STC_DO_DROP
wxString m_dragText; // wxEVT_STC_START_DRAG, wxEVT_STC_DO_DROP
int m_dragFlags; // wxEVT_STC_START_DRAG
wxDragResult m_dragResult; // wxEVT_STC_DRAG_OVER,wxEVT_STC_DO_DROP
#endif
#endif
};