Index: trunk/src/lib/graphics/text_engine/limited_width_text.cc
===================================================================
--- trunk/src/lib/graphics/text_engine/limited_width_text.cc	(revision 8619)
+++ trunk/src/lib/graphics/text_engine/limited_width_text.cc	(revision 8619)
@@ -0,0 +1,175 @@
+/*
+   orxonox - the future of 3D-vertical-scrollers
+
+   Copyright (C) 2004 orx
+
+   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, or (at your option)
+   any later version.
+
+   ### File Specific:
+   main-programmer: Benjamin Grauer
+   co-programmer: ...
+*/
+
+#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_GRAPHICS
+
+#include "limited_width_text.h"
+#include "font.h"
+
+/**
+ * @brief creates a new Text Element
+ * @param fontFile the Font to render this text in
+ * @param type The renderType to display this font in
+ */
+LimitedWidthText::LimitedWidthText(const std::string& fontFile, unsigned int textSize, float lineWidth, DotsPosition dotsPosition)
+    : Text(fontFile, textSize)
+{
+  this->setClassID(CL_LIMITED_WIDTH_TEXT, "LimitedWidthText");
+
+  this->_dotsPosition = End;
+  this->setLineWidth(lineWidth);
+}
+
+/**
+ * @brief sets the maximum Line width
+ * @param lineWidth the maximum lineWidth.
+ */
+void LimitedWidthText::setLineWidth(float lineWidth)
+{
+  this->_lineWidth = lineWidth;
+  this->setupTextWidth();
+}
+
+/**
+ * @brief sets the Dots Position
+ * @param dotsPosition the Position of the Dots
+ */
+void LimitedWidthText::setDotsPosition(DotsPosition dotsPosition)
+{
+  this->_dotsPosition = dotsPosition;
+  this->setupTextWidth();
+}
+
+
+/**
+ * @brief draws the Text
+ */
+void LimitedWidthText::draw() const
+{
+  if (unlikely(this->_dotedText.empty()))
+    return;
+  glPushMatrix();
+  glPushAttrib(GL_ENABLE_BIT);
+  // transform for alignment.
+  if (this->getAlignment() == TEXT_ALIGN_RIGHT)
+    glTranslatef(-this->getSizeX2D(), 0, 0);
+  else if (this->getAlignment() == TEXT_ALIGN_CENTER || this->getAlignment() == TEXT_ALIGN_SCREEN_CENTER)
+    glTranslatef(-this->getSizeX2D()/2, 0, 0);
+
+  // drawing this Text.
+  // setting the Blending effects
+  glColor4fv(&this->color()[0]);
+
+
+  glActiveTexture(GL_TEXTURE0);
+
+  glEnable(GL_BLEND);
+  glEnable(GL_TEXTURE_2D);
+  glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+  glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, GL_MODULATE );
+
+  glBindTexture(GL_TEXTURE_2D, this->font()->getTexture());
+  glTranslatef(getAbsCoor2D().x, getAbsCoor2D().y, 0);
+  glRotatef(this->getAbsDir2D(), 0, 0, 1);
+
+  Glyph* tmpGlyph;
+  float posX = 0.0f;
+  glBegin(GL_QUADS);
+  for (unsigned int i = 0; i < this->_dotedText.size(); i++)
+  {
+    if(likely((tmpGlyph = this->font()->getGlyphArray()[this->_dotedText[i]]) != NULL))
+    {
+      glTexCoord2f(tmpGlyph->texCoord[1], tmpGlyph->texCoord[2]);
+      glVertex2d(posX+tmpGlyph->maxX*this->size(), 0);
+
+      glTexCoord2f(tmpGlyph->texCoord[1], tmpGlyph->texCoord[3]);
+      glVertex2d(posX+tmpGlyph->maxX*this->size(), this->size());
+
+      glTexCoord2f(tmpGlyph->texCoord[0], tmpGlyph->texCoord[3]);
+      glVertex2d(posX+tmpGlyph->minX*this->size(), this->size());
+
+      glTexCoord2f(tmpGlyph->texCoord[0], tmpGlyph->texCoord[2]);
+      glVertex2d(posX+tmpGlyph->minX*this->size(), 0);
+
+      posX += tmpGlyph->advance * this->size();
+    }
+  }
+  glEnd();
+  glPopAttrib();
+  glPopMatrix();
+}
+
+
+/**
+ * @brief setting up the Text-Width if DYNAMIC
+ */
+void LimitedWidthText::setupTextWidth()
+{
+  float dotsSize = this->font()->getGlyphArray()[46]->advance * 3.0;
+
+  float width = 0.0f;
+  float maxWidth = this->_lineWidth / this->size();
+
+  this->_dotedText = this->text();
+
+  switch (this->_dotsPosition)
+  {
+    case End:
+      for (unsigned int i = 0; i < this->text().size(); i++)
+      {
+        if (width + dotsSize > maxWidth )
+        {
+          this->_dotedText = this->text().substr(0, i) + "...";
+          if (i > 0)
+            width -= this->font()->getGlyphArray()[this->text()[i-1]]->advance;
+          width += dotsSize;
+          break;
+        }
+        // Advance the Text.
+        if(this->font()->getGlyphArray()[this->text()[i]] != NULL)
+          width += this->font()->getGlyphArray()[this->text()[i]]->advance;
+      }
+      break;
+
+    case Begin:
+      int i = text().size() -1;
+      for (; i >= 0; --i)
+      {
+        if (width + dotsSize > maxWidth )
+        {
+          this->_dotedText = std::string("...") + this->text().substr(i);
+          if (i + 1 < (int)text().size() )
+            width -= this->font()->getGlyphArray()[this->text()[i+1]]->advance;
+          width += dotsSize;
+          break;
+        }
+        // Advance the Text.
+        if(this->font()->getGlyphArray()[this->text()[i]] != NULL)
+          width += this->font()->getGlyphArray()[this->text()[i]]->advance;
+      }
+      break;
+  }
+
+  printf("%f %s\n", width, _dotedText.c_str());
+  this->setSizeX2D(width * this->size());
+}
+
+/**
+ * @brief print out some nice debug output
+ */
+void LimitedWidthText::debug() const
+{
+  printf("Debug %s::%s \n", this->getClassName(), this->getName() );
+}
Index: trunk/src/lib/graphics/text_engine/limited_width_text.h
===================================================================
--- trunk/src/lib/graphics/text_engine/limited_width_text.h	(revision 8619)
+++ trunk/src/lib/graphics/text_engine/limited_width_text.h	(revision 8619)
@@ -0,0 +1,51 @@
+/*!
+ * @file limited_width_text.h
+ * @brief Definition of a text Class, that is able to render text.
+ */
+
+#ifndef _LIMITED_WIDTH_TEXT_H
+#define _LIMITED_WIDTH_TEXT_H
+
+#include "text.h"
+
+#include <vector>
+
+//! Represents one textElement.
+class LimitedWidthText : public Text
+{
+  public:
+    typedef enum {
+      Begin,
+      End,
+    } DotsPosition;
+
+
+  public:
+    LimitedWidthText(const std::string& fontFile = "", unsigned int fontSize = TEXT_DEFAULT_SIZE, float lineWidth = 100.0, DotsPosition dotsPosition = Begin);
+
+    // Setup:
+    void setLineWidth(float lineWidth);
+    void setDotsPosition(DotsPosition dotsPosition);
+
+    // Retrieve:
+    /** @returns the LineWidth (maximum distance from the left to the right */
+    inline float lineWidth() const { return this->_lineWidth; };
+    /** @returns the dots position. */
+    inline float dotsPosition() const { return this->_dotsPosition; };
+
+    virtual void draw() const;
+
+    void debug() const;
+
+  protected:
+    virtual void setupTextWidth();
+
+  private:
+    std::string                _dotedText;
+
+    DotsPosition               _dotsPosition;
+    float                      _lineWidth;
+    unsigned int               _lineEnds;
+};
+
+#endif /* _LIMITED_WIDTH_TEXT_H */
Index: trunk/src/lib/graphics/text_engine/multi_line_text.cc
===================================================================
--- trunk/src/lib/graphics/text_engine/multi_line_text.cc	(revision 8518)
+++ trunk/src/lib/graphics/text_engine/multi_line_text.cc	(revision 8619)
@@ -61,5 +61,5 @@
 void MultiLineText::draw() const
 {
-  if (unlikely(this->getText().empty()))
+  if (unlikely(this->text().empty()))
     return;
   glPushMatrix();
@@ -76,5 +76,5 @@
   glActiveTexture(GL_TEXTURE0);
 
-  glColor4fv(&this->getColor()[0]);
+  glColor4fv(&this->color()[0]);
   glEnable(GL_BLEND);
   glEnable(GL_TEXTURE_2D);
@@ -82,5 +82,5 @@
   glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, GL_MODULATE );
 
