1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2017 - TortoiseGit
4 // Copyright (C) 2003-2006,2009-2010,2015,2017 - TortoiseSVN
6 // This program is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU General Public License
8 // as published by the Free Software Foundation; either version 2
9 // of the License, or (at your option) any later version.
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the Free Software Foundation,
18 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26 * Provides simplified access to the system icons. Only small system icons
29 * \note This class is implemented as a singleton.
30 * The singleton instance is created when first accessed. See SYS_IMAGE_LIST() function
31 * easy access of the singleton instance. All
33 class CSysImageList
: public CImageList
35 // Singleton constructor and destructor (private)
40 CSysImageList(const CSysImageList
&) = delete;
41 CSysImageList
& operator=(const CSysImageList
&) = delete;
43 // Singleton specific operations
46 * Returns a reference to the one and only instance of this class.
48 static CSysImageList
& GetInstance();
50 * Frees all allocated resources (if necessary). Don't call this
51 * function when the image list is currently bound to any control!
53 static void Cleanup();
58 * Returns the icon index for a directory.
60 int GetDirIconIndex();
62 * Returns the icon index for a directory that's open (e.g. for a tree control)
64 int GetDirOpenIconIndex();
66 * Returns the icon index for a file which has no special icon associated.
68 int GetDefaultIconIndex();
70 * Get the index for a Git-style path file.
71 * Uses a cache to speed things up
73 int GetPathIconIndex(const CTGitPath
& file
);
74 int GetPathIconIndex(const CString
& file
);
77 * Adds an icon to the image list and returns the index of the
78 * added icon (or -1 if adding the icon fails)
80 int AddIcon(const HICON hIcon
);
84 * Returns the icon index for the specified \a file. Only the file extension
85 * is used to determine the file's icon.
87 int GetFileIconIndex(const CString
& file
);
88 int GetFileIcon(LPCTSTR file
, DWORD attributes
, UINT extraFlags
);
90 static CSysImageList
*instance
;
92 HIMAGELIST hSystemImageList
;
93 mutable std::map
<CString
, int> m_indexCache
;
95 int m_dirOpenIconIndex
;
96 int m_defaultIconIndex
;
101 * \relates CSysImageList
102 * Singleton access for CSysImageList.
104 inline CSysImageList
& SYS_IMAGE_LIST() { return CSysImageList::GetInstance(); }