/*************************************************************************** * 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_TEXTLABEL_H #define SDLWIDGETS_TEXTLABEL_H #include #include #include #include "widget.h" #include "action.h" namespace SDLwidgets { class TextLabel : public WidgetLeaf, public ActionWidget { public: enum Action { CLICKED }; private: TTF_Font* _font; SDL_Surface* _rendered_text; std::string _text; public: TextLabel( std::string font_name, int font_size, std::string text ); TextLabel( std::string text, int font_size = 16 ); virtual ~TextLabel(); virtual void draw( SDL_Surface* surface ); virtual void drawOffset( SDL_Surface* surface, int x_offset, int y_offset ); virtual int getWidth() const { if ( _rendered_text ) return _rendered_text->w; return 0; } virtual int getHeight() const { if ( _rendered_text ) return _rendered_text->h; return 0; } virtual void setColor( const SDL_Color& color ); void setText( std::string text ); virtual bool handleEvent( SDL_Event* event ); private: void renderText(); }; } #endif // SDLWIDGETS_TEXTLABEL_H