示例#1
0
文件: window.cpp 项目: galek/gamegui
void base_window::Align()
{
	if(!m_parent)
		return;
	if(!m_alignment)
		return;

	point pos = m_area.getPosition();
	Size sz = m_area.getSize();
	Size parent_size(m_parent->getSize());

	if(m_alignment & HCenter)
	{
		float original_width = m_alignmentRect.m_left + m_alignmentRect.m_right;
		float x = 0.f;
		if(original_width > 0.f)
		{
			float width = parent_size.width - sz.width;
			x = width * m_alignmentRect.m_left / original_width;
		}
		m_area.setPosition(point(x, pos.y));
	}
	else
	{
		if(m_alignment & Left)
		{
			m_area.setPosition(point(m_alignmentRect.m_left, pos.y));
		}
		else if(m_alignment & Right)
		{
			m_area.setPosition(point(parent_size.width - sz.width - m_alignmentRect.m_right, pos.y));
		}
	}

	pos = m_area.getPosition();

	if(m_alignment & VCenter)
	{
		float original_height = m_alignmentRect.m_top + m_alignmentRect.m_bottom;
		float y = 0.f;
		if(original_height > 0.f)
		{
			float height = parent_size.height - sz.height;
			y = height * m_alignmentRect.m_top / original_height;
		}
		m_area.setPosition(point(pos.x, y));
	}
	else
	{
		if(m_alignment & Top)
		{
			m_area.setPosition(point(pos.x, m_alignmentRect.m_top));
		}
		else if(m_alignment & Bottom)
		{
			m_area.setPosition(point(pos.x, parent_size.height - sz.height - m_alignmentRect.m_bottom));
		}
	}
}
示例#2
0
void TCWin::RecalculateSize()
{
    wxSize parent_size(2000,2000);
    if( pParent )
        parent_size = pParent->GetClientSize();
    
    int unscaledheight = 600;
    int unscaledwidth  = 650;

    // value of m_tcwin_scaler should be about unity on a 100 dpi display,
    // when scale parameter g_tcwin_scale is 100
    // parameter g_tcwin_scale is set in config file as value of TideCurrentWindowScale
    g_tcwin_scale = wxMax(g_tcwin_scale,10); // sanity check on g_tcwin_scale
    m_tcwin_scaler = g_Platform->GetDisplayDPmm() * 0.254 * g_tcwin_scale / 100.0;

    m_tc_size.x = (int) (unscaledwidth * m_tcwin_scaler + 0.5);
    m_tc_size.y = (int) (unscaledheight * m_tcwin_scaler + 0.5);
    
    m_tc_size.x = wxMin(m_tc_size.x, parent_size.x);
    m_tc_size.y = wxMin(m_tc_size.y, parent_size.y);
   
    int xc = m_x + 8;
    int yc = m_y;
    
    //  Arrange for tcWindow to be always totally visible
    //  by shifting left and/or up
    if( ( m_x + 8 + m_tc_size.x ) > parent_size.x ) xc = xc - m_tc_size.x - 16;
    if( ( m_y + m_tc_size.y ) > parent_size.y ) yc = yc - m_tc_size.y;
    
    //  Don't let the window origin move out of client area
    if( yc < 0 ) yc = 0;
    if( xc < 0 ) xc = 0;
    
    if( pParent )
        pParent->ClientToScreen( &xc, &yc );
    m_position = wxPoint( xc, yc );
    
    if(m_created){
        SetSize(m_tc_size);
        Move(m_position);
    }
}
示例#3
0
文件: window.cpp 项目: galek/gamegui
void base_window::Stick()
{
	if(!m_parent)
		return;
	if(!m_stick)
		return;

	Size sz = m_area.getSize();
	Size parent_size(m_parent->getSize());

	if(m_stick & HCenter)
	{
		m_area.setPosition(point((parent_size.width - sz.width) / 2, m_area.m_top));
	}
	else
	{
		if(m_stick & Left)
		{
			m_area.setPosition(point(m_stickRect.m_left, m_area.m_top));
		}
		else if(m_stick & Right)
		{
			m_area.setPosition(point(parent_size.width - sz.width - m_stickRect.m_right, m_area.m_top));
		}
	}

	if(m_stick & VCenter)
	{
		m_area.setPosition(point(m_area.m_left, (parent_size.height - sz.height) / 2));
	}
	else
	{
		if(m_stick & Top)
		{
			m_area.setPosition(point(m_area.m_left, m_stickRect.m_top));
		}
		else if(m_stick & Bottom)
		{
			m_area.setPosition(point(m_area.m_left, parent_size.height - sz.height - m_stickRect.m_bottom));
		}
	}
}
示例#4
0
文件: TCWin.cpp 项目: adwuk/OpenCPN
void TCWin::RecalculateSize()
{
    wxSize parent_size(2000,2000);
    if( pParent )
        parent_size = pParent->GetClientSize();
    
    if(m_created)
        m_tc_size.x = GetCharWidth() * 50;
    else
        m_tc_size.x = 650;
        
    
    m_tc_size.x = wxMin(m_tc_size.x, parent_size.x);
    m_tc_size.y = wxMin(480, parent_size.y);
    

   
    int xc = m_x + 8;
    int yc = m_y;
    
    //  Arrange for tcWindow to be always totally visible
    //  by shifting left and/or up
    if( ( m_x + 8 + m_tc_size.x ) > parent_size.x ) xc = xc - m_tc_size.x - 16;
    if( ( m_y + m_tc_size.y ) > parent_size.y ) yc = yc - m_tc_size.y;
    
    //  Don't let the window origin move out of client area
    if( yc < 0 ) yc = 0;
    if( xc < 0 ) xc = 0;
    
    if( pParent )
        pParent->ClientToScreen( &xc, &yc );
    m_position = wxPoint( xc, yc );
    
    if(m_created){
        SetSize(m_tc_size);
        Move(m_position);
    }
}