Something went wrong. Try again.
Reactos
Something went wrong. Try again.
6.5 kB · 275 lines
C
at master
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276/* * Copyright 2003, 2004, 2005 Martin Fuchs * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */
// // Explorer clone // // shellbrowser.h // // Martin Fuchs, 23.07.2003 //
#include "../utility/treedroptarget.h"#include "../utility/shellbrowserimpl.h"
#include <memory>
/// information structure to hold current shell folder informationstruct ShellPathInfo{ ShellPathInfo(int mode=0) : _open_mode(mode) {}
ShellPathInfo(const ShellChildWndInfo& info) : _shell_path(info._shell_path), _root_shell_path(info._root_shell_path), _open_mode(info._open_mode) { }
ShellPath _shell_path; ShellPath _root_shell_path;
int _open_mode; //OPEN_WINDOW_MODE};
struct BrowserCallback{ virtual ~BrowserCallback() {} virtual void entry_selected(Entry* entry) = 0;};
/// Implementation of IShellBrowserImpl interface in explorer child windowsstruct ShellBrowser : public IShellBrowserImpl, public IComSrvBase<IShellFolderViewCB, ShellBrowser>, public SimpleComObject{ ShellBrowser(HWND hwnd, HWND hwndFrame, HWND left_hwnd, WindowHandle& right_hwnd, ShellPathInfo& create_info, BrowserCallback* cb, CtxMenuInterfaces& cm_ifs); virtual ~ShellBrowser();
//IOleWindow virtual HRESULT STDMETHODCALLTYPE GetWindow(HWND* lphwnd) { *lphwnd = _hwnd; return S_OK; }
//IShellBrowser virtual HRESULT STDMETHODCALLTYPE QueryActiveShellView(IShellView** ppshv) { _pShellView->AddRef(); *ppshv = _pShellView; return S_OK; }
virtual HRESULT STDMETHODCALLTYPE GetControlWindow(UINT id, HWND* lphwnd) { if (!lphwnd) return E_POINTER;
if (id == FCW_TREE) { *lphwnd = _left_hwnd; return S_OK; }
HWND hwnd = (HWND)SendMessage(_hwndFrame, PM_GET_CONTROLWINDOW, id, 0);
if (hwnd) { *lphwnd = hwnd; return S_OK; }
return E_NOTIMPL; }
virtual HRESULT STDMETHODCALLTYPE SendControlMsg(UINT id, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT* pret) { if (!pret) return E_POINTER;
HWND hstatusbar = (HWND)SendMessage(_hwndFrame, PM_GET_CONTROLWINDOW, id, 0);
if (hstatusbar) { *pret = ::SendMessage(hstatusbar, uMsg, wParam, lParam); return S_OK; }
return E_NOTIMPL; }
const Root& get_root() const {return _root;}
void OnTreeGetDispInfo(int idCtrl, LPNMHDR pnmh); void OnTreeItemExpanding(int idCtrl, LPNMTREEVIEW pnmtv); void OnTreeItemRClick(int idCtrl, LPNMHDR pnmh); void OnTreeItemSelected(int idCtrl, LPNMTREEVIEW pnmtv);
void Init();
int InsertSubitems(HTREEITEM hParentItem, Entry* entry, IShellFolder* pParentFolder);
bool jump_to_pidl(LPCITEMIDLIST pidl);
HRESULT OnDefaultCommand(LPIDA pida);
void UpdateFolderView(IShellFolder* folder); HTREEITEM select_entry(HTREEITEM hitem, Entry* entry, bool expand=true);
bool select_folder(Entry* entry, bool expand);
// for SDIMainFrame void jump_to(LPCITEMIDLIST pidl);
void invalidate_cache();
bool TranslateAccelerator(LPMSG lpmsg);
protected: HWND _hwnd; HWND _hwndFrame; HWND _left_hwnd; WindowHandle& _right_hwnd; ShellPathInfo& _create_info; HIMAGELIST _himl; HIMAGELIST _himl_old; BrowserCallback* _callback;
ShellFolder _folder;
IShellView* _pShellView; // current hosted shellview TreeDropTarget* _pDropTarget;
HTREEITEM _last_sel;
Root _root; ShellDirectory* _cur_dir;
CtxMenuInterfaces& _cm_ifs;
void InitializeTree(); bool InitDragDrop();
typedef IComSrvBase<IShellFolderViewCB, ShellBrowser> super;
// IShellFolderViewCB virtual HRESULT STDMETHODCALLTYPE MessageSFVCB(UINT uMsg, WPARAM wParam, LPARAM lParam);
map<int, int> _image_map;
int get_image_idx(int icon_id);
void refresh();};
#define C_DRIVE_STR TEXT("C:\\")
// work around GCC's wide string constant bug#ifdef __GNUC__extern const LPCTSTR C_DRIVE;#else#define C_DRIVE C_DRIVE_STR#endif
template<typename BASE> struct ShellBrowserChildT : public BASE, public BrowserCallback{ typedef BASE super;
// constructor for SDIMainFrame ShellBrowserChildT(HWND hwnd) : super(hwnd) { }
// constructor for MDIShellBrowserChild ShellBrowserChildT(HWND hwnd, const ShellChildWndInfo& info) : super(hwnd, info) { }
protected: auto_ptr<ShellBrowser> _shellBrowser;
LRESULT WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam) { switch(nmsg) { case PM_GET_SHELLBROWSER_PTR: return (LRESULT)&*_shellBrowser;
case WM_GETISHELLBROWSER: // for Registry Explorer Plugin return (LRESULT)static_cast<IShellBrowser*>(&*_shellBrowser);
default: return super::WndProc(nmsg, wparam, lparam); }
return 0; }
int Notify(int id, NMHDR* pnmh) { if (_shellBrowser.get()) switch(pnmh->code) { case TVN_GETDISPINFO: _shellBrowser->OnTreeGetDispInfo(id, pnmh); break; case TVN_SELCHANGED: _shellBrowser->OnTreeItemSelected(id, (LPNMTREEVIEW)pnmh); break; case TVN_ITEMEXPANDING: _shellBrowser->OnTreeItemExpanding(id, (LPNMTREEVIEW)pnmh); break; case NM_RCLICK: _shellBrowser->OnTreeItemRClick(id, pnmh); break; default: return super::Notify(id, pnmh); } else return super::Notify(id, pnmh);
return 0; }};
#ifndef _NO_MDI
struct MDIShellBrowserChild : public ExtContextMenuHandlerT< ShellBrowserChildT<ChildWindow> >{ typedef ExtContextMenuHandlerT< ShellBrowserChildT<ChildWindow> > super;
MDIShellBrowserChild(HWND hwnd, const ShellChildWndInfo& info);
static MDIShellBrowserChild* create(const ShellChildWndInfo& info);
LRESULT Init(LPCREATESTRUCT);
virtual String jump_to_int(LPCTSTR url);
protected: ShellChildWndInfo _create_info; ShellPathInfo _shellpath_info;
LRESULT WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam);
void update_shell_browser();
// interface BrowserCallback virtual void entry_selected(Entry* entry);};
#endif