-  glBindTexture(GL_TEXTURE_2D, this->getFont()->getTexture());
+  glBindTexture(GL_TEXTURE_2D, this->font()->getTexture());
   glTranslatef(this->getAbsCoor2D().x, this->getAbsCoor2D().y, 0);
   glRotatef(this->getAbsDir2D(), 0, 0, 1);
@@ -92,5 +92,5 @@
 
   glBegin(GL_QUADS);
-  for (unsigned int i = 0; i < this->getText().size(); ++i)
+  for (unsigned int i = 0; i < this->text().size(); ++i)
   {
     if (unlikely(this->lineEnds.size() > lineNumber && i == this->lineEnds[lineNumber]))
@@ -99,22 +99,22 @@
       ++lineNumber;
       posX = 0.0f;
-      posY += this->lineSpacing + this->getSize(); //this->getFont()->getMaxHeight();
+      posY += this->lineSpacing + this->size(); //this->font()->getMaxHeight();
     }
 
-    if(likely((tmpGlyph = this->getFont()->getGlyphArray()[this->getText()[i]]) != NULL))
+    if(likely((tmpGlyph = this->font()->getGlyphArray()[this->text()[i]]) != NULL))
     {
       glTexCoord2f(tmpGlyph->texCoord[1], tmpGlyph->texCoord[2]);
-      glVertex2d(posX+tmpGlyph->maxX*this->getSize(), posY);
+      glVertex2d(posX+tmpGlyph->maxX*this->size(), posY);
 
       glTexCoord2f(tmpGlyph->texCoord[1], tmpGlyph->texCoord[3]);
-      glVertex2d(posX+tmpGlyph->maxX*this->getSize(), posY + this->getSize());
+      glVertex2d(posX+tmpGlyph->maxX*this->size(), posY + this->size());
 
       glTexCoord2f(tmpGlyph->texCoord[0], tmpGlyph->texCoord[3]);
-      glVertex2d(posX+tmpGlyph->minX*this->getSize(), posY+ this->getSize());
+      glVertex2d(posX+tmpGlyph->minX*this->size(), posY+ this->size());
 
       glTexCoord2f(tmpGlyph->texCoord[0], tmpGlyph->texCoord[2]);
-      glVertex2d(posX+tmpGlyph->minX*this->getSize(), posY);
+      glVertex2d(posX+tmpGlyph->minX*this->size(), posY);
 
-      posX += tmpGlyph->advance * this->getSize();
+      posX += tmpGlyph->advance * this->size();
     }
   }
