1 // TortoiseSVN - a Windows shell extension for easy version control
\r
3 // Copyright (C) 2003-2008 - TortoiseSVN
\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
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
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
20 #include "StandardLayoutTextList.h"
\r
21 #include "UnicodeUtils.h"
\r
22 #include "VisibleGraphNode.h"
\r
26 CStandardLayoutTextList::CStandardLayoutTextList
\r
27 ( const std::vector<CStandardLayoutNodeInfo>& nodes
\r
28 , const std::vector<CStandardLayout::STextInfo>& texts)
\r
34 // implement ILayoutItemList
\r
36 index_t CStandardLayoutTextList::GetCount() const
\r
38 return static_cast<index_t>(texts.size());
\r
41 CString CStandardLayoutTextList::GetToolTip (index_t /* index */) const
\r
46 index_t CStandardLayoutTextList::GetFirstVisible
\r
47 (const CRect& viewRect) const
\r
49 return GetNextVisible (static_cast<index_t>(-1), viewRect);
\r
52 index_t CStandardLayoutTextList::GetNextVisible
\r
54 , const CRect& viewRect) const
\r
56 for (size_t i = prev+1, count = texts.size(); i < count; ++i)
\r
58 const CStandardLayout::STextInfo& text = texts[i];
\r
59 const CRect& nodeRect = nodes[text.nodeIndex].rect;
\r
61 if (FALSE != CRect().IntersectRect (nodeRect, viewRect))
\r
62 return static_cast<index_t>(i);
\r
65 return static_cast<index_t>(NO_INDEX);
\r
68 index_t CStandardLayoutTextList::GetAt
\r
69 ( const CPoint& /* point */
\r
70 , long /* delta */) const
\r
72 return static_cast<index_t>(NO_INDEX);
\r
75 // implement ILayoutTextList
\r
77 CStandardLayoutTextList::SText
\r
78 CStandardLayoutTextList::GetText (index_t index) const
\r
80 // determine the text and its bounding rect
\r
82 const CStandardLayout::STextInfo& textInfo = texts[index];
\r
83 const CStandardLayoutNodeInfo& nodeInfo = nodes[textInfo.nodeIndex];
\r
86 CRect rect = nodeInfo.rect;
\r
87 if (textInfo.subPathIndex > 0)
\r
89 rect.top = rect.top + 25 + 21 * (textInfo.subPathIndex-1);
\r
91 CString path = CUnicodeUtils::StdGetUnicode
\r
92 (nodeInfo.node->GetPath().GetPath()).c_str();
\r
94 for (int i = textInfo.subPathIndex; i > 0; --i)
\r
95 text = path.Tokenize (_T("/"), index);
\r
97 text.Insert (0, _T('/'));
\r
104 _itot_s (nodeInfo.node->GetRevision(), buffer, 10);
\r
108 // construct result
\r
112 result.style = textInfo.subPathIndex == 0;
\r
113 result.rotation = 0;
\r
114 result.rect = rect;
\r
115 result.text = text;
\r