Пример #1
0
PushButton* StartMenu::addButton( const std::string& caption, int id )
{
    Size btnSize( 200, 25 );
    int offsetY = 40;

    PushButton* btn = new PushButton( this, Rect( Point( 0, 0 ), btnSize ), caption, id ); 

    Point offsetBtn( ( getWidth() - btnSize.getWidth() ) / 2, ( getHeight() - offsetY * 3 ) / 2 );
    List< PushButton* > buttons = findChildren< PushButton* >(); 
    foreach( PushButton* btn, buttons )
    {
        btn->setPosition( offsetBtn );
        offsetBtn += Point( 0, offsetY );
    }
Пример #2
0
PushButton* StartMenu::addButton( const std::string& caption, int id )
{
    Size btnSize( 200, 25 );
    int offsetY = 40;

    PushButton* btn = new PushButton( this, Rect( Point( 0, 0 ), btnSize ), caption, id ); 

    Point offsetBtn( ( getWidth() - btnSize.getWidth() ) / 2, ( getHeight() - offsetY * 3 ) / 2 );
    List< PushButton* > buttons = findChildren< PushButton* >(); 
    for( List< PushButton* >::iterator it=buttons.begin(); it != buttons.end(); it++ )
    {
        (*it)->setPosition( offsetBtn );
        offsetBtn += Point( 0, offsetY );
    }

    return btn;
}