- Use a separate icon for minimizing windows.
[reactos.git] / reactos / subsys / system / explorer / globals.h
index 2bc0a56..99f8ffd 100644 (file)
@@ -18,7 +18,7 @@
 
 
  //
- // Explorer clone, lean version
+ // Explorer clone
  //
  // globals.h
  //
  //
 
 
+#include "utility/xmlstorage.h"
+
+using namespace XMLStorage;
+
+#include "taskbar/favorites.h"
+
+
  /// management of file types
 struct FileTypeInfo {
        String  _classname;
@@ -73,6 +80,8 @@ enum ICON_ID {
        ICID_NETWORK,
        ICID_COMPUTER,
        ICID_LOGOFF,
+       ICID_BOOKMARK,
+    ICID_MINIMIZE,
 
        ICID_DYNAMIC
 };
@@ -87,8 +96,10 @@ struct Icon {
 
        void    draw(HDC hdc, int x, int y, int cx, int cy, COLORREF bk_color, HBRUSH bk_brush) const;
        HBITMAP create_bitmap(COLORREF bk_color, HBRUSH hbrBkgnd, HDC hdc_wnd) const;
+       int             add_to_imagelist(HIMAGELIST himl, HDC hdc_wnd, COLORREF bk_color=GetSysColor(COLOR_WINDOW), HBRUSH bk_brush=GetSysColorBrush(COLOR_WINDOW)) const;
 
        int             get_sysiml_idx() const {return _itype==IT_SYSCACHE? _sys_idx: -1;}
+       HICON   get_hicon() const {return _itype!=IT_SYSCACHE? _hicon: 0;}
 
        bool    destroy() {if (_itype == IT_DYNAMIC) {DestroyIcon(_hicon); return true;} else return false;}
 
@@ -105,19 +116,20 @@ struct SysCacheIcon : public Icon {
 };
 
 struct IconCache {
-       IconCache() : _himlSys(0) {}
+       IconCache() : _himlSys_small(0) {}
 
        void    init();
 
-       const Icon&     extract(const String& path);
-       const Icon&     extract(LPCTSTR path, int idx);
-       const Icon&     extract(IExtractIcon* pExtract, LPCTSTR path, int idx);
+       const Icon&     extract(LPCTSTR path, ICONCACHE_FLAGS flags=ICF_NORMAL);
+       const Icon&     extract(LPCTSTR path, int idx, ICONCACHE_FLAGS flags=ICF_HICON);
+       const Icon&     extract(IExtractIcon* pExtract, LPCTSTR path, int idx, ICONCACHE_FLAGS flags=ICF_HICON);
 
        const Icon&     add(HICON hIcon, ICON_TYPE type=IT_DYNAMIC);
        const Icon&     add(int sys_idx/*, ICON_TYPE type=IT_SYSCACHE*/);
 
        const Icon&     get_icon(int icon_id);
-       HIMAGELIST get_sys_imagelist() const {return _himlSys;}
+
+       HIMAGELIST get_sys_imagelist() const {return _himlSys_small;}
 
        void    free_icon(int icon_id);
 
@@ -127,22 +139,67 @@ protected:
        typedef map<int, Icon> IconMap;
        IconMap _icons;
 
-       typedef map<String, ICON_ID> PathMap;
-       PathMap _pathMap;
+       typedef pair<String,int/*ICONCACHE_FLAGS*/> CacheKey;
+       typedef map<CacheKey, ICON_ID> PathCacheMap;
+       PathCacheMap _pathCache;
 
-       typedef pair<String, int> CachePair;
-       typedef map<CachePair, ICON_ID> PathIdxMap;
-       PathIdxMap _pathIdxMap;
+       typedef pair<String,pair<int,int/*ICONCACHE_FLAGS*/> > IdxCacheKey;
+       typedef map<IdxCacheKey, ICON_ID> IdxCacheMap;
+       IdxCacheMap _idxCache;
 
-       HIMAGELIST _himlSys;
+       HIMAGELIST _himlSys_small;
 };
 
 
+#define        ICON_SIZE_X             GetSystemMetrics(large_icons? SM_CXICON: SM_CXSMICON)
+#define        ICON_SIZE_Y             GetSystemMetrics(large_icons? SM_CYICON: SM_CYSMICON)
+
+
  /// create a bitmap from an icon
-extern HBITMAP create_bitmap_from_icon(HICON hIcon, HBRUSH hbrush_bkgnd, HDC hdc_wnd);
+extern HBITMAP create_bitmap_from_icon(HICON hIcon, HBRUSH hbrush_bkgnd, HDC hdc_wnd/*, bool large_icons*/);
+
+ /// add icon with alpha channel to imagelist using the specified background color
+extern int ImageList_AddAlphaIcon(HIMAGELIST himl, HICON hIcon, HBRUSH hbrush_bkgnd, HDC hdc_wnd);
+
+ /// retrieve icon from window
+extern HICON get_window_icon_small(HWND hwnd);
+extern HICON get_window_icon_big(HWND hwnd, bool allow_from_class=true);
 
 
  /// desktop management
+#ifdef _USE_HDESK
+
+typedef auto_ptr<struct DesktopThread> DesktopThreadPtr;
+
+struct Desktop
+{
+       HDESK   _hdesktop;
+//     HWINSTA _hwinsta;
+       DesktopThreadPtr _pThread;
+       WindowHandle _hwndDesktop;
+
+       Desktop(HDESK hdesktop=0/*, HWINSTA hwinsta=0*/);
+       ~Desktop();
+};
+
+typedef auto_ptr<Desktop> DesktopPtr;
+typedef DesktopPtr DesktopRef;
+
+ /// Thread class for additional desktops
+struct DesktopThread : public Thread
+{
+       DesktopThread(Desktop& desktop)
+        :      _desktop(desktop)
+       {
+       }
+
+       int     Run();
+
+protected:
+       Desktop&        _desktop;
+};
+
+#else
 
 typedef pair<HWND, DWORD> MinimizeStruct;
 
@@ -154,6 +211,8 @@ struct Desktop
 };
 typedef Desktop DesktopRef;
 
+#endif
+
 
 #define        DESKTOP_COUNT   4
 
@@ -166,6 +225,10 @@ struct Desktops : public vector<DesktopRef>
        void    SwitchToDesktop(int idx);
        void    ToggleMinimize();
 
+#ifdef _USE_HDESK
+       DesktopRef& get_current_Desktop() {return (*this)[_current_desktop];}
+#endif
+
        int             _current_desktop;
 };
 
@@ -175,14 +238,23 @@ extern struct ExplorerGlobals
 {
        ExplorerGlobals();
 
-       void            init(HINSTANCE hInstance);
+       void    init(HINSTANCE hInstance);
+
+       void    read_persistent();
+       void    write_persistent();
+
+       XMLPos  get_cfg();
+       XMLPos  get_cfg(const char* path);
 
        HINSTANCE       _hInstance;
-       ATOM            _hframeClass;
        UINT            _cfStrFName;
+
+#ifndef ROSSHELL
+       ATOM            _hframeClass;
        HWND            _hMainWnd;
-       bool            _prescan_nodes;
        bool            _desktop_mode;
+       bool            _prescan_nodes;
+#endif
 
        FILE*           _log;
 
@@ -198,6 +270,13 @@ extern struct ExplorerGlobals
        HWND            _hwndDesktop;
 
        Desktops        _desktops;
+
+       XMLDoc          _cfg;
+       String          _cfg_dir;
+       String          _cfg_path;
+
+       Favorites       _favorites;
+       String          _favorites_path;
 } g_Globals;