1
// TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2012, 2016, 2018-2019 - TortoiseGit
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 2
8 // of the License, or (at your option) any later version.
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software Foundation,
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 #include "UpdateListCtrl.h"
24 IMPLEMENT_DYNAMIC(CUpdateListCtrl
, CListCtrl
)
26 CUpdateListCtrl::CUpdateListCtrl()
30 CUpdateListCtrl::~CUpdateListCtrl()
34 void CUpdateListCtrl::PreSubclassWindow()
36 __super::PreSubclassWindow();
38 // use the default font, create a copy of it and
39 // change the copy to BOLD (leave the rest of the font
42 GetFont()->GetLogFont(&lf
);
43 lf
.lfWeight
= FW_BOLD
;
44 m_boldFont
.CreateFontIndirect(&lf
);
47 BEGIN_MESSAGE_MAP(CUpdateListCtrl
, CListCtrl
)
48 ON_NOTIFY_REFLECT(NM_CUSTOMDRAW
, &CUpdateListCtrl::OnNMCustomdraw
)
53 // CUpdateListCtrl message handlers
54 void CUpdateListCtrl::OnNMCustomdraw(NMHDR
*pNMHDR
, LRESULT
*pResult
)
56 NMLVCUSTOMDRAW
*pNMCD
= reinterpret_cast<NMLVCUSTOMDRAW
*>(pNMHDR
);
61 switch (pNMCD
->nmcd
.dwDrawStage
)
65 *pResult
= CDRF_NOTIFYITEMDRAW
;
69 case CDDS_ITEMPREPAINT
:
71 // This is the prepaint stage for an item. Here's where we set the
74 // Tell Windows to send draw notifications for each subitem.
75 *pResult
= CDRF_NOTIFYSUBITEMDRAW
;
77 auto data
= reinterpret_cast<CUpdateListCtrl::Entry
*>(this->GetItemData(static_cast<int>(pNMCD
->nmcd
.dwItemSpec
)));
78 switch(data
->m_status
& STATUS_MASK
)
81 pNMCD
->clrText
= RGB(0,128,0);
84 pNMCD
->clrText
= RGB(255,0,0);
87 pNMCD
->clrText
= RGB(128,128,128);
91 if(data
->m_status
& STATUS_DOWNLOADING
)
93 SelectObject(pNMCD
->nmcd
.hdc
, m_boldFont
.GetSafeHandle());
94 *pResult
= CDRF_NOTIFYSUBITEMDRAW
| CDRF_NEWFONT
;
100 *pResult
= CDRF_DODEFAULT
;