// /// Returns the size of the maximize box rectangle. // TRect TTinyCaption::GetMaxBoxRect() { TRect boxRect(GetCaptionRect()); boxRect.left = boxRect.right - CaptionHeight; boxRect.top -= 1; boxRect.right += 1; return boxRect; }
// /// Returns the size of the system box rectangle. // TRect TTinyCaption::GetSysBoxRect() { TRect boxRect(GetCaptionRect()); boxRect.right = boxRect.left + CaptionHeight; boxRect.left -= 1; boxRect.top -= 1; return boxRect; }
CRect CXTPTaskPanelGroup::GetHitTestRect() const { if (!m_pPanel) return CRect(0, 0, 0, 0); CRect rc = GetCaptionRect(); rc.OffsetRect(0, -m_pPanel->GetScrollOffset()); return rc; }
// /// Return the size of our client area, leaving room for caption bar // /// If the caption bar is not enabled or is iconic, returns esPartial. Otherwise, /// calculates the dimensions of the caption and returns esComplete. // TEventStatus TTinyCaption::DoNCCalcSize(bool /*calcValidRects*/, NCCALCSIZE_PARAMS & calcSize, uint& /*evRes*/) { if (!TCEnabled || IsIconic()) return esPartial; calcSize.rgrc[0].top += GetCaptionRect().Height(); return esComplete; }
void CEGPaneBar::OnPaint() { CPaintDC pdc(this); CRect rc; GetClientRect(rc); pdc.FillSolidRect(rc, GetSysColor(COLOR_3DFACE)); if ( m_pszCaption ) { rc = GetCaptionRect(); HFONT hOldFont = (HFONT) ::SelectObject( pdc.GetSafeHdc(), m_fntCaption ); pdc.SetBkMode( TRANSPARENT ); if ( m_bActive ) { pdc.FillSolidRect(rc, GetSysColor( COLOR_ACTIVECAPTION )); pdc.SetTextColor( GetSysColor( COLOR_CAPTIONTEXT ) ); } else { CPen *pOldPen, pen(PS_SOLID,1,GetSysColor(COLOR_INACTIVECAPTION)); pOldPen = pdc.SelectObject(&pen); pdc.MoveTo( rc.left + 1, rc.top ); pdc.LineTo( rc.right - 1, rc.top ); pdc.MoveTo( rc.right - 1, rc.top+1 ); pdc.LineTo( rc.right - 1, rc.bottom - 1 ); pdc.MoveTo( rc.right - 2, rc.bottom - 1 ); pdc.LineTo( rc.left, rc.bottom - 1 ); pdc.MoveTo( rc.left, rc.bottom - 2 ); pdc.LineTo( rc.left, rc.top ); pdc.SelectObject(pOldPen); pdc.SetTextColor( GetSysColor( COLOR_WINDOWTEXT ) ); } rc.left += SPLITTER_SIZE; pdc.DrawText( m_pszCaption, &rc, DT_LEFT | DT_SINGLELINE | DT_VCENTER ); // X-button ( Marlett :: 0x72 ) rc = GetCloseButtonRect(); ::SelectObject( pdc.GetSafeHdc(), m_fntXButton ); pdc.DrawText( _T("\x72"), &rc, DT_CENTER | DT_SINGLELINE | DT_VCENTER ); if ( !m_bClosePressed && m_bCloseHover ) { pdc.DrawEdge( rc, BDR_RAISEDINNER , BF_RECT | BF_ADJUST ); } else if( m_bClosePressed && m_bCloseHover ) { pdc.DrawEdge( rc, BDR_SUNKENINNER , BF_RECT | BF_ADJUST ); } else if( m_bClosePressed && !m_bCloseHover ) { pdc.DrawEdge( rc, BDR_RAISEDINNER , BF_RECT | BF_ADJUST ); } ::SelectObject( pdc.GetSafeHdc(), hOldFont ); } }
// /// If the caption bar is not enabled, returns esPartial. Otherwise, sends a message /// to the caption bar that the mouse or the cursor has moved, and returns /// esComplete. // TEventStatus TTinyCaption::DoNCHitTest(const TPoint& screenPt, uint& evRes) { if (!TCEnabled) return esPartial; // Check style bits to see what to paint // long style = GetStyle(); bool hasSysMenu, hasMaximize, hasMinimize; hasSysMenu = hasMaximize = hasMinimize = false; if (style & WS_SYSMENU) hasSysMenu = true; if (style & WS_MAXIMIZEBOX) hasMaximize = true; if (style & WS_MINIMIZEBOX) hasMinimize = true; // Convert to window coordinates // TPoint winPt = screenPt - GetWindowRect().TopLeft(); if ((hasSysMenu || CloseBox) && GetSysBoxRect().Contains(winPt)) { evRes = HTSYSMENU; return esComplete; } else if (hasMinimize && GetMinBoxRect().Contains(winPt)) { evRes = HTMINBUTTON; return esComplete; } else if (hasMaximize && GetMaxBoxRect().Contains(winPt)) { evRes = HTMAXBUTTON; return esComplete; } // CaptionRect includes buttons so make sure it's last checked // Should modify this one to allow clicking in left, top, right thin // borders of caption // else if (GetCaptionRect().Contains(winPt)) { evRes = HTCAPTION; return esComplete; } else { return esPartial; } }
void CEGPaneBar::OnLButtonUp(UINT nFlags, CPoint point) { if ( m_bDragging ) { ReleaseCapture(); OnInvertTracker(m_dragRect); DWORD dwStyle = GetBarStyle(); CRect rcCaption = GetCaptionRect(); int nMinHeight = rcCaption.Height() + SPLITTER_SIZE*2; int nMinWidth = nMinHeight*4; if( ( dwStyle & CBRS_TOP ) == CBRS_TOP ) { m_iSize = point.y > nMinHeight ? point.y : nMinHeight; } else if( ( dwStyle & CBRS_BOTTOM ) == CBRS_BOTTOM ) { m_iSize = m_iSize - point.y; if ( m_iSize < nMinHeight ) m_iSize = nMinHeight; } else if( ( dwStyle & CBRS_RIGHT ) == CBRS_RIGHT ) { m_iSize = m_iSize - point.x; if ( m_iSize < nMinWidth ) m_iSize = nMinWidth; } else { m_iSize = point.x > nMinWidth ? point.x : nMinWidth; } GetParentFrame()->RecalcLayout(); } m_bDragging = FALSE; BOOL bOldClosePressed = m_bClosePressed; m_bClosePressed = FALSE; if ( bOldClosePressed ) { ReleaseCapture(); CRect rcCloseButton = GetCloseButtonRect(); if ( rcCloseButton.PtInRect( point ) ) { HidePane( ); } else { InvalidateCaption(); } } CControlBar::OnLButtonUp(nFlags, point); }
void CKofDlgImpl::UpdateCaption() { if (!IsOwnerDrawCaption ()) { return; } if (m_lstCaptionSysButtons.IsEmpty ()) { //------------------------ // Create caption buttons: //------------------------ const DWORD dwStyle = m_Dlg.GetStyle (); HMENU hSysMenu = NULL; CMenu* pSysMenu = m_Dlg.GetSystemMenu (FALSE); if (pSysMenu != NULL && ::IsMenu (pSysMenu->m_hMenu)) { hSysMenu = pSysMenu->GetSafeHmenu (); if (!::IsMenu (hSysMenu) || (m_Dlg.GetStyle () & WS_SYSMENU) == 0) { hSysMenu = NULL; } } if (hSysMenu != NULL) { m_lstCaptionSysButtons.AddTail (new CMFCCaptionButtonEx (AFX_HTCLOSE)); if ((dwStyle & WS_MAXIMIZEBOX) == WS_MAXIMIZEBOX) { m_lstCaptionSysButtons.AddTail (new CMFCCaptionButtonEx (AFX_HTMAXBUTTON)); } if ((dwStyle & WS_MINIMIZEBOX) == WS_MINIMIZEBOX) { m_lstCaptionSysButtons.AddTail (new CMFCCaptionButtonEx (AFX_HTMINBUTTON)); } if ((dwStyle & DS_CONTEXTHELP) == DS_CONTEXTHELP) { if (!m_Dlg.IsKindOf (RUNTIME_CLASS (CPropertySheet))) { m_lstCaptionSysButtons.AddTail (new CMFCCaptionButtonEx (AFX_HTMINBUTTON + 1)); } } } } CRect rectCaption = GetCaptionRect (); { CSize sizeButton = CMFCVisualManager::GetInstance()->GetNcBtnSize (FALSE); sizeButton.cy = min (sizeButton.cy, rectCaption.Height () - 2); int x = rectCaption.right - sizeButton.cx; int y = rectCaption.top + max (0, (rectCaption.Height () - sizeButton.cy) / 2); for (POSITION pos = m_lstCaptionSysButtons.GetHeadPosition (); pos != NULL;) { CMFCCaptionButtonEx* pButton = (CMFCCaptionButtonEx*) m_lstCaptionSysButtons.GetNext (pos); ASSERT_VALID (pButton); pButton->SetRect (CRect (CPoint (x, y), sizeButton)); x -= sizeButton.cx; } } m_Dlg.RedrawWindow (NULL, NULL, RDW_FRAME | RDW_INVALIDATE | RDW_UPDATENOW | RDW_NOCHILDREN); }
UINT CKofDlgImpl::OnNcHitTest( CPoint point ) { m_Dlg.ScreenToClient (&point); if (!m_rectResizeBox.IsRectEmpty ()) { if (m_rectResizeBox.PtInRect(point)) { BOOL bRTL = m_Dlg.GetExStyle() & WS_EX_LAYOUTRTL; return bRTL ? HTBOTTOMLEFT : HTBOTTOMRIGHT; } } if (!IsOwnerDrawCaption ()) { return HTNOWHERE; } const CSize szSystemBorder(::GetSystemMetrics (SM_CXSIZEFRAME), ::GetSystemMetrics (SM_CYSIZEFRAME)); int cxOffset = szSystemBorder.cx; int cyOffset = szSystemBorder.cy; if (!m_Dlg.IsIconic ()) { cyOffset += GetCaptionHeight (); } if (m_Dlg.IsZoomed ()) { cxOffset -= szSystemBorder.cx; cyOffset -= szSystemBorder.cy; } point.Offset (cxOffset, cyOffset); for (POSITION pos = m_lstCaptionSysButtons.GetHeadPosition (); pos != NULL;) { CMFCCaptionButtonEx* pButton = (CMFCCaptionButtonEx*) m_lstCaptionSysButtons.GetNext (pos); ASSERT_VALID (pButton); if (pButton->GetRect ().PtInRect (point)) { return pButton->m_nHit; } } CRect rectCaption = GetCaptionRect (); if (rectCaption.PtInRect (point)) { if ((m_Dlg.GetExStyle () & WS_EX_TOOLWINDOW) == 0) { CRect rectSysMenu = rectCaption; rectSysMenu.right = rectSysMenu.left + ::GetSystemMetrics (SM_CXSMICON) + 2 + (m_Dlg.IsZoomed () ? szSystemBorder.cx : 0); return rectSysMenu.PtInRect (point) ? HTSYSMENU : HTCAPTION; } return HTCAPTION; } return HTNOWHERE; }
void CEGPaneBar::InvalidateCaption() { CRect rc = GetCaptionRect(); InvalidateRect( &rc, FALSE ); }
CRect CEGPaneBar::GetCloseButtonRect() { CRect rc = GetCaptionRect(); rc.left = rc.right - (rc.bottom - rc.top); ::InflateRect( &rc, -2, -2 ); return rc; }
//************************************************************************* void CBCGPDlgImpl::UpdateCaption () { if (!IsOwnerDrawCaption ()) { return; } if (m_lstCaptionSysButtons.IsEmpty ()) { //------------------------ // Create caption buttons: //------------------------ const DWORD dwStyle = m_Dlg.GetStyle (); HMENU hSysMenu = NULL; CMenu* pSysMenu = m_Dlg.GetSystemMenu (FALSE); if (pSysMenu != NULL && ::IsMenu (pSysMenu->m_hMenu)) { hSysMenu = pSysMenu->GetSafeHmenu (); if (!::IsMenu (hSysMenu) || (m_Dlg.GetStyle () & WS_SYSMENU) == 0) { hSysMenu = NULL; } } if (hSysMenu != NULL) { m_lstCaptionSysButtons.AddTail (new CBCGPFrameCaptionButton (HTCLOSE_BCG)); if ((dwStyle & WS_MAXIMIZEBOX) == WS_MAXIMIZEBOX) { m_lstCaptionSysButtons.AddTail (new CBCGPFrameCaptionButton (HTMAXBUTTON_BCG)); } if ((dwStyle & WS_MINIMIZEBOX) == WS_MINIMIZEBOX) { m_lstCaptionSysButtons.AddTail (new CBCGPFrameCaptionButton (HTMINBUTTON_BCG)); } #ifndef _BCGSUITE_ if ((dwStyle & DS_CONTEXTHELP) == DS_CONTEXTHELP) { if (!m_Dlg.IsKindOf (RUNTIME_CLASS (CPropertySheet))) { m_lstCaptionSysButtons.AddTail (new CBCGPFrameCaptionButton (HTHELPBUTTON_BCG)); } } #endif } } CRect rectCaption = GetCaptionRect (); #ifndef _BCGSUITE_ if (!visualManagerMFC->OnUpdateNcButtons(&m_Dlg, m_lstCaptionSysButtons, rectCaption)) #endif { CSize sizeButton = visualManagerMFC->GetNcBtnSize (FALSE); sizeButton.cy = min (sizeButton.cy, rectCaption.Height () - 2); int x = rectCaption.right - sizeButton.cx; int y = rectCaption.top + max (0, (rectCaption.Height () - sizeButton.cy) / 2); for (POSITION pos = m_lstCaptionSysButtons.GetHeadPosition (); pos != NULL;) { CBCGPFrameCaptionButton* pButton = (CBCGPFrameCaptionButton*) m_lstCaptionSysButtons.GetNext (pos); ASSERT_VALID (pButton); pButton->SetRect (CRect (CPoint (x, y), sizeButton)); x -= sizeButton.cx; } } #ifndef _BCGSUITE_ m_Dlg.SendMessage (BCGM_ONAFTERUPDATECAPTION); #endif m_Dlg.RedrawWindow (NULL, NULL, RDW_FRAME | RDW_INVALIDATE | RDW_UPDATENOW | RDW_NOCHILDREN); }
// /// Calls dc.SelectObject() to select the given rectangle and dc.PatBlt() to paint the /// tiny caption bar using the currently selected brush for this device context. // void TTinyCaption::PaintCaption(bool active) { // Paint caption background and caption text if any. // TWindowDC dc(*this); TRect captRect = GetCaptionRect(); dc.SetTextColor(active ? TColor::SysCaptionText : TColor::SysInactiveCaptionText); // Could use a TBrush and PatBlt instead, but text backgrounds are always // solid so this works well. // dc.TextRect(captRect, active ? TColor::SysActiveCaption : TColor::SysInactiveCaption); CHECK(CaptionFont); dc.SelectObject(*CaptionFont); dc.SetBkMode(TRANSPARENT); LPCTSTR c = GetCaption() ? GetCaption() : _T(""); TSize textSize = dc.GetTextExtent(c, static_cast<int>(::_tcslen(c))); // Calc x coord for text, so that text is centered between caption buttons // int xOrg = captRect.right - captRect.left; long style = GetWindowLong(GWL_STYLE); if (style & WS_MINIMIZEBOX) xOrg -= GetMinBoxRect().Width(); if (style & WS_MAXIMIZEBOX) xOrg -= GetMaxBoxRect().Width(); if ((style & WS_SYSMENU) || CloseBox) xOrg -= GetSysBoxRect().Width(); xOrg -= textSize.cx; if (xOrg<0) xOrg = 0; else xOrg = xOrg/2; xOrg += captRect.left; if ((style & WS_SYSMENU) || CloseBox) xOrg += GetSysBoxRect().Width(); dc.ExtTextOut(xOrg, captRect.top-Border.cy, ETO_CLIPPED, &captRect, c, static_cast<int>(::_tcslen(c)) ); dc.RestoreFont(); // Paint widgets: sysmenu or close button, minimize button, maximize button // They currently all use a black pen // dc.SelectStockObject(BLACK_PEN); // Paint system menu or close button // if (CloseBox) { TRect rect(GetSysBoxRect()); PaintCloseBox(dc, rect, false); } else if (style & WS_SYSMENU) { TRect rect(GetSysBoxRect()); PaintSysBox(dc, rect, false); } // Paint minimize button // if (style & WS_MINIMIZEBOX) { TRect rect(GetMinBoxRect()); PaintMinBox(dc, rect, false); } // Paint maximize button // if (style & WS_MAXIMIZEBOX) { TRect rect(GetMaxBoxRect()); PaintMaxBox(dc, rect, false); } // Draw window-frame color line under caption // TBrush winFrameBr(TColor::SysWindowFrame); dc.FrameRect(captRect.left, captRect.bottom-1, captRect.right, captRect.bottom, winFrameBr); }