OSDN Git Service

Merge from rev.7121:7123
[winmerge-jp/winmerge-jp.git] / Src / LocationView.h
1 //////////////////////////////////////////////////////////////////////
2 /** 
3  * @file  LocationView.h
4  *
5  * @brief Declaration of CLocationView class
6  */
7 //
8 //////////////////////////////////////////////////////////////////////
9
10 // ID line follows -- this is updated by SVN
11 // $Id: LocationView.h 6085 2008-11-12 17:31:24Z kimmov $
12
13 #ifndef __LOCATIONVIEW_H__
14 #define __LOCATIONVIEW_H__
15
16 #include <vector>
17
18 /**
19  * @brief Status for display moved block
20  */
21 enum DISPLAY_MOVED_BLOCKS
22 {
23         DISPLAY_MOVED_NONE = 0,
24         DISPLAY_MOVED_ALL,
25         DISPLAY_MOVED_FOLLOW_DIFF,
26 };
27
28 /**
29  * @brief Endpoints of line connecting moved blocks
30  */
31 struct MovedLine
32 {
33         CPoint ptLeft;
34         CPoint ptRight;
35 };
36
37 typedef CList<MovedLine, MovedLine&> MOVEDLINE_LIST;
38
39 /**
40  * @brief A struct mapping difference lines to pixels in location pane.
41  * This structure maps one difference's line numbers to pixel locations in
42  * the location pane. The line numbers are "fixed" i.e. they are converted to
43  * word-wrapped absolute line numbers if needed.
44  */
45 struct DiffBlock
46 {
47         unsigned top_line; /**< First line of the difference. */
48         unsigned bottom_line; /**< Last line of the difference. */
49         unsigned top_coord; /**< X-coord of diff block begin. */
50         unsigned bottom_coord; /**< X-coord of diff block end. */
51         unsigned diff_index; /**< Index of difference in the original diff list. */
52 };
53
54 /** 
55  * @brief Class showing map of files.
56  * The location is a view showing two vertical bars. Each bar depicts one file
57  * in the file compare. The bars show a scaled view of the files. The
58  * difference areas are drawn with the same colors than in actual file compare.
59  * Also visible area of files is drawn as "shaded".
60  *
61  * These visualizations allow user to easily see a overall picture of the files
62  * in comparison. Using mouse it allows easy and fast moving in files.
63  */
64 class CLocationView : public CView
65 {
66 public:
67         CLocationView();
68         ~CLocationView();
69         DECLARE_DYNCREATE(CLocationView)
70         void SetConnectMovedBlocks(int displayMovedBlocks);
71         void UpdateVisiblePos(int nTopLine = -1, int nBottomLine = -1);
72         void SetFrameHwnd(HWND hwndFrame);
73         void ForceRecalculate();
74
75 protected:
76
77 // Overrides
78         // ClassWizard generated virtual function overrides
79         //{{AFX_VIRTUAL(CMergeDiffDetailView)
80         public:
81         virtual void OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint);
82         virtual void OnDraw(CDC* pDC);
83         //}}AFX_VIRTUAL
84
85 protected:
86         CMergeDoc* GetDocument();
87         void DrawRect(CDC* pDC, const CRect& r, COLORREF cr, BOOL bSelected = FALSE);
88         bool GotoLocation(const CPoint& point, bool bRealLine = true);
89         int GetLineFromYPos(int nYCoord, int bar, BOOL bRealLine = TRUE);
90         int IsInsideBar(const CRect& rc, const POINT& pt);
91         void DrawVisibleAreaRect(CDC* pDC, int nTopLine = -1, int nBottomLine = -1);
92         void DrawConnectLines(CDC* pDC);
93         void DrawDiffMarker(CDC* pDC, int yCoord);
94         void CalculateBars();
95         void CalculateBlocks();
96         void CalculateBlocksPixel(int nBlockStart, int nBlockEnd, int nBlockLength,
97                         int &nBeginY, int &nEndY);
98         void DrawBackground(CDC* pDC);
99
100 private:
101         CMergeEditView* m_view[3]; //*< Table for view pointers */
102         int m_displayMovedBlocks; //*< Setting for displaying moved blocks */
103         double m_pixInLines; //*< How many pixels is one line in bars */
104         double m_lineInPix; //*< How many lines is one pixel?
105         CRect m_bar[3]; //*< Left/middle/riggt bar */
106         int m_visibleTop; //*< Top visible line for visible area indicator */
107         int m_visibleBottom; //*< Bottom visible line for visible area indicator */
108         int m_nSubLineCount[3]; //*< Cached subline count */
109         MOVEDLINE_LIST m_movedLines; //*< List of moved block connecting lines */
110         HWND m_hwndFrame; //*< Frame window handle */
111         CBitmap *m_pSavedBackgroundBitmap; //*< Saved background */
112         bool m_bDrawn; //*< Is already drawn in location pane? */
113         std::vector<DiffBlock> m_diffBlocks; //*< List of pre-calculated diff blocks.
114         BOOL m_bRecalculateBlocks; //*< Recalculate diff blocks in next repaint.
115         CSize m_currentSize; //*< Current size of the panel.
116
117         // Generated message map functions
118 protected:
119         //{{AFX_MSG(CLocationView)
120         afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
121         afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
122         afx_msg void OnMouseMove(UINT nFlags, CPoint point);
123         afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point);
124         afx_msg void OnContextMenu(CWnd* pWnd, CPoint point);
125         afx_msg void OnClose();
126         afx_msg void OnVScroll (UINT nSBCode, UINT nPos, CScrollBar * pScrollBar);
127         afx_msg void OnSize(UINT nType, int cx, int cy);
128         afx_msg BOOL OnEraseBkgnd(CDC* pDC);
129         afx_msg void OnPaint();
130         afx_msg void OnSetFocus(CWnd* pOldWnd);
131         //}}AFX_MSG
132         DECLARE_MESSAGE_MAP()
133 };
134
135 #ifndef _DEBUG  // debug version in DiffView.cpp
136 inline CMergeDoc* CLocationView::GetDocument()
137    { return (CMergeDoc*)m_pDocument; }
138 #endif
139
140 /////////////////////////////////////////////////////////////////////////////
141
142 //{{AFX_INSERT_LOCATION}}
143 // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
144
145
146 #endif //__LOCATIONVIEW_H__