void CMainDlg::DrawFocusRect(CPoint pt, BOOL bRemoveRect) { ASSERT(m_pDesktopDC != NULL); // Get frame sizes CSize szFrame(m_iBandPx, m_iBandPx); CSize szLast = szFrame; if(bRemoveRect) szFrame.cx = szFrame.cy = 0; // Create brushes //CBrush* pWhiteBrush = CBrush::FromHandle // ((HBRUSH)::GetStockObject(WHITE_BRUSH)); CBrush* pWhiteBrush = CBrush::FromHandle ((HBRUSH)::CreateSolidBrush(RGB(255,255,255))); CBrush* pDitherBrush = CDC::GetHalftoneBrush(); CBrush* pBrush = pWhiteBrush; // Get rect coorinates of last and current box CRect rNow(m_ptFirst, pt); rNow.NormalizeRect(); CRect rLast(m_ptFirst, m_ptLast); rLast.NormalizeRect(); // Draw the drag frame m_pDesktopDC->DrawDragRect(&rNow, szFrame, &rLast, szLast, pBrush, m_bDitherLast ? pDitherBrush : pWhiteBrush); // Save for next frame m_bDitherLast = (pBrush == pDitherBrush); }
CRect SSkinScrollbar::GetPartRect(int nSbCode, int nState,BOOL bVertical) { CSize sz=GetSkinSize(); CSize szFrame(sz.cx/9,sz.cx/9); if(nSbCode==SB_CORNOR) { return CRect(CPoint(szFrame.cx*8,0),szFrame); }else if(nSbCode==SB_THUMBGRIPPER) { return CRect(CPoint(szFrame.cx*8,(1+(bVertical?0:1))*szFrame.cy),szFrame); }else { if(nState==SBST_INACTIVE && !m_bHasInactive) { nState=SBST_NORMAL; } CRect rcRet; int iPart=-1; switch(nSbCode) { case SB_LINEUP: iPart=0; break; case SB_LINEDOWN: iPart=1; break; case SB_THUMBTRACK: iPart=2; break; case SB_PAGEUP: case SB_PAGEDOWN: iPart=3; break; } if(!bVertical) iPart+=4; return CRect(CPoint(szFrame.cx*iPart,szFrame.cy*nState),szFrame); } }
HRESULT CCUILayoutHorizontal::CalcSize(IUIFrame* pHostFrame, SIZE szOld, SIZE* pOutSize) { DEBUG_ASSERT(pHostFrame) ; IF_RETURN(NULL == pHostFrame, E_INVALIDARG) ; DEBUG_ASSERT(pOutSize) ; IF_RETURN(NULL == pOutSize, E_INVALIDARG) ; BOOL bAutoWidth = FALSE, bAutoHeight = FALSE ; pHostFrame->GetAutoWidth(&bAutoWidth) ; pHostFrame->GetAutoHeight(&bAutoHeight) ; if (!bAutoWidth && !bAutoHeight) { *pOutSize = szOld ; return S_OK ; } CRect _rcPadding(0, 0, 0, 0) ; pHostFrame->GetPadding(_rcPadding) ; CRect _rcExtPadding(0, 0, 0, 0) ; CComQIPtr<IUIFrameInternal> pFrameInternal = pHostFrame ; if (pFrameInternal) { pFrameInternal->GetExtPadding(&_rcExtPadding) ; } CSize szMinBoundSize = szOld ; if (bAutoHeight) { szMinBoundSize.cy = 0 ; } if (bAutoWidth) { szMinBoundSize.cx = 0 ; } VEC_FRAME _vec_frame ; LONG lChildrenCount = 0 ; pHostFrame->GetChildrenCount(&lChildrenCount) ; for (INT i = 0; i < lChildrenCount; ++i) { //IF_CONTINUE(i == this->m_nFillItem - 1) ; CComPtr<IUIElement> pElement ; pHostFrame->GetChildByIndex(i, &pElement) ; CComQIPtr<IUIFrame> pFrame = pElement ; IF_CONTINUE(NULL == pFrame) ; CComQIPtr<IUIFrameInternal> pFrameInternal = pFrame ; IF_CONTINUE(NULL == pFrameInternal) ; BOOL bHidden = FALSE ; pFrame->GetHidden(&bHidden) ; IF_CONTINUE(TRUE == bHidden) ; BOOL bFloat = TRUE ; pFrame->GetFloat(&bFloat) ; IF_CONTINUE(TRUE == bFloat) ; BOOL bChildHeightAsParent = FALSE ; pFrame->GetHeightAsParent(&bChildHeightAsParent) ; BOOL bChildWidthAsParent = FALSE ; pFrame->GetWidthAsParent(&bChildWidthAsParent) ; BOOL bChildAutoHeight = FALSE ; pFrame->GetAutoHeight(&bChildAutoHeight) ; BOOL bChildAutoWidth = FALSE ; pFrame->GetAutoWidth(&bChildAutoWidth) ; if (bChildHeightAsParent && bChildAutoWidth && bAutoHeight) { _vec_frame.push_back(pFrame) ; } else { CRect rcFrameMargin(0, 0, 0, 0) ; pFrame->GetMargin(&rcFrameMargin) ; CSize szEstimateSize(-1, -1) ; if (bChildWidthAsParent) { szEstimateSize.cx = 0 ; } if (bChildHeightAsParent && !bAutoHeight) { szEstimateSize.cy = szOld.cy - _rcPadding.top - _rcPadding.bottom - _rcExtPadding.top - _rcExtPadding.bottom ; } pFrameInternal->SetEstimateSize(szEstimateSize) ; CSize szFrame(0, 0) ; pFrame->GetSize(&szFrame) ; if (i == this->m_nFillItem -1 || -1 * lChildrenCount + i == this->m_nFillItem) { szFrame.cx = 0 ; } if (bAutoHeight) { INT nHeight = szFrame.cy + rcFrameMargin.top + rcFrameMargin.bottom ; if (nHeight > szMinBoundSize.cy) { szMinBoundSize.cy = nHeight ; } } if (bAutoWidth) { szMinBoundSize.cx += (szFrame.cx + rcFrameMargin.left + rcFrameMargin.right) ; } } } if (bAutoWidth) { for (INT i = 0; i < (INT)_vec_frame.size(); ++i) { CComPtr<IUIFrame> pFrame = _vec_frame[i] ; CComQIPtr<IUIFrameInternal> pFrameInternal = _vec_frame[i] ; IF_CONTINUE(NULL == pFrame || NULL == pFrameInternal) ; CRect rcMargin(0, 0, 0, 0) ; pFrame->GetMargin(&rcMargin) ; CSize szEstimateSize(0, 0) ; szEstimateSize.cx = -1 ; szEstimateSize.cy = szMinBoundSize.cy - rcMargin.top - rcMargin.bottom ; pFrameInternal->SetEstimateSize(szEstimateSize) ; CSize szFrame(0, 0) ; pFrame->GetSize(&szFrame) ; szMinBoundSize.cx = szFrame.cx + rcMargin.left + rcMargin.right ; } } if (bAutoWidth) { szMinBoundSize.cx += _rcPadding.left + _rcPadding.right + _rcExtPadding.left + _rcExtPadding.right ; } if (bAutoHeight) { szMinBoundSize.cy += _rcPadding.top + _rcPadding.bottom + _rcExtPadding.top + _rcExtPadding.bottom ; } *pOutSize = szMinBoundSize ; return S_OK ; }