void CGUIDialogKeyboardGeneric::UpdateLabel() // FIXME seems to be called twice for one USB SDL keyboard action/character { CGUILabelControl* pEdit = ((CGUILabelControl*)GetControl(CTL_LABEL_EDIT)); if (pEdit) { CStdStringW edit = m_strEdit; pEdit->SetHighlight(0, 0); pEdit->SetSelection(0, 0); if (m_hiddenInput) { // convert to *'s edit.clear(); if (m_lastRemoteClickTime + REMOTE_SMS_DELAY > CTimeUtils::GetFrameTime() && m_iCursorPos > 0) { // using the remove to input, so display the last key input edit.append(m_iCursorPos - 1, L'*'); edit.append(1, m_strEdit[m_iCursorPos - 1]); } else edit.append(m_strEdit.size(), L'*'); } else if (!m_strEditing.empty()) { edit.insert(m_iCursorPos, m_strEditing); pEdit->SetHighlight(m_iCursorPos, m_iCursorPos + m_strEditing.size()); if (m_iEditingLength > 0) pEdit->SetSelection(m_iCursorPos + m_iEditingOffset, m_iCursorPos + m_iEditingOffset + m_iEditingLength); } // convert back to utf8 CStdString utf8Edit; g_charsetConverter.wToUTF8(edit, utf8Edit); pEdit->SetLabel(utf8Edit); // Send off a search message unsigned int now = CTimeUtils::GetFrameTime(); // don't send until the REMOTE_SMS_DELAY has passed if (m_lastRemoteClickTime && m_lastRemoteClickTime + REMOTE_SMS_DELAY >= now) return; if (m_pCharCallback) { // do not send editing text comes from system input method if (!m_hiddenInput && !m_strEditing.empty()) g_charsetConverter.wToUTF8(m_strEdit, utf8Edit); m_pCharCallback(this, utf8Edit); } } }
static BOOL CALLBACK DSEnumCallback(LPGUID lpGuid, LPCTSTR lpcstrDescription, LPCTSTR lpcstrModule, LPVOID lpContext) { DSDevice dev; std::list<DSDevice> &enumerator = *static_cast<std::list<DSDevice>*>(lpContext); int bufSize = MultiByteToWideChar(CP_ACP, 0, lpcstrDescription, -1, NULL, 0); CStdStringW strW (L"", bufSize); if ( bufSize == 0 || MultiByteToWideChar(CP_ACP, 0, lpcstrDescription, -1, strW.GetBuf(bufSize), bufSize) != bufSize ) strW.clear(); strW.RelBuf(); dev.name = localWideToUtf(strW); dev.lpGuid = lpGuid; if (lpGuid) enumerator.push_back(dev); return TRUE; }
// BidiTransform is used to handle RTL text flipping in the string void CGUITextLayout::BidiTransform(vector<CGUIString> &lines, bool forceLTRReadingOrder) { for (unsigned int i=0; i<lines.size(); i++) { CGUIString &line = lines[i]; // reserve enough space in the flipped text vecText flippedText; flippedText.reserve(line.m_text.size()); character_t sectionStyle = 0xffff0000; // impossible to achieve CStdStringW sectionText; for (vecText::iterator it = line.m_text.begin(); it != line.m_text.end(); ++it) { character_t style = *it & 0xffff0000; if (style != sectionStyle) { if (!sectionText.IsEmpty()) { // style has changed, bidi flip text CStdStringW sectionFlipped = BidiFlip(sectionText, forceLTRReadingOrder); for (unsigned int j = 0; j < sectionFlipped.size(); j++) flippedText.push_back(sectionStyle | sectionFlipped[j]); } sectionStyle = style; sectionText.clear(); } sectionText.push_back( (wchar_t)(*it & 0xffff) ); } // handle the last section if (!sectionText.IsEmpty()) { CStdStringW sectionFlipped = BidiFlip(sectionText, forceLTRReadingOrder); for (unsigned int j = 0; j < sectionFlipped.size(); j++) flippedText.push_back(sectionStyle | sectionFlipped[j]); } // replace the original line with the proccessed one lines[i] = CGUIString(flippedText.begin(), flippedText.end(), line.m_carriageReturn); } }