OSDN Git Service

Merge X64 Build
[tortoisegit/TortoiseGitJp.git] / src / Utils / SysImageList.h
1 // TortoiseSVN - a Windows shell extension for easy version control\r
2 \r
3 // Copyright (C) 2003-2006 - Stefan Kueng\r
4 \r
5 // This program is free software; you can redistribute it and/or\r
6 // modify it under the terms of the GNU General Public License\r
7 // as published by the Free Software Foundation; either version 2\r
8 // of the License, or (at your option) any later version.\r
9 \r
10 // This program is distributed in the hope that it will be useful,\r
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of\r
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
13 // GNU General Public License for more details.\r
14 \r
15 // You should have received a copy of the GNU General Public License\r
16 // along with this program; if not, write to the Free Software Foundation,\r
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\r
18 //\r
19 #pragma once\r
20 \r
21 class CTGitPath;\r
22 \r
23 /**\r
24  * \ingroup Utils\r
25  * Provides simplified access to the system icons. Only small system icons\r
26  * are supported.\r
27  *\r
28  * \note This class is implemented as a singleton.\r
29  * The singleton instance is created when first accessed. See SYS_IMAGE_LIST() function\r
30  * easy access of the singleton instance. All \r
31  */\r
32 class CSysImageList : public CImageList\r
33 {\r
34 // Singleton constructor and destructor (private)\r
35 private:\r
36         CSysImageList();\r
37         ~CSysImageList();\r
38 \r
39 // Singleton specific operations\r
40 public:\r
41         /**\r
42          * Returns a reference to the one and only instance of this class.\r
43          */\r
44         static CSysImageList& GetInstance();\r
45         /**\r
46          * Frees all allocated resources (if necessary). Don't call this\r
47          * function when the image list is currently bound to any control!\r
48          */\r
49         static void Cleanup();\r
50 \r
51 // Operations\r
52 public:\r
53         /**\r
54          * Returns the icon index for a directory.\r
55          */\r
56         int GetDirIconIndex() const;\r
57         /**\r
58          * Returns the icon index for a directory that's open (e.g. for a tree control)\r
59          */\r
60         int GetDirOpenIconIndex() const;\r
61         /**\r
62          * Returns the icon index for a file which has no special icon associated.\r
63          */\r
64         int GetDefaultIconIndex() const;\r
65         /**\r
66          * Returns the icon index for the specified \a file. Only the file extension\r
67          * is used to determine the file's icon.\r
68          */\r
69         int GetFileIconIndex(const CString& file) const;\r
70 \r
71         /**\r
72          * Get the index for a Git-style path file.  \r
73          * Uses a cache to speed things up\r
74          */\r
75         int GetPathIconIndex(const CTGitPath& file) const;\r
76 \r
77 private:\r
78         static CSysImageList *instance;\r
79 \r
80         typedef std::map<CString, int> IconIndexMap;\r
81         mutable IconIndexMap m_indexCache;\r
82 };\r
83 \r
84 \r
85 /**\r
86  * \relates CSysImageList\r
87  * Singleton access for CSysImageList.\r
88  */\r
89 inline CSysImageList& SYS_IMAGE_LIST() { return CSysImageList::GetInstance(); }\r