4 * @brief Declaration of CLocationView class
15 * @brief Status for display moved block
17 enum DISPLAY_MOVED_BLOCKS
19 DISPLAY_MOVED_NONE = 0,
21 DISPLAY_MOVED_FOLLOW_DIFF,
25 * @brief Endpoints of line connecting moved blocks
33 typedef CList<MovedLine, MovedLine&> MOVEDLINE_LIST;
36 * @brief A struct mapping difference lines to pixels in location pane.
37 * This structure maps one difference's line numbers to pixel locations in
38 * the location pane. The line numbers are "fixed" i.e. they are converted to
39 * word-wrapped absolute line numbers if needed.
43 unsigned top_line; /**< First line of the difference. */
44 unsigned bottom_line; /**< Last line of the difference. */
45 unsigned top_coord; /**< X-coord of diff block begin. */
46 unsigned bottom_coord; /**< X-coord of diff block end. */
47 unsigned diff_index; /**< Index of difference in the original diff list. */
52 * @brief Class showing map of files.
53 * The location is a view showing two vertical bars. Each bar depicts one file
54 * in the file compare. The bars show a scaled view of the files. The
55 * difference areas are drawn with the same colors than in actual file compare.
56 * Also visible area of files is drawn as "shaded".
58 * These visualizations allow user to easily see a overall picture of the files
59 * in comparison. Using mouse it allows easy and fast moving in files.
61 class CLocationView : public CView
66 DECLARE_DYNCREATE(CLocationView)
67 void SetConnectMovedBlocks(int displayMovedBlocks);
68 void UpdateVisiblePos(int nTopLine = -1, int nBottomLine = -1);
69 void SetFrameHwnd(HWND hwndFrame);
70 void ForceRecalculate();
75 // ClassWizard generated virtual function overrides
76 //{{AFX_VIRTUAL(CLocationView)
78 virtual void OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint);
79 virtual void OnDraw(CDC* pDC);
83 CMergeDoc* GetDocument();
84 void DrawRect(CDC* pDC, const CRect& r, COLORREF cr, BOOL bSelected = FALSE);
85 bool GotoLocation(const CPoint& point, bool bRealLine = true);
86 int GetLineFromYPos(int nYCoord, int bar, BOOL bRealLine = TRUE);
87 int IsInsideBar(const CRect& rc, const POINT& pt);
88 void DrawVisibleAreaRect(CDC* pDC, int nTopLine = -1, int nBottomLine = -1);
89 void DrawConnectLines(CDC* pDC);
90 void DrawDiffMarker(CDC* pDC, int yCoord);
92 void CalculateBlocks();
93 void CalculateBlocksPixel(int nBlockStart, int nBlockEnd, int nBlockLength,
94 int &nBeginY, int &nEndY);
95 void DrawBackground(CDC* pDC);
98 CMergeEditView* m_view[3]; //*< Table for view pointers */
99 int m_displayMovedBlocks; //*< Setting for displaying moved blocks */
100 double m_pixInLines; //*< How many pixels is one line in bars */
101 double m_lineInPix; //*< How many lines is one pixel?
102 CRect m_bar[3]; //*< Left/middle/riggt bar */
103 int m_visibleTop; //*< Top visible line for visible area indicator */
104 int m_visibleBottom; //*< Bottom visible line for visible area indicator */
105 int m_nSubLineCount[3]; //*< Cached subline count */
106 MOVEDLINE_LIST m_movedLines; //*< List of moved block connecting lines */
107 HWND m_hwndFrame; //*< Frame window handle */
108 std::unique_ptr<CBitmap> m_pSavedBackgroundBitmap; //*< Saved background */
109 bool m_bDrawn; //*< Is already drawn in location pane? */
110 std::vector<DiffBlock> m_diffBlocks; //*< List of pre-calculated diff blocks.
111 BOOL m_bRecalculateBlocks; //*< Recalculate diff blocks in next repaint.
112 CSize m_currentSize; //*< Current size of the panel.
114 // Generated message map functions
116 //{{AFX_MSG(CLocationView)
117 afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
118 afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
119 afx_msg void OnMouseMove(UINT nFlags, CPoint point);
120 afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point);
121 afx_msg void OnContextMenu(CWnd* pWnd, CPoint point);
122 afx_msg void OnClose();
123 afx_msg void OnVScroll (UINT nSBCode, UINT nPos, CScrollBar * pScrollBar);
124 afx_msg void OnSize(UINT nType, int cx, int cy);
125 afx_msg BOOL OnEraseBkgnd(CDC* pDC);
126 afx_msg void OnSetFocus(CWnd* pOldWnd);
127 afx_msg void OnUpdateFileSave(CCmdUI* pCmdUI);
128 afx_msg void OnUpdateFileSaveLeft(CCmdUI* pCmdUI);
129 afx_msg void OnUpdateFileSaveMiddle(CCmdUI* pCmdUI);
130 afx_msg void OnUpdateFileSaveRight(CCmdUI* pCmdUI);
132 DECLARE_MESSAGE_MAP()
135 #ifndef _DEBUG // debug version in DiffView.cpp
136 inline CMergeDoc* CLocationView::GetDocument()
137 { return reinterpret_cast<CMergeDoc*>(m_pDocument); }