From 1029ed189dd88c3dc8c4a3b31197d472ecf9e363 Mon Sep 17 00:00:00 2001 From: Shamus Hammons Date: Wed, 24 Aug 2005 14:35:53 +0000 Subject: [PATCH] Preliminary text editing widget --- src/gui.cpp | 35 +++++++++++++++++++++++++++-------- 1 file changed, 27 insertions(+), 8 deletions(-) diff --git a/src/gui.cpp b/src/gui.cpp index 28b626f..38fc128 100644 --- a/src/gui.cpp +++ b/src/gui.cpp @@ -36,7 +36,9 @@ class Window; // Forward declaration... void DrawTransparentBitmapDeprecated(uint32 * screen, uint32 x, uint32 y, uint32 * bitmap); void DrawTransparentBitmap(uint32 * screen, uint32 x, uint32 y, const void * bitmap); void DrawBitmap(uint32 * screen, uint32 x, uint32 y, const void * bitmap); -void ClearScreenRectangle(uint32 * screen, uint32 x, uint32 y, uint32 w, uint32 h); +//Should call this FillScreenRectangle with a number representing the RGBA value to fill. !!! FIX !!! +//void ClearScreenRectangle(uint32 * screen, uint32 x, uint32 y, uint32 w, uint32 h); +void FillScreenRectangle(uint32 * screen, uint32 x, uint32 y, uint32 w, uint32 h, uint32 color); void DrawStringTrans(uint32 * screen, uint32 x, uint32 y, uint32 color, uint8 opacity, const char * text, ...); void DrawStringOpaque(uint32 * screen, uint32 x, uint32 y, uint32 color1, uint32 color2, const char * text, ...); void DrawString(uint32 * screen, uint32 x, uint32 y, bool invert, const char * text, ...); @@ -593,9 +595,11 @@ class TextEdit: public Element { public: TextEdit(uint32 x = 0, uint32 y = 0, uint32 w = 0, uint32 h = 0): Element(x, y, w, h), - fgColor(0xFF8484FF), bgColor(0xFF84FF4D), text(""), caretPos(0) {} - TextEdit(uint32 x, uint32 y, string s, uint32 fg = 0xFF8484FF, uint32 bg = 0xFF84FF4D): - Element(x, y, 0, 0), fgColor(fg), bgColor(bg), text(s), caretPos(0) {} + fgColor(0xFF8484FF), bgColor(0xFF84FF4D), text(""), caretPos(0), + maxScreenSize(10) {} + TextEdit(uint32 x, uint32 y, string s, uint32 mss = 10, uint32 fg = 0xFF8484FF, + uint32 bg = 0xFF84FF4D): Element(x, y, 0, 0), fgColor(fg), bgColor(bg), text(s), + caretPos(0), maxScreenSize(mss) {} virtual void HandleKey(SDLKey key); virtual void HandleMouseMove(uint32 x, uint32 y) {} virtual void HandleMouseButton(uint32 x, uint32 y, bool mouseDown) {} @@ -606,6 +610,7 @@ class TextEdit: public Element uint32 fgColor, bgColor; string text; uint32 caretPos; + uint32 maxScreenSize; }; //Set different filters depending on type passed in on construction, e.g., filename, amount, etc...? @@ -616,9 +621,11 @@ void TextEdit::HandleKey(SDLKey key) { //Need to handle shift key as well... text[caretPos++] = key; + Draw(); } else if (key == SDLK_BACKSPACE) { + } else if (key == SDLK_DELETE) { @@ -629,8 +636,13 @@ void TextEdit::HandleKey(SDLKey key) void TextEdit::Draw(uint32 offsetX/*= 0*/, uint32 offsetY/*= 0*/) { if (text.length() > 0) + { + FillScreenRectangle(screenBuffer, extents.x + offsetX, extents.y + offsetY, FONT_WIDTH * maxScreenSize, FONT_HEIGHT, bgColor); // DrawString(screenBuffer, extents.x + offsetX, extents.y + offsetY, false, "%s", text.c_str()); DrawStringOpaque(screenBuffer, extents.x + offsetX, extents.y + offsetY, fgColor, bgColor, "%s", text.c_str()); + } + + // Draw the caret (underscore? or vertical line?) } @@ -1585,16 +1597,17 @@ void DrawBitmap(uint32 * screen, uint32 x, uint32 y, const void * bitmap) } // -// Clear a portion of the screen +// Fill a portion of the screen with the passed in color // -void ClearScreenRectangle(uint32 * screen, uint32 x, uint32 y, uint32 w, uint32 h) +void FillScreenRectangle(uint32 * screen, uint32 x, uint32 y, uint32 w, uint32 h, uint32 color) +//void ClearScreenRectangle(uint32 * screen, uint32 x, uint32 y, uint32 w, uint32 h) { uint32 pitch = sdlemuGetOverlayWidthInPixels(); uint32 address = x + (y * pitch); for(uint32 yy=0; yyAddElement(new SlideSwitch(8, 120, (bool *)&vjs.glFilter, "Sharp", "Blurry")); window->AddElement(new SlideSwitch(8, 152, (bool *)&vjs.renderType, "Normal render", "TV style")); + window->AddElement(new TextEdit(88, 8, vjs.ROMPath, 20, 0xFF8484FF, 0xFF000000)); + +/*TextEdit(uint32 x, uint32 y, string s, uint32 mss = 10, uint32 fg = 0xFF8484FF, + uint32 bg = 0xFF84FF4D): Element(x, y, 0, 0), fgColor(fg), bgColor(bg), text(s), + caretPos(0), maxScreenSize(mss) {}*/ // Missing: // * BIOS path // * ROM path -- 2.37.2