4 * @brief Declaration of CLocationView class
15 * @brief Endpoints of line connecting moved blocks
29 typedef CList<MovedLine, MovedLine&> MOVEDLINE_LIST;
32 * @brief A struct mapping difference lines to pixels in location pane.
33 * This structure maps one difference's line numbers to pixel locations in
34 * the location pane. The line numbers are "fixed" i.e. they are converted to
35 * word-wrapped absolute line numbers if needed.
39 unsigned top_line; /**< First line of the difference. */
40 unsigned bottom_line; /**< Last line of the difference. */
41 unsigned top_coord; /**< X-coord of diff block begin. */
42 unsigned bottom_coord; /**< X-coord of diff block end. */
43 unsigned diff_index; /**< Index of difference in the original diff list. */
48 * @brief Class showing map of files.
49 * The location is a view showing two vertical bars. Each bar depicts one file
50 * in the file compare. The bars show a scaled view of the files. The
51 * difference areas are drawn with the same colors than in actual file compare.
52 * Also visible area of files is drawn as "shaded".
54 * These visualizations allow user to easily see a overall picture of the files
55 * in comparison. Using mouse it allows easy and fast moving in files.
57 class CLocationView : public CView
62 DECLARE_DYNCREATE(CLocationView)
63 void SetConnectMovedBlocks(bool displayMovedBlocks);
64 void UpdateVisiblePos(int nTopLine = -1, int nBottomLine = -1);
65 void SetFrameHwnd(HWND hwndFrame);
66 void ForceRecalculate();
71 // ClassWizard generated virtual function overrides
72 //{{AFX_VIRTUAL(CLocationView)
74 virtual void OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint);
75 virtual void OnDraw(CDC* pDC);
79 CMergeDoc* GetDocument();
80 void DrawRect(CDC* pDC, const CRect& r, COLORREF cr, bool bSelected = false);
81 bool GotoLocation(const CPoint& point, bool bRealLine = true, bool bMoveAnchor = true);
82 int GetLineFromYPos(int nYCoord, int bar, bool bRealLine = true);
83 int IsInsideBar(const CRect& rc, const POINT& pt);
84 void DrawVisibleAreaRect(CDC* pDC, int nTopLine = -1, int nBottomLine = -1);
85 void DrawConnectLines(CDC* pDC);
86 void DrawDiffMarker(CDC* pDC, int yCoord);
88 void CalculateBlocks();
89 void CalculateBlocksPixel(int nBlockStart, int nBlockEnd, int nBlockLength,
90 int &nBeginY, int &nEndY);
91 COLORREF GetBackgroundColor();
92 void DrawBackground(CDC* pDC);
95 bool m_displayMovedBlocks; //*< Setting for displaying moved blocks */
96 double m_pixInLines; //*< How many pixels is one line in bars */
97 double m_lineInPix; //*< How many lines is one pixel?
98 CRect m_bar[3]; //*< Left/middle/riggt bar */
99 int m_visibleTop; //*< Top visible line for visible area indicator */
100 int m_visibleBottom; //*< Bottom visible line for visible area indicator */
101 int m_nSubLineCount[3]; //*< Cached subline count */
102 MOVEDLINE_LIST m_movedLines; //*< List of moved block connecting lines */
103 HWND m_hwndFrame; //*< Frame window handle */
104 std::unique_ptr<CBitmap> m_pSavedBackgroundBitmap; //*< Saved background */
105 bool m_bDrawn; //*< Is already drawn in location pane? */
106 std::vector<DiffBlock> m_diffBlocks; //*< List of pre-calculated diff blocks.
107 bool m_bRecalculateBlocks; //*< Recalculate diff blocks in next repaint.
108 CSize m_currentSize; //*< Current size of the panel.
110 // Generated message map functions
112 //{{AFX_MSG(CLocationView)
113 afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
114 afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
115 afx_msg void OnMouseMove(UINT nFlags, CPoint point);
116 afx_msg int OnMouseActivate(CWnd* pDesktopWnd, UINT nHitTest, UINT message);
117 afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point);
118 afx_msg void OnContextMenu(CWnd* pWnd, CPoint point);
119 afx_msg void OnClose();
120 afx_msg void OnVScroll (UINT nSBCode, UINT nPos, CScrollBar * pScrollBar);
121 afx_msg void OnSize(UINT nType, int cx, int cy);
122 afx_msg BOOL OnEraseBkgnd(CDC* pDC);
124 DECLARE_MESSAGE_MAP()
127 #ifndef _DEBUG // debug version in DiffView.cpp
128 inline CMergeDoc* CLocationView::GetDocument()
129 { return reinterpret_cast<CMergeDoc*>(m_pDocument); }
133 * @brief Stores HWND of frame window (CMergeEditFrame).
135 inline void CLocationView::SetFrameHwnd(HWND hwndFrame)
137 m_hwndFrame = hwndFrame;