src/graphic/text_list.cpp

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  * List of Text Clases. 
00020  * TextBox is not valid while playing game
00021  * nefertum - Jon de Andres
00022  *****************************************************************************/
00023 
00024 #include "text_list.h"
00025 
00026 
00027 TextList::TextList()
00028 {}
00029 
00030 TextList::~TextList()
00031 {
00032   list.clear();
00033 }
00034 
00035 void TextList::AddText(const std::string &txt, uint maxlines){
00036   Text* new_txt = new Text(txt);
00037   list.push_back(new_txt);
00038   
00039   if(list.size() >= maxlines)
00040     list.pop_front();
00041 }
00042 
00043 int TextList::Size(){
00044   return list.size();
00045 }
00046 
00047 void TextList::DeleteLine(){
00048   if(list.size())
00049     list.pop_front();
00050 }
00051 
00052 void TextList::Clear(){
00053   list.clear();
00054 }
00055 
00056 void TextList::Draw(int x, int y, int height){
00057   iterator it = list.begin(), end = list.end();
00058 
00059   for(; it!=end; it++){
00060     //Draw each item in the list
00061     (*it)->DrawTopLeft(x, y);
00062     y+=height;
00063   }
00064 }
00065 
00066 void TextList::DrawLine(Text* newline, int x, int y, int height){
00067   int size = list.size();
00068 
00069   y += (size * height);
00070   newline->DrawTopLeft(x, y);
00071 }

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