11 TextEdit::TextEdit(uint32 x/*= 0*/, uint32 y/*= 0*/, uint32 w/*= 0*/, uint32 h/*= 0*/):
12 Element(x, y, w, h), fgColor(0xFF8484FF), bgColor(0xFF84FF4D), text(""),
13 caretPos(0), maxScreenSize(10)
17 TextEdit::TextEdit(uint32 x, uint32 y, std::string s, uint32 mss/*= 10*/, uint32 fg/*= 0xFF8484FF*/, uint32 bg/*= 0xFF84FF4D*/):
18 Element(x, y, 0, 0), fgColor(fg), bgColor(bg), text(s), caretPos(0), maxScreenSize(mss)
22 //Set different filters depending on type passed in on construction, e.g., filename, amount, etc...?
23 void TextEdit::HandleKey(SDLKey key)
25 if ((key >= SDLK_a && key <= SDLK_z) || (key >= SDLK_0 && key <= SDLK_9) || key == SDLK_PERIOD
28 //Need to handle shift key as well...
29 text[caretPos++] = key;
32 else if (key == SDLK_BACKSPACE)
36 else if (key == SDLK_DELETE)
42 void TextEdit::Draw(uint32 offsetX/*= 0*/, uint32 offsetY/*= 0*/)
44 if (text.length() > 0)
46 FillScreenRectangle(screenBuffer, extents.x + offsetX, extents.y + offsetY, FONT_WIDTH * maxScreenSize, FONT_HEIGHT, bgColor);
47 // DrawString(screenBuffer, extents.x + offsetX, extents.y + offsetY, false, "%s", text.c_str());
48 DrawStringOpaque(screenBuffer, extents.x + offsetX, extents.y + offsetY, fgColor, bgColor, "%s", text.c_str());
51 // Draw the caret (underscore? or vertical line?)