update for HEAD-2003091401
[reactos.git] / subsys / system / explorer / shell / shellbrowser.h
1 /*
2  * Copyright 2003 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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17  */
18
19
20  //
21  // Explorer clone
22  //
23  // shellbrowser.h
24  //
25  // Martin Fuchs, 23.07.2003
26  //
27
28 #include "../utility/treedroptarget.h"
29 #include "../utility/shellbrowserimpl.h"
30
31
32 struct ShellBrowserChild : public ChildWindow, public IShellBrowserImpl
33 {
34         typedef ChildWindow super;
35
36         ShellBrowserChild(HWND hwnd, const ShellChildWndInfo& info);
37         ~ShellBrowserChild();
38
39         static ShellBrowserChild* create(HWND hmdiclient, const FileChildWndInfo& info)
40         {
41 #ifndef _NO_MDI
42                 ChildWindow* child = ChildWindow::create(hmdiclient, info._pos.rcNormalPosition,
43                                                                                                         WINDOW_CREATOR_INFO(ShellBrowserChild,ShellChildWndInfo), CLASSNAME_CHILDWND, NULL, &info);
44 #else
45                 //TODO: SDI implementation
46 #endif
47
48                 ShowWindow(*child, info._pos.showCmd);
49
50                 return static_cast<ShellBrowserChild*>(child);
51         }
52
53         //IOleWindow
54         STDMETHOD(GetWindow)(HWND* lphwnd)
55         {
56                 *lphwnd = _hwnd;
57                 return S_OK;
58         }
59
60         //IShellBrowser
61         STDMETHOD(QueryActiveShellView)(IShellView** ppshv)
62         {
63                 _pShellView->AddRef();
64                 *ppshv = _pShellView;
65                 return S_OK;
66         }
67
68         STDMETHOD(GetControlWindow)(UINT id, HWND* lphwnd)
69         {
70                 if (!lphwnd)
71                         return E_POINTER;
72
73                 if (id == FCW_TREE) {
74                         *lphwnd = _left_hwnd;
75                         return S_OK;
76                 }
77
78                 HWND hwnd = (HWND)SendMessage(_hWndFrame, PM_GET_CONTROLWINDOW, id, 0);
79
80                 if (hwnd) {
81                         *lphwnd = hwnd;
82                         return S_OK;
83                 }
84
85                 return E_NOTIMPL;
86         }
87
88         STDMETHOD(SendControlMsg)(UINT id, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT* pret)
89         {
90                 if (!pret)
91                         return E_POINTER;
92
93                 HWND hstatusbar = (HWND)SendMessage(_hWndFrame, PM_GET_CONTROLWINDOW, id, 0);
94
95                 if (hstatusbar) {
96                         *pret = ::SendMessage(hstatusbar, uMsg, wParam, lParam);
97                         return S_OK;
98                 }
99
100                 return E_NOTIMPL;
101         }
102
103         STDMETHOD(OnDefaultCommand)(IShellView* ppshv);
104
105 protected:
106         Root _root;
107
108         WindowHandle _hWndFrame;
109         ShellChildWndInfo _create_info;
110
111         IShellView*     _pShellView;    // current hosted shellview
112         HIMAGELIST      _himlSmall;             // list
113 //      HIMAGELIST      _himlLarge;             // shell image
114         TreeDropTarget* _pDropTarget;
115
116         HTREEITEM _last_sel;
117
118         LRESULT WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam);
119         int     Notify(int id, NMHDR* pnmh);
120
121         LRESULT Init(LPCREATESTRUCT);
122         void    InitializeTree(/*const FileChildWndInfo& info*/);
123         void    InsertSubitems(HTREEITEM hParentItem, Entry* entry, IShellFolder* pParentFolder);
124         bool    InitDragDrop();
125
126         void    OnTreeGetDispInfo(int idCtrl, LPNMHDR pnmh);
127         void    OnTreeItemExpanding(int idCtrl, LPNMTREEVIEW pnmtv);
128         void    OnTreeItemRClick(int idCtrl, LPNMHDR pnmh);
129         void    OnTreeItemSelected(int idCtrl, LPNMTREEVIEW pnmtv);
130
131         void    UpdateFolderView(IShellFolder* folder);
132         void    Tree_DoItemMenu(HWND hwndTreeView, HTREEITEM hItem, LPPOINT pptScreen);
133         bool    expand_folder(ShellDirectory* entry);
134 };