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 "RevisionGraph/FullHistory.h"
\r
21 #include "RevisionGraph/FullGraph.h"
\r
22 #include "RevisionGraph/VisibleGraph.h"
\r
23 #include "RevisionGraph/IRevisionGraphLayout.h"
\r
24 #include "ProgressDlg.h"
\r
26 #include "SVNDiff.h"
\r
27 #include "AppUtils.h"
\r
29 using namespace Gdiplus;
\r
31 #define REVGRAPH_PREVIEW_WIDTH 100
\r
32 #define REVGRAPH_PREVIEW_HEIGHT 200
\r
34 // we need at least 5x2 pixels per node
\r
35 // to draw a meaningful pre-view
\r
37 #define REVGRAPH_PREVIEW_MAX_NODES (REVGRAPH_PREVIEW_HEIGHT * REVGRAPH_PREVIEW_WIDTH / 10)
\r
39 // don't try to draw nodes smaller than that:
\r
41 #define REVGRAPH_MIN_NODE_HIGHT (0.5f)
\r
44 * \ingroup TortoiseProc
\r
45 * node shapes for the revision graph
\r
56 #define MAX_TT_LENGTH 60000
\r
57 #define MAX_TT_LENGTH_DEFAULT 1000
\r
59 // forward declarations
\r
61 class CVisibleGraphNode;
\r
62 class IRevisionGraphLayout;
\r
63 class CAllRevisionGraphOptions;
\r
66 * \ingroup TortoiseProc
\r
67 * Window class showing a revision graph.
\r
69 * The analyzation of the log data is done in the child class CRevisionGraph.
\r
70 * Here, we handle the window notifications.
\r
72 class CRevisionGraphWnd : public CWnd //, public CRevisionGraph
\r
75 CRevisionGraphWnd(); // standard constructor
\r
76 virtual ~CRevisionGraphWnd();
\r
79 IDD = IDD_REVISIONGRAPH,
\r
80 WM_WORKERTHREADDONE = WM_APP +1
\r
86 volatile LONG m_bThreadRunning;
\r
87 CProgressDlg* m_pProgress;
\r
90 void Init(CWnd * pParent, LPRECT rect);
\r
91 void SaveGraphAs(CString sSavePath);
\r
93 bool FetchRevisionData ( const CString& path
\r
94 , SVNRev pegRevision
\r
95 , const CAllRevisionGraphOptions& options);
\r
96 bool AnalyzeRevisionData (const CAllRevisionGraphOptions& options);
\r
97 CString GetLastErrorMessage() const;
\r
99 bool GetShowOverview() const;
\r
100 void SetShowOverview (bool value);
\r
102 void CompareRevs(bool bHead);
\r
103 void UnifiedDiffRevs(bool bHead);
\r
105 CRect GetViewRect();
\r
106 int GetNodeCount();
\r
107 void DoZoom(float nZoomFactor);
\r
109 void SetDlgTitle (bool offline);
\r
111 svn_revnum_t GetHeadRevision() const;
\r
112 CString GetRepositoryRoot() const;
\r
113 CString GetRepositoryUUID() const;
\r
117 CRect m_OverviewPosRect;
\r
118 CRect m_OverviewRect;
\r
120 BOOL m_bShowOverview;
\r
122 std::auto_ptr<CFullHistory> m_fullHistory;
\r
123 std::auto_ptr<CFullGraph> m_fullGraph;
\r
124 std::auto_ptr<CVisibleGraph> m_visibleGraph;
\r
125 std::auto_ptr<IRevisionGraphLayout> m_layout;
\r
127 const CVisibleGraphNode * m_SelectedEntry1;
\r
128 const CVisibleGraphNode * m_SelectedEntry2;
\r
129 LOGFONT m_lfBaseFont;
\r
130 CFont * m_apFonts[MAXFONTS];
\r
132 CToolTipCtrl * m_pDlgTip;
\r
133 char m_szTip[MAX_TT_LENGTH+1];
\r
134 wchar_t m_wszTip[MAX_TT_LENGTH+1];
\r
137 float m_fZoomFactor;
\r
139 bool m_bTweakTrunkColors;
\r
140 bool m_bTweakTagsColors;
\r
141 bool m_bIsRubberBand;
\r
142 CPoint m_ptRubberStart;
\r
143 CPoint m_ptRubberEnd;
\r
146 int m_previewWidth;
\r
147 int m_previewHeight;
\r
148 float m_previewZoom;
\r
150 virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
\r
151 afx_msg void OnPaint();
\r
152 afx_msg BOOL OnEraseBkgnd(CDC* pDC);
\r
153 afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
\r
154 afx_msg void OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
\r
155 afx_msg void OnSize(UINT nType, int cx, int cy);
\r
156 afx_msg INT_PTR OnToolHitTest(CPoint point, TOOLINFO* pTI) const;
\r
157 afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
\r
158 afx_msg BOOL OnToolTipNotify(UINT id, NMHDR *pNMHDR, LRESULT *pResult);
\r
159 afx_msg BOOL OnMouseWheel(UINT nFlags, short zDelta, CPoint pt);
\r
160 afx_msg void OnContextMenu(CWnd* /*pWnd*/, CPoint /*point*/);
\r
161 afx_msg void OnMouseMove(UINT nFlags, CPoint point);
\r
162 afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
\r
163 afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);
\r
164 afx_msg LRESULT OnWorkerThreadDone(WPARAM, LPARAM);
\r
166 DECLARE_MESSAGE_MAP()
\r
169 typedef bool (SVNDiff::*TDiffFunc)(const CTSVNPath& url1, const SVNRev& rev1,
\r
170 const CTSVNPath& url2, const SVNRev& rev2,
\r
172 bool ignoreancestry,
\r
174 typedef bool (*TStartDiffFunc)(HWND hWnd, const CTSVNPath& url1, const SVNRev& rev1,
\r
175 const CTSVNPath& url2, const SVNRev& rev2,
\r
176 const SVNRev& peg, const SVNRev& headpeg,
\r
177 bool bAlternateDiff,
\r
178 bool bIgnoreAncestry,
\r
181 void Compare (TDiffFunc diffFunc, TStartDiffFunc startDiffFunc, bool bHead);
\r
182 bool PromptShown() const;
\r
184 void SetScrollbars(int nVert = 0, int nHorz = 0, int oldwidth = 0, int oldheight = 0);
\r
185 CRect GetGraphRect();
\r
186 CFont* GetFont(BOOL bItalic = FALSE, BOOL bBold = FALSE);
\r
188 CSize UsableTooltipRect();
\r
189 CString DisplayableText (const CString& wholeText, const CSize& tooltipSize);
\r
190 CString TooltipText (index_t index);
\r
192 index_t GetHitNode (CPoint point) const;
\r
194 typedef PointF TCutRectangle[8];
\r
195 void CutawayPoints (const RectF& rect, float cutLen, TCutRectangle& result);
\r
196 void DrawRoundedRect (Graphics& graphics, const Pen* pen, const Brush* brush, const RectF& rect);
\r
197 void DrawOctangle (Graphics& graphics, const Pen* pen, const Brush* brush, const RectF& rect);
\r
198 void DrawShape (Graphics& graphics, const Pen* pen, const Brush* brush, const RectF& rect, NodeShape shape);
\r
199 void DrawShadow(Graphics& graphics, const RectF& rect,
\r
200 Color shadowColor, NodeShape shape);
\r
201 void DrawNode(Graphics& graphics, const RectF& rect,
\r
202 COLORREF contourRef, Color overlayColor,
\r
203 const CVisibleGraphNode *node, NodeShape shape);
\r
204 RectF GetNodeRect (const ILayoutNodeList::SNode& node, const CSize& offset) const;
\r
206 void DrawShadows (Graphics& graphics, const CRect& logRect, const CSize& offset);
\r
207 void DrawNodes (Graphics& graphics, const CRect& logRect, const CSize& offset);
\r
208 void DrawConnections (CDC* pDC, const CRect& logRect, const CSize& offset);
\r
209 void DrawTexts (CDC* pDC, const CRect& logRect, const CSize& offset);
\r
210 void DrawGraph(CDC* pDC, const CRect& rect, int nVScrollPos, int nHScrollPos, bool bDirectDraw);
\r
212 int GetEncoderClsid(const WCHAR* format, CLSID* pClsid);
\r
213 void DrawRubberBand();
\r
215 void BuildPreview();
\r