From 8b3f239e2b1393fffed7826dc5e1072c19f6b717 Mon Sep 17 00:00:00 2001 From: Frank Li Date: Wed, 14 Jan 2009 00:25:44 +0800 Subject: [PATCH] Hover Balloon at gitblame view support Signed-off-by: Frank Li --- src/Git/targetver.h | 4 +- src/TortoiseGitBlame/TortoiseGitBlameView.cpp | 75 ++++++++++++++++++++++++++- src/TortoiseGitBlame/TortoiseGitBlameView.h | 7 ++- src/TortoiseGitBlame/targetver.h | 4 +- src/TortoiseProc/GitLogListBase.cpp | 2 +- src/Utils/targetver.h | 4 +- 6 files changed, 86 insertions(+), 10 deletions(-) diff --git a/src/Git/targetver.h b/src/Git/targetver.h index f583181..8d61047 100644 --- a/src/Git/targetver.h +++ b/src/Git/targetver.h @@ -8,11 +8,11 @@ // Modify the following defines if you have to target a platform prior to the ones specified below. // Refer to MSDN for the latest info on corresponding values for different platforms. #ifndef WINVER // Specifies that the minimum required platform is Windows Vista. -#define WINVER 0x0600 // Change this to the appropriate value to target other versions of Windows. +#define WINVER 0x0500 // Change this to the appropriate value to target other versions of Windows. #endif #ifndef _WIN32_WINNT // Specifies that the minimum required platform is Windows Vista. -#define _WIN32_WINNT 0x0600 // Change this to the appropriate value to target other versions of Windows. +#define _WIN32_WINNT 0x0500 // Change this to the appropriate value to target other versions of Windows. #endif #ifndef _WIN32_WINDOWS // Specifies that the minimum required platform is Windows 98. diff --git a/src/TortoiseGitBlame/TortoiseGitBlameView.cpp b/src/TortoiseGitBlame/TortoiseGitBlameView.cpp index e152a90..6382244 100644 --- a/src/TortoiseGitBlame/TortoiseGitBlameView.cpp +++ b/src/TortoiseGitBlame/TortoiseGitBlameView.cpp @@ -25,6 +25,7 @@ #include "TortoiseGitBlameDoc.h" #include "TortoiseGitBlameView.h" #include "MainFrm.h" +#include "Balloon.h" #ifdef _DEBUG #define new DEBUG_NEW @@ -122,6 +123,9 @@ int CTortoiseGitBlameView::OnCreate(LPCREATESTRUCT lpcs) m_wEditor = m_TextView.m_hWnd; CreateFont(); InitialiseEditor(); + m_ToolTip.Create(this->GetParent()); + m_ToolTip.AddTool(this,_T("Test")); + return CView::OnCreate(lpcs); } @@ -1132,8 +1136,8 @@ void CTortoiseGitBlameView::DrawBlame(HDC hDC) ::SetTextColor(hDC, m_textcolor); if (m_CommitHash[i].GetLength()>0) { - if (m_CommitHash[i].Compare(m_MouseHash)==0) - ::SetBkColor(hDC, m_mouseauthorcolor); + //if (m_CommitHash[i].Compare(m_MouseHash)==0) + // ::SetBkColor(hDC, m_mouseauthorcolor); if (m_CommitHash[i].Compare(m_SelectedHash)==0) { ::SetBkColor(hDC, m_selectedauthorcolor); @@ -2607,4 +2611,71 @@ void CTortoiseGitBlameView::FocusOn(GitRev *pRev) this->Invalidate(); this->m_TextView.Invalidate(); +} + +void CTortoiseGitBlameView::OnMouseHover(UINT nFlags, CPoint point) +{ + + LONG_PTR line = SendEditor(SCI_GETFIRSTVISIBLELINE); + LONG_PTR height = SendEditor(SCI_TEXTHEIGHT); + line = line + (point.y/height); + + if (line < (LONG)m_CommitHash.size()) + { + if (line != m_MouseLine) + { + m_MouseLine = line;//m_CommitHash[line]; +// app.m_selectedorigrev = app.origrevs[line]; +// app.m_selectedauthor = app.authors[line]; +// app.m_selecteddate = app.dates[line]; + + + GitRev *pRev; + pRev=&this->GetLogData()->at(this->GetLogList()->GetItemCount()-m_ID[line]); + //this->GetDocument()->GetMainFrame()->m_wndProperties.UpdateProperties(pRev); + this->ClientToScreen(&point); + //BALLOON_INFO bi; + //if(m_ToolTip.GetTool(this, bi)) + //{ + // bi.sBalloonTip=pRev->m_CommitHash; + CString str; + str.Format(_T("%s\n%s\n%s"),pRev->m_CommitHash,pRev->m_Subject,pRev->m_AuthorDate.Format(_T("%Y-%m-%d %H:%M"))); + m_ToolTip.AddTool(this,str); + m_ToolTip.DisplayToolTip(&point); + //} + + } + else + { + m_MouseLine=-1; +// app.m_selecteddate.clear(); +// app.m_selectedrev = -2; +// app.m_selectedorigrev = -2; + } + //::InvalidateRect( NULL, FALSE); + //this->Invalidate(); + } + +// const CString str=_T("this is a Message Balloon\n\nWarning! Warning!\nSomething unexpected happened"); + //CBalloon::ShowBalloon(NULL, point, + // str, + // FALSE, (HICON)IDI_EXCLAMATION, + // (UINT)CBalloon ::BALLOON_RIGHT_TOP, (UINT)CBalloon ::BALLOON_EFFECT_SOLID,(COLORREF)NULL, (COLORREF)NULL, (COLORREF)NULL); +} + +void CTortoiseGitBlameView::OnMouseMove(UINT nFlags, CPoint point) +{ + TRACKMOUSEEVENT tme; + tme.cbSize=sizeof(TRACKMOUSEEVENT); + tme.dwFlags=TME_HOVER|TME_LEAVE; + tme.hwndTrack=this->m_hWnd; + tme.dwHoverTime=1; + TrackMouseEvent(&tme); +} + + +BOOL CTortoiseGitBlameView::PreTranslateMessage(MSG* pMsg) +{ + m_ToolTip.RelayEvent(pMsg); + return CView::PreTranslateMessage(pMsg); } \ No newline at end of file diff --git a/src/TortoiseGitBlame/TortoiseGitBlameView.h b/src/TortoiseGitBlame/TortoiseGitBlameView.h index bbee267..b0f2a09 100644 --- a/src/TortoiseGitBlame/TortoiseGitBlameView.h +++ b/src/TortoiseGitBlame/TortoiseGitBlameView.h @@ -11,6 +11,7 @@ #include "SciEdit.h" #include "GitBlameLogList.h" +#include "Balloon.h" const COLORREF black = RGB(0,0,0); const COLORREF white = RGB(0xff,0xff,0xff); @@ -70,6 +71,7 @@ protected: // Generated message map functions protected: + BOOL PreTranslateMessage(MSG* pMsg); afx_msg void OnFilePrintPreview(); afx_msg void OnRButtonUp(UINT nFlags, CPoint point); afx_msg void OnContextMenu(CWnd* pWnd, CPoint point); @@ -79,6 +81,8 @@ protected: afx_msg void OnLButtonDown(UINT nFlags,CPoint point); afx_msg void OnRButtonDown(UINT nFlags,CPoint point){OnLButtonDown(nFlags,point);CView::OnRButtonDown(nFlags,point);}; afx_msg void OnSciGetBkColor(NMHDR*, LRESULT*); + afx_msg void OnMouseHover(UINT nFlags, CPoint point); + afx_msg void OnMouseMove(UINT nFlags, CPoint point); DECLARE_MESSAGE_MAP() public: @@ -87,6 +91,7 @@ public: void FocusOn(GitRev *pRev); CSciEdit m_TextView; + CBalloon m_ToolTip; HINSTANCE hInstance; HINSTANCE hResource; @@ -139,7 +144,7 @@ public: void SetSelectedLine(LONG line) { m_SelectedLine=line;}; LONG m_mouserev; - CString m_MouseHash; + LONG m_MouseLine; LONG m_selectedrev; LONG m_selectedorigrev; CString m_SelectedHash; diff --git a/src/TortoiseGitBlame/targetver.h b/src/TortoiseGitBlame/targetver.h index 27867ba..72b5953 100644 --- a/src/TortoiseGitBlame/targetver.h +++ b/src/TortoiseGitBlame/targetver.h @@ -9,11 +9,11 @@ // Modify the following defines if you have to target a platform prior to the ones specified below. // Refer to MSDN for the latest info on corresponding values for different platforms. #ifndef WINVER // Specifies that the minimum required platform is Windows Vista. -#define WINVER 0x0600 // Change this to the appropriate value to target other versions of Windows. +#define WINVER 0x0500 // Change this to the appropriate value to target other versions of Windows. #endif #ifndef _WIN32_WINNT // Specifies that the minimum required platform is Windows Vista. -#define _WIN32_WINNT 0x0600 // Change this to the appropriate value to target other versions of Windows. +#define _WIN32_WINNT 0x0500 // Change this to the appropriate value to target other versions of Windows. #endif #ifndef _WIN32_WINDOWS // Specifies that the minimum required platform is Windows 98. diff --git a/src/TortoiseProc/GitLogListBase.cpp b/src/TortoiseProc/GitLogListBase.cpp index 2433d19..b43065f 100644 --- a/src/TortoiseProc/GitLogListBase.cpp +++ b/src/TortoiseProc/GitLogListBase.cpp @@ -126,7 +126,7 @@ int CGitLogListBase:: OnCreate(LPCREATESTRUCT lpCreateStruct) void CGitLogListBase::PreSubclassWindow() { - SetExtendedStyle(LVS_EX_FULLROWSELECT | LVS_EX_DOUBLEBUFFER | LVS_EX_SUBITEMIMAGES); + SetExtendedStyle(LVS_EX_FULLROWSELECT | LVS_EX_SUBITEMIMAGES); // load the icons for the action columns m_Theme.SetWindowTheme(GetSafeHwnd(), L"Explorer", NULL); CHintListCtrl::PreSubclassWindow(); diff --git a/src/Utils/targetver.h b/src/Utils/targetver.h index f583181..8d61047 100644 --- a/src/Utils/targetver.h +++ b/src/Utils/targetver.h @@ -8,11 +8,11 @@ // Modify the following defines if you have to target a platform prior to the ones specified below. // Refer to MSDN for the latest info on corresponding values for different platforms. #ifndef WINVER // Specifies that the minimum required platform is Windows Vista. -#define WINVER 0x0600 // Change this to the appropriate value to target other versions of Windows. +#define WINVER 0x0500 // Change this to the appropriate value to target other versions of Windows. #endif #ifndef _WIN32_WINNT // Specifies that the minimum required platform is Windows Vista. -#define _WIN32_WINNT 0x0600 // Change this to the appropriate value to target other versions of Windows. +#define _WIN32_WINNT 0x0500 // Change this to the appropriate value to target other versions of Windows. #endif #ifndef _WIN32_WINDOWS // Specifies that the minimum required platform is Windows 98. -- 2.11.0