Merge pull request #4687 from ruuk/textboxgettext
authorjmarshallnz <jcmarsha@gmail.com>
Mon, 9 Jun 2014 19:46:12 +0000 (07:46 +1200)
committerJonathan Marshall <jmarshall@xbmc.org>
Sun, 15 Jun 2014 04:25:14 +0000 (16:25 +1200)
Add ability to get text from ControlTextBox via python and infolabels

xbmc/guilib/GUITextBox.cpp
xbmc/guilib/GUITextBox.h
xbmc/guilib/GUITextLayout.cpp
xbmc/guilib/GUITextLayout.h
xbmc/interfaces/legacy/Control.cpp
xbmc/interfaces/legacy/Control.h

index 31a3c44..7415bdc 100644 (file)
@@ -387,6 +387,11 @@ CStdString CGUITextBox::GetLabel(int info) const
   return label;
 }
 
+CStdString CGUITextBox::GetDescription() const
+{
+  return GetText();
+}
+
 void CGUITextBox::UpdateVisibility(const CGUIListItem *item)
 {
   // we have to update the page control when we become visible
index 7e683ec..995ed9e 100644 (file)
@@ -62,6 +62,7 @@ public:
   void SetAutoScrolling(const TiXmlNode *node);
   void ResetAutoScrolling();
   CStdString GetLabel(int info) const;
+  CStdString GetDescription() const;
 
   void Scroll(unsigned int offset);
 
index 4782aa0..ed179b3 100644 (file)
@@ -630,6 +630,17 @@ float CGUITextLayout::GetTextWidth(const CStdStringW &text) const
   return m_font->GetTextWidth(utf32);
 }
 
+std::string CGUITextLayout::GetText() const
+{
+  if (m_lastUpdateW)
+  {
+    std::string utf8;
+    g_charsetConverter.wToUTF8(m_lastText, utf8);
+    return utf8;
+  }
+  return m_lastUtf8Text;
+}
+
 void CGUITextLayout::DrawText(CGUIFont *font, float x, float y, color_t color, color_t shadowColor, const CStdString &text, uint32_t align)
 {
   if (!font) return;
index a855663..46975da 100644 (file)
@@ -117,7 +117,12 @@ protected:
   static CStdStringW BidiFlip(const CStdStringW &text, bool forceLTRReadingOrder);
   void CalcTextExtent();
   void UpdateCommon(const CStdStringW &text, float maxWidth, bool forceLTRReadingOrder);
-
+  
+  /*! \brief Returns the text, utf8 encoded
+   \return utf8 text
+   */
+  std::string GetText() const;
+  
   // our text to render
   vecColors m_colors;
   std::vector<CGUIString> m_lines;
index ae9831e..821144f 100644 (file)
@@ -141,6 +141,14 @@ namespace XBMCAddon
       g_windowManager.SendThreadMessage(msg, iParentId);
     }
 
+    String ControlTextBox::getText() throw (UnimplementedException)
+    {
+      if (!pGUIControl) return NULL;
+
+      LOCKGUI;
+      return ((CGUITextBox*) pGUIControl)->GetDescription();
+    }
+
     void ControlTextBox::reset() throw(UnimplementedException)
     {
       // create message
index 55a4d4b..68411ec 100644 (file)
@@ -891,6 +891,15 @@ namespace XBMCAddon
        */
       virtual void setText(const String& text) throw(UnimplementedException);
 
+      // getText() Method
+      /**
+       * getText() -- Returns the text value for this textbox.
+       *
+       * example:
+       *   - text = self.text.getText()
+       */
+      virtual String getText() throw(UnimplementedException);
+
       // reset() Method
       /**
        * reset() -- Clear's this textbox.