src/graphic/text.h

Go to the documentation of this file.
00001 /******************************************************************************
00002  *  Wormux is a convivial mass murder game.
00003  *  Copyright (C) 2001-2004 Lawrence Azzoug.
00004  *
00005  *  This program is free software; you can redistribute it and/or modify
00006  *  it under the terms of the GNU General Public License as published by
00007  *  the Free Software Foundation; either version 2 of the License, or
00008  *  (at your option) any later version.
00009  *
00010  *  This program is distributed in the hope that it will be useful,
00011  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  *  GNU General Public License for more details.
00014  *
00015  *  You should have received a copy of the GNU General Public License
00016  *  along with this program; if not, write to the Free Software
00017  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
00018  ******************************************************************************/
00019 
00020 #ifndef TEXT_H
00021 #define TEXT_H
00022 
00023 #include <string>
00024 #include "colors.h"
00025 #include "font.h"
00026 #include "surface.h"
00027 
00028 class Text
00029 {
00030   Surface surf;
00031   Surface background; //shadow or outline or nothing;
00032   std::string txt;
00033   Font* font;
00034   Color color;
00035   bool shadowed;
00036   uint bg_offset;
00037   uint max_width;
00038 
00039   void Render();
00040   void RenderMultiLines();
00041 public:
00042   Text(const std::string &new_txt, Color new_color = white_color, 
00043        Font* new_font = NULL, bool shadowed = true);
00044   ~Text();
00045 
00046   //Draw method using windows coordinates
00047   void DrawCenter(int x, int y) const;
00048   void DrawCenter(const Point2i &position) const;
00049   void DrawTopLeft(int x, int y) const;
00050   void DrawTopLeft(const Point2i &position) const;
00051   void DrawTopRight(int x, int y) const;
00052   void DrawCenterTop(int x, int y) const;
00053 
00054   //Draw method using map coordinates
00055   void DrawCenterOnMap(int x, int y) const;
00056   void DrawTopLeftOnMap(int x, int y) const;
00057   void DrawCenterTopOnMap(int x, int y) const;
00058 
00059   void Set(const std::string &new_txt);
00060   const std::string& GetText() const;
00061   void SetColor( const Color &new_color);
00062   void SetMaxWidth(uint max_w);
00063   int GetWidth() const;
00064   int GetHeight() const;
00065 };
00066 
00067 void DrawTmpBoxText(Font &font, 
00068                     Point2i pos,
00069                     const std::string &txt, uint space=3,
00070                     Color boxColor = defaultColorBox,
00071                     Color rectColor = defaultColorRect);
00072 
00073 void DrawTmpBoxTextWithReturns(Font &font,
00074                                const Point2i &position,
00075                                const std::string &txt, uint space=3,
00076                                Color boxColor = defaultColorBox,
00077                                Color rectColor = defaultColorRect);
00078 
00079 
00080 #endif

Generated on Mon Jan 1 13:10:56 2007 for Wormux by  doxygen 1.4.7