#include <globals.h>
Public Member Functions | |
| IconCache () | |
| virtual | ~IconCache () |
| void | init () |
| const Icon & | extract (LPCTSTR path, ICONCACHE_FLAGS flags=ICF_NORMAL) |
| const Icon & | extract (LPCTSTR path, int icon_idx, ICONCACHE_FLAGS flags=ICF_HICON) |
| const Icon & | extract (IExtractIcon *pExtract, LPCTSTR path, int icon_idx, ICONCACHE_FLAGS flags=ICF_HICON) |
| const Icon & | extract (LPCITEMIDLIST pidl, ICONCACHE_FLAGS flags=ICF_NORMAL) |
| const Icon & | add (HICON hIcon, ICON_TYPE type=IT_DYNAMIC) |
| const Icon & | add (int sys_idx) |
| const Icon & | get_icon (int icon_id) |
| HIMAGELIST | get_sys_imagelist () const |
| void | free_icon (int icon_id) |
Protected Types | |
| typedef map< int, Icon > | IconMap |
| typedef pair< String, int > | CacheKey |
| typedef map< CacheKey, ICON_ID > | PathCacheMap |
| typedef pair< String, pair < int, int > > | IdxCacheKey |
| typedef map< IdxCacheKey, ICON_ID > | IdxCacheMap |
| typedef pair< ShellPath, int > | PidlCacheKey |
| typedef map< PidlCacheKey, ICON_ID > | PidlCacheMap |
Protected Attributes | |
| IconMap | _icons |
| PathCacheMap | _pathCache |
| IdxCacheMap | _idxCache |
| PidlCacheMap | _pidlcache |
| HIMAGELIST | _himlSys_small |
Static Protected Attributes | |
| static int | s_next_id = ICID_DYNAMIC |
Definition at line 127 of file globals.h.
typedef pair<String,int> IconCache::CacheKey [protected] |
typedef map<int, Icon> IconCache::IconMap [protected] |
typedef pair<String,pair<int,int> > IconCache::IdxCacheKey [protected] |
typedef map<IdxCacheKey, ICON_ID> IconCache::IdxCacheMap [protected] |
typedef map<CacheKey, ICON_ID> IconCache::PathCacheMap [protected] |
typedef pair<ShellPath,int> IconCache::PidlCacheKey [protected] |
typedef map<PidlCacheKey, ICON_ID> IconCache::PidlCacheMap [protected] |
| IconCache::IconCache | ( | ) | [inline] |
Definition at line 128 of file globals.h.
: _himlSys_small(0) {}
| IconCache::~IconCache | ( | ) | [virtual] |
Definition at line 634 of file explorer.cpp.
{
/* We don't need to free cached resources - they are automatically freed at process termination
for (int index = s_next_id; index >= 0; index--) {
IconMap::iterator found = _icons.find(index);
if (found != _icons.end()) {
Icon& icon = found->second;
if ((icon.get_icontype() == IT_DYNAMIC) ||
(icon.get_icontype() == IT_CACHED))
{
DestroyIcon(icon.get_hicon());
_icons.erase(found);
}
}
}
*/
}
| const Icon & IconCache::add | ( | int | sys_idx ) |
Definition at line 622 of file explorer.cpp.
References _icons, and s_next_id.
{
int id = ++s_next_id;
return _icons[id] = SysCacheIcon(id, sys_idx);
}
| const Icon & IconCache::extract | ( | IExtractIcon * | pExtract, |
| LPCTSTR | path, | ||
| int | icon_idx, | ||
| ICONCACHE_FLAGS | flags = ICF_HICON |
||
| ) |
Definition at line 522 of file explorer.cpp.
References _icons, add(), ICID_NONE, ICON_SIZE_FROM_ICF, and ICON_SIZE_SMALL.
{
HICON hIconLarge = 0;
HICON hIcon;
int icon_size = ICON_SIZE_FROM_ICF(flags);
HRESULT hr = pExtract->Extract(path, icon_idx, &hIconLarge, &hIcon, MAKELONG(GetSystemMetrics(SM_CXICON), icon_size));
if (hr == NOERROR) { //@@ oder SUCCEEDED(hr) ?
if (icon_size > ICON_SIZE_SMALL) { //@@ OK?
if (hIcon)
DestroyIcon(hIcon);
hIcon = hIconLarge;
} else {
if (hIconLarge)
DestroyIcon(hIconLarge);
}
if (hIcon)
return add(hIcon); //@@ When do we want not to free this icons?
}
return _icons[ICID_NONE];
}
| const Icon & IconCache::extract | ( | LPCITEMIDLIST | pidl, |
| ICONCACHE_FLAGS | flags = ICF_NORMAL |
||
| ) |
Definition at line 548 of file explorer.cpp.
References _icons, _pidlcache, add(), ICF_HICON, ICF_LARGE, ICF_MIDDLE, ICF_OPEN, ICF_OVERLAYS, ICF_SYSCACHE, ICID_NONE, IT_CACHED, and SHGFI_ADDOVERLAYS.
{
// search for matching icon with unchanged flags in the cache
PidlCacheKey mapkey(pidl, flags);
PidlCacheMap::iterator found = _pidlcache.find(mapkey);
if (found != _pidlcache.end())
return _icons[found->second];
// search for matching icon with handle
PidlCacheKey mapkey_hicon(pidl, flags|ICF_HICON);
if (flags != mapkey_hicon.second) {
found = _pidlcache.find(mapkey_hicon);
if (found != _pidlcache.end())
return _icons[found->second];
}
// search for matching icon in the system image list cache
PidlCacheKey mapkey_syscache(pidl, flags|ICF_SYSCACHE);
if (flags != mapkey_syscache.second) {
found = _pidlcache.find(mapkey_syscache);
if (found != _pidlcache.end())
return _icons[found->second];
}
SHFILEINFO sfi;
int shgfi_flags = SHGFI_PIDL;
if (!(flags & (ICF_LARGE|ICF_MIDDLE)))
shgfi_flags |= SHGFI_SMALLICON;
if (flags & ICF_OPEN)
shgfi_flags |= SHGFI_OPENICON;
if (flags & ICF_SYSCACHE) {
assert(!(flags&ICF_OVERLAYS));
HIMAGELIST himlSys = (HIMAGELIST) SHGetFileInfo((LPCTSTR)pidl, 0, &sfi, sizeof(sfi), SHGFI_SYSICONINDEX|shgfi_flags);
if (himlSys) {
const Icon& icon = add(sfi.iIcon/*, IT_SYSCACHE*/);
///@todo limit cache size
_pidlcache[mapkey_syscache] = icon;
return icon;
}
} else {
if (flags & ICF_OVERLAYS)
shgfi_flags |= SHGFI_ADDOVERLAYS;
if (SHGetFileInfo((LPCTSTR)pidl, 0, &sfi, sizeof(sfi), SHGFI_ICON|shgfi_flags)) {
const Icon& icon = add(sfi.hIcon, IT_CACHED);
///@todo limit cache size
_pidlcache[mapkey_hicon] = icon;
return icon;
}
}
return _icons[ICID_NONE];
}
| const Icon & IconCache::extract | ( | LPCTSTR | path, |
| ICONCACHE_FLAGS | flags = ICF_NORMAL |
||
| ) |
Definition at line 420 of file explorer.cpp.
References _himlSys_small, _icons, _pathCache, add(), ICF_HICON, ICF_LARGE, ICF_MIDDLE, ICF_OPEN, ICF_OVERLAYS, ICF_SYSCACHE, ICID_NONE, IT_CACHED, and SHGFI_ADDOVERLAYS.
Referenced by FavoritesMenu::AddEntries(), Entry::extract_icon(), and BookmarkList::fill_tree().
{
// search for matching icon with unchanged flags in the cache
CacheKey mapkey(path, flags);
PathCacheMap::iterator found = _pathCache.find(mapkey);
if (found != _pathCache.end())
return _icons[found->second];
// search for matching icon with handle
CacheKey mapkey_hicon(path, flags|ICF_HICON);
if (flags != mapkey_hicon.second) {
found = _pathCache.find(mapkey_hicon);
if (found != _pathCache.end())
return _icons[found->second];
}
// search for matching icon in the system image list cache
CacheKey mapkey_syscache(path, flags|ICF_SYSCACHE);
if (flags != mapkey_syscache.second) {
found = _pathCache.find(mapkey_syscache);
if (found != _pathCache.end())
return _icons[found->second];
}
SHFILEINFO sfi;
int shgfi_flags = 0;
if (flags & ICF_OPEN)
shgfi_flags |= SHGFI_OPENICON;
if ((flags&(ICF_LARGE|ICF_MIDDLE|ICF_OVERLAYS|ICF_HICON)) && !(flags&ICF_SYSCACHE)) {
shgfi_flags |= SHGFI_ICON;
if (!(flags & (ICF_LARGE|ICF_MIDDLE)))
shgfi_flags |= SHGFI_SMALLICON;
if (flags & ICF_OVERLAYS)
shgfi_flags |= SHGFI_ADDOVERLAYS;
// get small/big icons with/without overlays
if (SHGetFileInfo(path, 0, &sfi, sizeof(sfi), shgfi_flags)) {
const Icon& icon = add(sfi.hIcon, IT_CACHED);
///@todo limit cache size
_pathCache[mapkey_hicon] = icon;
return icon;
}
} else {
assert(!(flags&ICF_OVERLAYS));
shgfi_flags |= SHGFI_SYSICONINDEX|SHGFI_SMALLICON;
// use system image list - the "search program dialog" needs it
HIMAGELIST himlSys_small = (HIMAGELIST) SHGetFileInfo(path, 0, &sfi, sizeof(sfi), shgfi_flags);
if (himlSys_small) {
_himlSys_small = himlSys_small;
const Icon& icon = add(sfi.iIcon/*, IT_SYSCACHE*/);
///@todo limit cache size
_pathCache[mapkey_syscache] = icon;
return icon;
}
}
return _icons[ICID_NONE];
}
| const Icon & IconCache::extract | ( | LPCTSTR | path, |
| int | icon_idx, | ||
| ICONCACHE_FLAGS | flags = ICF_HICON |
||
| ) |
Definition at line 495 of file explorer.cpp.
References _icons, _idxCache, add(), ICF_HICON, ICF_SYSCACHE, ICID_NONE, and IT_CACHED.
{
IdxCacheKey key(path, make_pair(icon_idx, (flags|ICF_HICON)&~ICF_SYSCACHE));
key.first.toLower();
IdxCacheMap::iterator found = _idxCache.find(key);
if (found != _idxCache.end())
return _icons[found->second];
HICON hIcon;
if ((int)ExtractIconEx(path, icon_idx, NULL, &hIcon, 1) > 0) {
const Icon& icon = add(hIcon, IT_CACHED);
_idxCache[key] = icon;
return icon;
} else {
///@todo retreive "http://.../favicon.ico" format icons
return _icons[ICID_NONE];
}
}
| void IconCache::free_icon | ( | int | icon_id ) |
Definition at line 654 of file explorer.cpp.
References _icons, and Icon::destroy().
Referenced by ShellBrowser::invalidate_cache(), and Entry::~Entry().
{
IconMap::iterator found = _icons.find(icon_id);
if (found != _icons.end()) {
Icon& icon = found->second;
if (icon.destroy())
_icons.erase(found);
}
}
| const Icon & IconCache::get_icon | ( | int | icon_id ) |
Definition at line 629 of file explorer.cpp.
References _icons.
Referenced by StartMenu::AddButton(), QuickLaunchBar::AddShortcuts(), Pane::draw_item(), MainFrameBase::FillBookmarks(), ShellBrowser::get_image_idx(), and FindProgramDlg::Notify().
{
return _icons[id];
}
| HIMAGELIST IconCache::get_sys_imagelist | ( | ) | const [inline] |
Definition at line 143 of file globals.h.
Referenced by Icon::add_to_imagelist(), Icon::create_bitmap(), Icon::draw(), and FindProgramDlg::FindProgramDlg().
{return _himlSys_small;}
| void IconCache::init | ( | ) |
Definition at line 385 of file explorer.cpp.
References _icons, ICID_ACTION, ICID_ADMIN, ICID_APPS, ICID_BOOKMARK, ICID_COMPUTER, ICID_CONFIG, ICID_CONTROLPAN, ICID_DESKSETTING, ICID_DOCUMENTS, ICID_EXPLORER, ICID_FAVORITES, ICID_FOLDER, ICID_INFO, ICID_LOGOFF, ICID_MINIMIZE, ICID_NETCONNS, ICID_NETWORK, ICID_NONE, ICID_PRINTER, ICID_RECENT, ICID_RESTART, ICID_SEARCH, ICID_SEARCH_DOC, ICID_SHUTDOWN, IDI_ACTION, IDI_ADMIN, IDI_APPS, IDI_COMPUTER, IDI_CONFIG, IDI_CONTROLPAN, IDI_DESKSETTING, IDI_DOCUMENTS, IDI_DOT_TRANS, IDI_EXPLORER, IDI_FAVORITES, IDI_FOLDER, IDI_INFO, IDI_LOGOFF, IDI_MINIMIZE, IDI_NETCONNS, IDI_NETWORK, IDI_PRINTER, IDI_RECENT, IDI_RESTART, IDI_SEARCH, IDI_SEARCH_DOC, IDI_SHUTDOWN, IT_STATIC, and STARTMENUROOT_ICON_SIZE.
Referenced by ExplorerGlobals::init().
{
int icon_size = STARTMENUROOT_ICON_SIZE;
_icons[ICID_NONE] = Icon(IT_STATIC, ICID_NONE, (HICON)0);
_icons[ICID_FOLDER] = Icon(ICID_FOLDER, IDI_FOLDER);
//_icons[ICID_DOCUMENT] = Icon(ICID_DOCUMENT, IDI_DOCUMENT);
_icons[ICID_EXPLORER] = Icon(ICID_EXPLORER, IDI_EXPLORER);
// _icons[ICID_APP] = Icon(ICID_APP, IDI_APPICON);
_icons[ICID_CONFIG] = Icon(ICID_CONFIG, IDI_CONFIG, icon_size);
_icons[ICID_DOCUMENTS] = Icon(ICID_DOCUMENTS, IDI_DOCUMENTS, icon_size);
_icons[ICID_FAVORITES] = Icon(ICID_FAVORITES, IDI_FAVORITES, icon_size);
_icons[ICID_INFO] = Icon(ICID_INFO, IDI_INFO, icon_size);
_icons[ICID_APPS] = Icon(ICID_APPS, IDI_APPS, icon_size);
_icons[ICID_SEARCH] = Icon(ICID_SEARCH, IDI_SEARCH, icon_size);
_icons[ICID_ACTION] = Icon(ICID_ACTION, IDI_ACTION, icon_size);
_icons[ICID_SEARCH_DOC] = Icon(ICID_SEARCH_DOC, IDI_SEARCH_DOC, icon_size);
_icons[ICID_PRINTER] = Icon(ICID_PRINTER, IDI_PRINTER, icon_size);
_icons[ICID_NETWORK] = Icon(ICID_NETWORK, IDI_NETWORK, icon_size);
_icons[ICID_COMPUTER] = Icon(ICID_COMPUTER, IDI_COMPUTER, icon_size);
_icons[ICID_LOGOFF] = Icon(ICID_LOGOFF, IDI_LOGOFF, icon_size);
_icons[ICID_SHUTDOWN] = Icon(ICID_SHUTDOWN, IDI_SHUTDOWN, icon_size);
_icons[ICID_RESTART] = Icon(ICID_RESTART, IDI_RESTART, icon_size);
_icons[ICID_BOOKMARK] = Icon(ICID_BOOKMARK, IDI_DOT_TRANS, icon_size);
_icons[ICID_MINIMIZE] = Icon(ICID_MINIMIZE, IDI_MINIMIZE, icon_size);
_icons[ICID_CONTROLPAN] = Icon(ICID_CONTROLPAN, IDI_CONTROLPAN, icon_size);
_icons[ICID_DESKSETTING]= Icon(ICID_DESKSETTING,IDI_DESKSETTING,icon_size);
_icons[ICID_NETCONNS] = Icon(ICID_NETCONNS, IDI_NETCONNS, icon_size);
_icons[ICID_ADMIN] = Icon(ICID_ADMIN, IDI_ADMIN, icon_size);
_icons[ICID_RECENT] = Icon(ICID_RECENT, IDI_RECENT, icon_size);
}
HIMAGELIST IconCache::_himlSys_small [protected] |
IconMap IconCache::_icons [protected] |
Definition at line 151 of file globals.h.
Referenced by add(), extract(), free_icon(), get_icon(), and init().
IdxCacheMap IconCache::_idxCache [protected] |
PathCacheMap IconCache::_pathCache [protected] |
PidlCacheMap IconCache::_pidlcache [protected] |
int IconCache::s_next_id = ICID_DYNAMIC [static, protected] |
|
ROS Explorer Source Code Documentation
generated on 02.01.2013 by
|