Extend static functions in CAppUtils with a window handle parameter
[TortoiseGit.git] / src / TortoiseProc / UpdateListCtrl.cpp
blobff585ccfdc7ec9d70318f8730380d100197b8046
1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2012, 2016 - 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.
19 // CUpdateListCtrl
21 #include "stdafx.h"
22 #include "UpdateListCtrl.h"
24 IMPLEMENT_DYNAMIC(CUpdateListCtrl, CListCtrl)
26 CUpdateListCtrl::CUpdateListCtrl()
28 HFONT hFont = (HFONT)GetStockObject(DEFAULT_GUI_FONT);
29 LOGFONT lf = {0};
30 GetObject(hFont, sizeof(LOGFONT), &lf);
31 lf.lfWeight = FW_BOLD;
32 m_boldFont.CreateFontIndirect(&lf);
35 CUpdateListCtrl::~CUpdateListCtrl()
39 BEGIN_MESSAGE_MAP(CUpdateListCtrl, CListCtrl)
40 ON_NOTIFY_REFLECT(NM_CUSTOMDRAW, &CUpdateListCtrl::OnNMCustomdraw)
41 END_MESSAGE_MAP()
45 // CUpdateListCtrl message handlers
46 void CUpdateListCtrl::OnNMCustomdraw(NMHDR *pNMHDR, LRESULT *pResult)
48 NMLVCUSTOMDRAW *pNMCD = reinterpret_cast<NMLVCUSTOMDRAW*>(pNMHDR);
50 *pResult = 0;
53 switch (pNMCD->nmcd.dwDrawStage)
55 case CDDS_PREPAINT:
57 *pResult = CDRF_NOTIFYITEMDRAW;
58 return;
60 break;
61 case CDDS_ITEMPREPAINT:
63 // This is the prepaint stage for an item. Here's where we set the
64 // item's text color.
66 // Tell Windows to send draw notifications for each subitem.
67 *pResult = CDRF_NOTIFYSUBITEMDRAW;
69 CUpdateListCtrl::Entry *data = (CUpdateListCtrl::Entry *)this->GetItemData((int)pNMCD->nmcd.dwItemSpec);
70 switch(data->m_status & STATUS_MASK)
72 case STATUS_SUCCESS:
73 pNMCD->clrText = RGB(0,128,0);
74 break;
75 case STATUS_FAIL:
76 pNMCD->clrText = RGB(255,0,0);
77 break;
78 case STATUS_IGNORE:
79 pNMCD->clrText = RGB(128,128,128);
80 break;
83 if(data->m_status & STATUS_DOWNLOADING)
85 SelectObject(pNMCD->nmcd.hdc, m_boldFont.GetSafeHandle());
86 *pResult = CDRF_NOTIFYSUBITEMDRAW | CDRF_NEWFONT;
90 break;
92 *pResult = CDRF_DODEFAULT;