00001
00002
00003 #include "TextBox.h"
00004
00005 #include "FontRenderer.h"
00006
00007
00008 namespace pge {
00009 namespace gui {
00010
00011
00012
00013
00014
00015
00016
00017 TextBox::TextBox(int x, int y, int width, int height) : Component(x, y, width, height) {
00018 m_textColor = Vector3f(1.0f, 1.0f, 1.0f);
00019 m_textSize = 15;
00020 m_backgroundEnabled = false;
00021 }
00022
00023
00024
00025
00026
00027
00028
00029 TextBox::~TextBox(void) {
00030 }
00031
00032
00033
00034
00035
00036
00037
00038 bool TextBox::init(void) {
00039 return true;
00040 }
00041
00042
00043
00044
00045
00046
00047
00048 void TextBox::render(void) {
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
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
00078 m_lines.erase(m_lines.begin());
00079 }
00080 }
00081 }
00082
00083
00084
00085
00086
00087
00088
00089 void TextBox::timer(unsigned int delay) {
00090 }
00091 };
00092 };