示例#1
0
// For the layout engine.
BOOL ClsFlatButton::OnGetMinSize( ClsSize& szMinSize )
{
	// Add room for the frame.
	szMinSize.CX() += ::GetSystemMetrics( SM_CXFRAME ) * 3;

	// For vista and up we use different numbers.
	if ( ClsGetApp()->GetMajorVersion() >= 6 )
	{
		szMinSize.CY() += ::GetSystemMetrics( SM_CYFRAME ) * 1 + 4;
	}
	else
	{
		szMinSize.CY() += ::GetSystemMetrics( SM_CYFRAME ) * 3;
	}

	// Images?
	int cxi = 0, cyi = 0;
	if ( m_hImages && ImageList_GetImageCount( m_hImages ))
	{
		// Get the image size.
		ImageList_GetIconSize( m_hImages, &cxi, &cyi );

		// Make room.
		cxi += 4;

		// Add sizes.
		szMinSize.CX() += cxi;
		szMinSize.CY() += cyi;
	}

	// Do we have a caption?
	ClsString str( GetSafeHWND());
	if ( str.GetStringLength())
	{
		// Setup the DC.
		ClsGetDC dc( this );
		ClsFont font;
		GetFont( font );
		ClsSelector sel( &dc, font );

		// Measure the caption.
		ClsRect rc;
		dc.DrawText( str, rc, DT_CALCRECT );

		// Add the width of the caption.
		szMinSize.CX() += rc.Width() + 4;

		// Adjust the height if necessary.
		if ( rc.Height() > cyi )
			szMinSize.CY() += rc.Height() - cyi;
	}
	return TRUE;
}
示例#2
0
文件: panel.cpp 项目: jcbaar/ClassLib
BOOL ClsPanel::OnGetMinSize( ClsSize& szMinSize )
{
	// Use the minimum button size.
	szMinSize.CX() = szMinSize.CY() = 0;
	m_pPanelCaption->OnGetMinSize( szMinSize );

	// Store the button height.
	m_nCaptionHeight = szMinSize.CY();
	return TRUE;
}
示例#3
0
// Calculate the minimum size of a
// vertical group.
BOOL ClsLayoutEngine::GroupVMinSize( ClsSize& szMinSize )
{
	// Reset values.
	m_nFixedSize = m_nFullWeight = 0;

	// Query minimum sizes.
	if ( MaxMinSize() == FALSE )
		return FALSE;

	// Iterate members.
	ClsMember *pMember;
	for ( pMember = m_Members.GetFirst(); pMember; pMember = m_Members.GetNext( pMember )) 
	{
		// Is it a spacing member?
		if (( pMember->m_dwFlags & ClsMember::MF_SPACING ) != ClsMember::MF_SPACING ) 
		{
			// Is it a equal height group?
			if ( m_dwFlags & LF_EQUALHEIGHT )
				// Make the group it's minimum height the
				// member it's minimum height.
				pMember->m_nMinHeight = m_nMaxMinHeight;
		}
	}

	// Iterate members.
	UINT nWidth = 0, nHeight = 0;
	for ( pMember = m_Members.GetFirst(); pMember; pMember = m_Members.GetNext( pMember )) 
	{
		// Does the member have fixed minimum dimensions?
		if (( pMember->m_dwFlags & ClsMember::MF_ASKMIN ) != ClsMember::MF_ASKMIN) 
		{
			// Is it a fixed height member?
			if ( pMember->m_dwFlags & ClsMember::MF_FIXEDHEIGHT )
				// Increase the group it's fixed height.
				m_nFixedSize += pMember->m_nFixedHeight;
			else 
			{
				// Increase the group height and total weight.
				nHeight	      += pMember->m_nMinHeight;
				m_nFullWeight += pMember->m_nWeight;
			}
		} 
		else 
		{
			// Is it a fixed height member?
                        if ( pMember->m_dwFlags & ClsMember::MF_FIXEDHEIGHT ) 
			{
				// Make the fixed height the minimum height.
				m_nFixedSize	       += pMember->m_nMinHeight;
				pMember->m_nFixedHeight = pMember->m_nMinHeight;
			} 
			else 
			{
				// Increase the group height and total weight.
				nHeight	      += pMember->m_nMinHeight;
				m_nFullWeight += pMember->m_nWeight;
			}
		}

		// Does the member have fixed minimum dimensions?
                if (( pMember->m_dwFlags & ClsMember::MF_ASKMIN ) != ClsMember::MF_ASKMIN ) 
		{
			// Does it have a fixed width?
			if ( pMember->m_dwFlags & ClsMember::MF_FIXEDWIDTH ) 
			{
				// Store the width when it is larger than
				// the width sofar.
				if ( pMember->m_nFixedWidth > nWidth )
					nWidth = pMember->m_nFixedWidth;
			}
			else
			{
				// Store the width when it is larger than
				// the width sofar.
				if ( pMember->m_nMinWidth > nWidth )
					nWidth = pMember->m_nMinWidth;
			}
		}
		else
		{
			// Does it have a fixed width?
			if ( pMember->m_dwFlags & ClsMember::MF_FIXEDWIDTH )
				// Make the fixed width the minimum width.
				pMember->m_nFixedWidth = pMember->m_nMinWidth;

			// Store the width when it is larger than the width
			// sofar.
			if ( pMember->m_nMinWidth > nWidth )
				nWidth = pMember->m_nMinWidth;
		}
	}

	// Add the offsets etc. to the sizes. The result will be the total
	// group minimum dimensions.
	nHeight += m_nFixedSize + ( m_rcOffsets.Top() + m_rcOffsets.Bottom() + (( m_Members.GetSize() - 1 ) * m_nSpacing ));
	nWidth  += ( m_rcOffsets.Left() + m_rcOffsets.Right());

	// Adjust for the frame.
	if ( m_bFrameGroup && m_Frame.GetSafeHWND())
	{
		nWidth  += ( ::GetSystemMetrics( SM_CXEDGE )) * 2 + ( m_nSpacing * 2 );
		nHeight += ::GetSystemMetrics( SM_CYEDGE ) + ( m_nFontHeight + ( m_nSpacing * 2 ));
	}

	// Store the values.
	szMinSize.CX() = max( 1, nWidth  );
	szMinSize.CY() = max( 1, nHeight );

	// Success...
	return TRUE;
}
示例#4
0
// For the layout engine.
BOOL ClsSplitter::OnGetMinSize( ClsSize& szMinSize )
{
	// Setup values.
	szMinSize.CX() = szMinSize.CY() = SPLITTER_SIZE;
	return TRUE;
}
示例#5
0
// Calculate the minumum size of a
// horizontal group.
BOOL ClsLayoutEngine::GroupHMinSize( ClsSize& szMinSize )
{
	// Reset values.
	m_nFullWeight = m_nFixedSize = 0;

	// Query minimum sizes.
	if ( MaxMinSize() == FALSE )
		return FALSE;

	// Scan through the members.
	ClsMember *pMember;
	UINT nWidth = 0, nHeight = 0;
	for ( pMember = m_Members.GetFirst(); pMember; pMember = m_Members.GetNext( pMember )) 
	{
		// Is this a spacing member?
		if (( pMember->m_dwFlags & ClsMember::MF_SPACING ) != ClsMember::MF_SPACING ) 
		{
			// No. If this group has equal widths we set the
			// witdth of the member to the group width.
			if ( m_dwFlags & LF_EQUALWIDTH )
				pMember->m_nMinWidth = m_nMaxMinWidth;
		}

		// Does the member have fixed minimum dimensions?
		if (( pMember->m_dwFlags & ClsMember::MF_ASKMIN ) != ClsMember::MF_ASKMIN ) 
		{
			// No. Is it a fixed width object?
			if ( pMember->m_dwFlags & ClsMember::MF_FIXEDWIDTH )
				// Increase the group it's total fixed width.
				m_nFixedSize += pMember->m_nFixedWidth;
			else 
			{
				// Increase the groups width and the total
				// weight.
				nWidth	      += pMember->m_nMinWidth;
				m_nFullWeight += pMember->m_nWeight;
			}
		} 
		else 
		{
			// Is it a fixed width member?
			if ( pMember->m_dwFlags & ClsMember::MF_FIXEDWIDTH ) 
			{
				// Increase the total fixed width by the member
				// it's minimum width.
				m_nFixedSize	      += pMember->m_nMinWidth;
				pMember->m_nFixedWidth = pMember->m_nMinWidth;
			}
			else
			{
				// Increase the group width and the total weight.
				nWidth	      += pMember->m_nMinWidth;
				m_nFullWeight += pMember->m_nWeight;
			}
		}

		// Does the member have fixed minimum dimensions?
		if (( pMember->m_dwFlags & ClsMember::MF_ASKMIN ) != ClsMember::MF_ASKMIN ) 
		{
			// Is it a fixed height object?
			if ( pMember->m_dwFlags & ClsMember::MF_FIXEDHEIGHT ) 
			{
				// Store the member height when it is larger than
				// the height sofar.
				if ( pMember->m_nFixedHeight > nHeight )
					nHeight = pMember->m_nFixedHeight;
			} 
			else 
			{
				// Store the member minimum height when it is larger
				// than the height sofar.
				if ( pMember->m_nMinHeight > nHeight )
					nHeight = pMember->m_nMinHeight;
			}
		} 
		else 
		{
			// Is it a fixed height object?
			if ( pMember->m_dwFlags & ClsMember::MF_FIXEDHEIGHT )
				// Store the minimum height as the fixed height.
				pMember->m_nFixedHeight = pMember->m_nMinHeight;

			// Store the height when it is larger than
			// the height sofar.
			if ( pMember->m_nMinHeight > nHeight )
				nHeight = pMember->m_nMinHeight;
		}
	}

	// Add the offsets etc. to the sizes. The result will be the total
	// group minimum dimensions.
        nWidth  += m_nFixedSize + ( m_rcOffsets.Left() + m_rcOffsets.Right() + (( m_Members.GetSize() - 1 ) * m_nSpacing ));
        nHeight += ( m_rcOffsets.Top() + m_rcOffsets.Bottom());

	//	Adjust for the frame.
	if ( m_bFrameGroup && m_Frame.GetSafeHWND())
	{
		nWidth  += ( ::GetSystemMetrics( SM_CXEDGE ) * 2 ) + ( m_nSpacing * 2 );
		nHeight += ::GetSystemMetrics( SM_CYEDGE ) + ( m_nFontHeight + ( m_nSpacing * 2 ));
	}

	// Store the values.
	szMinSize.CX() = max( 1, nWidth );
        szMinSize.CY() = max( 1, nHeight );

	// Success...
	return TRUE;
}