OSDN Git Service

Version browse in switch, export, new branch/tag and merge dialogs
[tortoisegit/TortoiseGitJp.git] / src / TortoiseProc / RevisionGraph / IRevisionGraphLayout.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 "LogCacheGlobals.h"\r
22 \r
23 using namespace LogCache;\r
24 \r
25 class CVisibleGraphNode;\r
26 \r
27 // Scintilla uses defines :/\r
28 \r
29 #ifdef STYLE_DEFAULT\r
30 #undef STYLE_DEFAULT\r
31 #endif\r
32 \r
33 /**\r
34 * Base interface to all layout info access interfaces.\r
35 */\r
36 \r
37 class ILayoutItemList\r
38 {\r
39 public:\r
40 \r
41     /// make sub-classes deletable through the base interface\r
42 \r
43     virtual ~ILayoutItemList() {};\r
44 \r
45     /// standard data access\r
46 \r
47     virtual index_t GetCount() const = 0;\r
48 \r
49     virtual CString GetToolTip (index_t index) const = 0;\r
50 \r
51     /// lookup (return NO_INDEX if not found)\r
52 \r
53     virtual index_t GetFirstVisible (const CRect& viewRect) const = 0;\r
54     virtual index_t GetNextVisible (index_t prev, const CRect& viewRect) const = 0;\r
55     virtual index_t GetAt (const CPoint& point, long delta) const = 0;\r
56 };\r
57 \r
58 class ILayoutConnectionList : public ILayoutItemList\r
59 {\r
60 public:\r
61 \r
62     /// Connections are Bezier lines.\r
63 \r
64     struct SConnection\r
65     {\r
66         /// stype (usually pen) index. \r
67         /// To be interpreted by drawing code. Starts with 0.\r
68 \r
69         index_t style;\r
70 \r
71         /// number of Bezier points valid in @ref points.\r
72 \r
73         index_t numberOfPoints;\r
74 \r
75         /// Bezier points to draw the curve for.\r
76 \r
77         const CPoint* points;\r
78     };\r
79 \r
80     /// standard data access\r
81 \r
82     virtual SConnection GetConnection (index_t index) const = 0;\r
83 };\r
84 \r
85 class ILayoutNodeList : public ILayoutItemList\r
86 {\r
87 public:\r
88 \r
89     /// Nodes occupy a rectangular area.\r
90 \r
91     struct SNode\r
92     {\r
93                 /// style-flags\r
94 \r
95                 enum \r
96                 {\r
97                         STYLE_DEFAULT  = 0,\r
98 \r
99                         STYLE_ADDED    = 1,\r
100                         STYLE_DELETED  = 2,\r
101                         STYLE_RENAMED  = 3,\r
102                         STYLE_LAST         = 4,\r
103             STYLE_MODIFIED = 5\r
104                 };\r
105 \r
106         /// Area occupied by this node.\r
107 \r
108         CRect rect;\r
109 \r
110         /// tree node represented by this graphical node.\r
111         /// Can be NULL, if there is none or multiple such nodes\r
112 \r
113         const CVisibleGraphNode* node;\r
114 \r
115         /// style (shape, border, filling) index. \r
116         /// To be interpreted by drawing code. Starts with 0.\r
117 \r
118         index_t style;\r
119 \r
120         /// extended style info (usually presense of sub-structures). \r
121         /// To be interpreted by drawing code. Starts with 0.\r
122 \r
123         DWORD styleFlags;\r
124 \r
125     };\r
126 \r
127     /// standard data access\r
128 \r
129     virtual SNode GetNode (index_t index) const = 0;\r
130 };\r
131 \r
132 class ILayoutTextList : public ILayoutItemList\r
133 {\r
134 public:\r
135 \r
136     /// Texts occupy a rectangular area.\r
137 \r
138     struct SText\r
139     {\r
140                 /// Values allowed for @a style \r
141 \r
142                 enum\r
143                 {\r
144             STYLE_DEFAULT   = 0,\r
145                         STYLE_HEADING   = 1\r
146                 };\r
147 \r
148         /// style (shape, font, size) index. \r
149         /// To be interpreted by drawing code. Starts with 0.\r
150 \r
151         index_t style;\r
152 \r
153         /// style info (bold, etc.).\r
154         /// To be interpreted by drawing code. Starts with 0.\r
155 \r
156         long rotation;\r
157 \r
158         /// The text.\r
159 \r
160         CString text;\r
161 \r
162         /// Area occupied by this text.\r
163 \r
164         CRect rect;\r
165     };\r
166 \r
167     /// standard data access\r
168 \r
169     virtual SText GetText (index_t index) const = 0;\r
170 };\r
171 \r
172 /** The 'graph' layout contains of three collections:\r
173 * One for the nodes, one for the connecting lines and\r
174 * one for the texts to be shown.\r
175\r
176 * The whole graph uses a discrete coordinate system\r
177 * confined in a rect.\r
178 */\r
179 \r
180 class IRevisionGraphLayout\r
181 {\r
182 public:\r
183 \r
184     /// make sub-classes deletable through the base interface\r
185 \r
186     virtual ~IRevisionGraphLayout() {};\r
187 \r
188     /// total graph size (logical units)\r
189 \r
190     virtual CRect GetRect() const = 0;\r
191 \r
192     /// access to the sub-structures.\r
193     /// The caller is required to delete the return objects.\r
194 \r
195     virtual const ILayoutNodeList* GetNodes() const = 0;\r
196     virtual const ILayoutConnectionList* GetConnections() const = 0;\r
197     virtual const ILayoutTextList* GetTexts() const = 0;\r
198 };\r