8658ca0d3814b1e7c126963d91ac6a1914c194e5
[reactos.git] / subsys / system / explorer / Seashell / SeaShellExt / Include / UIDragDropTree.h
1 //*******************************************************************************
2 // COPYRIGHT NOTES
3 // ---------------
4 // You may use this source code, compile or redistribute it as part of your application 
5 // for free. You cannot redistribute it as a part of a software development 
6 // library without the agreement of the author. If the sources are 
7 // distributed along with the application, you should leave the original 
8 // copyright notes in the source code without any changes.
9 // This code can be used WITHOUT ANY WARRANTIES at your own risk.
10 // 
11 // For the latest updates to this code, check this site:
12 // http://www.masmex.com 
13 // after Sept 2000
14 // 
15 // Copyright(C) 2000 Philip Oldaker <email: philip@masmex.com>
16 //*******************************************************************************
17
18 #if !defined(AFX_DRAGDROPTREE_H__072E5B93_FD2A_11D0_ADBE_0000E81B9EF1__INCLUDED_)
19 #define AFX_DRAGDROPTREE_H__072E5B93_FD2A_11D0_ADBE_0000E81B9EF1__INCLUDED_
20
21 #if _MSC_VER >= 1000
22 #pragma once
23 #endif // _MSC_VER >= 1000
24 // DragDropTree.h : header file
25 //
26
27 #include "UIImageDropTarget.h"
28 // ///////////////////////////////////////////////////////////////////////////
29 class CUI_TreeDropTarget : public CUI_ImageDropTarget
30 {
31 public:
32         virtual DROPEFFECT OnDragEnter( CWnd* pWnd, COleDataObject* pDataObject, DWORD dwKeyState, CPoint point );
33         virtual DROPEFFECT OnDragOver( CWnd* pWnd, COleDataObject* pDataObject, DWORD dwKeyState, CPoint point );
34         virtual BOOL OnDrop( CWnd* pWnd, COleDataObject* pDataObject, DROPEFFECT dropEffect, CPoint point );
35         virtual void OnDragLeave( CWnd* pWnd);
36 protected:
37         DWORD m_dwKeyboardState;
38         DWORD m_dwEnterKeyboardState;
39 };
40
41 /////////////////////////////////////////////////////////////////////////////
42 // CUIDragDropTree window
43
44 class CTRL_EXT_CLASS CUIDragDropTree : public CTreeCtrl
45 {
46         friend class CUI_TreeDropTarget;
47 // Construction
48 public:
49         DECLARE_DYNAMIC(CUIDragDropTree)
50         CUIDragDropTree(bool bDragDrop=true);
51
52 // Attributes
53 public:
54         enum CopyMode
55         {
56                 eDDNull,
57                 eDDMove,
58                 eDDCopy,
59                 eDDCancel
60         };
61         enum SCROLLMODE
62           {
63                 SCROLL_UP_SLOW,
64                 SCROLL_DOWN_SLOW,
65                 SCROLL_UP_NORMAL,
66                 SCROLL_DOWN_NORMAL
67           };
68
69         const COleDropTarget &GetDropTarget();
70
71 // Operations
72 public:
73         void RegisterDropTarget();
74         void SetDragTimer();
75         void KillDragTimer();
76
77         virtual DROPEFFECT SelectCurrentTarget(CDD_OleDropTargetInfo *pInfo);
78 // Overrides
79         // ClassWizard generated virtual function overrides
80         //{{AFX_VIRTUAL(CUIDragDropTree)
81         //}}AFX_VIRTUAL
82
83 // Implementation
84 public:
85         virtual ~CUIDragDropTree();
86
87 protected:
88         HTREEITEM GetDragItem();
89         HTREEITEM GetDropItem();
90         virtual BOOL    IsChildNodeOf(HTREEITEM hitemChild, HTREEITEM hitemSuspectedParent);
91         virtual BOOL            NeedToScroll( CPoint ptMouse );
92         virtual SCROLLMODE      RefineScrollMode( CPoint ptMouse );
93         virtual BOOL    TransferItem(HTREEITEM hitem, HTREEITEM hNewParent);
94         virtual void OnButtonUp(bool bMove);
95         virtual void OnDropFile(HTREEITEM hItem,LPCTSTR pszFile,UINT nFlags);
96         virtual void NewTransferItem(HTREEITEM hNewItem);
97         virtual BOOL StartDragDrop(NM_TREEVIEW* pNMTreeView);
98         virtual bool GetRDragMenu(CMenu *pMenu);
99         virtual void EndDragging();
100         // Generated message map functions
101 protected:
102         //{{AFX_MSG(CUIDragDropTree)
103         afx_msg BOOL OnBegindrag(NMHDR* pNMHDR, LRESULT* pResult);
104         afx_msg BOOL OnBeginRDrag(NMHDR* pNMHDR, LRESULT* pResult);
105         afx_msg void OnTimer(UINT nIDEvent);
106         afx_msg void OnRButtonUp(UINT nFlags, CPoint point);
107         afx_msg void OnMouseMove(UINT nFlags, CPoint point);
108         afx_msg void OnDestroy();
109         afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
110         afx_msg void OnDropFiles( HDROP hDropInfo);
111         afx_msg void OnDDMove();
112         afx_msg void OnDDCopy();
113         afx_msg void OnDDCancel();
114         //}}AFX_MSG
115
116         DECLARE_MESSAGE_MAP()
117 private:
118         bool m_bDragDrop;
119         bool m_bDropFiles;
120         CImageList*     m_pImageList;
121         BOOL            m_bDragging;
122         HTREEITEM       m_hitemDrag;
123         HTREEITEM       m_hitemDrop;
124         UINT    m_nTimerID;
125         int             m_nSlowScrollTimeout;
126         int             m_nUpperYCoor;
127         int             m_nLowerYCoor;  
128         int             m_nScrollBarSize;
129         CUI_TreeDropTarget m_OleDropTarget;
130         COleDataSource m_OleDataSource;
131 protected:
132         CopyMode                m_CopyMode;
133 public:
134         void SetDragDrop(bool bDragDrop);
135         bool GetDragDrop();
136         void SetDropFiles(bool bDropFiles);
137         bool GetDropFiles();
138 };
139
140 inline void CUIDragDropTree::SetDragDrop(bool bDragDrop)
141 {
142         m_bDragDrop = bDragDrop;
143 }
144
145 inline bool CUIDragDropTree::GetDragDrop()
146 {
147         return m_bDragDrop;
148 }
149
150 inline void CUIDragDropTree::SetDropFiles(bool bDropFiles)
151 {
152         m_bDropFiles = bDropFiles;
153 }
154
155 inline bool CUIDragDropTree::GetDropFiles()
156 {
157         return m_bDropFiles;
158 }
159
160 inline const COleDropTarget &CUIDragDropTree::GetDropTarget()
161 {
162         return m_OleDropTarget;
163 }
164
165 inline HTREEITEM CUIDragDropTree::GetDragItem()
166 {
167         return m_hitemDrag;
168 }
169
170 inline HTREEITEM CUIDragDropTree::GetDropItem()
171 {
172         return m_hitemDrop;
173 }
174
175 /////////////////////////////////////////////////////////////////////////////
176
177 //{{AFX_INSERT_LOCATION}}
178 // Microsoft Developer Studio will insert additional declarations immediately before the previous line.
179
180 #endif // !defined(AFX_DRAGDROPTREE_H__072E5B93_FD2A_11D0_ADBE_0000E81B9EF1__INCLUDED_)