void TextField::addToNextCharacter( int unichar ) { if(getTextLength() + 1 > getMaxLength()) { return; } char buffer[8]; for(int i = 0; i < 8; ++i) { buffer[i] = 0; } unicodeFunctions.encodeUtf8(buffer,unichar); std::string appendStr = buffer; std::string text; if(!isPassword()) text = getText(); else text = getPassword(); unicodeFunctions.insert(text,getCaretPosition(),buffer); setThisText(text); positionCaret(getCaretPosition() + 1); }
bool OTPassword::addChar(uint8_t theChar) { OT_ASSERT(isPassword()); if (getPasswordSize() < getBlockSize()) { data_[size_] = theChar; ++size_; data_[size_] = '\0'; return true; } return false; }
bool OTPassword::addChar(uint8_t theChar) { OT_ASSERT(isPassword()); if (getPasswordSize() < getBlockSize()) { m_szPassword[m_nPasswordSize] = theChar; ++m_nPasswordSize; m_szPassword[m_nPasswordSize] = '\0'; return true; } return false; }
void TextField::setText( const std::string &text ) { //truncate string if it is too long if(isPassword()) { int len = int(unicodeFunctions.length(text)); int subLen = len; if( len > getMaxLength()) { subLen = maxLength; } passText = ""; for(int i = 0; i < subLen ; ++i) { passText += passwordChar; } if(getMaxLength() < len) { passwordText = unicodeFunctions.subStr(text,0,getMaxLength()); } else { passwordText = text; } Widget::setText(passText); } else { if(getMaxLength() < (int) unicodeFunctions.length(text)) { Widget::setText(unicodeFunctions.subStr(text,0,getMaxLength())); } else { Widget::setText(text); } } if(!selfSetText) { positionCaret(getTextLength()); } setSelection(0,0); }
void AP_UnixDialog_GenericInput::_populateWindowData() { // set the focus on the text input // TODO: implement me // set the password style input if requested gtk_entry_set_visibility(GTK_ENTRY(m_wInput), !isPassword()); // set the initial input gtk_entry_set_text(GTK_ENTRY(m_wInput), getInput().utf8_str()); // force the initial sensitivy state of the buttons eventTextChanged(); }
bool OTPassword::Compare(OTPassword& rhs) const { OT_ASSERT(isPassword() || isMemory()); OT_ASSERT(rhs.isPassword() || rhs.isMemory()); if (isPassword() && !rhs.isPassword()) return false; if (isMemory() && !rhs.isMemory()) return false; const uint32_t nThisSize = isPassword() ? getPasswordSize() : getMemorySize(); const uint32_t nRhsSize = rhs.isPassword() ? rhs.getPasswordSize() : rhs.getMemorySize(); if (nThisSize != nRhsSize) return false; if (0 == memcmp(isPassword() ? getPassword_uint8() : getMemory_uint8(), rhs.isPassword() ? rhs.getPassword_uint8() : rhs.getMemory_uint8(), rhs.isPassword() ? rhs.getPasswordSize() : rhs.getMemorySize())) return true; return false; }
void TextField::setPasswordCharacter( int unichar ) { char buffer[8]; for(int i = 0; i < 8; ++i) { buffer[i] = 0; } unicodeFunctions.encodeUtf8(buffer,unichar); passwordChar = buffer; if(isPassword()) setThisText(getPassword()); else setThisText(getText()); }
void TextField::removeNextCharacter() { //don't try to remove past the end if(getCaretPosition() + 1 > getTextLength()) { return; } std::string text; if(!isPassword()) text = getText(); else text = getPassword(); unicodeFunctions.erase(text,getCaretPosition(),1); setThisText(text); positionCaret(getCaretPosition()); }
void TextField::removeLastCharacter() { //don't try to remove past the beginning if(getCaretPosition() - 1 < 0) { return; } std::string text; if(!isPassword()) text = getText(); else text = getPassword(); unicodeFunctions.erase(text,getCaretPosition() - 1,1); setThisText(text); positionCaret(getCaretPosition() - 1,false); }
BOOL AP_Win32Dialog_GenericInput::_onInitDialog(HWND hWnd, WPARAM wParam, LPARAM lParam) { m_hOk = GetDlgItem(hWnd, AP_RID_DIALOG_GENERICINPUT_OK_BUTTON); UT_return_val_if_fail(m_hOk, false); m_hWnd = hWnd; // Get ourselves a custom DialogHelper DELETEP(m_pWin32Dialog); m_pWin32Dialog = new XAP_Win32DialogHelper(hWnd); // Center Window m_pWin32Dialog->centerDialog(); // set the dialog title m_pWin32Dialog->setDialogTitle(getTitle().utf8_str()); // set the question SetDlgItemTextA(hWnd, AP_RID_DIALOG_GENERICINPUT_QUESTION, getQuestion().utf8_str()); SetDlgItemTextA(hWnd, AP_RID_DIALOG_GENERICINPUT_LABEL, getLabel().utf8_str()); // set the password char for the password field if (isPassword()) { HWND hPasswordEntry = GetDlgItem(hWnd, AP_RID_DIALOG_GENERICINPUT_PASSWORD_EDIT); UT_return_val_if_fail(hPasswordEntry != NULL, false) SendMessage(hPasswordEntry, EM_SETPASSWORDCHAR, '*', 0); } // set the initial input SetDlgItemTextA(hWnd, AP_RID_DIALOG_GENERICINPUT_PASSWORD_EDIT, getInput().utf8_str()); // force the initial sensitivy state of the buttons _eventTextChanged(); return true; }
void TextBoxWidget::updateCursorPosition() { cursorVisualPosition = isPassword() ? glutBitmapWidth(getFont(), '*') * cursorPosition : glutBitmapLength(getFont(), (const unsigned char *) getText().substr(0, cursorPosition).c_str()); }