@@ -132,14 +132,14 @@
   this->lineEnds.clear();
   float width = 0.0f;
-  float maxWidth = this->lineWidth / this->getSize();
+  float maxWidth = this->lineWidth / this->size();
 
-  for (unsigned int i = 0; i < this->getText().size(); i++)
+  for (unsigned int i = 0; i < this->text().size(); i++)
   {
-    if (width > maxWidth || this->getText()[i] == '\n')
+    if (width > maxWidth || this->text()[i] == '\n')
     {
       if (likely(i > 0))
       {
         this->lineEnds.push_back( i -1 );
-        width = this->getFont()->getGlyphArray()[this->getText()[i-1]]->advance;
+        width = this->font()->getGlyphArray()[this->text()[i-1]]->advance;
       }
       else
@@ -148,9 +148,9 @@
 
     // Advance the Text.
-    if(this->getFont()->getGlyphArray()[this->getText()[i]] != NULL)
-      width += this->getFont()->getGlyphArray()[this->getText()[i]]->advance;
+    if(this->font()->getGlyphArray()[this->text()[i]] != NULL)
+      width += this->font()->getGlyphArray()[this->text()[i]]->advance;
   }
   this->lineCount = lineEnds.size() + 1;
-  this->setSizeY2D((this->lineEnds.size()+1) * (this->lineSpacing + this->getFont()->getMaxHeight()));
+  this->setSizeY2D((this->lineEnds.size()+1) * (this->lineSpacing + this->font()->getMaxHeight()));
 }
 
