LRESULT CXTPShortcutBarPopup::OnNcHitTest(CPoint point) { CRect rectWindow; GetWindowRect(&rectWindow); CRect rcBorder(rectWindow.right - FRAME_GAP, rectWindow.top, rectWindow.right, rectWindow.bottom); if (rcBorder.PtInRect(point)) return HTRIGHT; return HTCLIENT; }
void CXTPShortcutListBoxTheme::DrawItem(CXTPShortcutListBox* pMenuListBox, LPDRAWITEMSTRUCT lpDIS) { // Define temporary variables. CDC* pDC = CDC::FromHandle (lpDIS->hDC); CRect rcIcon = lpDIS->rcItem; CRect rcText = lpDIS->rcItem; int iItemID = lpDIS->itemID; // if empty, draw focus rect. if (iItemID < 0) { rcIcon.bottom = rcIcon.top + 15; pDC->DrawFocusRect(rcIcon); return; } // Get the menu item. CXTPShortcutListBox::CONTENT_ITEM* pCI = pMenuListBox->GetMenuItem(iItemID); ASSERT(pCI); if (!pCI) return; // set the text foreground and background colors. pDC->SetTextColor(GetTextColor()); // repaint the background. pDC->SetBkMode(TRANSPARENT); long iMargin = (rcIcon.Width()-m_cxIcon)/2; rcIcon.top += m_cyEdge; rcIcon.left += iMargin; rcIcon.right = rcIcon.left + m_cxIcon; rcIcon.bottom = rcIcon.top + m_cyIcon; int iOffset = 0; BOOL bSelected = FALSE; BOOL bPressed = FALSE; if ((lpDIS->itemState & ODS_SELECTED) && pCI->m_bEnabled) { bSelected = TRUE; CRect rcBorder(rcIcon); rcBorder.InflateRect(2, 2); if (::GetKeyState(VK_LBUTTON) < 0) { if (!m_crgItemBackPressed.IsNull()) XTPDrawHelpers()->GradientFill(pDC, rcBorder, m_crgItemBackPressed, FALSE); pDC->Draw3dRect(&rcBorder, m_crgItemBorder.clrLight, m_crgItemBorder.clrDark); iOffset = 1; bPressed = TRUE; } else { if (!m_crgItemBackHot.IsNull()) XTPDrawHelpers()->GradientFill(pDC, rcBorder, m_crgItemBackHot, FALSE); pDC->Draw3dRect(&rcBorder, m_crgItemBorder.clrDark, m_crgItemBorder.clrLight); iOffset = -1; } } LOGFONT lf; pMenuListBox->GetFont()->GetLogFont(&lf); if (bSelected && !pMenuListBox->m_bNoUnderline) lf.lfUnderline = 1; // select the font used by the button text. CFont font; font.CreateFontIndirect(&lf); CXTPFontDC fnt(pDC, &font); // get the text height. int iTextHeight = pMenuListBox->GetTextHeight(pCI->m_strText); // define the text rect. rcText.top = rcText.bottom - (iTextHeight + m_cyEdge); rcText.left += m_cyEdge; rcText.right -= m_cyEdge; if ((pMenuListBox->m_bNoBorder) && (iOffset != 0)) { rcIcon.OffsetRect(iOffset, iOffset); rcText.OffsetRect(iOffset, iOffset); } if (pCI->m_pIcon) { DrawImage(pDC, rcIcon, pCI->m_pIcon, pCI->m_bEnabled, bSelected, bPressed); } DrawText(pDC, rcText, pCI); }
void CDittoWindow::DoNcPaint(CWnd *pWnd) { CWindowDC dc(pWnd); CRect rcFrame; pWnd->GetWindowRect(rcFrame); pWnd->ScreenToClient(rcFrame); CRect rc; pWnd->GetClientRect(rc); pWnd->ClientToScreen(rc); long lWidth = rcFrame.Width(); // Draw the window border CRect rcBorder(0, 0, lWidth, rcFrame.Height()); dc.Draw3dRect(rcBorder, m_CaptionColorLeft, m_CaptionColorLeft); rcBorder.DeflateRect(1, 1, 1, 1); dc.Draw3dRect(rcBorder, m_CaptionColorLeft, m_CaptionColorLeft); rcBorder.InflateRect(1, 1, 1, 1); int smallBorder = theApp.m_metrics.ScaleX(4); int largeBorder = theApp.m_metrics.ScaleX(7); int widthHeight = theApp.m_metrics.ScaleX(8); BOOL bVertical = FALSE; if(m_lRightBorder == CAPTION_BORDER) { m_crCloseBT.SetRect(rcBorder.right - widthHeight - smallBorder, largeBorder, rcBorder.right - smallBorder, largeBorder + widthHeight); m_crChevronBT.SetRect(rcBorder.right - widthHeight - smallBorder, rcBorder.bottom - widthHeight - largeBorder, rcBorder.right - smallBorder, rcBorder.bottom - largeBorder); m_crMaximizeBT.left = m_crCloseBT.left; m_crMaximizeBT.top = m_crCloseBT.bottom + largeBorder; m_crMaximizeBT.right = m_crCloseBT.right; m_crMaximizeBT.bottom = m_crMaximizeBT.top + widthHeight; m_crMinimizeBT.left = m_crMaximizeBT.left; m_crMinimizeBT.top += m_crMaximizeBT.bottom + largeBorder; m_crMinimizeBT.right = m_crMaximizeBT.right; m_crMinimizeBT.bottom += m_crMinimizeBT.top + widthHeight; rcBorder.left = rcBorder.right - m_lRightBorder; bVertical = TRUE; } else if(m_lLeftBorder == CAPTION_BORDER) { m_crCloseBT.SetRect(smallBorder, largeBorder, widthHeight+smallBorder, widthHeight+largeBorder); m_crChevronBT.SetRect(smallBorder, rcBorder.bottom - largeBorder - widthHeight, widthHeight+smallBorder, rcBorder.bottom - largeBorder); m_crMaximizeBT = m_crCloseBT; m_crMaximizeBT.top += m_crCloseBT.Height() + largeBorder; m_crMaximizeBT.bottom += m_crCloseBT.Height() + largeBorder; m_crMinimizeBT = m_crMaximizeBT; m_crMinimizeBT.top += m_crCloseBT.Height() + largeBorder; m_crMinimizeBT.bottom += m_crCloseBT.Height() + largeBorder; rcBorder.right = rcBorder.left + m_lLeftBorder; bVertical = TRUE; } else if(m_lTopBorder == CAPTION_BORDER) { m_crCloseBT.SetRect(rcBorder.right - widthHeight - largeBorder, smallBorder, rcBorder.right - largeBorder, widthHeight + smallBorder); m_crChevronBT.SetRect(largeBorder, smallBorder, largeBorder+widthHeight, smallBorder+widthHeight); m_crMaximizeBT = m_crCloseBT; m_crMaximizeBT.left -= m_crCloseBT.Width() + largeBorder; m_crMaximizeBT.right -= m_crCloseBT.Width() + largeBorder; m_crMinimizeBT = m_crMaximizeBT; m_crMinimizeBT.left -= m_crCloseBT.Width() + largeBorder; m_crMinimizeBT.right -= m_crCloseBT.Width() + largeBorder; rcBorder.bottom = rcBorder.top + m_lTopBorder; bVertical = FALSE; } else if(m_lBottomBorder == CAPTION_BORDER) { m_crCloseBT.SetRect(rcBorder.right - largeBorder-widthHeight, rcBorder.bottom - smallBorder-widthHeight, rcBorder.right - largeBorder, rcBorder.bottom - smallBorder); m_crChevronBT.SetRect(largeBorder, rcBorder.bottom - smallBorder-widthHeight, largeBorder+widthHeight, rcBorder.bottom - smallBorder); m_crMaximizeBT = m_crCloseBT; m_crMaximizeBT.left -= m_crCloseBT.Width() + largeBorder; m_crMaximizeBT.right -= m_crCloseBT.Width() + largeBorder; m_crMinimizeBT = m_crMaximizeBT; m_crMinimizeBT.left -= m_crCloseBT.Width() + largeBorder; m_crMinimizeBT.right -= m_crCloseBT.Width() + largeBorder; rcBorder.top = rcBorder.bottom - m_lBottomBorder; bVertical = FALSE; } if(m_bDrawClose == false) { m_crCloseBT.SetRectEmpty(); } if(m_bDrawChevron == false) { m_crChevronBT.SetRectEmpty(); } if(m_bDrawMaximize == false) { m_crMaximizeBT.SetRectEmpty(); } if(m_bDrawMinimize == false) { m_crMinimizeBT.SetRectEmpty(); } int r1 = GetRValue(m_CaptionColorLeft); int g1 = GetGValue(m_CaptionColorLeft); int b1 = GetBValue(m_CaptionColorLeft); int r2 = GetRValue(m_CaptionColorRight); int g2 = GetGValue(m_CaptionColorRight); int b2 = GetBValue(m_CaptionColorRight); bool bGradient = true; if(m_CaptionColorLeft == m_CaptionColorRight) { bGradient = false; } HBRUSH color; long lHeight = rcBorder.Height(); CRect cr = rcBorder; long lCount = rcBorder.Width(); if(bVertical) lCount = lHeight; for(int i = 0; i < lCount; i++) { int r, g, b; r = r1 + (i * (r2 - r1) / lCount); g = g1 + (i * (g2 - g1) / lCount); b = b1 + (i * (b2 - b1) / lCount); if(bVertical) { cr.top = i; cr.bottom = i + 1; } else { cr.left = i; cr.right = i + 1; } if(bGradient || i == 0) { color = CreateSolidBrush(RGB(r, g, b)); } ::FillRect(dc, &cr, color); if(bGradient) DeleteObject(color); } if(bGradient == false) DeleteObject(color); int nOldBKMode = dc.SetBkMode(TRANSPARENT); COLORREF oldColor = dc.SetTextColor(m_CaptionTextColor); CFont *pOldFont = NULL; if(bVertical) pOldFont=dc.SelectObject(&m_VertFont); else pOldFont=dc.SelectObject(&m_HorFont); CString csText; pWnd->GetWindowText(csText); if(m_lRightBorder == CAPTION_BORDER) { int nTop = largeBorder; if (m_bDrawClose) nTop += widthHeight + largeBorder; if (m_bDrawMaximize) nTop += widthHeight + largeBorder; if (m_bDrawMaximize) nTop += widthHeight + largeBorder; cr.SetRect(rcBorder.right - 1, nTop, rcBorder.right - theApp.m_metrics.ScaleX(13), rcBorder.bottom - theApp.m_metrics.ScaleY(20)); dc.DrawText(csText, cr, DT_SINGLELINE); } else if(m_lBottomBorder == CAPTION_BORDER) { cr.SetRect(theApp.m_metrics.ScaleX(20), rcBorder.bottom - theApp.m_metrics.ScaleY(15), rcBorder.right - theApp.m_metrics.ScaleX(20), rcBorder.bottom - 1); dc.DrawText(csText, cr, DT_SINGLELINE); } else if(m_lLeftBorder == CAPTION_BORDER) { int nTop = largeBorder; if(m_bDrawClose) nTop += widthHeight + largeBorder; if(m_bDrawMaximize) nTop += widthHeight + largeBorder; if(m_bDrawMaximize) nTop += widthHeight + largeBorder; cr.SetRect(theApp.m_metrics.ScaleX(15) , nTop, 2, rcBorder.bottom - theApp.m_metrics.ScaleY(20)); dc.DrawText(csText, cr, DT_SINGLELINE); } else if(m_lTopBorder == CAPTION_BORDER) { cr.SetRect(theApp.m_metrics.ScaleX(20), 1, rcBorder.right - theApp.m_metrics.ScaleX(20), theApp.m_metrics.ScaleY(15)); dc.DrawText(csText, cr, DT_SINGLELINE); } DrawCloseBtn(dc, pWnd); DrawChevronBtn(dc, pWnd); DrawMaximizeBtn(dc, pWnd); DrawMinimizeBtn(dc); dc.SelectObject(pOldFont); dc.SetTextColor(oldColor); dc.SetBkMode(nOldBKMode); }