Main Page | Namespace List | Class Hierarchy | Alphabetical List | Data Structures | File List | Namespace Members | Data Fields | Globals

pge::gui::TextBox Class Reference

#include <TextBox.h>

Inheritance diagram for pge::gui::TextBox:

Inheritance graph
[legend]
Collaboration diagram for pge::gui::TextBox:

Collaboration graph
[legend]

Public Member Functions

 TextBox (int x, int y, int width, int height)
 Constructor.

virtual ~TextBox (void)
 Destructor.

bool init (void)
void render (void)
 Called when the object should render itself.

void timer (unsigned int delay)
 Called when the timer event comes.

void addLine (const std::string &line)
std::vector< std::string > getLines (void)
int getTextSize (void)
void setTextSize (int size)
Vector3f getTextColor (void)
void setTextColor (const Vector3f &color)
void setBackgroundEnabled (bool background)

Private Attributes

std::vector< std::string > m_lines
Vector3f m_textColor
int m_textSize
bool m_backgroundEnabled

Constructor & Destructor Documentation

pge::gui::TextBox::TextBox int  x,
int  y,
int  width,
int  height
 

Constructor.

Definition at line 17 of file TextBox.cpp.

References m_backgroundEnabled, m_textColor, and m_textSize.

00017                                                                     : Component(x, y, width, height) {
00018                         m_textColor = Vector3f(1.0f, 1.0f, 1.0f);
00019                         m_textSize = 15;
00020                         m_backgroundEnabled = false;
00021                 }

pge::gui::TextBox::~TextBox void   )  [virtual]
 

Destructor.

Definition at line 29 of file TextBox.cpp.

00029                                       {
00030                 }


Member Function Documentation

void pge::gui::TextBox::addLine const std::string &  line  )  [inline]
 

Definition at line 49 of file TextBox.h.

References m_lines.

Referenced by pge::gui::Console::Console(), and pge::gui::Console::keyTypeCall().

00049                                                             {
00050                                 m_lines.push_back(line);
00051                         }

std::vector<std::string> pge::gui::TextBox::getLines void   )  [inline]
 

Definition at line 53 of file TextBox.h.

References m_lines.

00053                                                             {
00054                                 return m_lines;
00055                         }

Vector3f pge::gui::TextBox::getTextColor void   )  [inline]
 

Definition at line 65 of file TextBox.h.

References m_textColor.

00065                                                     {
00066                                 return m_textColor;
00067                         }

int pge::gui::TextBox::getTextSize void   )  [inline]
 

Definition at line 57 of file TextBox.h.

References m_textSize.

00057                                               {
00058                                 return m_textSize;
00059                         }

bool pge::gui::TextBox::init void   )  [virtual]
 

Implements pge::IRenderableObject.

Definition at line 38 of file TextBox.cpp.

00038                                        {
00039                         return true;
00040                 }

void pge::gui::TextBox::render void   )  [virtual]
 

Called when the object should render itself.

Reimplemented from pge::gui::Component.

Definition at line 48 of file TextBox.cpp.

References pge::gui::Component::getDimension(), pge::gui::Component::getPosition(), m_backgroundEnabled, m_lines, m_textSize, and pge::Vector2i::m_v.

Referenced by pge::gui::Console::render().

00048                                          {
00049                         int x;
00050                         int y;
00051                         int maxLines = getDimension().m_v[1] / m_textSize;
00052                         int i;
00053                         int j;
00054                         int lineNum = (int)m_lines.size();
00055                         int maxLineStorage = 100;
00056                         std::string line;
00057 
00058 
00059                         if(m_backgroundEnabled) {
00060                                 // Render background by super class
00061                                 Component::render();
00062                         }
00063 
00064                         x = getPosition().m_v[0];
00065                         y = getPosition().m_v[1];
00066 
00067                         if((i = lineNum - maxLines) < 0) {
00068                                 i = 0;
00069                         }
00070                         for(j = 0; i < lineNum; i++, j++) {
00071                                 line = m_lines.at(i);
00072                                 FontRenderer::getInstance()->renderString(line, m_textSize, x, y + (j * m_textSize));
00073                         }
00074 
00075                         if(lineNum > maxLineStorage) {
00076                                 for(i = 0; i < lineNum - maxLineStorage; i++) {
00077                                         // Always remove element at 0 (start).
00078                                         m_lines.erase(m_lines.begin());
00079                                 }
00080                         }
00081                 }

Here is the call graph for this function:

void pge::gui::TextBox::setBackgroundEnabled bool  background  )  [inline]
 

Definition at line 73 of file TextBox.h.

References m_backgroundEnabled.

Referenced by pge::gui::Console::Console().

00073                                                                    {
00074                                 m_backgroundEnabled = background;
00075                         }

void pge::gui::TextBox::setTextColor const Vector3f color  )  [inline]
 

Definition at line 69 of file TextBox.h.

References m_textColor.

00069                                                                  {
00070                                 m_textColor = color;
00071                         }

void pge::gui::TextBox::setTextSize int  size  )  [inline]
 

Definition at line 61 of file TextBox.h.

References m_textSize.

00061                                                    {
00062                                 m_textSize = size;
00063                         }

void pge::gui::TextBox::timer unsigned int  delay  )  [virtual]
 

Called when the timer event comes.

Implements pge::IRenderableObject.

Definition at line 89 of file TextBox.cpp.

00089                                                       {
00090                 }


Field Documentation

bool pge::gui::TextBox::m_backgroundEnabled [private]
 

Definition at line 87 of file TextBox.h.

Referenced by render(), setBackgroundEnabled(), and TextBox().

std::vector<std::string> pge::gui::TextBox::m_lines [private]
 

Definition at line 84 of file TextBox.h.

Referenced by addLine(), getLines(), and render().

Vector3f pge::gui::TextBox::m_textColor [private]
 

Definition at line 85 of file TextBox.h.

Referenced by getTextColor(), setTextColor(), and TextBox().

int pge::gui::TextBox::m_textSize [private]
 

Definition at line 86 of file TextBox.h.

Referenced by getTextSize(), render(), setTextSize(), and TextBox().


The documentation for this class was generated from the following files:
Generated on Mon Oct 16 12:09:59 2006 for Phobosengine by doxygen 1.3.4