2 * Copyright 2003 Martin Fuchs
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.
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.
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
25 // Martin Fuchs, 23.07.2003
29 /// management of file types
36 struct FileTypeManager
: public map
<String
, FileTypeInfo
>
38 typedef map
<String
, FileTypeInfo
> super
;
40 const FileTypeInfo
& operator[](String ext
);
42 static bool is_exe_file(LPCTSTR ext
);
44 LPCTSTR
set_type(struct Entry
* entry
, bool dont_hide_ext
=false);
82 Icon(ICON_ID id
, UINT nid
);
83 Icon(ICON_TYPE itype
, int id
, HICON hIcon
);
84 Icon(ICON_TYPE itype
, int id
, int sys_idx
);
86 operator ICON_ID() const {return _id
;}
88 void draw(HDC hdc
, int x
, int y
, int cx
, int cy
, COLORREF bk_color
, HBRUSH bk_brush
) const;
89 HBITMAP
create_bitmap(COLORREF bk_color
, HBRUSH hbrBkgnd
, HDC hdc_wnd
) const;
91 int get_sysiml_idx() const {return _itype
==IT_SYSCACHE
? _sys_idx
: -1;}
93 bool destroy() {if (_itype
== IT_DYNAMIC
) {DestroyIcon(_hicon
); return true;} else return false;}
102 struct SysCacheIcon
: public Icon
{
103 SysCacheIcon(int id
, int sys_idx
)
104 : Icon(IT_SYSCACHE
, id
, sys_idx
) {}
108 IconCache() : _himlSys(0) {}
112 const Icon
& extract(const String
& path
);
113 const Icon
& extract(LPCTSTR path
, int idx
);
114 const Icon
& extract(IExtractIcon
* pExtract
, LPCTSTR path
, int idx
);
116 const Icon
& add(HICON hIcon
, ICON_TYPE type
=IT_DYNAMIC
);
117 const Icon
& add(int sys_idx
/*, ICON_TYPE type=IT_SYSCACHE*/);
119 const Icon
& get_icon(int icon_id
);
120 HIMAGELIST
get_sys_imagelist() const {return _himlSys
;}
122 void free_icon(int icon_id
);
125 static int s_next_id
;
127 typedef map
<int, Icon
> IconMap
;
130 typedef map
<String
, ICON_ID
> PathMap
;
133 typedef pair
<String
, int> CachePair
;
134 typedef map
<CachePair
, ICON_ID
> PathIdxMap
;
135 PathIdxMap _pathIdxMap
;
141 /// create a bitmap from an icon
142 extern HBITMAP
create_bitmap_from_icon(HICON hIcon
, HBRUSH hbrush_bkgnd
, HDC hdc_wnd
);
145 /// desktop management
148 typedef auto_ptr
<struct DesktopThread
> DesktopThreadPtr
;
154 DesktopThreadPtr _pThread
;
155 WindowHandle _hwndDesktop
;
157 Desktop(HDESK hdesktop
=0/*, HWINSTA hwinsta=0*/);
161 typedef auto_ptr
<Desktop
> DesktopPtr
;
162 typedef DesktopPtr DesktopRef
;
164 /// Thread class for additional desktops
165 struct DesktopThread
: public Thread
167 DesktopThread(Desktop
& desktop
)
184 typedef Desktop DesktopRef
;
189 #define DESKTOP_COUNT 4
191 struct Desktops
: public vector
<DesktopRef
>
197 void SwitchToDesktop(int idx
);
200 DesktopRef
& get_current_Desktop() {return (*this)[_current_desktop
];}
203 int _current_desktop
;
207 /// structure containing global variables of Explorer
208 extern struct ExplorerGlobals
212 void init(HINSTANCE hInstance
);
214 HINSTANCE _hInstance
;
223 #ifndef __MINGW32__ // SHRestricted() missing in MinGW (as of 29.10.2003)
224 DWORD(STDAPICALLTYPE
* _SHRestricted
)(RESTRICTIONS
);
227 FileTypeManager _ftype_mgr
;
228 IconCache _icon_cache
;
230 HWND _hwndDesktopBar
;
238 /// convenient loading of string resources
239 struct ResString
: public String
244 /// convenient loading of standard (32x32) icon resources
249 operator HICON() const {return _hicon
;}
255 /// convenient loading of small (16x16) icon resources
260 operator HICON() const {return _hicon
;}
266 /// convenient loading of icon resources with specified sizes
269 ResIconEx(UINT nid
, int w
, int h
);
271 operator HICON() const {return _hicon
;}
277 /// set big and small icons out of the resources for a window
278 extern void SetWindowIcon(HWND hwnd
, UINT nid
);
280 /// convenient loading of bitmap resources
284 ~ResBitmap() {DeleteObject(_hBmp
);}
286 operator HBITMAP() const {return _hBmp
;}