/* $Id: wopwindow.cpp,v 1.7 2005/11/30 21:36:06 chfreund Exp $ */ #include "wopwindow.hpp" #include #include "graphics.h" #include "layout.h" using namespace SDLwidgets; #include "wopsettings.hpp" WopWindow::WopWindow() : m_titleLabel( "tahomabd.ttf", 14, "" ), m_widget( 0 ) { // default colors m_titleColor.r = 0; m_titleColor.g = 0; m_titleColor.b = 0; m_titleBackgroundColor.r = 0; m_titleBackgroundColor.g = 0; m_titleBackgroundColor.b = 255; m_titleAlpha = 50; m_contentBackgroundColor.r = 0; m_contentBackgroundColor.g = 0; m_contentBackgroundColor.b = 255; m_contentAlpha = 50; m_rule = new BackgroundWidget( 0, 4 ); m_rule->setColor( m_titleColor ); m_rule->setHorizontalStretch( FILL ); m_content = new WidgetComposite( 0, 0 ); VerticalLayout* contentLayout = new VerticalLayout( m_content ); contentLayout->setBorderSpacing( 10 ); contentLayout->setSpacing( 5 ); m_content->setLayout( contentLayout ); m_titleLabel.setColor( m_titleColor ); std::ostringstream path; path << WopSettings::getInstance()->getData(); path << "/images/gui/bg.png"; m_background = new BackgroundWidget( m_content, path.str().c_str() ); m_border = new Border3DWidget( m_background ); WidgetProxy::setWidget( m_border ); } WopWindow::WopWindow( Widget* widget, std::string title ) : m_titleLabel( "tahomabd.ttf", 14, title ) { // default colors m_titleColor.r = 0; m_titleColor.g = 0; m_titleColor.b = 0; m_titleBackgroundColor.r = 0; m_titleBackgroundColor.g = 0; m_titleBackgroundColor.b = 255; m_titleAlpha = 50; m_contentBackgroundColor.r = 0; m_contentBackgroundColor.g = 0; m_contentBackgroundColor.b = 255; m_contentAlpha = 50; m_content = new WidgetComposite( 0, 0 ); VerticalLayout* contentLayout = new VerticalLayout( m_content ); contentLayout->setBorderSpacing( 10 ); contentLayout->setSpacing( 5 ); m_content->setLayout( contentLayout ); m_titleLabel.setColor( m_titleColor ); /* m_rule = new Image( widget->getWidth(), 8 ); Uint32 white = SDL_MapRGB( SDL_GetVideoSurface()->format, 255, 255, 255 ); Uint32 color = SDL_MapRGB( SDL_GetVideoSurface()->format, m_titleColor.r, m_titleColor.g, m_titleColor.b ); SDL_Rect rect; rect.x = rect.y = 0; rect.w = m_rule->getSurface()->w; rect.h = 3; SDL_FillRect( m_rule->getSurface(), 0, white ); SDL_FillRect( m_rule->getSurface(), &rect, color ); SDL_SetColorKey( m_rule->getSurface(), SDL_SRCCOLORKEY | SDL_RLEACCEL, white );*/ m_rule = new BackgroundWidget( 0, 4 ); m_rule->setColor( m_titleColor ); m_rule->setHorizontalStretch( FILL ); setWidget( widget ); std::ostringstream path; path << WopSettings::getInstance()->getData(); path << "/images/gui/bg.png"; m_background = new BackgroundWidget( m_content, path.str().c_str() ); m_border = new Border3DWidget( m_background ); WidgetProxy::setWidget( m_border ); } WopWindow::~WopWindow() { } void WopWindow::setWidget( Widget* widget ) { /* if ( !m_rule || m_widget != widget ) { delete m_rule; m_rule = new Image( widget->getWidth(), 8 ); Uint32 white = SDL_MapRGB( SDL_GetVideoSurface()->format, 255, 255, 255 ); Uint32 color = SDL_MapRGB( SDL_GetVideoSurface()->format, m_titleColor.r, m_titleColor.g, m_titleColor.b ); SDL_Rect rect; rect.x = rect.y = 0; rect.w = m_rule->getSurface()->w; rect.h = 3; SDL_FillRect( m_rule->getSurface(), 0, white ); SDL_FillRect( m_rule->getSurface(), &rect, color ); SDL_SetColorKey( m_rule->getSurface(), SDL_SRCCOLORKEY | SDL_RLEACCEL, white ); }*/ m_widget = widget; m_content->removeAll(); m_content->add( &m_titleLabel ); m_content->add( m_rule ); m_content->add( m_widget ); } void WopWindow::setTitle( std::string title ) { m_titleLabel.setText( title ); /* m_content->removeAll(); m_content->add( &m_titleLabel ); m_content->add( m_rule ); if ( m_widget ) m_content->add( m_widget );*/ }