OSDN Git Service

igit added as submodule
[tortoisegit/TortoiseGitJp.git] / src / TortoiseGitBlame / TortoiseGitBlameView.h
1 \r
2 // TortoiseGitBlameView.h : interface of the CTortoiseGitBlameView class\r
3 //\r
4 \r
5 \r
6 #pragma once\r
7 \r
8 #include "Scintilla.h"\r
9 #include "SciLexer.h"\r
10 #include "registry.h"\r
11 #include "SciEdit.h"\r
12 \r
13 #include "GitBlameLogList.h"\r
14 #include "Balloon.h"\r
15 \r
16 const COLORREF black = RGB(0,0,0);\r
17 const COLORREF white = RGB(0xff,0xff,0xff);\r
18 const COLORREF red = RGB(0xFF, 0, 0);\r
19 const COLORREF offWhite = RGB(0xFF, 0xFB, 0xF0);\r
20 const COLORREF darkGreen = RGB(0, 0x80, 0);\r
21 const COLORREF darkBlue = RGB(0, 0, 0x80);\r
22 const COLORREF lightBlue = RGB(0xA6, 0xCA, 0xF0);\r
23 const int blockSize = 128 * 1024;\r
24 \r
25 #define BLAMESPACE 5\r
26 #define HEADER_HEIGHT 18\r
27 #define LOCATOR_WIDTH 10\r
28 \r
29 #define MAX_LOG_LENGTH 2000\r
30 \r
31 \r
32 #ifndef GET_X_LPARAM\r
33 #define GET_X_LPARAM(lp)                        ((int)(short)LOWORD(lp))\r
34 #endif\r
35 #ifndef GET_Y_LPARAM\r
36 #define GET_Y_LPARAM(lp)                        ((int)(short)HIWORD(lp))\r
37 #endif\r
38 \r
39 \r
40 class CTortoiseGitBlameView : public CView\r
41 {\r
42 protected: // create from serialization only\r
43         CTortoiseGitBlameView();\r
44         DECLARE_DYNCREATE(CTortoiseGitBlameView)\r
45 \r
46 // Attributes\r
47 public:\r
48         CTortoiseGitBlameDoc* GetDocument() const;\r
49 \r
50 // Operations\r
51 public:\r
52 \r
53 // Overrides\r
54 public:\r
55         virtual void OnDraw(CDC* pDC);  // overridden to draw this view\r
56         virtual BOOL PreCreateWindow(CREATESTRUCT& cs);\r
57 protected:\r
58         virtual BOOL OnPreparePrinting(CPrintInfo* pInfo);\r
59         virtual void OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo);\r
60         virtual void OnEndPrinting(CDC* pDC, CPrintInfo* pInfo);\r
61 \r
62 // Implementation\r
63 public:\r
64         virtual ~CTortoiseGitBlameView();\r
65 #ifdef _DEBUG\r
66         virtual void AssertValid() const;\r
67         virtual void Dump(CDumpContext& dc) const;\r
68 #endif\r
69 \r
70 protected:\r
71 \r
72 // Generated message map functions\r
73 protected:\r
74         BOOL PreTranslateMessage(MSG* pMsg);\r
75         afx_msg void OnEditFind();\r
76         afx_msg void OnEditGoto();\r
77         afx_msg void OnFilePrintPreview();\r
78         afx_msg void OnRButtonUp(UINT nFlags, CPoint point);\r
79         afx_msg void OnContextMenu(CWnd* pWnd, CPoint point);\r
80         afx_msg int OnCreate(LPCREATESTRUCT lpcs);\r
81         afx_msg void OnSize(UINT nType, int cx, int cy);\r
82         afx_msg void OnSciPainted(NMHDR*, LRESULT*);\r
83         afx_msg void OnLButtonDown(UINT nFlags,CPoint point);\r
84         afx_msg void OnRButtonDown(UINT nFlags,CPoint point){OnLButtonDown(nFlags,point);CView::OnRButtonDown(nFlags,point);};\r
85         afx_msg void OnSciGetBkColor(NMHDR*, LRESULT*);\r
86         afx_msg void OnMouseHover(UINT nFlags, CPoint point);\r
87         afx_msg void OnMouseMove(UINT nFlags, CPoint point);\r
88     afx_msg LRESULT OnFindDialogMessage(WPARAM   wParam,   LPARAM   lParam);\r
89         afx_msg void OnViewNext();\r
90         afx_msg void OnViewPrev();\r
91         \r
92         int FindNextLine(CString commithash, bool bUpOrDown=false);\r
93         int FindFirstLine(CString commithash, int line)\r
94         {\r
95                 while(line>=0)\r
96                 {\r
97                         if( m_CommitHash[line] != commithash )\r
98                         {\r
99                                 return line++;\r
100                         }\r
101                         line--;\r
102                 }\r
103                 return line;\r
104         }\r
105 \r
106         DECLARE_MESSAGE_MAP()\r
107 \r
108     static UINT m_FindDialogMessage;\r
109 public:\r
110 \r
111         void UpdateInfo();\r
112         void FocusOn(GitRev *pRev);\r
113 \r
114         CSciEdit                        m_TextView;\r
115         CBalloon                        m_ToolTip;\r
116 \r
117         HINSTANCE hInstance;\r
118         HINSTANCE hResource;\r
119         HWND currentDialog;\r
120         HWND wMain;\r
121         HWND m_wEditor;\r
122         HWND wBlame;\r
123         HWND wHeader;\r
124         HWND wLocator;\r
125         HWND hwndTT;\r
126 \r
127         BOOL bIgnoreEOL;\r
128         BOOL bIgnoreSpaces;\r
129         BOOL bIgnoreAllSpaces;\r
130 \r
131         BOOL m_bShowAuthor;\r
132         BOOL m_bShowDate;\r
133 \r
134 \r
135         LRESULT SendEditor(UINT Msg, WPARAM wParam=0, LPARAM lParam=0);\r
136 \r
137         void GetRange(int start, int end, char *text);\r
138 \r
139         void SetTitle();\r
140         BOOL OpenFile(const char *fileName);\r
141         BOOL OpenLogFile(const char *fileName);\r
142 \r
143         void Command(int id);\r
144         void Notify(SCNotification *notification);\r
145 \r
146         void SetAStyle(int style, COLORREF fore, COLORREF back=::GetSysColor(COLOR_WINDOW), int size=-1, CString *face=0);\r
147 \r
148         void InitialiseEditor();\r
149     void InitSize();\r
150         LONG GetBlameWidth();\r
151         void DrawBlame(HDC hDC);\r
152         void DrawHeader(HDC hDC);\r
153         void DrawLocatorBar(HDC hDC);\r
154         void StartSearch();\r
155         void CopySelectedLogToClipboard();\r
156         void BlamePreviousRevision();\r
157         void DiffPreviousRevision();\r
158         void ShowLog();\r
159         bool DoSearch(CString what, DWORD flags);\r
160         bool GotoLine(long line);\r
161         bool ScrollToLine(long line);\r
162         void GotoLineDlg();\r
163         static INT_PTR CALLBACK GotoDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);\r
164 \r
165         void SetSelectedLine(LONG line) { m_SelectedLine=line;};\r
166 \r
167         LONG                                            m_mouserev;\r
168         LONG                                            m_MouseLine;\r
169         LONG                                            m_selectedrev;\r
170         LONG                                            m_selectedorigrev;\r
171         CString                                         m_SelectedHash;\r
172         CString                                         m_selecteddate;\r
173         static long                                     m_gotoline;\r
174         long                                            m_lowestrev;\r
175         long                                            m_highestrev;\r
176         bool                                            m_colorage;\r
177 \r
178 //      std::vector<bool>               m_Mergelines;\r
179         std::vector<LONG>               m_ID;\r
180         std::vector<LONG>               m_LineNum;\r
181 //      std::vector<LONG>               m_Origrevs;\r
182         std::vector<CString>    m_Dates;\r
183         std::vector<CString>    m_Authors;\r
184         std::vector<CString>    m_CommitHash;\r
185 \r
186         std::map<CString,GitRev> m_NoListCommit;\r
187 \r
188 //      std::vector<CString>    m_Paths;\r
189 //      std::map<LONG, CString> logmessages;\r
190         char                                            m_szTip[MAX_LOG_LENGTH*2+6];\r
191         wchar_t                                         m_wszTip[MAX_LOG_LENGTH*2+6];\r
192         void StringExpand(LPSTR str);\r
193         void StringExpand(LPWSTR str);\r
194         BOOL                                            ttVisible;\r
195 \r
196         CLogDataVector *                GetLogData();\r
197 \r
198         BOOL m_bShowLine;\r
199 \r
200 protected:\r
201         void CreateFont();\r
202         void SetupLexer(CString filename);\r
203         void SetupCppLexer();\r
204         COLORREF InterColor(COLORREF c1, COLORREF c2, int Slider);\r
205         CString GetAppDirectory();\r
206         std::vector<COLORREF>           colors;\r
207         HFONT                                           m_font;\r
208         HFONT                                           m_italicfont;\r
209         LONG                                            m_blamewidth;\r
210         LONG                                            m_revwidth;\r
211         LONG                                            m_datewidth;\r
212         LONG                                            m_authorwidth;\r
213         LONG                                            m_pathwidth;\r
214         LONG                                            m_linewidth;\r
215         LONG                                            m_SelectedLine; ///< zero-based\r
216 \r
217         COLORREF                                        m_mouserevcolor;\r
218         COLORREF                                        m_mouseauthorcolor;\r
219         COLORREF                                        m_selectedrevcolor;\r
220         COLORREF                                        m_selectedauthorcolor;\r
221         COLORREF                                        m_windowcolor;\r
222         COLORREF                                        m_textcolor;\r
223         COLORREF                                        m_texthighlightcolor;\r
224 \r
225         LRESULT                                         m_directFunction;\r
226         LRESULT                                         m_directPointer;\r
227         FINDREPLACE                                     fr;\r
228         TCHAR                                           szFindWhat[80];\r
229 \r
230         CRegStdWORD                                     m_regOldLinesColor;\r
231         CRegStdWORD                                     m_regNewLinesColor;\r
232 \r
233         CGitBlameLogList * GetLogList();\r
234 \r
235     CFindReplaceDialog          *m_pFindDialog;\r
236 \r
237         DWORD                                           m_DateFormat;   // DATE_SHORTDATE or DATE_LONGDATE\r
238 };\r
239 \r
240 #ifndef _DEBUG  // debug version in TortoiseGitBlameView.cpp\r
241 inline CTortoiseGitBlameDoc* CTortoiseGitBlameView::GetDocument() const\r
242    { return reinterpret_cast<CTortoiseGitBlameDoc*>(m_pDocument); }\r
243 #endif\r
244 \r