@@ -162,5 +162,5 @@
  printf("Debug %s::%s: %d lines\n", this->getClassName(), this->getName(), this->getLineCount());
 
- std::string tmpText = this->getText();
+ std::string tmpText = this->text();
  std::vector<unsigned int> ends = this->lineEnds;
  ends.push_back(tmpText.size());
Index: trunk/src/lib/graphics/text_engine/text.cc
===================================================================
--- trunk/src/lib/graphics/text_engine/text.cc	(revision 8518)
+++ trunk/src/lib/graphics/text_engine/text.cc	(revision 8619)
@@ -22,6 +22,4 @@
 #include "debug.h"
 
-using namespace std;
-
 /**
  * @brief creates a new Text Element
@@ -34,8 +32,8 @@
 
   // initialize this Text
-  this->font = NULL;
-  this->size = textSize;
-  this->setSizeY2D(size);
-  this->color = TEXT_DEFAULT_COLOR;
+  this->_font = NULL;
+  this->_size = textSize;
+  this->setSizeY2D(textSize);
+  this->_color = TEXT_DEFAULT_COLOR;
 
   this->setAlignment(TEXT_DEFAULT_ALIGNMENT);
@@ -47,5 +45,5 @@
 {
   this->setClassID(CL_TEXT, "Text");
-  this->font = NULL;
+  this->_font = NULL;
 
   *this = text;
@@ -58,6 +56,6 @@
 Text::~Text()
 {
-  if (this->font != NULL && this->font != Font::getDefaultFont())
-    ResourceManager::getInstance()->unload(this->font);
+  if (this->_font != NULL && this->_font != Font::getDefaultFont())
+    ResourceManager::getInstance()->unload(this->_font);
 }
 
@@ -69,8 +67,8 @@
 bool Text::operator==(const Text& text) const
 {
-  return (this->text == text.text &&
-          this->size == text.size &&
-          this->font == text.font &&
-          this->color == text.color);
+  return (this->_text == text._text &&
+          this->_size == text._size &&
+          this->_font == text._font &&
+          this->_color == text._color);
 }
 
@@ -82,5 +80,5 @@
 bool Text::operator==(const std::string& text) const
 {
-  return (this->text == text);
+  return (this->_text == text);
 }
 
@@ -92,13 +90,13 @@
 Text& Text::operator=(const Text& text)
 {
-  this->size = text.size;
-  this->color = text.color;
+  this->_size = text._size;
+  this->_color = text._color;
   this->setAlignment(text.getAlignment());
-  if (this->font != NULL)
-    ResourceManager::getInstance()->unload(this->font);
-
-  this->font = (Font*)ResourceManager::getInstance()->copy( text.font ); //!< HACK
-
-  this->text = text.text;
+  if (this->_font != NULL)
+    ResourceManager::getInstance()->unload(this->_font);
+
+  this->_font = (Font*)ResourceManager::getInstance()->copy( text._font ); //!< HACK
+
+  this->_text = text._text;
   return *this;
 }
@@ -110,5 +108,5 @@
 void Text::setText(const std::string& text)
 {
-  this->text = text;
+  this->_text = text;
   this->setupTextWidth();
 }
@@ -120,5 +118,5 @@
 void Text::append(const std::string& appendText)
 {
-  this->text += appendText;
+  this->_text += appendText;
   this->setupTextWidth();
 }
@@ -129,5 +127,5 @@
 void Text::appendCharacter(char character)
 {
-  this->text += character;
+  this->_text += character;
   this->setupTextWidth();
 }
@@ -141,5 +139,5 @@
 {
   this->append(appendText);
-  return this->text;
+  return this->_text;
 }
 
@@ -152,8 +150,8 @@
 void Text::removeCharacters(unsigned int chars)
 {
-  if (text.size() > chars)
-    this->text.resize(this->text.size()-chars);
-  else if (!text.empty())
-    text.clear();
+  if (this->_text.size() > chars)
+    this->_text.resize(this->_text.size()-chars);
+  else if (!this->_text.empty())
+    this->_text.clear();
   this->setupTextWidth();
 }
@@ -165,5 +163,5 @@
 void Text::clear()
 {
-  text.clear();
+  this->_text.clear();
   this->setupTextWidth();
 }
@@ -177,5 +175,5 @@
 {
   Font* newFont = NULL;
-  Font* oldFont = this->font;
+  Font* oldFont = this->_font;
 
   // load a new Font
@@ -194,5 +192,5 @@
 
   // unloading the Font if we alrady have one loaded.
-  this->font = newFont;
+  this->_font = newFont;
   if (oldFont != NULL && oldFont != Font::getDefaultFont())
     ResourceManager::getInstance()->unload(oldFont);
@@ -207,5 +205,5 @@
 void Text::setSize(float size)
 {
-  this->size = size;
+  this->_size = size;
   this->setSizeY2D(size);
   this->setupTextWidth();
@@ -218,5 +216,5 @@
 void Text::draw() const
 {
-  if (unlikely(this->text.empty()))
+  if (unlikely(this->_text.empty()))
     return;
   glPushMatrix();
@@ -230,5 +228,5 @@
   // drawing this Text.
   // setting the Blending effects
-  glColor4fv(&this->color[0]);
+  glColor4fv(&this->_color[0]);
 
 
@@ -240,5 +238,5 @@
   glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, GL_MODULATE );
 
-  glBindTexture(GL_TEXTURE_2D, font->getTexture());
+  glBindTexture(GL_TEXTURE_2D, this->_font->getTexture());
   glTranslatef(getAbsCoor2D().x, getAbsCoor2D().y, 0);
   glRotatef(this->getAbsDir2D(), 0, 0, 1);
@@ -247,21 +245,21 @@
   float posX = 0.0f;
   glBegin(GL_QUADS);
-  for (unsigned int i = 0; i < this->text.size(); i++)
+  for (unsigned int i = 0; i < this->_text.size(); i++)
   {
-    if(likely((tmpGlyph = this->getFont()->getGlyphArray()[this->text[i]]) != NULL))
+    if(likely((tmpGlyph = this->font()->getGlyphArray()[this->_text[i]]) != NULL))
     {
       glTexCoord2f(tmpGlyph->texCoord[1], tmpGlyph->texCoord[2]);
-      glVertex2d(posX+tmpGlyph->maxX*this->getSize(), 0);
+      glVertex2d(posX+tmpGlyph->maxX*this->size(), 0);
 
       glTexCoord2f(tmpGlyph->texCoord[1], tmpGlyph->texCoord[3]);
-      glVertex2d(posX+tmpGlyph->maxX*this->getSize(), this->getSize());
+      glVertex2d(posX+tmpGlyph->maxX*this->size(), this->size());
 
       glTexCoord2f(tmpGlyph->texCoord[0], tmpGlyph->texCoord[3]);
-      glVertex2d(posX+tmpGlyph->minX*this->getSize(), this->getSize());
+      glVertex2d(posX+tmpGlyph->minX*this->size(), this->size());
 
       glTexCoord2f(tmpGlyph->texCoord[0], tmpGlyph->texCoord[2]);
-      glVertex2d(posX+tmpGlyph->minX*this->getSize(), 0);
-
-      posX += tmpGlyph->advance * this->getSize();
+      glVertex2d(posX+tmpGlyph->minX*this->size(), 0);
+
+      posX += tmpGlyph->advance * this->size();
     }
   }
@@ -278,8 +276,8 @@
 {
   float width = 0;
-  for (unsigned int i = 0; i < this->text.size(); i++)
-    if(this->font->getGlyphArray()[this->text[i]] != NULL)
-      width += this->font->getGlyphArray()[this->text[i]]->advance;
-  this->setSizeX2D(width * this->getSize());
+  for (unsigned int i = 0; i < this->_text.size(); i++)
+    if(this->_font->getGlyphArray()[this->_text[i]] != NULL)
+      width += this->_font->getGlyphArray()[this->_text[i]]->advance;
+  this->setSizeX2D(width * this->size());
 }
 
@@ -290,6 +288,6 @@
 void Text::debug() const
 {
-  PRINT(0)("=== TEXT: %s (with Font:'%s')  displaying %s ===\n", this->getName(), this->font->getName(), this->text.c_str());
-  PRINT(0)("Color: r=%0.2f g=%0.2f b=%0.2f a=%0.2f\n", this->color.r(), this->color.g(), this->color.b(), this->color.a());
-}
-
+  PRINT(0)("=== TEXT: %s (with Font:'%s')  displaying %s ===\n", this->getName(), this->_font->getName(), this->_text.c_str());
+  PRINT(0)("Color: r=%0.2f g=%0.2f b=%0.2f a=%0.2f\n", this->_color.r(), this->_color.g(), this->_color.b(), this->_color.a());
+}
+
Index: trunk/src/lib/graphics/text_engine/text.h
===================================================================
--- trunk/src/lib/graphics/text_engine/text.h	(revision 8518)
+++ trunk/src/lib/graphics/text_engine/text.h	(revision 8619)
@@ -45,9 +45,9 @@
     void setFont(const std::string& fontFile, unsigned int renderSize);
     /** @param blending the blending intensity to set (between 0.0 and 1.0) */
