OSDN Git Service

Fix Create Repository path problem
[tortoisegit/TortoiseGitJp.git] / src / TortoiseProc / RevisionGraph / StandardLayout.h
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 #pragma once\r
20 \r
21 #include "IRevisionGraphLayout.h"\r
22 \r
23 class CVisibleGraphNode;\r
24 class CVisibleGraph;\r
25 \r
26 namespace LogCache\r
27 {\r
28     class CCachedLogInfo;\r
29 }\r
30 \r
31 class CStandardLayoutNodeInfo\r
32 {\r
33 public:\r
34 \r
35     /// the node to place within the layout\r
36 \r
37     const CVisibleGraphNode* node;\r
38 \r
39     /// links for faster navigation\r
40 \r
41     CStandardLayoutNodeInfo* parentBranch;\r
42     CStandardLayoutNodeInfo* firstSubBranch;\r
43     CStandardLayoutNodeInfo* nextInBranch;\r
44     CStandardLayoutNodeInfo* previousInBranch;\r
45     CStandardLayoutNodeInfo* lastInBranch;\r
46     CStandardLayoutNodeInfo* nextBranch;\r
47     CStandardLayoutNodeInfo* previousBranch;\r
48     CStandardLayoutNodeInfo* lastBranch;\r
49 \r
50     /// branch sizes\r
51 \r
52     index_t subTreeWidth;\r
53     index_t subTreeHeight;\r
54     index_t subTreeWeight;\r
55     index_t branchLength;\r
56 \r
57     /// node properties\r
58 \r
59     bool requiresRevision;\r
60     bool requiresPath;\r
61     bool requiresGap;\r
62 \r
63     /// required size(s) to display all content\r
64 \r
65     CSize requiredSize;\r
66 \r
67     /// temp. value used to store the offset of the final position\r
68     /// to the current one (logical coordinates)\r
69 \r
70     CSize treeShift;\r
71     CSize subTreeShift;\r
72 \r
73     /// actual position (logical coordinates)\r
74 \r
75     CRect rect;\r
76 \r
77     /// initialization\r
78 \r
79     CStandardLayoutNodeInfo();\r
80 };\r
81 \r
82 /**\r
83 * utility interface that gives layout options access to the layout info\r
84 */\r
85 \r
86 class IStandardLayoutNodeAccess\r
87 {\r
88 public:\r
89 \r
90     /// make sub-classes deletable through the base interface\r
91 \r
92     virtual ~IStandardLayoutNodeAccess() {};\r
93 \r
94     /// access graph node layout\r
95 \r
96     virtual index_t GetNodeCount() const = 0;\r
97     virtual CStandardLayoutNodeInfo* GetNode (index_t index) = 0;\r
98 };\r
99 \r
100 class CStandardLayout \r
101     : public IRevisionGraphLayout\r
102     , public IStandardLayoutNodeAccess\r
103 {\r
104 public:\r
105 \r
106     struct STextInfo\r
107     {\r
108         index_t nodeIndex;\r
109         int subPathIndex;   // 0 -> revNum, pathElementIndex otherwise\r
110 \r
111         STextInfo (index_t nodeIndex, int subPathIndex)\r
112             : nodeIndex (nodeIndex)\r
113             , subPathIndex (subPathIndex) \r
114         {\r
115         }\r
116     };\r
117 \r
118 private:\r
119 \r
120     /// source of revision data\r
121 \r
122     const CCachedLogInfo* cache;\r
123 \r
124     /// nodes (in the order defined by CVisibleGraphNode::index)\r
125 \r
126     std::vector<CStandardLayoutNodeInfo> nodes;\r
127 \r
128     /// connections with length > 0. Stored as node index pairs.\r
129 \r
130     std::vector<std::pair<index_t, index_t> > connections;\r
131 \r
132     /// non-empty texts. Stored as node index, 'is path' pairs\r
133 \r
134     std::vector<STextInfo> texts;\r
135 \r
136     /// area that covers all visible items\r
137 \r
138     CRect boundingRect;\r
139 \r
140     /// layout creation\r
141 \r
142     void SortNodes();\r
143     void InitializeNodes ( const CVisibleGraphNode* node\r
144                          , CStandardLayoutNodeInfo* parentBranch);\r
145     void InitializeNodes (const CVisibleGraph* graph);\r
146 \r
147     void CreateConnections();\r
148     void CreateTexts();\r
149     void CalculateBoundingRect();\r
150 \r
151 public:\r
152 \r
153     /// construction / destruction\r
154 \r
155     CStandardLayout (const CCachedLogInfo* cache, const CVisibleGraph* graph);\r
156     virtual ~CStandardLayout(void);\r
157 \r
158     /// call this after executing the format options\r
159 \r
160     void Finalize();\r
161 \r
162     /// implement IRevisionGraphLayout\r
163 \r
164     virtual CRect GetRect() const;\r
165 \r
166     virtual const ILayoutNodeList* GetNodes() const;\r
167     virtual const ILayoutConnectionList* GetConnections() const;\r
168     virtual const ILayoutTextList* GetTexts() const;\r
169 \r
170     /// implement IStandardLayoutNodeAccess\r
171 \r
172     virtual index_t GetNodeCount() const;\r
173     virtual CStandardLayoutNodeInfo* GetNode (index_t index);\r
174 };\r
175 \r