CGUIEditControl::CGUIEditControl(int parentID, int controlID, float posX, float posY, float width, float height, const CTextureInfo &textureFocus, const CTextureInfo &textureNoFocus, const CLabelInfo& labelInfo, const std::string &text, const CLabelInfo& emptylabelInfo, const std::string &emptyText, int maxTextSize) : CGUIButtonControl(parentID, controlID, posX, posY, width, height, textureFocus, textureNoFocus, labelInfo), m_emptyLayout(emptylabelInfo.font, false) { ControlType = GUICONTROL_EDIT; m_textOffset = 0; m_textWidth = width; m_cursorPos = 0; m_cursorBlink = 0; m_inputHeading = 0; m_inputType = INPUT_TYPE_TEXT; m_smsLastKey = 0; m_smsKeyIndex = 0; m_highlighted = false; m_emptyLabelInfo = emptylabelInfo; CGUIInfoLabel info; info.SetLabel(emptyText,""); CStdStringW emptyTextW; g_charsetConverter.utf8ToW(info.GetLabel(GetParentID(), false), emptyTextW, false); m_emptyLayout.SetText(emptyTextW); m_maxTextSize = maxTextSize; std::string allowedText = GetAllowedText(text); SetLabel(allowedText); m_addToText2Counter = -1; }
bool CGUIControlFactory::GetInfoLabelFromElement(const TiXmlElement *element, CGUIInfoLabel &infoLabel, int parentID) { if (!element || !element->FirstChild()) return false; CStdString label = element->FirstChild()->Value(); if (label.IsEmpty() || label == "-") return false; CStdString fallback = element->Attribute("fallback"); if (StringUtils::IsNaturalNumber(label)) label = g_localizeStrings.Get(atoi(label)); else // we assume the skin xml's aren't encoded as UTF-8 g_charsetConverter.unknownToUTF8(label); if (StringUtils::IsNaturalNumber(fallback)) fallback = g_localizeStrings.Get(atoi(fallback)); else g_charsetConverter.unknownToUTF8(fallback); infoLabel.SetLabel(label, fallback, parentID); return true; }