示例#1
0
LONG CLayoutRuleRelativeControl::Apply(const CDialogTemplate& tmpl, UINT nDirection,
										const CRect& rcLayout) const
{
	CDialogItemTemplate item = tmpl.FindControl( m_nCtrlID );
	ATLASSERT( item.IsValid() );

	switch ( this->m_nDirection )
	{
		case LAYOUT_DIRECTION_LEFT:
			ATLASSERT( nDirection == LAYOUT_DIRECTION_LEFT || nDirection == LAYOUT_DIRECTION_RIGHT );
			return item.GetX() - m_nPadding;
		case LAYOUT_DIRECTION_TOP:
			ATLASSERT( nDirection == LAYOUT_DIRECTION_TOP || nDirection == LAYOUT_DIRECTION_BOTTOM );
			return item.GetY() - m_nPadding;
		case LAYOUT_DIRECTION_RIGHT:
			ATLASSERT( nDirection == LAYOUT_DIRECTION_LEFT || nDirection == LAYOUT_DIRECTION_RIGHT );
			return item.GetX() + item.GetWidth() + m_nPadding;
		case LAYOUT_DIRECTION_BOTTOM:
			ATLASSERT( nDirection == LAYOUT_DIRECTION_TOP || nDirection == LAYOUT_DIRECTION_BOTTOM );
			return item.GetY() + item.GetHeight() + m_nPadding;
		default:
			ATLASSERT(FALSE);
			return 0;
	}

}
示例#2
0
CLayoutControl::CLayoutControl(const CDialogTemplate& rTmpl,
							   const CLayoutContainer& parent,
							   UINT nID, UINT nAnchor)
	: m_nID(nID), m_nAnchor(nAnchor)
{
	CDialogItemTemplate item = rTmpl.FindControl(nID);
	ATLASSERT( item.IsValid() );

	const CRect& rcParent = parent.GetBounds();
	
	m_rcMargins.SetRect( item.GetX() - rcParent.left,
		item.GetY() - rcParent.top,
		rcParent.right - item.GetX() - item.GetWidth(),
        rcParent.bottom - item.GetY() - item.GetHeight() );
	//ATLASSERT( m_rcMargins.left >= 0 && m_rcMargins.top >= 0 );
	rTmpl.MapDialogRect(m_rcMargins);
}