eliminate GCC warning about initialization order
[reactos.git] / reactos / subsys / system / explorer / shell / shellbrowser.h
index 18360e9..1de9369 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2003, 2004 Martin Fuchs
+ * 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
@@ -50,14 +50,19 @@ struct ShellPathInfo
 
 struct BrowserCallback
 {
+       virtual ~BrowserCallback() {}
        virtual void entry_selected(Entry* entry) = 0;
 };
 
 
  /// Implementation of IShellBrowserImpl interface in explorer child windows
 struct ShellBrowser : public IShellBrowserImpl
+#ifndef __MINGW32__    // IShellFolderViewCB missing in MinGW (as of 25.09.2005)
+       ,       public IComSrvBase<IShellFolderViewCB, ShellBrowser>, public SimpleComObject
+#endif
 {
-       ShellBrowser(HWND hwnd, HWND left_hwnd, WindowHandle& right_hwnd, ShellPathInfo& create_info, HIMAGELIST himl, BrowserCallback* cb);
+       ShellBrowser(HWND hwnd, HWND hwndFrame, HWND left_hwnd, WindowHandle& right_hwnd, ShellPathInfo& create_info,
+                                       BrowserCallback* cb, CtxMenuInterfaces& cm_ifs);
        virtual ~ShellBrowser();
 
        //IOleWindow
@@ -85,7 +90,7 @@ struct ShellBrowser : public IShellBrowserImpl
                        return S_OK;
                }
 
-               HWND hwnd = (HWND)SendMessage(_hWndFrame, PM_GET_CONTROLWINDOW, id, 0);
+               HWND hwnd = (HWND)SendMessage(_hwndFrame, PM_GET_CONTROLWINDOW, id, 0);
 
                if (hwnd) {
                        *lphwnd = hwnd;
@@ -100,7 +105,7 @@ struct ShellBrowser : public IShellBrowserImpl
                if (!pret)
                        return E_POINTER;
 
-               HWND hstatusbar = (HWND)SendMessage(_hWndFrame, PM_GET_CONTROLWINDOW, id, 0);
+               HWND hstatusbar = (HWND)SendMessage(_hwndFrame, PM_GET_CONTROLWINDOW, id, 0);
 
                if (hstatusbar) {
                        *pret = ::SendMessage(hstatusbar, uMsg, wParam, lParam);
@@ -117,13 +122,7 @@ struct ShellBrowser : public IShellBrowserImpl
        void    OnTreeItemRClick(int idCtrl, LPNMHDR pnmh);
        void    OnTreeItemSelected(int idCtrl, LPNMTREEVIEW pnmtv);
 
-       LRESULT Init(HWND hWndFrame);
-
-       void    Init(HIMAGELIST himl)
-       {
-               InitializeTree(himl);
-               InitDragDrop();
-       }
+       void    Init();
 
        int             InsertSubitems(HTREEITEM hParentItem, Entry* entry, IShellFolder* pParentFolder);
 
@@ -134,33 +133,60 @@ struct ShellBrowser : public IShellBrowserImpl
        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();
+
 protected:
-       HWND    _hwnd;
-       HWND    _left_hwnd;
-       WindowHandle& _right_hwnd;
-       ShellPathInfo& _create_info;
-       HIMAGELIST      _himl;
+       HWND                    _hwnd;
+       HWND                    _hwndFrame;
+       HWND                    _left_hwnd;
+       WindowHandle&   _right_hwnd;
+       ShellPathInfo&  _create_info;
+       HIMAGELIST              _himl;
+       HIMAGELIST              _himl_old;
        BrowserCallback* _callback;
 
-       WindowHandle _hWndFrame;
-       ShellFolder     _folder;
+       ShellFolder             _folder;
 
-       IShellView*     _pShellView;    // current hosted shellview
-       TreeDropTarget* _pDropTarget;
+       IShellView*             _pShellView;    // current hosted shellview
+       TreeDropTarget* _pDropTarget;
 
-       HTREEITEM _last_sel;
+       HTREEITEM               _last_sel;
 
-       Root    _root;
+       Root                    _root;
        ShellDirectory* _cur_dir;
 
-       void    InitializeTree(HIMAGELIST himl);
+       CtxMenuInterfaces& _cm_ifs;
+
+       void    InitializeTree();
        bool    InitDragDrop();
 
-        // for SDIMainFrame
-       void    jump_to(LPCITEMIDLIST pidl);
+#ifndef __MINGW32__    // IShellFolderViewCB missing in MinGW (as of 25.09.2005)
+       typedef IComSrvBase<IShellFolderViewCB, ShellBrowser> super;
+
+        // IShellFolderViewCB
+       virtual HRESULT STDMETHODCALLTYPE MessageSFVCB(UINT uMsg, WPARAM wParam, LPARAM lParam);
+#endif
+
+       map<int, int> _image_map;
+
+       int             get_image_idx(int icon_id);
 };
 
 
+#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
 {
@@ -170,28 +196,14 @@ template<typename BASE> struct ShellBrowserChildT
        ShellBrowserChildT(HWND hwnd)
         :      super(hwnd)
        {
-               _himlSmall = 0;
        }
 
         // constructor for MDIShellBrowserChild
        ShellBrowserChildT(HWND hwnd, const ShellChildWndInfo& info)
         :      super(hwnd, info)
        {
-               _himlSmall = 0;
        }
 
-       void init_himl()
-       {
-               SHFILEINFO sfi;
-
-               _himlSmall = (HIMAGELIST)SHGetFileInfo(TEXT("C:\\"), 0, &sfi, sizeof(SHFILEINFO), SHGFI_SYSICONINDEX|SHGFI_SMALLICON);
-//             _himlLarge = (HIMAGELIST)SHGetFileInfo(TEXT("C:\\"), 0, &sfi, sizeof(SHFILEINFO), SHGFI_SYSICONINDEX|SHGFI_LARGEICON);
-       }
-
-protected:
-       HIMAGELIST      _himlSmall;             // list
-//     HIMAGELIST      _himlLarge;             // shell image
-
 protected:
        auto_ptr<ShellBrowser> _shellBrowser;
 
@@ -213,7 +225,7 @@ protected:
 
        int Notify(int id, NMHDR* pnmh)
        {
-               if (&*_shellBrowser)
+               if (_shellBrowser.get())
                        switch(pnmh->code) {
                          case TVN_GETDISPINFO:         _shellBrowser->OnTreeGetDispInfo(id, pnmh);                                     break;
                          case TVN_SELCHANGED:          _shellBrowser->OnTreeItemSelected(id, (LPNMTREEVIEW)pnmh);      break;
@@ -231,9 +243,13 @@ protected:
 
 #ifndef _NO_MDI
 
-struct MDIShellBrowserChild : public ShellBrowserChildT<ChildWindow>
+struct MDIShellBrowserChild : public ExtContextMenuHandlerT<
+                               ShellBrowserChildT<ChildWindow>
+                       >
 {
-       typedef ShellBrowserChildT<ChildWindow> super;
+       typedef ExtContextMenuHandlerT<
+                               ShellBrowserChildT<ChildWindow>
+                       > super;
 
        MDIShellBrowserChild(HWND hwnd, const ShellChildWndInfo& info);
 
@@ -252,7 +268,7 @@ protected:
        void    update_shell_browser();
 
         // interface BrowserCallback
-       virtual void    entry_selected(Entry* entry);
+       virtual void entry_selected(Entry* entry);
 };
 
 #endif