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
35 struct FileTypeManager
: public map
<String
, FileTypeInfo
>
37 typedef map
<String
, FileTypeInfo
> super
;
39 const FileTypeInfo
& operator[](String ext
);
77 Icon(ICON_ID id
, UINT nid
);
78 Icon(ICON_TYPE itype
, int id
, HICON hIcon
);
79 Icon(ICON_TYPE itype
, int id
, int sys_idx
);
81 operator ICON_ID() const {return _id
;}
83 void draw(HDC hdc
, int x
, int y
, int cx
, int cy
, COLORREF bk_color
, HBRUSH bk_brush
) const;
84 HBITMAP
create_bitmap(COLORREF bk_color
, HBRUSH hbrBkgnd
, HDC hdc_wnd
) const;
86 int get_sysiml_idx() const {return _itype
==IT_SYSCACHE
? _sys_idx
: -1;}
88 bool destroy() {if (_itype
== IT_DYNAMIC
) {DestroyIcon(_hicon
); return true;} else return false;}
97 struct SysCacheIcon
: public Icon
{
98 SysCacheIcon(int id
, int sys_idx
)
99 : Icon(IT_SYSCACHE
, id
, sys_idx
) {}
103 IconCache() : _himlSys(0) {}
107 const Icon
& extract(const String
& path
);
108 const Icon
& extract(LPCTSTR path
, int idx
);
109 const Icon
& extract(IExtractIcon
* pExtract
, LPCTSTR path
, int idx
);
111 const Icon
& add(HICON hIcon
, ICON_TYPE type
=IT_DYNAMIC
);
112 const Icon
& add(int sys_idx
/*, ICON_TYPE type=IT_SYSCACHE*/);
114 const Icon
& get_icon(int icon_id
);
115 HIMAGELIST
get_sys_imagelist() const {return _himlSys
;}
117 void free_icon(int icon_id
);
120 static int s_next_id
;
122 typedef map
<int, Icon
> IconMap
;
125 typedef map
<String
, ICON_ID
> PathMap
;
128 typedef pair
<String
, int> CachePair
;
129 typedef map
<CachePair
, ICON_ID
> PathIdxMap
;
130 PathIdxMap _pathIdxMap
;
136 /// create a bitmap from an icon
137 extern HBITMAP
create_bitmap_from_icon(HICON hIcon
, HBRUSH hbrush_bkgnd
, HDC hdc_wnd
);
140 /// structure containing global variables of Explorer
141 extern struct ExplorerGlobals
145 void init(HINSTANCE hInstance
);
147 HINSTANCE _hInstance
;
156 #ifndef __MINGW32__ // SHRestricted() missing in MinGW (as of 29.10.2003)
157 DWORD(STDAPICALLTYPE
* _SHRestricted
)(RESTRICTIONS
);
160 FileTypeManager _ftype_mgr
;
161 IconCache _icon_cache
;
163 HWND _hwndDesktopBar
;
168 /// convenient loading of string resources
169 struct ResString
: public String
174 /// convenient loading of standard (32x32) icon resources
179 operator HICON() const {return _hicon
;}
185 /// convenient loading of small (16x16) icon resources
190 operator HICON() const {return _hicon
;}
196 /// convenient loading of icon resources with specified sizes
199 ResIconEx(UINT nid
, int w
, int h
);
201 operator HICON() const {return _hicon
;}
207 /// set big and small icons out of the resources for a window
208 extern void SetWindowIcon(HWND hwnd
, UINT nid
);
210 /// convenient loading of bitmap resources
214 ~ResBitmap() {DeleteObject(_hBmp
);}
216 operator HBITMAP() const {return _hBmp
;}