/*************************************************************************** * Copyright (C) 2004 by Christoph Freundl * * Christoph.Freundl@informatik.uni-erlangen.de * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ #ifndef SDLWIDGETS_BACKGROUNDWIDGET_H #define SDLWIDGETS_BACKGROUNDWIDGET_H #include "widget.h" namespace SDLwidgets { class BackgroundWidget : public WidgetDecorator { private: Uint8 _alpha; SDL_Surface* _image; public: BackgroundWidget( Widget* widget ) : WidgetDecorator( widget ), _alpha( SDL_ALPHA_TRANSPARENT ), _image( 0 ) { if ( widget ) { widget->setPosition( 0, 0 ); _min_width = _widget->getMinWidth(); _min_height = _widget->getMinHeight(); _max_width = _widget->getMaxWidth(); _max_height = _widget->getMaxHeight(); _width = _widget->getWidth(); _height = _widget->getHeight(); } _color.r = 0; _color.g = 0; _color.b = 0; } BackgroundWidget( Widget* widget, const SDL_Color& color, int alpha = 255 ) : WidgetDecorator( widget ), _alpha( alpha ), _image( 0 ) { if ( widget ) { widget->setPosition( 0, 0 ); _min_width = _widget->getMinWidth(); _min_height = _widget->getMinHeight(); _max_width = _widget->getMaxWidth(); _max_height = _widget->getMaxHeight(); _width = _widget->getWidth(); _height = _widget->getHeight(); } _color = color; } BackgroundWidget( Widget* widget, const char* filename ); BackgroundWidget( int width, int height ); virtual ~BackgroundWidget() { } virtual void setColor( const SDL_Color& color ); virtual void setAlpha( int alpha ); virtual void draw( SDL_Surface* surface ); virtual void setWidth( const Uint16 width ); virtual void setMinWidth( const Uint16 min_width ); virtual void setHeight( const Uint16 height ); virtual void doLayout(); }; } #endif // SDLWIDGETS_BACKGROUNDWIDGET_H