1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2003-2006,2009-2010,2015 - TortoiseSVN
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 2
8 // of the License, or (at your option) any later version.
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software Foundation,
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25 * Provides simplified access to the system icons. Only small system icons
28 * \note This class is implemented as a singleton.
29 * The singleton instance is created when first accessed. See SYS_IMAGE_LIST() function
30 * easy access of the singleton instance. All
32 class CSysImageList
: public CImageList
34 // Singleton constructor and destructor (private)
39 CSysImageList(const CSysImageList
&) = delete;
40 CSysImageList
& operator=(const CSysImageList
&) = delete;
42 // Singleton specific operations
45 * Returns a reference to the one and only instance of this class.
47 static CSysImageList
& GetInstance();
49 * Frees all allocated resources (if necessary). Don't call this
50 * function when the image list is currently bound to any control!
52 static void Cleanup();
57 * Returns the icon index for a directory.
59 int GetDirIconIndex() const;
61 * Returns the icon index for a directory that's open (e.g. for a tree control)
63 int GetDirOpenIconIndex() const;
65 * Returns the icon index for a file which has no special icon associated.
67 int GetDefaultIconIndex() const;
69 * Returns the icon index for the specified \a file. Only the file extension
70 * is used to determine the file's icon.
72 int GetFileIconIndex(const CString
& file
) const;
75 * Get the index for a Git-style path file.
76 * Uses a cache to speed things up
78 int GetPathIconIndex(const CTGitPath
& file
) const;
81 * Adds an icon to the image list and returns the index of the
82 * added icon (or -1 if adding the icon fails)
84 int AddIcon(const HICON hIcon
);
87 static CSysImageList
*instance
;
89 typedef std::map
<CString
, int> IconIndexMap
;
90 mutable IconIndexMap m_indexCache
;
92 int GetFileIcon(LPCTSTR file
, DWORD attributes
, UINT extraFlags
) const;
97 * \relates CSysImageList
98 * Singleton access for CSysImageList.
100 inline CSysImageList
& SYS_IMAGE_LIST() { return CSysImageList::GetInstance(); }