OSDN Git Service

Change Dir Structure to be same as TortoiseSVN'
[tortoisegit/TortoiseGitJp.git] / src / TortoiseProc / RevisionGraph / StandardLayoutTextList.cpp
1 // TortoiseSVN - a Windows shell extension for easy version control\r
2 \r
3 // Copyright (C) 2003-2008 - TortoiseSVN\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 #include "StdAfx.h"\r
20 #include "StandardLayoutTextList.h"\r
21 #include "UnicodeUtils.h"\r
22 #include "VisibleGraphNode.h"\r
23 \r
24 // construction\r
25 \r
26 CStandardLayoutTextList::CStandardLayoutTextList \r
27     ( const std::vector<CStandardLayoutNodeInfo>& nodes\r
28     , const std::vector<CStandardLayout::STextInfo>& texts)\r
29     : nodes (nodes)\r
30     , texts (texts)\r
31 {\r
32 }\r
33 \r
34 // implement ILayoutItemList\r
35 \r
36 index_t CStandardLayoutTextList::GetCount() const\r
37 {\r
38     return static_cast<index_t>(texts.size());\r
39 }\r
40 \r
41 CString CStandardLayoutTextList::GetToolTip (index_t /* index */) const\r
42 {\r
43     return CString();\r
44 }\r
45 \r
46 index_t CStandardLayoutTextList::GetFirstVisible \r
47     (const CRect& viewRect) const\r
48 {\r
49     return GetNextVisible (static_cast<index_t>(-1), viewRect);\r
50 }\r
51 \r
52 index_t CStandardLayoutTextList::GetNextVisible \r
53     ( index_t prev\r
54     , const CRect& viewRect) const\r
55 {\r
56     for (size_t i = prev+1, count = texts.size(); i < count; ++i)\r
57     {\r
58         const CStandardLayout::STextInfo& text = texts[i];\r
59         const CRect& nodeRect = nodes[text.nodeIndex].rect;\r
60 \r
61         if (FALSE != CRect().IntersectRect (nodeRect, viewRect))\r
62             return static_cast<index_t>(i);\r
63     }\r
64 \r
65     return static_cast<index_t>(NO_INDEX);\r
66 }\r
67 \r
68 index_t CStandardLayoutTextList::GetAt \r
69     ( const CPoint& /* point */\r
70     , long /* delta */) const\r
71 {\r
72     return static_cast<index_t>(NO_INDEX);\r
73 }\r
74 \r
75 // implement ILayoutTextList\r
76 \r
77 CStandardLayoutTextList::SText \r
78 CStandardLayoutTextList::GetText (index_t index) const\r
79 {\r
80     // determine the text and its bounding rect\r
81 \r
82     const CStandardLayout::STextInfo& textInfo = texts[index];\r
83     const CStandardLayoutNodeInfo& nodeInfo = nodes[textInfo.nodeIndex];\r
84 \r
85     CString text;\r
86     CRect rect = nodeInfo.rect;\r
87     if (textInfo.subPathIndex > 0)\r
88     {\r
89         rect.top = rect.top + 25 + 21 * (textInfo.subPathIndex-1);\r
90 \r
91         CString path = CUnicodeUtils::StdGetUnicode \r
92                          (nodeInfo.node->GetPath().GetPath()).c_str();\r
93         int index = 0;\r
94         for (int i = textInfo.subPathIndex; i > 0; --i)\r
95             text = path.Tokenize (_T("/"), index);\r
96 \r
97         text.Insert (0, _T('/'));\r
98     }\r
99     else\r
100     {\r
101         rect.top += 3;\r
102 \r
103         TCHAR buffer[20];\r
104         _itot_s (nodeInfo.node->GetRevision(), buffer, 10);\r
105         text = buffer;\r
106     }\r
107 \r
108     // construct result\r
109 \r
110     SText result;\r
111 \r
112     result.style = textInfo.subPathIndex == 0;\r
113     result.rotation = 0;\r
114     result.rect = rect;\r
115     result.text = text;\r
116 \r
117     return result;\r
118 }\r