-    inline void setBlending(float blending) { this->color.a() = blending; };
+    inline void setBlending(float blending) { this->_color.a() = blending; };
     /** @param r red @param g green @param b blue @brief sets the Color of the Text to render (values in [0-1]) */
-    void setColor(float r, float g, float b) { this->color = Color(r, g, b, this->color.a()); };
-    void setColor(float r, float g, float b, float a) { this->color = Color(r, g, b, a); };
-    void setColor(const Color& color) { this->color = color; };
+    void setColor(float r, float g, float b) { this->_color = Color(r, g, b, this->_color.a()); };
+    void setColor(float r, float g, float b, float a) { this->_color = Color(r, g, b, a); };
+    void setColor(const Color& color) { this->_color = color; };
     void setSize(float size);
 
@@ -55,14 +55,14 @@
     /// RETRIEVE
     /** @returns the String this Text displays */
-    inline const std::string& getText() const { return this->text; };
+    inline const std::string& text() const { return this->_text; };
 
     /** @returns the pointer to the stored Font (not changeable) */
-    inline const Font* const getFont() const { return this->font; };
+    inline const Font* const font() const { return this->_font; };
     /** @returns the Blending Value [0 invisible 1.0 full visible */
-    inline float getBlending() const { return this->color.a(); };
+    inline float blending() const { return this->_color.a(); };
     /** @returns: a Vector(r,g,b) @brief: retrieve a Vector holding the Color of the Text */
-    inline const Color& getColor() const { return this->color; };
+    inline const Color& color() const { return this->_color; };
     /** @returns the Size of the Text */
-    inline float getSize() const { return this->size; };
+    inline float size() const { return this->_size; };
 
     virtual void draw() const;
@@ -76,9 +76,9 @@
 
   private:
-    Font*             font;           //!< Font of this text
+    Font*             _font;           //!< Font of this text
 
-    std::string       text;           //!< The text to display
-    Color             color;          //!< The color of the font.
-    float             size;           //!< The size of the Text.
+    std::string       _text;           //!< The text to display
+    Color             _color;          //!< The color of the font.
+    float             _size;           //!< The size of the Text.
 };
 
