class CXTPRibbonBackstagePageRecentCustom : public CXTPRibbonBackstagePageRecent{
public:
CXTPRibbonBackstagePageRecentCustom();
virtual ~CXTPRibbonBackstagePageRecentCustom();
public:
virtual void InitCustomIcons();
virtual BOOL OnSetActive();
protected:
CXTPImageManager* m_pCustomIcons;
};
CXTPRibbonBackstagePageRecentCustom::CXTPRibbonBackstagePageRecentCustom()
: m_pCustomIcons(NULL)
{
}
CXTPRibbonBackstagePageRecentCustom::~CXTPRibbonBackstagePageRecentCustom()
{
if (m_pCustomIcons)
m_pCustomIcons->InternalRelease();
}
void CXTPRibbonBackstagePageRecentCustom::InitCustomIcons()
{
CBitmap bmp;
XTPResourceManager()->LoadBitmap(&bmp, XTP_IDB_CUSTOMIZE_ICONS); // XTP_IDB_WORKSPACE_ICONS
BITMAP bmpInfo;
bmp.GetBitmap(&bmpInfo);
UINT nCount = bmpInfo.bmWidth / 16;
if (m_pCustomIcons)
m_pCustomIcons->InternalRelease();
m_pCustomIcons = new CXTPImageManager;
UINT* pIDs = new UINT[nCount];
for (UINT i = 0; i < nCount; i++)
{
pIDs[ i ] = i + 1;
}
VERIFY(m_pCustomIcons->SetIcons(bmp, pIDs, nCount, CSize(16, 16), xtpImageNormal));
delete[] pIDs;
UINT nIDs[] = {0, 1001, 1000}; //ID_ICON_UNPINNED, ID_ICON_PINNED
m_pCustomIcons->SetIcons(XTP_IDB_RIBBON_PINICON, nIDs, 3, CSize(16, 16), xtpImageNormal);
m_wndList.GetItems()->SetImageManager(m_pCustomIcons);
m_pCustomIcons->InternalAddRef();
}
BOOL CXTPRibbonBackstagePageRecentCustom::OnSetActive()
{
CXTPRecentFileList* pRecentFileList = (CXTPRecentFileList*) m_wndList.GetRecentFileList();
if (pRecentFileList && pRecentFileList->m_strOriginal == _T("PinableRecentFileList"))
{
for (int nIndex = 0; nIndex < pRecentFileList->m_nSize; nIndex++)
{
CXTPRecentFileListItem* pItem = pRecentFileList->GetItem(nIndex);
if (!pItem)
continue;
//if ( some_condition ) then set_some_icon
pItem->SetIconId(nIndex+1);
}
m_wndList.BuildItems((CXTPRecentFileList*)pRecentFileList);
return TRUE;
}
return FALSE;
}