From ea76b6988ccafaa6a4d4ed90f2489d0e49e1f180 Mon Sep 17 00:00:00 2001 From: Benjamin Barenblat Date: Sat, 5 Sep 2015 09:32:30 -0400 Subject: Imported Upstream version 0.40.24 --- g_src/ViewBase.cpp | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100755 g_src/ViewBase.cpp (limited to 'g_src/ViewBase.cpp') diff --git a/g_src/ViewBase.cpp b/g_src/ViewBase.cpp new file mode 100755 index 0000000..6063732 --- /dev/null +++ b/g_src/ViewBase.cpp @@ -0,0 +1,38 @@ +#include +#include +#include "ViewBase.h" + +using namespace std; +using namespace widgets; + +void textbox::feed(set &input) { + // Backspace + if (input.count(INTERFACEKEY_STRING_A000) && text.size()) + text.resize(text.size() - 1); + // Hopefully we'll never get multiple characters in one input set, + // but it's possible. We deal with this by inserting them in + // alphabetical order. + for (set::iterator it = input.lower_bound(INTERFACEKEY_STRING_A001); + it != input.end() && *it <= INTERFACEKEY_STRING_A255; + ++it) { + if (keep == false) { + keep = true; + text.clear(); + } + char c = *it - INTERFACEKEY_STRING_A000; + text += c; + } +} + +void textbox::render(int x1, int x2, int y1, int y2) { + // We need to do some kind of line-breaking for multi-line text + // entry boxes. This shall be implemented at need, and there is none + // yet. + assert(y1 == y2); + gps.erasescreen_rect(x1,x2,y1,y2); + gps.locate(y1,x1); + gps.changecolor(7,0,keep); + int width = x2 - x1 + 1; + int start = text.length() - width; + gps.addst(text.substr(MAX(start,0))); +} -- cgit v1.2.3