inline void TabMenuDisplay::PaintMainMenuItems(Canvas &canvas, const unsigned CaptionStyle) const { PaintMainMenuBorder(canvas); const bool is_focused = !HasCursorKeys() || HasFocus(); unsigned main_menu_index = 0; for (auto i = main_menu_buttons.begin(), end = main_menu_buttons.end(); i != end; ++i, ++main_menu_index) { const bool isDown = main_menu_index == down_index.main_index && !down_index.IsSub() && !drag_off_button; const bool is_selected = isDown || main_menu_index == GetPageMainIndex(cursor); canvas.SetTextColor(look.list.GetTextColor(is_selected, is_focused, isDown)); canvas.SetBackgroundColor(look.list.GetBackgroundColor(is_selected, is_focused, isDown)); const PixelRect &rc = GetMainMenuButtonSize(main_menu_index); TabDisplay::PaintButton(canvas, CaptionStyle, gettext(GetGroupCaption(main_menu_index)), rc, nullptr, isDown, false); } }
void CFeedIcoItemListCtrl::DrawGroupInfo(CDC & dcMem, const CRect & rectClip, const CRect & rectClient) { dcMem.SelectObject(&m_FontBold); if (thePrefs.GetWindowsVersion() >= _WINVER_VISTA_ ) { int n = GetGroupCount(); for(int i = 0 ; i < n; ++i) { CString strGroupCaption = GetGroupCaption( i ); CString strGroupTotals; if ( strGroupCaption == m_mapGroups.GetKeyAt(i) ) { const CSimpleArray<int>& groupRows = m_mapGroups.GetValueAt(i); strGroupTotals.Format(_T("(共%d个)"), groupRows.GetSize()); } LVGROUP lg = GetGroupInfoByIndex(i, LVGF_GROUPID); CRect rcGroup = GetRectbyGroupID(lg.iGroupId, LVGGR_HEADER); CRect rcIntersect; rcIntersect.IntersectRect(rectClip, rcGroup); //rcGroup.DeflateRect(0, 7);//缩小7像素高度 //rcGroup.OffsetRect(0, -7);//向上偏移7像素 if ( !rcIntersect.IsRectEmpty() ) { DrawGroup(dcMem, rcGroup, strGroupCaption, strGroupTotals); } #ifdef LVGS_COLLAPSIBLE // Maintain LVGS_COLLAPSIBLE state CRect rcDropDown(rcGroup.right - 20, rcGroup.top + 10, rcGroup.right - 5, rcGroup.bottom - 3); if (HasGroupState(i, LVGS_COLLAPSED)) { if (m_imageRss_Group_Drop_Up_Nor) { m_imageRss_Group_Drop_Up_Nor->Draw(dcMem, rcDropDown.left, rcDropDown.top); } } else if (HasGroupState(i, LVGS_NORMAL)) { if (m_imageRss_Group_Drop_Down_Nor) { m_imageRss_Group_Drop_Down_Nor->Draw(dcMem, rcDropDown.left, rcDropDown.top); } } #endif //CRect rcDropDown(rcGroup.right - 20, rcGroup.top + 7, rcGroup.right - 5, rcGroup.bottom - 3); //CRgn rgDropDown;//画圆角矩形 //rgDropDown.CreateRoundRectRgn( rcDropDown.left, rcDropDown.top, rcDropDown.right, rcDropDown.bottom, 3, 3 ); // //CBrush* brushFrame; //brushFrame = new CBrush( GetSysColor(COLOR_GRAYTEXT) ); //dcMem.FrameRgn(&rgDropDown,brushFrame,1,1);//画焦点边框 //delete brushFrame; } } else { if ( nGroupHeight == -1 ) { CRect rcFirstItem;//算法有待优化 GetItemRect(0, rcFirstItem, LVIR_BOUNDS); if ( !rcFirstItem.IsRectEmpty() ) { nGroupHeight = rcFirstItem.top; } }//计算group 高度 CFeedCatalogs & feedCatalogs = CFeedCatalogs::GetInstance(); //遍历Catlogs 获得每个一级分类的Start RssData[只要用第一个就行了....第一个向上偏移绘制] for ( CFeedCatalogs::iterator it = feedCatalogs.GetBegin(); it != feedCatalogs.GetEnd(); ++it ) { FeedCatalog & feedCatlog = it->second; if ( feedCatlog.IsTop() && feedCatlog.GetFeedCount() > 0 ) { CRssFeedBase* feedStart = feedCatlog.GetFirstFeed(); int nStartIndex = GetItemIndex( (CRssFeed*)feedStart );//确定第一个item位置 if ( nStartIndex > -1 ) { int nGroupID = GetGroupIDByItemIndex( nStartIndex ); CString strGroupCaption = GetGroupCaption( nGroupID ); CString strGroupTotals; const CSimpleArray<int>& groupRows = m_mapGroups.GetValueAt(nGroupID); strGroupTotals.Format(_T("(共%d个)"), groupRows.GetSize()); //strGroupTotals.Format(_T("(共 %n 个)"), GetGroupCount()); CRect itemRect; GetItemRect(nStartIndex, &itemRect, LVIR_BOUNDS); //根据item rect获得group rect CRect rcGroup(rectClient.left, itemRect.top - nGroupHeight, rectClient.right, itemRect.top - 6); CRect rtIntersect; rtIntersect.IntersectRect(rectClip, rcGroup); if ( !rtIntersect.IsRectEmpty() ) { DrawGroup(dcMem, rcGroup, strGroupCaption, strGroupTotals); } } } } } }