void UITextInput::checkBufferLines() { if(neededBufferLines < currentBufferLines) return; int aaMode = Label::ANTIALIAS_FULL; if(useStrongHinting) { aaMode = Label::ANTIALIAS_STRONG; } for(int i=0; i < neededBufferLines - currentBufferLines; i++) { if(multiLine) { ScreenLabel *newNumberLine = new ScreenLabel(L"", fontSize, fontName, aaMode); newNumberLine->color = lineNumberColor; lineNumberAnchor->addChild(newNumberLine); numberLines.push_back(newNumberLine); if(!lineNumbersEnabled) { newNumberLine->visible = false; } } ScreenLabel *newLine = new ScreenLabel(L"", fontSize, fontName, aaMode); newLine->color = textColor; lineHeight = newLine->getHeight(); linesContainer->addChild(newLine); bufferLines.push_back(newLine); } currentBufferLines = neededBufferLines; }
int UITextInput::insertLine(bool after) { numLines++; int aaMode = Label::ANTIALIAS_FULL; if(useStrongHinting) { aaMode = Label::ANTIALIAS_STRONG; } if(multiLine) { ScreenLabel *newNumberLine = new ScreenLabel(L"", fontSize, fontName, aaMode); newNumberLine->color = lineNumberColor; lineNumberAnchor->addChild(newNumberLine); numberLines.push_back(newNumberLine); if(!lineNumbersEnabled) { newNumberLine->visible = false; } } ScreenLabel *newLine = new ScreenLabel(L"", fontSize, fontName, aaMode); newLine->color = textColor; lineHeight = newLine->getHeight(); linesContainer->addChild(newLine); if(after) { if(currentLine) { String ctext = currentLine->getText(); String text2 = ctext.substr(caretPosition, ctext.length()-caretPosition); ctext = ctext.substr(0,caretPosition); currentLine->setText(ctext); newLine->setText(text2); caretPosition=0; } currentLine = newLine; vector<ScreenLabel*>::iterator it; it = lines.begin(); for(int i=0; i < lineOffset+1; i++) { it++; } lineOffset = lineOffset + 1; lines.insert(it,newLine); renumberLines(); restructLines(); } else { // do we even need that? I don't think so. } changedText(); return 1; }
int UITextInput::insertLine(bool after) { numLines++; ScreenLabel *newLine = new ScreenLabel(L"", fontSize, fontName, Label::ANTIALIAS_FULL); newLine->setColor(0,0,0,1); lineHeight = newLine->getHeight(); addChild(newLine); if(after) { if(currentLine) { String ctext = currentLine->getText(); String text2 = ctext.substr(caretPosition, ctext.length()-caretPosition); ctext = ctext.substr(0,caretPosition); currentLine->setText(ctext); newLine->setText(text2); caretPosition=0; } currentLine = newLine; vector<ScreenLabel*>::iterator it; it = lines.begin(); for(int i=0; i < lineOffset+1; i++) { it++; } lineOffset = lineOffset + 1; lines.insert(it,newLine); restructLines(); } else { // do we even need that? I don't think so. } dispatchEvent(new UIEvent(), UIEvent::CHANGE_EVENT); return 1; }