TextWidget.h

Go to the documentation of this file.
00001 /*
00002  *  Copyright (C) 2003-2006  The Pentagram Team
00003  *
00004  *  This program is free software; you can redistribute it and/or modify
00005  *  it under the terms of the GNU General Public License as published by
00006  *  the Free Software Foundation; either version 2 of the License, or
00007  *  (at your option) any later version.
00008  *
00009  *  This program is distributed in the hope that it will be useful,
00010  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  *  GNU General Public License for more details.
00013  *
00014  *  You should have received a copy of the GNU General Public License
00015  *  along with this program; if not, write to the Free Software
00016  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00017  */
00018 
00019 #ifndef TEXTWIDGET_H_INCLUDED
00020 #define TEXTWIDGET_H_INCLUDED
00021 
00022 //
00023 // TextWidget. Displays text in either a fixed-size or a fit-to-text rectangle.
00024 //
00025 
00026 #include "Gump.h"
00027 
00028 #include "Font.h"
00029 
00030 using Pentagram::Font;
00031 
00032 class RenderedText;
00033 
00034 class TextWidget : public Gump
00035 {
00036 protected:
00037         std::string             text;
00038         bool                    gamefont;
00039         int                             fontnum;
00040         uint32                  blendColour;
00041         int                             tx, ty;
00042 
00043         unsigned int    current_start; 
00044         unsigned int    current_end;   
00045 
00046         int targetwidth, targetheight;
00047 
00048         RenderedText* cached_text;
00049         Font::TextAlign textalign;
00050 public:
00051         ENABLE_RUNTIME_CLASSTYPE();
00052 
00053         TextWidget();
00054         TextWidget(int X, int Y, std::string txt, bool gamefont, int fontnum,
00055                            int width = 0, int height = 0,
00056                            Font::TextAlign align = Font::TEXT_LEFT);
00057         virtual ~TextWidget(void);
00058 
00059         // Init the gump, call after construction
00060         virtual void                    InitGump(Gump* newparent, bool take_focus=true);
00061 
00062         // Overloadable method to Paint just this Gump (RenderSurface is relative to this)
00063         virtual void                    PaintThis(RenderSurface*, sint32 lerp_factor, bool scaled);
00064 
00065         virtual void                    PaintComposited(RenderSurface* surf, sint32 lerp_factor, sint32 scalex, sint32 scaley);
00066 
00067         virtual Gump* OnMouseMotion(int mx, int my);
00068 
00071         bool setupNextText();
00072 
00074         void rewind();
00075 
00079         void getCurrentText(unsigned int& start, unsigned int& end) const {
00080                 start = current_start; end = current_end;
00081         }
00082 
00084         void setBlendColour(uint32 col) { blendColour = col; }
00085 
00087         int getVlead();
00088 
00089 protected:
00090         void renderText();
00091 
00092         Pentagram::Font* getFont() const;
00093 
00094 public:
00095         bool loadData(IDataSource* ids, uint32 version);
00096 
00097 protected:
00098         virtual void saveData(ODataSource* ods);
00099 };
00100 
00101 #endif

Generated on Fri Jul 27 22:27:42 2007 for pentagram by  doxygen 1.4.7