예제 #1
0
파일: Window.cpp 프로젝트: Zykr/SFGUI
sf::FloatRect Window::GetClientRect() const {
	sf::FloatRect  clientrect( 0, 0, GetAllocation().Width, GetAllocation().Height );
	float  title_height( HasStyle( Titlebar ) ? Context::Get().GetEngine().GetProperty<float>( "TitleHeight", shared_from_this() ) : 0.f );
	float  border_width( Context::Get().GetEngine().GetProperty<float>( "BorderWidth", shared_from_this() ) );

	clientrect.Left += border_width + GetBorderWidth();
	clientrect.Top += title_height + border_width + GetBorderWidth();
	clientrect.Width -= 2 * border_width + 2 * GetBorderWidth();
	clientrect.Height -= title_height + 2 * border_width + 2 * GetBorderWidth();

	return clientrect;
}
예제 #2
0
sf::FloatRect Window::GetClientRect() const {
	sf::FloatRect clientrect( 0, 0, GetAllocation().width, GetAllocation().height );
	float border_width( Context::Get().GetEngine().GetProperty<float>( "BorderWidth", shared_from_this() ) );
	float gap( Context::Get().GetEngine().GetProperty<float>( "Gap", shared_from_this() ) );

	clientrect.left += border_width + gap;
	clientrect.top += border_width + gap;
	clientrect.width -= 2 * border_width + 2 * gap;
	clientrect.height -= 2 * border_width + 2 * gap;

	if( HasStyle( TITLEBAR ) ) {
		unsigned int title_font_size( Context::Get().GetEngine().GetProperty<unsigned int>( "FontSize", shared_from_this() ) );
		const sf::Font& title_font( *Context::Get().GetEngine().GetResourceManager().GetFont( Context::Get().GetEngine().GetProperty<std::string>( "FontName", shared_from_this() ) ) );
		float title_height(
			Context::Get().GetEngine().GetFontLineHeight( title_font, title_font_size ) +
			2 * Context::Get().GetEngine().GetProperty<float>( "TitlePadding", shared_from_this() )
		);

		clientrect.top += title_height;
		clientrect.height -= title_height;
	}

	return clientrect;
}