Fixed issue #1220: ext/CrashServer/CommonLibs/Zlib/Zlib.vcproj immediate dir Win32...
[TortoiseGit.git] / src / TortoiseGitBlame / TortoiseGitBlameView.h
bloba4c86b835be41fc39797ed5ff70cf76da577437e
1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2008-2011 - TortoiseGit
4 // Copyright (C) 2003-2008 - TortoiseSVN
6 // This program is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU General Public License
8 // as published by the Free Software Foundation; either version 2
9 // of the License, or (at your option) any later version.
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the Free Software Foundation,
18 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 // TortoiseGitBlameView.h : interface of the CTortoiseGitBlameView class
26 #pragma once
28 #include "Scintilla.h"
29 #include "SciLexer.h"
30 #include "registry.h"
31 #include "SciEdit.h"
33 #include "GitBlameLogList.h"
34 #include "Tooltip.h"
36 const COLORREF black = RGB(0,0,0);
37 const COLORREF white = RGB(0xff,0xff,0xff);
38 const COLORREF red = RGB(0xFF, 0, 0);
39 const COLORREF offWhite = RGB(0xFF, 0xFB, 0xF0);
40 const COLORREF darkGreen = RGB(0, 0x80, 0);
41 const COLORREF darkBlue = RGB(0, 0, 0x80);
42 const COLORREF lightBlue = RGB(0xA6, 0xCA, 0xF0);
43 const int blockSize = 128 * 1024;
45 #define BLAMESPACE 5
46 #define HEADER_HEIGHT 18
47 #define LOCATOR_WIDTH 10
49 #define MAX_LOG_LENGTH 2000
52 #ifndef GET_X_LPARAM
53 #define GET_X_LPARAM(lp) ((int)(short)LOWORD(lp))
54 #endif
55 #ifndef GET_Y_LPARAM
56 #define GET_Y_LPARAM(lp) ((int)(short)HIWORD(lp))
57 #endif
59 class CSciEditBlame: public CSciEdit
61 DECLARE_DYNAMIC(CSciEditBlame)
62 public:
63 afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
65 switch (nChar)
67 case (VK_ESCAPE):
69 if ((Call(SCI_AUTOCACTIVE)==0)&&(Call(SCI_CALLTIPACTIVE)==0))
71 ::SendMessage(::AfxGetApp()->GetMainWnd()->m_hWnd, WM_CLOSE, 0, 0);
72 return;
75 break;
77 CWnd::OnKeyDown(nChar, nRepCnt, nFlags);
81 class CTortoiseGitBlameView : public CView
83 protected: // create from serialization only
84 CTortoiseGitBlameView();
85 DECLARE_DYNCREATE(CTortoiseGitBlameView)
87 // Attributes
88 public:
89 CTortoiseGitBlameDoc* GetDocument() const;
90 int GetEncode(unsigned char * buffer, int size, int *bomoffset);
91 // Operations
92 public:
94 // Overrides
95 public:
96 virtual void OnDraw(CDC* pDC); // overridden to draw this view
97 virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
98 protected:
99 virtual BOOL OnPreparePrinting(CPrintInfo* pInfo);
100 virtual void OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo);
101 virtual void OnEndPrinting(CDC* pDC, CPrintInfo* pInfo);
103 // Implementation
104 public:
105 virtual ~CTortoiseGitBlameView();
106 #ifdef _DEBUG
107 virtual void AssertValid() const;
108 virtual void Dump(CDumpContext& dc) const;
109 #endif
111 protected:
113 // Generated message map functions
114 protected:
115 BOOL PreTranslateMessage(MSG* pMsg);
116 afx_msg void OnChangeEncode(UINT nID);
117 afx_msg void OnEditFind();
118 afx_msg void OnEditGoto();
119 afx_msg void OnFilePrintPreview();
120 afx_msg void OnRButtonUp(UINT nFlags, CPoint point);
121 afx_msg int OnCreate(LPCREATESTRUCT lpcs);
122 afx_msg void OnSize(UINT nType, int cx, int cy);
123 afx_msg void OnSciPainted(NMHDR*, LRESULT*);
124 afx_msg void OnLButtonDown(UINT nFlags,CPoint point);
125 afx_msg void OnRButtonDown(UINT nFlags,CPoint point){OnLButtonDown(nFlags,point);CView::OnRButtonDown(nFlags,point);};
126 afx_msg void OnSciGetBkColor(NMHDR*, LRESULT*);
127 afx_msg void OnMouseHover(UINT nFlags, CPoint point);
128 afx_msg void OnMouseMove(UINT nFlags, CPoint point);
129 afx_msg LRESULT OnFindDialogMessage(WPARAM wParam, LPARAM lParam);
130 afx_msg void OnViewNext();
131 afx_msg void OnViewPrev();
132 afx_msg void OnViewToggleAuthor();
133 afx_msg void OnUpdateViewToggleAuthor(CCmdUI *pCmdUI);
134 afx_msg void OnViewToggleFollowRenames();
135 afx_msg void OnUpdateViewToggleFollowRenames(CCmdUI *pCmdUI);
136 afx_msg void CopyHashToClipboard();
137 afx_msg void OnUpdateBlamePopupBlamePrevious(CCmdUI *pCmdUI);
138 afx_msg void OnUpdateBlamePopupDiffPrevious(CCmdUI *pCmdUI);
140 int FindNextLine(CGitHash commithash, bool bUpOrDown=false);
141 int FindFirstLine(CGitHash commithash, int line)
143 while(line>=0)
145 if( m_CommitHash[line] != commithash )
147 return line++;
149 line--;
151 return line;
154 DECLARE_MESSAGE_MAP()
156 static UINT m_FindDialogMessage;
157 public:
159 void UpdateInfo(int encode = 0);
160 void FocusOn(GitRev *pRev);
162 CSciEditBlame m_TextView;
163 CToolTips m_ToolTip;
165 HINSTANCE hInstance;
166 HINSTANCE hResource;
167 HWND currentDialog;
168 HWND wMain;
169 HWND m_wEditor;
170 HWND wBlame;
171 HWND wHeader;
172 HWND wLocator;
173 HWND hwndTT;
175 BOOL bIgnoreEOL;
176 BOOL bIgnoreSpaces;
177 BOOL bIgnoreAllSpaces;
179 BOOL m_bShowAuthor;
180 BOOL m_bShowDate;
181 BOOL m_bFollowRenames;
183 LRESULT SendEditor(UINT Msg, WPARAM wParam=0, LPARAM lParam=0);
185 void GetRange(int start, int end, char *text);
187 void SetTitle();
188 BOOL OpenFile(const char *fileName);
189 BOOL OpenLogFile(const char *fileName);
191 void Command(int id);
192 void Notify(SCNotification *notification);
194 void SetAStyle(int style, COLORREF fore, COLORREF back=::GetSysColor(COLOR_WINDOW), int size=-1, CString *face=0);
196 void InitialiseEditor();
197 void InitSize();
198 LONG GetBlameWidth();
199 void DrawBlame(HDC hDC);
200 void DrawHeader(HDC hDC);
201 void DrawLocatorBar(HDC hDC);
202 void StartSearch();
203 void CopySelectedLogToClipboard();
204 void BlamePreviousRevision();
205 void DiffPreviousRevision();
206 void ShowLog();
207 bool DoSearch(CString what, DWORD flags);
208 bool GotoLine(long line);
209 bool ScrollToLine(long line);
210 void GotoLineDlg();
211 static INT_PTR CALLBACK GotoDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
213 void SetSelectedLine(LONG line) { m_SelectedLine=line;};
215 LONG m_mouserev;
216 LONG m_MouseLine;
217 LONG m_selectedrev;
218 LONG m_selectedorigrev;
219 CGitHash m_SelectedHash;
220 CGitHash m_selecteddate;
221 static long m_gotoline;
222 long m_lowestrev;
223 long m_highestrev;
224 bool m_colorage;
226 // std::vector<bool> m_Mergelines;
227 std::vector<LONG> m_ID;
228 std::vector<LONG> m_LineNum;
229 // std::vector<LONG> m_Origrevs;
230 std::vector<CString> m_Dates;
231 std::vector<CString> m_Authors;
232 std::vector<CGitHash> m_CommitHash;
234 std::map<CString,GitRev> m_NoListCommit;
236 // std::vector<CString> m_Paths;
237 // std::map<LONG, CString> logmessages;
238 char m_szTip[MAX_LOG_LENGTH*2+6];
239 wchar_t m_wszTip[MAX_LOG_LENGTH*2+6];
240 void StringExpand(LPSTR str);
241 void StringExpand(LPWSTR str);
242 BOOL ttVisible;
244 CLogDataVector * GetLogData();
246 BOOL m_bShowLine;
248 protected:
249 void CreateFont();
250 void SetupLexer(CString filename);
251 void SetupCppLexer();
252 COLORREF InterColor(COLORREF c1, COLORREF c2, int Slider);
253 CString GetAppDirectory();
254 std::vector<COLORREF> colors;
255 HFONT m_font;
256 HFONT m_italicfont;
257 LONG m_blamewidth;
258 LONG m_revwidth;
259 LONG m_datewidth;
260 LONG m_authorwidth;
261 LONG m_pathwidth;
262 LONG m_linewidth;
263 LONG m_SelectedLine; ///< zero-based
265 COLORREF m_mouserevcolor;
266 COLORREF m_mouseauthorcolor;
267 COLORREF m_selectedrevcolor;
268 COLORREF m_selectedauthorcolor;
269 COLORREF m_windowcolor;
270 COLORREF m_textcolor;
271 COLORREF m_texthighlightcolor;
273 LRESULT m_directFunction;
274 LRESULT m_directPointer;
275 FINDREPLACE fr;
276 TCHAR szFindWhat[80];
278 CRegStdDWORD m_regOldLinesColor;
279 CRegStdDWORD m_regNewLinesColor;
281 CGitBlameLogList * GetLogList();
283 CFindReplaceDialog *m_pFindDialog;
285 char *m_Buffer;
287 DWORD m_DateFormat; // DATE_SHORTDATE or DATE_LONGDATE
288 bool m_bRelativeTimes; // Show relative times
290 CString m_sRev;
291 CString m_sAuthor;
292 CString m_sDate;
293 CString m_sMessage;
296 #ifndef _DEBUG // debug version in TortoiseGitBlameView.cpp
297 inline CTortoiseGitBlameDoc* CTortoiseGitBlameView::GetDocument() const
298 { return reinterpret_cast<CTortoiseGitBlameDoc*>(m_pDocument); }
299 #endif