[EXPLORER][EXPLORER_NEW]
[reactos.git] / base / shell / explorer / desktop / desktop.h
1 /*
2 * Copyright 2003, 2004 Martin Fuchs
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18
19
20 //
21 // Explorer clone
22 //
23 // desktop.h
24 //
25 // Martin Fuchs, 09.08.2003
26 //
27
28
29 #define PM_SET_ICON_ALGORITHM (WM_APP+0x19)
30 #define PM_GET_ICON_ALGORITHM (WM_APP+0x1A)
31 #define PM_DISPLAY_VERSION (WM_APP+0x24)
32
33
34 /// subclassed background window behind the visible desktop window
35 struct BackgroundWindow : public SubclassedWindow
36 {
37 typedef SubclassedWindow super;
38
39 BackgroundWindow(HWND hwnd);
40
41 protected:
42 LRESULT WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam);
43
44 void DrawDesktopBkgnd(HDC hdc);
45
46 int _display_version;
47 };
48
49
50 /// Implementation of the Explorer desktop window
51 struct DesktopWindow : public PreTranslateWindow, public IShellBrowserImpl
52 {
53 typedef PreTranslateWindow super;
54
55 DesktopWindow(HWND hwnd);
56 ~DesktopWindow();
57
58 static HWND Create();
59
60 virtual HRESULT STDMETHODCALLTYPE GetWindow(HWND* lphwnd)
61 {
62 *lphwnd = _hwnd;
63 return S_OK;
64 }
65
66 virtual HRESULT STDMETHODCALLTYPE QueryActiveShellView(IShellView** ppshv)
67 {
68 _pShellView->AddRef();
69 *ppshv = _pShellView;
70 return S_OK;
71 }
72
73 virtual HRESULT STDMETHODCALLTYPE GetControlWindow(UINT id, HWND* lphwnd)
74 {
75 return E_NOTIMPL;
76 }
77
78 virtual HRESULT STDMETHODCALLTYPE SendControlMsg(UINT id, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT* pret)
79 {
80 return E_NOTIMPL;
81 }
82
83 protected:
84 LRESULT Init(LPCREATESTRUCT pcs);
85 LRESULT WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam);
86
87 IShellView* _pShellView;
88 WindowHandle _desktopBar;
89
90 virtual HRESULT OnDefaultCommand(LPIDA pida);
91 };
92
93
94 /// OLE drop target for the desktop window
95 class DesktopDropTarget : public IDropTargetImpl
96 {
97 typedef IDropTargetImpl super;
98
99 public:
100 DesktopDropTarget(HWND hTargetWnd) : super(hTargetWnd) {}
101
102 virtual bool OnDrop(FORMATETC* pFmtEtc, STGMEDIUM& medium, DWORD *pdwEffect)
103 {
104 if (pFmtEtc->cfFormat==CF_HDROP && medium.tymed==TYMED_HGLOBAL) {
105 HDROP hDrop = (HDROP)GlobalLock(medium.hGlobal);
106
107 if (hDrop) {
108 TCHAR szFileName[MAX_PATH];
109
110 UINT cFiles = DragQueryFile(hDrop, 0xFFFFFFFF, NULL, 0);
111
112 for(UINT i=0; i<cFiles; ++i) {
113 DragQueryFile(hDrop, i, szFileName, sizeof(szFileName) / sizeof(szFileName[0]));
114
115 if (DROPEFFECT_COPY & *pdwEffect) {
116 // copy the file or dir
117
118 ///@todo Add the code to handle Copy
119
120 } else if (DROPEFFECT_MOVE & *pdwEffect) {
121 // move the file or dir
122
123 ///@todo Add the code to handle Move
124
125 }
126 }
127 //DragFinish(hDrop); // base class calls ReleaseStgMedium
128 }
129
130 GlobalUnlock(medium.hGlobal);
131 }
132
133 //@@TreeView_SelectDropTarget(m_hTargetWnd, NULL);
134
135 return true; //let base free the medium
136 }
137
138 virtual HRESULT STDMETHODCALLTYPE DragOver(
139 /* [in] */ DWORD grfKeyState,
140 /* [in] */ POINTL pt,
141 /* [out][in] */ DWORD __RPC_FAR *pdwEffect)
142 {
143 TVHITTESTINFO hit;
144 hit.pt.x = pt.x;
145 hit.pt.y = pt.y;
146 ScreenToClient(m_hTargetWnd, &hit.pt);
147 hit.flags = TVHT_ONITEM;
148
149 /*@@
150 HTREEITEM hItem = TreeView_HitTest(m_hTargetWnd,&hit);
151
152 if (hItem != NULL)
153 TreeView_SelectDropTarget(m_hTargetWnd, hItem);
154 */
155
156 return super::DragOver(grfKeyState, pt, pdwEffect);
157 }
158
159 virtual HRESULT STDMETHODCALLTYPE DragLeave(void)
160 {
161 //@@ TreeView_SelectDropTarget(m_hTargetWnd, NULL);
162
163 return super::DragLeave();
164 }
165 };
166
167
168 /// subclassed ShellView window
169 struct DesktopShellView : public ExtContextMenuHandlerT<SubclassedWindow>
170 {
171 typedef ExtContextMenuHandlerT<SubclassedWindow> super;
172
173 DesktopShellView(HWND hwnd, IShellView* pShellView);
174 ~DesktopShellView();
175
176 bool InitDragDrop();
177
178 protected:
179 IShellView* _pShellView;
180
181 LRESULT WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam);
182 int Command(int id, int code);
183 int Notify(int id, NMHDR* pnmh);
184
185 bool DoContextMenu(int x, int y);
186 HRESULT DoDesktopContextMenu(int x, int y);
187 void PositionIcons(int dir=1);
188
189 void refresh();
190
191 HWND _hwndListView;
192 int _icon_algo;
193 };