aboutsummaryrefslogtreecommitdiff
path: root/lib/gui/einputstring.cpp
diff options
context:
space:
mode:
authorFelix Domke <tmbinc@elitedvb.net>2005-05-20 19:34:06 +0000
committerFelix Domke <tmbinc@elitedvb.net>2005-05-20 19:34:06 +0000
commitee0a99a85f0e8c01e44422c4bc2c81fce7ee7e5e (patch)
tree7d0eb0aa15792879b269962f14e08c1a76a978fb /lib/gui/einputstring.cpp
parent34c3f1a742135c764ced560e8479e77129082301 (diff)
downloadenigma2-ee0a99a85f0e8c01e44422c4bc2c81fce7ee7e5e.tar.gz
enigma2-ee0a99a85f0e8c01e44422c4bc2c81fce7ee7e5e.zip
- split einput contents to own files
- add string input
Diffstat (limited to 'lib/gui/einputstring.cpp')
-rw-r--r--lib/gui/einputstring.cpp126
1 files changed, 126 insertions, 0 deletions
diff --git a/lib/gui/einputstring.cpp b/lib/gui/einputstring.cpp
new file mode 100644
index 00000000..9ead4fa9
--- /dev/null
+++ b/lib/gui/einputstring.cpp
@@ -0,0 +1,126 @@
+#include <lib/gui/einputstring.h>
+
+DEFINE_REF(eInputContentString);
+
+eInputContentString::eInputContentString()
+{
+ m_string = "bla";
+ m_cursor = 0;
+ m_input = 0;
+ m_len = m_string.size();
+}
+
+void eInputContentString::getDisplay(std::string &res, int &cursor)
+{
+ res = m_string;
+ cursor = m_cursor;
+}
+
+void eInputContentString::moveCursor(int dir)
+{
+ int old_cursor = m_cursor;
+
+ switch (dir)
+ {
+ case dirLeft:
+ --m_cursor;
+ break;
+ case dirRight:
+ ++m_cursor;
+ break;
+ case dirHome:
+ m_cursor = 0;
+ break;
+ case dirEnd:
+ m_cursor = m_len;
+ break;
+ }
+
+ if (m_cursor < 0)
+ m_cursor = 0;
+ if (m_cursor > m_len)
+ m_cursor = m_len;
+
+ if (m_cursor != old_cursor)
+ if (m_input)
+ m_input->invalidate();
+}
+
+int eInputContentString::haveKey(int code, int overwrite)
+{
+ int have_char = -1;
+
+ if (code >= 0x8020)
+ have_char = code &~ 0x8000;
+
+ if (have_char != -1)
+ {
+ if (overwrite && m_cursor < m_len)
+ m_string[m_cursor] = have_char;
+ else
+ {
+ m_string.insert(m_cursor, 1, have_char);
+ ++m_len;
+ }
+
+ m_cursor++;
+
+ assert(m_cursor <= m_len);
+
+ if (m_input)
+ m_input->invalidate();
+ return 1;
+ }
+ return 0;
+}
+
+void eInputContentString::deleteChar(int dir)
+{
+ if (dir == deleteForward)
+ {
+ eDebug("forward");
+ if (m_cursor != m_len)
+ ++m_cursor;
+ else
+ return;
+ }
+ /* backward delete at begin */
+ if (!m_cursor)
+ return;
+
+ if (!m_len)
+ return;
+
+ m_string.erase(m_cursor - 1, m_cursor);
+
+ m_len--;
+ m_cursor--;
+
+ if (m_input)
+ m_input->invalidate();
+}
+
+int eInputContentString::isValid()
+{
+ return 1;
+}
+
+void eInputContentString::validate()
+{
+}
+
+void eInputContentString::setText(const std::string &str)
+{
+ m_string = str;
+ m_len = m_string.size();
+ if (m_cursor > m_len)
+ m_cursor = m_len;
+
+ if (m_input)
+ m_input->invalidate();
+}
+
+std::string eInputContentString::getText()
+{
+ return m_string;
+}