Fixed issue #4126: Capitalize the first letter in the Push dialog
[TortoiseGit.git] / src / TortoiseProc / UpdateListCtrl.cpp
blob9c07e017e73a9efcf5e091928bebe9d48bef380a
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.
19 // CUpdateListCtrl
21 #include "stdafx.h"
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
40 // the same)
41 LOGFONT lf = { 0 };
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)
49 END_MESSAGE_MAP()
53 // CUpdateListCtrl message handlers
54 void CUpdateListCtrl::OnNMCustomdraw(NMHDR *pNMHDR, LRESULT *pResult)
56 NMLVCUSTOMDRAW *pNMCD = reinterpret_cast<NMLVCUSTOMDRAW*>(pNMHDR);
58 *pResult = 0;
61 switch (pNMCD->nmcd.dwDrawStage)
63 case CDDS_PREPAINT:
65 *pResult = CDRF_NOTIFYITEMDRAW;
66 return;
68 break;
69 case CDDS_ITEMPREPAINT:
71 // This is the prepaint stage for an item. Here's where we set the
72 // item's text color.
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)
80 case STATUS_SUCCESS:
81 pNMCD->clrText = RGB(0,128,0);
82 break;
83 case STATUS_FAIL:
84 pNMCD->clrText = RGB(255,0,0);
85 break;
86 case STATUS_IGNORE:
87 pNMCD->clrText = RGB(128,128,128);
88 break;
91 if(data->m_status & STATUS_DOWNLOADING)
93 SelectObject(pNMCD->nmcd.hdc, m_boldFont.GetSafeHandle());
94 *pResult = CDRF_NOTIFYSUBITEMDRAW | CDRF_NEWFONT;
98 break;
100 *pResult = CDRF_DODEFAULT;