本文整理汇总了C++中CElement::GetBoundRect方法的典型用法代码示例。如果您正苦于以下问题:C++ CElement::GetBoundRect方法的具体用法?C++ CElement::GetBoundRect怎么用?C++ CElement::GetBoundRect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CElement
的用法示例。
在下文中一共展示了CElement::GetBoundRect方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OnDraw
void CSkViewView::OnDraw(CDC* pDC)
{
CSkViewDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
if (!pDoc)
return;
POSITION aPos = pDoc->GetListHeadPosition();
CElement* pElement = 0;
while(aPos)
{
pElement = pDoc->GetNext(aPos);
if(pDC->RectVisible(pElement->GetBoundRect()))
pElement->Draw(pDC);
}
}
示例2: OnDraw
void CSketcherView::OnDraw(CDC* pDC)
{
CSketcherDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
if(!pDoc)
return;
POSITION aPos = pDoc->GetListHeadPosition();
CElement* pElement = 0; // Store for an element pointer
while(aPos) // Loop while aPos is not null
{
pElement = pDoc->GetNext(aPos); // Get the current element pointer
// If the element is visible...
if(pDC->RectVisible(pElement->GetBoundRect()))
pElement->Draw(pDC, m_pSelected);// ...draw it
}
}
示例3: OnMouseMove
void CSketcherView::OnMouseMove(UINT nFlags, CPoint point)
{
// Define a Device Context object for the view
CClientDC aDC(this); // DC is for this view
OnPrepareDC(&aDC); // Get origin adjusted
// If we are in move mode, move the selected element and return
if(m_MoveMode)
{
aDC.DPtoLP(&point); // Convert to logical coordinatess
MoveElement(aDC, point); // Move the element
return;
}
aDC.SetROP2(R2_NOTXORPEN); // Set the drawing mode
if((nFlags&MK_LBUTTON) && (this==GetCapture()))
{
aDC.DPtoLP(&point); // convert point to Logical
m_SecondPoint = point; // Save the current cursor position
if(m_pTempElement)
{
if(CURVE == GetDocument()->GetElementType()) // Is it a curve?
{ // We are drawing a curve
// so add a segment to the existing curve
static_cast<CCurve*>(m_pTempElement)->AddSegment(m_SecondPoint);
m_pTempElement->Draw(&aDC); // Now draw it
return; // We are done
}
aDC.SetROP2(R2_NOTXORPEN); // Set drawing mode
// Redraw the old element so it disappears from the view
m_pTempElement->Draw(&aDC);
delete m_pTempElement; // Delete the old element
m_pTempElement = 0; // Reset the pointer to 0
}
// Create a temporary element of the type and color that
// is recorded in the document object, and draw it
m_pTempElement = CreateElement(); // Create a new element
m_pTempElement->Draw(&aDC); // Draw the element
}
else
{ // We are not drawing an element so do highlighting...
CSketcherDoc* pDoc=GetDocument(); // Get a pointer to the document
CElement* pElement = 0; // Store an element pointer
CRect aRect(0,0,0,0); // Store a rectangle
POSITION aPos = pDoc->GetListHeadPosition(); // Get first element posn
CElement* pOldSelection = m_pSelected; // Save old selected element
m_pSelected = 0;
while(aPos) // Iterate through the list
{
pElement = pDoc->GetNext(aPos);
aRect = pElement->GetBoundRect();
aDC.LPtoDP(aRect);
aRect.NormalizeRect();
// Select the first element that appears under the cursor
if(aRect.PtInRect(point))
{
m_pSelected = pElement;
break;
}
}
if(m_pSelected == pOldSelection) // If new selection is same as old
return; // we are done
// Unhighlight old selection if there is one
if(pOldSelection != 0) // Verify there is one
{
aRect = pOldSelection->GetBoundRect();
aDC.LPtoDP(aRect); // Convert to device coords
aRect.NormalizeRect(); // Normalize
InvalidateRect(aRect, FALSE); // Invalidate area
}
// Highlight new selection if there is one
if(m_pSelected != 0) // Verify there is one
{
aRect = m_pSelected->GetBoundRect();
aDC.LPtoDP(aRect); // Convert to device coords
aRect.NormalizeRect(); // Normalize
InvalidateRect(aRect, FALSE); // Invalidate area
}
}
}