void CDocStructRecordItem::OnDrawCaption(XTP_REPORTRECORDITEM_DRAWARGS* pDrawArgs, XTP_REPORTRECORDITEM_METRICS* pMetrics) { AFX_MANAGE_STATE(AfxGetStaticModuleState()); CDocStructRecord* pRecord = (CDocStructRecord*)GetRecord(); if (pRecord == NULL) { return; } pDrawArgs->nTextAlign = DT_VCENTER; if (pRecord->m_nCurrentLayout == DocumentStructureLayout(Thumbnail)) { if (pRecord->IsPage()) { CRect rcCaption; rcCaption.SetRect(pDrawArgs->rcItem.left - RECORD_ITEM_OFFSET + 1, pDrawArgs->rcItem.bottom - RECORD_TEXT_OFFSET - 5, pDrawArgs->rcItem.right - pDrawArgs->pRow->GetTreeDepth() * RECORD_ITEM_OFFSET, pDrawArgs->rcItem.bottom); pDrawArgs->rcItem.SetRect(rcCaption.TopLeft(), rcCaption.BottomRight()); } else { CRect rcCaption (pDrawArgs->rcItem); rcCaption.left += 3; rcCaption.right -= pDrawArgs->pRow->GetTreeDepth() * RECORD_ITEM_OFFSET; pDrawArgs->rcItem.SetRect(rcCaption.TopLeft(), rcCaption.BottomRight()); } } // If this is a "click" page, draw icon in front of page title bool bDrawClickIcon = pRecord->IsPage() && pRecord->m_pContainer != NULL && pRecord->m_pContainer->ShowClickIcon(pRecord->m_pvData); if (bDrawClickIcon) { CXTPReportPaintManager* pPaintManager = pDrawArgs->pControl->GetPaintManager(); if (pPaintManager) { CRect rcCaption(pDrawArgs->rcItem); CRect rcBitmap(rcCaption.right-22, rcCaption.top, rcCaption.right-2, rcCaption.bottom); CSize csBitmap = ((CXTPDocumentStructurePaintManager*)pPaintManager)->DrawCustomBitmap(pDrawArgs->pDC, pDrawArgs->pRow, rcBitmap, 5); pDrawArgs->rcItem.right = rcBitmap.left; } } CXTPReportRecordItem::OnDrawCaption(pDrawArgs, pMetrics); }
LRESULT CDBFrame::OnNcHitTest(CPoint point) { CRect rcWindow; GetWindowRect(&rcWindow); CRect rcCaption(rcWindow.left + m_rcSysBorder.left, rcWindow.top + m_rcSysBorder.top, rcWindow.left + rcWindow.Width() - m_rcSysBorder.right, rcWindow.top + m_rcSysBorder.top + m_imageCaption.Height()); if (rcCaption.PtInRect(point)) return HTCAPTION; CRect rcClient; GetClientRect(&rcClient); ClientToScreen(&rcClient); if(rcClient.PtInRect(point)) return HTCLIENT; return CFrameWnd::OnNcHitTest(point); }
//绘制标题栏 void CDBFrame::DrawCaption(CDC *pDC) { CRect rcWindow; GetWindowRect(&rcWindow); //画标题栏位图 CRect rcCaption(0,//m_rcSysBorder.left, m_rcSysBorder.top, rcWindow.Width(),// - m_rcSysBorder.right, m_rcSysBorder.top + m_imageCaption.Height()); if (m_bNcActivate) m_imageCaption.Render(pDC, rcCaption.TopLeft(), rcCaption.Size()); else m_imageCaptionNA.Render(pDC, rcCaption.TopLeft(), rcCaption.Size()); CRect rcTitle; GetTitleRect(rcTitle); DrawTitle(pDC, rcTitle); }
// 坐标命中测试消息 UINT QnSkinDialog::OnThemeNcHitTest(CPoint point) { //TRACE(_T("QnSkinDialog::OnThemeNcHitTest()")); CRect rcWin; GetWindowRect(&rcWin); point = point - CPoint(rcWin.left, rcWin.top); CRect rect; DWORD dwStyle = GetWindowLong(m_hWnd, GWL_STYLE); if (dwStyle & WS_SYSMENU) { GetCaptionButtonRect(rect, SC_CLOSE); if (PtInRect(rect, point)) { return HTCLOSE; } if (dwStyle & WS_MAXIMIZEBOX) { GetCaptionButtonRect(rect, SC_MAXIMIZE); if (PtInRect(rect, point)) { return HTMAXBUTTON; } } if (dwStyle & WS_MINIMIZEBOX) { GetCaptionButtonRect(rect, SC_MINIMIZE); if (PtInRect(rect, point)) { return HTMINBUTTON; } } } CRect rcCaption(&rcWin); rcCaption -= CPoint(rcWin.left, rcWin.top); rcCaption.bottom = rcCaption.top + m_pThemeDialog->m_nToTop; // 需要去掉边框,暂时定义为4,实际上应由边框的类型来取得。 rcCaption.DeflateRect(4,4,4,4); if (PtInRect(rcCaption, point)) { return HTCAPTION; } return HTCLIENT; }
//----------------------------------------------------------------------------- // Purpose: // Input : *pDC - // rect - // iFontHeight - // dwFlags - //----------------------------------------------------------------------------- void CMaterial::Draw(CDC *pDC, RECT& rect, int iFontHeight, int iIconHeight, DrawTexData_t &DrawTexData)//, BrowserData_t *pBrowserData) { g_pMaterialImageCache->EnCache(this); if (!this->HasData()) { return; } if (m_nWidth <= 0) { NoData: // draw "no data" CFont *pOldFont = (CFont*) pDC->SelectStockObject(ANSI_VAR_FONT); COLORREF cr = pDC->SetTextColor(RGB(0xff, 0xff, 0xff)); COLORREF cr2 = pDC->SetBkColor(RGB(0, 0, 0)); // draw black rect first pDC->FillRect(&rect, CBrush::FromHandle(HBRUSH(GetStockObject(BLACK_BRUSH)))); // then text pDC->TextOut(rect.left+2, rect.top+2, "No Image", 8); pDC->SelectObject(pOldFont); pDC->SetTextColor(cr); pDC->SetBkColor(cr2); return; } // no data - if (!m_pData) { // try to load - if (!Load()) { // can't load - goto NoData; } } // Draw the material image RECT srcRect, dstRect; srcRect.left = 0; srcRect.top = 0; srcRect.right = m_nWidth; srcRect.bottom = m_nHeight; dstRect = rect; if (DrawTexData.nFlags & drawCaption) { dstRect.bottom -= iFontHeight + 4; } if (DrawTexData.nFlags & drawIcons) { dstRect.bottom -= iIconHeight; } if (!(DrawTexData.nFlags & drawResizeAlways)) { if (m_nWidth < dstRect.right - dstRect.left ) { dstRect.right = dstRect.left + m_nWidth; } if (m_nHeight < dstRect.bottom - dstRect.top ) { dstRect.bottom = dstRect.top + m_nHeight; } } DrawBitmap( pDC, srcRect, dstRect ); // Draw the icons if (DrawTexData.nFlags & drawIcons) { dstRect = rect; if (DrawTexData.nFlags & drawCaption) { dstRect.bottom -= iFontHeight + 5; } dstRect.top = dstRect.bottom - iIconHeight; DrawBrowserIcons(pDC, dstRect, (DrawTexData.nFlags & drawErrors) != 0 ); } // ** caption ** if (DrawTexData.nFlags & drawCaption) { // draw background for name CBrush brCaption(RGB(0, 0, 255)); CRect rcCaption(rect); rcCaption.top = rcCaption.bottom - (iFontHeight + 5); pDC->FillRect(rcCaption, &brCaption); // draw name char szShortName[MAX_PATH]; int iLen = GetShortName(szShortName); pDC->TextOut(rect.left, rect.bottom - (iFontHeight + 4), szShortName, iLen); // draw usage count if (DrawTexData.nFlags & drawUsageCount) { CString str; str.Format("%d", DrawTexData.nUsageCount); CSize size = pDC->GetTextExtent(str); pDC->TextOut(rect.right - size.cx, rect.bottom - (iFontHeight + 4), str); } } }
CRect CXTPRibbonGroup::GetCaptionRect() const { CRect rcCaption(m_rcGroup); rcCaption.top = rcCaption.bottom - GetRibbonBar()->GetRibbonPaintManager()->GetGroupCaptionHeight(); return rcCaption; }
void ClsXPMenu::RenderItem( ClsDC *pDC, LPDRAWITEMSTRUCT pdis, ItemData *pData ) { // Determine the image, checkbox and text parts of the menu. ClsRect rcCaption( pdis->rcItem ), rcImage( pdis->rcItem ), rcCheck; rcImage.Right() = rcImage.Left() + m_cxBitmap + 8; rcCaption.Left() += m_cxBitmap + 8; rcCheck = rcImage; rcCheck.Deflate( 1, 1 ); rcCheck.Right()--; // A toplevel item? if ( pData->m_bToplevel ) { // Selected or hot? if ( pdis->itemState & ODS_SELECTED || pdis->itemState & ODS_HOTLIGHT ) { // Select appropiate colors. COLORREF crFg, crBg; if ( pdis->itemState & ODS_HOTLIGHT || ! IsDropped()) { crFg = XPColors.GetXPColor( ClsXPColors::XPC_OUTER_SELECTION); crBg = XPColors.GetXPColor( ClsXPColors::XPC_INNER_SELECTION ); } else { crFg = XPColors.GetXPColor( ClsXPColors::XPC_IMAGE_DISABLED ); crBg = XPColors.GetXPColor( ClsXPColors::XPC_IMAGE_BACKGROUND ); } // Render the background. pDC->OutlinedRectangle( &pdis->rcItem, crFg, crBg ); } else // Simply clear background. pDC->FillRect( &pdis->rcItem, ( HBRUSH )( COLOR_BTNFACE + 1 )); // Adjust the caption rectangle. rcCaption = pdis->rcItem; rcCaption.Offset( 6, 0 ); } else { // Is the item selected? if (( pdis->itemState & ODS_SELECTED ) && pData->m_bSeparator == FALSE ) { // Determine background color. COLORREF crBkgnd; // Is the item disabled or not? if ( ! ( pdis->itemState & ODS_DISABLED )) crBkgnd = XPColors.GetXPColor( ClsXPColors::XPC_INNER_SELECTION ); else { // See if either the up or the down arrow key is pressed. // If so the item is selected using one of these keys. In // That case we render the item differently. // // Sorry about the goto... if ( ! ISKEYDOWN( VK_UP ) && ! ISKEYDOWN( VK_DOWN ) && ! ISKEYDOWN( VK_LEFT ) && ! ISKEYDOWN( VK_RIGHT )) goto normal; crBkgnd = XPColors.GetXPColor( ClsXPColors::XPC_TEXT_BACKGROUND ); } // Render the selection rectangle. pDC->OutlinedRectangle( &pdis->rcItem, XPColors.GetXPColor( ClsXPColors::XPC_OUTER_SELECTION ), crBkgnd ); } else { normal: // Render the image background. ClsBrush brush( XPColors.GetXPColor( ClsXPColors::XPC_IMAGE_BACKGROUND )); pDC->FillRect( rcImage, &brush ); // render the text background. brush.Delete(); brush.CreateSolidBrush( XPColors.GetXPColor( ClsXPColors::XPC_TEXT_BACKGROUND )); pDC->FillRect( rcCaption, &brush ); } // Is the item checked? if ( pdis->itemState & ODS_CHECKED ) { // Disabled? COLORREF crBk, crFg; if ( ! ( pdis->itemState & ODS_DISABLED )) { // Select colors to use. crBk = XPColors.GetXPColor( pdis->itemState & ODS_SELECTED ? ClsXPColors::XPC_INNER_CHECKED_SELECTED : ClsXPColors::XPC_INNER_CHECKED ); crFg = XPColors.GetXPColor( ClsXPColors::XPC_OUTER_CHECKED ); } else { // Select colors to use. crBk = XPColors.GetXPColor( ClsXPColors::XPC_IMAGE_BACKGROUND ); crFg = XPColors.GetXPColor( ClsXPColors::XPC_IMAGE_DISABLED ); } // Render checkbox image. pDC->OutlinedRectangle( rcCheck, crFg, crBk ); // Does this item have a bitmap? if ( pData->m_iBitmap == -1 ) { // Get the item type and checkmark information. ClsMenuItemInfo mi; mi.fMask = MIIM_CHECKMARKS | MIIM_TYPE; if ( GetItemInfo( pdis->itemID, &mi )) { // Radiobutton? if ( mi.fType & MFT_RADIOCHECK ) // Render the radiobutton. RenderRadioBullet( pDC, rcCheck, XPColors.GetXPColor( pdis->itemState & ODS_DISABLED ? ClsXPColors::XPC_IMAGE_DISABLED : ClsXPColors::XPC_TEXT ), pdis->itemState ); else // Render the checkmark or checkmark bitmap. RenderCheckmark( pDC, rcCheck, XPColors.GetXPColor( pdis->itemState & ODS_DISABLED ? ClsXPColors::XPC_IMAGE_DISABLED : ClsXPColors::XPC_TEXT ), XPColors.GetXPColor( ClsXPColors::XPC_TEXT ), pdis->itemState & ~ODS_DISABLED, &mi ); } } } // If we do not have a bitmap and we are // not a seperator we check to see if we // are a Radio-check item. else if ( pData->m_iBitmap == -1 && pData->m_bSeparator == FALSE ) { // Radio item? ClsMenuItemInfo mi; mi.fMask = MIIM_CHECKMARKS | MIIM_TYPE; if ( GetItemInfo( pdis->itemID, &mi ) && mi.fType & MFT_RADIOCHECK ) { // Render the radiobutton. RenderRadioBullet( pDC, rcCheck, XPColors.GetXPColor( pdis->itemState & ODS_DISABLED ? ClsXPColors::XPC_IMAGE_DISABLED : ClsXPColors::XPC_TEXT ), pdis->itemState ); } } // Item data present? if ( pData ) { // Separator? if ( pData->m_bSeparator == TRUE ) { // Create and select pen to render the separator. ClsPen pen( PS_SOLID, 1, XPColors.GetXPColor( ClsXPColors::XPC_SEPARATOR )); ClsSelector s( pDC, pen ); // Render the separator. rcCaption.Top() += rcCaption.Height() / 2; rcCaption.Left() += 8; pDC->MoveTo( rcCaption.TopLeft()); pDC->LineTo( rcCaption.Right(), rcCaption.Top()); } else { // Does the item have a bitmap assigned to it? if ( pData->m_iBitmap >= 0 && reinterpret_cast<ClsXPMenu *>( pData->m_pOwner )->m_hImageList ) { // Adjust image position. rcImage.Offset( -1, 0 ); // Determine image rendering flags. The disabled flag is only used // when the item is disabled and we do not have a disabled imagelist. DWORD dwFlags = 0; if ( pdis->itemState & ODS_SELECTED && ( ! ( pdis->itemState & ODS_DISABLED )) && ( ! ( pdis->itemState & ODS_CHECKED ))) dwFlags |= ClsDrawTools::CDSF_HOT; if ( pdis->itemState & ODS_DISABLED && reinterpret_cast<ClsXPMenu *>( pData->m_pOwner )->m_hDisabledImageList == NULL ) dwFlags |= ClsDrawTools::CDSF_DISABLED; // Determine the image list to use, normal or disabled. HIMAGELIST himl = ( pdis->itemState & ODS_DISABLED && reinterpret_cast<ClsXPMenu *>( pData->m_pOwner )->m_hDisabledImageList ) ? reinterpret_cast<ClsXPMenu *>( pData->m_pOwner )->m_hDisabledImageList : reinterpret_cast<ClsXPMenu *>( pData->m_pOwner )->m_hImageList; // Render image... ClsDrawTools::RenderXPBitmap( *pDC, himl, pData->m_iBitmap, rcImage, dwFlags | ClsDrawTools::CDSF_TRANSPARENT ); // Restore image rectangle position. rcImage.Offset( 1, 0 ); } } } } if ( pData ) { // Any text? if ( pData->m_strItemName ) { // Setup text color and draw mode. pDC->SetTextColor( pdis->itemState & ODS_INACTIVE ? ::GetSysColor( COLOR_GRAYTEXT ) : ( XPColors.GetXPColor( pdis->itemState & ODS_DISABLED ? ClsXPColors::XPC_TEXT_DISABLED : ClsXPColors::XPC_TEXT ))); pDC->SetBkMode( TRANSPARENT ); // Adjust the rectangle. if ( ! pData->m_bToplevel ) { rcCaption.Left() += 8; rcCaption.Right() -= 6; } // Skip checkmark width. if ( ! pData->m_bToplevel ) rcCaption.Right() -= ::GetSystemMetrics( SM_CXMENUCHECK ); // Split caption in a left an right part. ClsString Left, Right; SplitCaption( pData->m_strItemName, Left, Right ); // Render the parts. if ( Left.GetStringLength()) ClsDrawTools::RenderText( *pDC, Left, rcCaption, ClsDrawTools::CDSF_LEFTALIGN | ( pdis->itemState & ODS_NOACCEL ? ClsDrawTools::CDSF_HIDEACCEL : 0 )); if ( Right.GetStringLength()) ClsDrawTools::RenderText( *pDC, Right, rcCaption, ClsDrawTools::CDSF_RIGHTALIGN ); } } }