| 304 | } |
| 305 | |
| 306 | void ScrolledWindow::AddWithViewport( Widget::Ptr widget ) { |
| 307 | float border_width( Context::Get().GetEngine().GetProperty<float>( "BorderWidth", shared_from_this() ) ); |
| 308 | |
| 309 | if( GetChildren().size() > 2 ) { |
| 310 | |
| 311 | #if defined( SFGUI_DEBUG ) |
| 312 | std::cerr << "SFGUI warning: Only one widget can be added to a ScrolledWindow.\n"; |
| 313 | #endif |
| 314 | |
| 315 | return; |
| 316 | } |
| 317 | |
| 318 | m_viewport = Viewport::Create(); |
| 319 | |
| 320 | m_viewport->SetHorizontalAdjustment( m_horizontal_scrollbar->GetAdjustment() ); |
| 321 | m_viewport->SetVerticalAdjustment( m_vertical_scrollbar->GetAdjustment() ); |
| 322 | |
| 323 | m_viewport->Add( widget ); |
| 324 | |
| 325 | Container::Add( m_viewport ); |
| 326 | |
| 327 | // Make sure the viewport is offset by the border width. |
| 328 | sf::FloatRect allocation( m_viewport->GetAllocation() ); |
| 329 | |
| 330 | allocation.position.x += border_width; |
| 331 | allocation.position.y += border_width; |
| 332 | |
| 333 | m_viewport->SetAllocation( allocation ); |
| 334 | } |
| 335 | |
| 336 | void ScrolledWindow::Add( Widget::Ptr /*widget*/ ) { |
| 337 | #if defined( SFGUI_DEBUG ) |