#include <TextBox.h>
Inheritance diagram for pge::gui::TextBox:
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.
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 } |
|
Destructor.
Definition at line 29 of file TextBox.cpp.
00029 { 00030 } |
|
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 } |
|
Definition at line 53 of file TextBox.h. References m_lines.
00053 { 00054 return m_lines; 00055 } |
|
Definition at line 65 of file TextBox.h. References m_textColor.
00065 { 00066 return m_textColor; 00067 } |
|
Definition at line 57 of file TextBox.h. References m_textSize.
00057 { 00058 return m_textSize; 00059 } |
|
Implements pge::IRenderableObject. Definition at line 38 of file TextBox.cpp.
00038 { 00039 return true; 00040 } |
|
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:
|
Definition at line 73 of file TextBox.h. References m_backgroundEnabled. Referenced by pge::gui::Console::Console().
00073 { 00074 m_backgroundEnabled = background; 00075 } |
|
Definition at line 69 of file TextBox.h. References m_textColor.
00069 { 00070 m_textColor = color; 00071 } |
|
Definition at line 61 of file TextBox.h. References m_textSize.
00061 { 00062 m_textSize = size; 00063 } |
|
Called when the timer event comes.
Implements pge::IRenderableObject. Definition at line 89 of file TextBox.cpp.
00089 { 00090 } |
|
Definition at line 87 of file TextBox.h. Referenced by render(), setBackgroundEnabled(), and TextBox(). |
|
Definition at line 84 of file TextBox.h. Referenced by addLine(), getLines(), and render(). |
|
Definition at line 85 of file TextBox.h. Referenced by getTextColor(), setTextColor(), and TextBox(). |
|
Definition at line 86 of file TextBox.h. Referenced by getTextSize(), render(), setTextSize(), and TextBox(). |