1
#ifndef _WX_FNB_DROP_TARGET_H
2
#define _WX_FNB_DROP_TARGET_H
8
\brief Contains the information about dragged page (page index and container).
12
wxWindow * m_Container;
17
\param container - pointer to wxPageContainer object which contains dragged page
18
\param pageindex - index of dragged page
20
wxFNBDragInfo(wxWindow * container, int pageindex) : m_Container(container), m_PageIndex(pageindex){}
23
* \brief default constructor
25
wxFNBDragInfo() : m_Container(0), m_PageIndex(0){}
28
Returns wxPageContainer object which contains dragged page
30
wxWindow * GetContainer() {return m_Container;}
33
Returns the index of dragged page
35
int GetPageIndex() {return m_PageIndex;}
38
class wxFNBDragInfoDataObject : public wxDataObjectSimple
41
wxFNBDragInfoDataObject(const wxDataFormat& format):wxDataObjectSimple(format)
44
wxFNBDragInfo DragInfo;
46
wxFNBDragInfo *GetData()
51
// get the size of our data
52
virtual size_t GetDataSize() const
53
{ return sizeof(wxFNBDragInfo); }
55
// copy our data to the buffer
56
virtual bool GetDataHere(void *buf) const
58
memcpy(buf, &DragInfo, sizeof(wxFNBDragInfo));
62
// copy data from buffer to our data
63
virtual bool SetData(size_t WXUNUSED(len), const void *buf)
65
// don't check the len. Under Win98 the value of 'len' == 0
66
memcpy(&DragInfo, buf, sizeof(wxFNBDragInfo));
72
\brief Used for processing drag-n-drop opeartions
75
class wxFNBDropTarget : public wxDropTarget
78
typedef wxDragResult (T::*pt2Func)(wxCoord, wxCoord, int, wxWindow *);
80
pt2Func m_pt2CallbackFunc;
81
wxFNBDragInfoDataObject * m_DataObject;
85
\param pParent - Object that will handle drag-n-drop operation
86
\param pt2CallbackFunc - Pointer to callback method which should be called after dragging the notebook page
88
wxFNBDropTarget(T* pParent, pt2Func pt2CallbackFunc)
90
, m_pt2CallbackFunc(pt2CallbackFunc)
93
m_DataObject = new wxFNBDragInfoDataObject(wxDataFormat(wxT("wxFNB")));
94
SetDataObject(m_DataObject);
97
\brief Virtual Destructor
99
virtual ~wxFNBDropTarget(void) {}
101
\brief Used for processing drop operation
102
\param x - X-coordinate
103
\param y - Y-coordinate
104
\param def - Result of drag-n-drop operation
106
virtual wxDragResult OnData(wxCoord x, wxCoord y, wxDragResult WXUNUSED(def))
109
wxFNBDragInfo * draginfo = (wxFNBDragInfo *)m_DataObject->GetData();
114
return (m_pParent->*m_pt2CallbackFunc)(x, y, draginfo->GetPageIndex(), (T *)draginfo->GetContainer());
119
* \ingroup wxFlatNotebook
120
* This class represents a source for a drag and drop operation
121
* We override wxDropSource class to provide user with a feedback
130
class wxFNBDropSource : public wxDropSource
135
* Parameterized constructor
141
wxFNBDropSource(wxWindow* win = NULL)
150
virtual ~wxFNBDropSource()
155
* give some custom UI feedback during the drag and drop operation in this function. It is called on each mouse move, so your implementation must not be too slow
156
* \param effect The effect to implement. One of wxDragCopy, wxDragMove, wxDragLink and wxDragNone
159
virtual bool GiveFeedback(wxDragResult effect);