本文整理汇总了C++中PlainDocumentLeafElementRefPtr::getTextLength方法的典型用法代码示例。如果您正苦于以下问题:C++ PlainDocumentLeafElementRefPtr::getTextLength方法的具体用法?C++ PlainDocumentLeafElementRefPtr::getTextLength怎么用?C++ PlainDocumentLeafElementRefPtr::getTextLength使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PlainDocumentLeafElementRefPtr
的用法示例。
在下文中一共展示了PlainDocumentLeafElementRefPtr::getTextLength方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: moveCaretEnd
void FixedHeightLayoutManager::moveCaretEnd(bool isControlPressed)
{
PlainDocumentLeafElementRefPtr theElement;
if(isControlPressed)
{
_CaretLine = rootElement->getElementCount()-1;
theElement = dynamic_cast<PlainDocumentLeafElement*>(rootElement->getElement(_CaretLine));
_CaretIndex = theElement->getTextLength()-2;
getParentTextDomArea()->setCaretPosition(getParentTextDomArea()->getDocumentModel()->getEndPosition()-2);
recalculateCaretPositions();
}
else
{
UInt32 prevIndex = _CaretIndex;
theElement = dynamic_cast<PlainDocumentLeafElement*>(rootElement->getElement(_CaretLine));
_CaretIndex = theElement->getTextLength()-2;
if(_CaretIndex<0)
{
SWARNING << "_CaretIndex < 0 .. Setting it to 0"<<std::endl;
_CaretIndex = 0;
}
if(_CaretIndex>prevIndex)
recalculateCaretPositions();
getParentTextDomArea()->setCaretPosition(getParentTextDomArea()->getCaretPosition()+ (_CaretIndex - prevIndex));
}
}
示例2: moveCaretLeft
void FixedHeightLayoutManager::moveCaretLeft(void)
{
PlainDocumentLeafElementRefPtr theElement;
if(_CaretIndex>0)
{
// set caret line
// set caret index
_CaretIndex--;
// set caret x,y position
recalculateCaretPositions();
// set the caret position wrt DOM
getParentTextDomArea()->setCaretPosition(getParentTextDomArea()->getCaretPosition()-1);
}
else
{
if(_CaretLine>0)
{
_CaretLine--;
theElement = dynamic_cast<PlainDocumentLeafElement*>(rootElement->getElement(_CaretLine));
_CaretIndex = theElement->getTextLength()-2;
if(_CaretIndex<0)_CaretIndex = 0;
recalculateCaretPositions();
getParentTextDomArea()->setCaretPosition(getParentTextDomArea()->getCaretPosition()-2);
}
}
}
示例3: doubleClickHandler
void FixedHeightLayoutManager::doubleClickHandler(void)
{
UInt32 initIndex = _CaretIndex;
PlainDocumentLeafElementRefPtr theElement = dynamic_cast<PlainDocumentLeafElement*>(rootElement->getElement(_CaretLine));
std::string theString = theElement->getText();
Int32 BeginWord = 0;
Int32 EndWord = theElement->getTextLength();
if(isPunctuationChar(theString[_CaretIndex]))
{
EndWord = _CaretIndex + 1;
BeginWord = _CaretIndex;
}
else
{
for(Int32 i = _CaretIndex; i < theElement->getTextLength(); i++)
{
if(!isWordChar(theString[i]))
{
EndWord = i;
break;
}
}
for(Int32 i = _CaretIndex; i >= 0; i--)
{
if(!isWordChar(theString[i]))
{
BeginWord = i + 1;
break;
}
}
}
HEL = HSL = _CaretLine;
HSI = BeginWord;
HEI = EndWord;
_CaretIndex = EndWord;
recalculateCaretPositions();
getParentTextDomArea()->setCaretPosition(getParentTextDomArea()->getCaretPosition()+ (EndWord - initIndex));
}
示例4: isLastCharacterOfDocument
bool FixedHeightLayoutManager::isLastCharacterOfDocument() const
{
if(_CaretLine == rootElement->getElementCount()-1)
{
PlainDocumentLeafElementRefPtr temp = dynamic_cast<PlainDocumentLeafElement*>(rootElement->getElement(_CaretLine));
if(_CaretIndex >= temp->getTextLength()-2) return true;
}
return false;
}
示例5: moveCaretUp
void FixedHeightLayoutManager::moveCaretUp(void)
{
PlainDocumentLeafElementRefPtr theElement;
if(_CaretLine > 0)
{
UInt32 prevIndex = _CaretIndex;
UInt32 prevLine = _CaretLine;
_CaretLine--;
theElement = dynamic_cast<PlainDocumentLeafElement*>(rootElement->getElement(_CaretLine));
if(_CaretIndex> theElement->getTextLength()-2)_CaretIndex = theElement->getTextLength()-2;
if(_CaretIndex<0)_CaretIndex=0;
recalculateCaretPositions();
UInt32 charactersToBeRewinded=0;
charactersToBeRewinded += prevIndex;
charactersToBeRewinded += (theElement->getTextLength() - _CaretIndex);
getParentTextDomArea()->setCaretPosition(getParentTextDomArea()->getCaretPosition()-charactersToBeRewinded);
}
}
示例6: moveCaretDown
void FixedHeightLayoutManager::moveCaretDown(void)
{
PlainDocumentLeafElementRefPtr theElement;
if(_CaretLine < rootElement->getElementCount()-1)
{
theElement = dynamic_cast<PlainDocumentLeafElement*>(rootElement->getElement(_CaretLine));
UInt32 prevIndex = _CaretIndex;
UInt32 prevLineLength = theElement->getTextLength();
_CaretLine++;
theElement = dynamic_cast<PlainDocumentLeafElement*>(rootElement->getElement(_CaretLine));
if(_CaretIndex> theElement->getTextLength()-2)_CaretIndex = theElement->getTextLength()-2;
if(_CaretIndex<0)_CaretIndex=0;
recalculateCaretPositions();
UInt32 charactersToBeForwarded=0;
charactersToBeForwarded += _CaretIndex;
charactersToBeForwarded += (prevLineLength - prevIndex);
getParentTextDomArea()->setCaretPosition(getParentTextDomArea()->getCaretPosition()+charactersToBeForwarded);
}
}
示例7: selectAll
void FixedHeightLayoutManager::selectAll(void)
{
HSL = 0;
HSI = 0;
HEL = rootElement->getElementCount()-1;
PlainDocumentLeafElementRefPtr temp = dynamic_cast<PlainDocumentLeafElement*>(rootElement->getElement(HEL));
HEI = temp->getTextLength()-2;
_CaretLine = HEL;
_CaretIndex = HEI;
recalculateCaretPositions();
}
示例8: CaretLineAndIndexToCaretOffsetInDOM
UInt32 FixedHeightLayoutManager::CaretLineAndIndexToCaretOffsetInDOM(UInt32 CaretLine,UInt32 CaretIndex)
{
UInt32 offset = 0;
if(rootElement)
{
for(UInt32 i=0;i<CaretLine;i++)
{
PlainDocumentLeafElementRefPtr temp = dynamic_cast<PlainDocumentLeafElement*>(rootElement->getElement(i));
offset += temp->getTextLength();
}
offset += CaretIndex;
}
return offset;
}
示例9: getNextCharacter
char FixedHeightLayoutManager::getNextCharacter(UInt32 _theOriginalCaretIndex,UInt32 _theOriginalCaretLine)
{
PlainDocumentLeafElementRefPtr temp = dynamic_cast<PlainDocumentLeafElement*>(rootElement->getElement(_theOriginalCaretLine));
if(temp->getTextLength()-2 == _theOriginalCaretIndex)
{
temp = dynamic_cast<PlainDocumentLeafElement*>(rootElement->getElement(_theOriginalCaretLine+1));
std::string tempstring = temp->getText();
return tempstring[0];
}
else
{
std::string tempstring = temp->getText();
return tempstring[_theOriginalCaretIndex];
}
}
示例10: isLastCharacterOfLine
bool FixedHeightLayoutManager::isLastCharacterOfLine(UInt32 _theOriginalCaretIndex,UInt32 _theOriginalCaretLine)
{
if(rootElement)
{
PlainDocumentLeafElementRefPtr temp = dynamic_cast<PlainDocumentLeafElement*>(rootElement->getElement(_theOriginalCaretLine));
if(temp->getTextLength()-2 == _theOriginalCaretIndex)
{
return true;
}
else
{
return false;
}
}
else
{
return true;
}
}
示例11: moveCaretRight
void FixedHeightLayoutManager::moveCaretRight(void)
{
PlainDocumentLeafElementRefPtr theElement;
theElement = dynamic_cast<PlainDocumentLeafElement*>(rootElement->getElement(_CaretLine));
if(_CaretIndex>=theElement->getTextLength()-2)
{
if(_CaretLine<rootElement->getElementCount()-1)
{
_CaretLine++;
_CaretIndex = 0;
recalculateCaretPositions();
getParentTextDomArea()->setCaretPosition(getParentTextDomArea()->getCaretPosition()+2);
}
}
else
{
_CaretIndex++;
recalculateCaretPositions();
getParentTextDomArea()->setCaretPosition(getParentTextDomArea()->getCaretPosition()+1);
}
}
示例12: populateCache
void FixedHeightLayoutManager::populateCache(void)
{
// cache exists only when the word wrap is enabled
if(getParentTextDomArea()->getWrapStyleWord())
{
linesToElements.clear();
if(getParentTextDomArea()->getDocumentModel())
{
ElementRefPtr defaultRoot=getParentTextDomArea()->getDocumentModel()->getDefaultRootElement();
if(defaultRoot)
{
PlainDocumentBranchElementRefPtr rootElement = dynamic_pointer_cast<PlainDocumentBranchElement>(defaultRoot);
Pnt2f init = getParentTextDomArea()->getPosition();
Vec2f dimensions = getParentTextDomArea()->getPreferredSize();
for(UInt32 i=0;i<rootElement->getElementCount();i++)
{
//GlyphViewRefPtr view = GlyphView::create();
PlainDocumentLeafElementRefPtr temp = dynamic_cast<PlainDocumentLeafElement*>(rootElement->getElement(i));
//view->setElement(ElementRefPtr(temp));
UInt32 noOfCharacters= temp->getTextLength();
/* to be edited............
Real32 totalLengthOfAllCharacters = noOfCharacters * widthOfCharacter;
UInt32 noOfLines = UInt32(ceil(totalLengthOfAllCharacters / dimensions.x()));
for(UInt32 j=0;j<noOfLines;j++)
linesToElements.push_back(i);
*/
}
}
}
}
}
示例13: drawBraceHighlight
void TextDomArea::drawBraceHighlight(Graphics * const TheGraphics, Real32 Opacity) const
{
if(getLayoutManager()->getBracesHighlightFlag())
{
if(getLayoutManager()->getStartingBraceLine() != -1 && getLayoutManager()->getStartingBraceIndex() != -1)
{
Pnt2f thePosition = getLayoutManager()->getXYPosition(getLayoutManager()->getStartingBraceLine(),getLayoutManager()->getStartingBraceIndex(),true);
TheGraphics->drawRect(thePosition,Pnt2f(thePosition.x()+5,thePosition.y()+getLayoutManager()->getHeightOfLine()),Color4f(0.7,0.7,0.0,1.0),Opacity);
}
if(getLayoutManager()->getEndingBraceLine() != -1 && getLayoutManager()->getEndingBraceIndex() != -1)
{
if(getLayoutManager()->getEndingBraceLine()<getLayoutManager()->getRootElement()->getElementCount())
{
PlainDocumentLeafElementRefPtr temp = dynamic_cast<PlainDocumentLeafElement*>(getLayoutManager()->getRootElement()->getElement(getLayoutManager()->getEndingBraceLine()));
if(getLayoutManager()->getEndingBraceIndex() < temp->getTextLength())
{
Pnt2f thePosition = getLayoutManager()->getXYPosition(getLayoutManager()->getEndingBraceLine(),getLayoutManager()->getEndingBraceIndex(),true);
TheGraphics->drawRect(thePosition,Pnt2f(thePosition.x()+5,thePosition.y()+getLayoutManager()->getHeightOfLine()),Color4f(0.7,0.7,0.0,1.0),Opacity);
}
}
}
}
}
示例14: write
bool PlainTextFileType::write(Document* const Doc, std::ostream &OutputStream,
const std::string& FileNameOrExtension)
{
PlainDocumentRefPtr TheDocument = dynamic_cast<PlainDocument*>(Doc);
std::vector<Element*> GenericRoots;
GenericRoots = TheDocument->getRootElements();
for(UInt32 i=0;i<GenericRoots.size();i++)
{
PlainDocumentBranchElementRefPtr RootElement;
RootElement = dynamic_cast<PlainDocumentBranchElement*>(GenericRoots[i]);
for(UInt32 j=0;j<RootElement->getElementCount()-1;j++)
{
PlainDocumentLeafElementRefPtr LeafElement;
LeafElement = dynamic_cast<PlainDocumentLeafElement*>(RootElement->getElement(j));
OutputStream<<LeafElement->getText();
}
PlainDocumentLeafElementRefPtr LeafElement;
LeafElement = dynamic_cast<PlainDocumentLeafElement*>(RootElement->getElement(RootElement->getElementCount()-1));
OutputStream<<LeafElement->getText().substr(0,LeafElement->getTextLength()-2);
}
return false;
}
示例15: moveTheCaret
//.........这里部分代码省略.........
{
_CaretLine = HSL; // set caret position to the Highlight Ending position
_CaretIndex = HSI;
HEI = HSI;
HEL = HSL;
}
moveCaretDown();
}
else // nothing was highlighted before this
{
moveCaretDown();
HSI = HEI = _CaretIndex;
HSL = HEL = _CaretLine;
}
}
else if(isShiftPressed && !isControlPressed) // if shift is pressed
{
moveCaretDown();
HEI = _CaretIndex;
HEL = _CaretLine;
}
break;
case HOME:
moveCaretHome(isControlPressed);
HEI = _CaretIndex;
HEL = _CaretLine;
if(!isShiftPressed)
{
HSI = HEI;
HSL = HEL;
}
break;
case HOMEOFNEXTLINE:
theElement = dynamic_cast<PlainDocumentLeafElement*>(rootElement->getElement(_CaretLine));
charactersToBeForwarded = theElement->getTextLength()-_CaretIndex;
_CaretIndex = 0;
_CaretLine++;
recalculateCaretPositions();
getParentTextDomArea()->setCaretPosition(getParentTextDomArea()->getCaretPosition()+ charactersToBeForwarded);
break;
case END:
moveCaretEnd(isControlPressed);
HEI = _CaretIndex;
HEL = _CaretLine;
if(!isShiftPressed)
{
HSI = HEI;
HSL = HEL;
}
break;
case PAGEUP:
tempIndex = _CaretIndex;
tempLine = _CaretLine;
tempLine -= getLinesToBeDisplayed();
if(tempLine<0)tempLine = 0;
theElement = dynamic_cast<PlainDocumentLeafElement*>(rootElement->getElement(tempLine));
if(tempIndex > theElement->getTextLength()-2)tempIndex = theElement->getTextLength()-2;
HEI = tempIndex;
HEL = tempLine;
if(!isShiftPressed)
{
HSI = HEI;
HSL = HEL;
}
_CaretLine = HEL; // set caret position to the Highlight Ending position
_CaretIndex = HEI;
recalculateCaretPositions();
break;
case PAGEDOWN:
tempIndex = _CaretIndex;
tempLine = _CaretLine;
tempLine += getLinesToBeDisplayed();
if(tempLine>=rootElement->getElementCount())tempLine = rootElement->getElementCount()-1;
theElement = dynamic_cast<PlainDocumentLeafElement*>(rootElement->getElement(tempLine));
if(tempIndex > theElement->getTextLength()-2)tempIndex = theElement->getTextLength()-2;
HEI = tempIndex;
HEL = tempLine;
if(!isShiftPressed)
{
HSI = HEI;
HSL = HEL;
}
_CaretLine = HEL; // set caret position to the Highlight Ending position
_CaretIndex = HEI;
recalculateCaretPositions();
break;
}
checkCaretVisibility(dir);
}