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