From d685cf205505de6d9c45be093d4453e95e15a4f6 Mon Sep 17 00:00:00 2001 From: Kimmo Varis Date: Sat, 16 Aug 2003 09:42:55 +0000 Subject: [PATCH] PATCH: [ 789204 ] Color dir compare based on left/right newer --- Src/DirView.cpp | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++++++-- Src/DirView.h | 4 ++++ Src/readme.txt | 4 ++++ 3 files changed, 64 insertions(+), 2 deletions(-) diff --git a/Src/DirView.cpp b/Src/DirView.cpp index 273410be8..fe8fd3fb4 100644 --- a/Src/DirView.cpp +++ b/Src/DirView.cpp @@ -20,6 +20,7 @@ ///////////////////////////////////////////////////////////////////////////// // DirView.cpp : implementation file // +// $Id$ #include "stdafx.h" #include "Merge.h" @@ -104,6 +105,7 @@ BEGIN_MESSAGE_MAP(CDirView, CListViewEx) //}}AFX_MSG_MAP ON_NOTIFY_REFLECT(LVN_COLUMNCLICK, OnColumnClick) ON_NOTIFY_REFLECT(LVN_GETINFOTIP, OnInfoTip) + ON_NOTIFY_REFLECT(NM_CUSTOMDRAW, OnCustomDraw) END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// @@ -801,8 +803,10 @@ DIFFITEM CDirView::GetItemAt(int ind) // Go to first diff // If none or one item selected select found item +// This is used for scrolling to first diff too void CDirView::OnFirstdiff() { + ASSERT(m_pList); DIFFITEM di; const int count = m_pList->GetItemCount(); BOOL found = FALSE; @@ -854,8 +858,6 @@ void CDirView::OnLastdiff() } } - - void CDirView::OnUpdateLastdiff(CCmdUI* pCmdUI) { int firstDiff = GetFirstDifferentItem(); @@ -1346,8 +1348,60 @@ void CDirView::OnInfoTip(NMHDR * pNMHDR, LRESULT * pResult) } } +/// Track mouse position for showing tooltips void CDirView::OnMouseMove(UINT nFlags, CPoint point) { m_ptLastMousePos = point; CListViewEx::OnMouseMove(nFlags, point); } + +/// Implement custom draw for DirView items +void CDirView::OnCustomDraw(NMHDR* pNMHDR, LRESULT* pResult) +{ + LPNMLVCUSTOMDRAW lplvcd = (LPNMLVCUSTOMDRAW)pNMHDR; + DIFFITEM ditem; + + switch (lplvcd->nmcd.dwDrawStage) + { + case CDDS_PREPAINT: // Request prepaint notifications for each item. + *pResult = CDRF_NOTIFYITEMDRAW; + break; + + case CDDS_ITEMPREPAINT: //Before an item is drawn + // Add code here to customise whole line and return: + // *pResult = CDRF_NEWFONT; // If no subitems customised + *pResult = CDRF_NOTIFYSUBITEMDRAW; // To customise subitems + break; + + case CDDS_SUBITEM | CDDS_ITEMPREPAINT: //Before a subitem is drawn + ditem = GetDiffItem(lplvcd->nmcd.dwItemSpec); + + // Set text color for filename colum + if (m_colorder[0] == lplvcd->iSubItem) + { + // Set text color based on timestamps + // Do not color unique items + if (ditem.ltime == 0 || ditem.rtime == 0) + lplvcd->clrText = GetSysColor(COLOR_WINDOWTEXT); + else + { + if (ditem.ltime < ditem.rtime) + lplvcd->clrText = RGB(53, 164, 34); + else if (ditem.ltime > ditem.rtime) + lplvcd->clrText = RGB(234, 21, 64); + else + // Make sure we use default color for ident. items + lplvcd->clrText = GetSysColor(COLOR_WINDOWTEXT); + } + } + // Set text color for other colums + else + lplvcd->clrText = GetSysColor(COLOR_WINDOWTEXT); + + *pResult = CDRF_NEWFONT; + break; + + default: + *pResult = CDRF_DODEFAULT; + } +} \ No newline at end of file diff --git a/Src/DirView.h b/Src/DirView.h index 369ae68cf..7f9884ee5 100644 --- a/Src/DirView.h +++ b/Src/DirView.h @@ -17,6 +17,9 @@ // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. // ///////////////////////////////////////////////////////////////////////////// +// +// $Id$ + #if !defined(AFX_DirView_H__16E7C721_351C_11D1_95CD_444553540000__INCLUDED_) #define AFX_DirView_H__16E7C721_351C_11D1_95CD_444553540000__INCLUDED_ @@ -218,6 +221,7 @@ protected: BOOL OnHeaderBeginDrag(LPNMHEADER hdr, LRESULT* pResult); BOOL OnHeaderEndDrag(LPNMHEADER hdr, LRESULT* pResult); afx_msg void OnInfoTip(NMHDR * pNMHDR, LRESULT * pResult); + afx_msg void OnCustomDraw(NMHDR* pNMHDR, LRESULT* pResult); private: void OpenSelection(); diff --git a/Src/readme.txt b/Src/readme.txt index a61749917..3d310ed76 100644 --- a/Src/readme.txt +++ b/Src/readme.txt @@ -1,3 +1,7 @@ +2003-08-16 Kimmo + PATCH: [ 789204 ] Color dir compare based on left/right newer + WinMerge: DirView.h DirView.cpp + 2003-08-12 Christian PATCH: [ 786618 ] Brazilian Portuguese translation Languages: BuilAll.bat and resurrected directory Brazilian -- 2.11.0