CommitDlg: Update empty file list message
[TortoiseGit.git] / src / Utils / SysImageList.h
blobb4172886a1d0a0c5d668dc38f458539da4b8760e
1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2003-2006,2009-2010 - 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.
19 #pragma once
21 class CTGitPath;
23 /**
24 * \ingroup Utils
25 * Provides simplified access to the system icons. Only small system icons
26 * are supported.
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)
35 private:
36 CSysImageList();
37 ~CSysImageList();
39 // Singleton specific operations
40 public:
41 /**
42 * Returns a reference to the one and only instance of this class.
44 static CSysImageList& GetInstance();
45 /**
46 * Frees all allocated resources (if necessary). Don't call this
47 * function when the image list is currently bound to any control!
49 static void Cleanup();
51 // Operations
52 public:
53 /**
54 * Returns the icon index for a directory.
56 int GetDirIconIndex() const;
57 /**
58 * Returns the icon index for a directory that's open (e.g. for a tree control)
60 int GetDirOpenIconIndex() const;
61 /**
62 * Returns the icon index for a file which has no special icon associated.
64 int GetDefaultIconIndex() const;
65 /**
66 * Returns the icon index for the specified \a file. Only the file extension
67 * is used to determine the file's icon.
69 int GetFileIconIndex(const CString& file) const;
71 /**
72 * Get the index for a Git-style path file.
73 * Uses a cache to speed things up
75 int GetPathIconIndex(const CTGitPath& file) const;
77 /**
78 * Adds an icon to the image list and returns the index of the
79 * added icon (or -1 if adding the icon fails)
81 int AddIcon(const HICON hIcon);
83 private:
84 static CSysImageList *instance;
86 typedef std::map<CString, int> IconIndexMap;
87 mutable IconIndexMap m_indexCache;
89 int GetFileIcon(LPCTSTR file, DWORD attributes, UINT extraFlags) const;
93 /**
94 * \relates CSysImageList
95 * Singleton access for CSysImageList.
97 inline CSysImageList& SYS_IMAGE_LIST() { return CSysImageList::GetInstance(); }