1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2012 - 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()
28 HFONT hFont
= (HFONT
)GetStockObject(DEFAULT_GUI_FONT
);
30 GetObject(hFont
, sizeof(LOGFONT
), &lf
);
31 lf
.lfWeight
= FW_BOLD
;
32 m_boldFont
= CreateFontIndirect(&lf
);
35 CUpdateListCtrl::~CUpdateListCtrl()
38 DeleteObject(m_boldFont
);
41 BEGIN_MESSAGE_MAP(CUpdateListCtrl
, CListCtrl
)
42 ON_NOTIFY_REFLECT(NM_CUSTOMDRAW
, &CUpdateListCtrl::OnNMCustomdraw
)
47 // CUpdateListCtrl message handlers
48 void CUpdateListCtrl::OnNMCustomdraw(NMHDR
*pNMHDR
, LRESULT
*pResult
)
50 NMLVCUSTOMDRAW
*pNMCD
= reinterpret_cast<NMLVCUSTOMDRAW
*>(pNMHDR
);
55 switch (pNMCD
->nmcd
.dwDrawStage
)
59 *pResult
= CDRF_NOTIFYITEMDRAW
;
63 case CDDS_ITEMPREPAINT
:
65 // This is the prepaint stage for an item. Here's where we set the
68 // Tell Windows to send draw notifications for each subitem.
69 *pResult
= CDRF_NOTIFYSUBITEMDRAW
;
71 CUpdateListCtrl::Entry
*data
= (CUpdateListCtrl::Entry
*)this->GetItemData((int)pNMCD
->nmcd
.dwItemSpec
);
72 switch(data
->m_status
& STATUS_MASK
)
75 pNMCD
->clrText
= RGB(0,128,0);
78 pNMCD
->clrText
= RGB(255,0,0);
81 pNMCD
->clrText
= RGB(128,128,128);
85 if(data
->m_status
& STATUS_DOWNLOADING
)
87 SelectObject(pNMCD
->nmcd
.hdc
, m_boldFont
);
88 *pResult
= CDRF_NOTIFYSUBITEMDRAW
| CDRF_NEWFONT
;
94 *pResult
= CDRF_DODEFAULT
;