本文整理汇总了C++中PlainDocumentLeafElementRefPtr类的典型用法代码示例。如果您正苦于以下问题:C++ PlainDocumentLeafElementRefPtr类的具体用法?C++ PlainDocumentLeafElementRefPtr怎么用?C++ PlainDocumentLeafElementRefPtr使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PlainDocumentLeafElementRefPtr类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getHighlightedStringInternal
std::string TextDomArea::getHighlightedStringInternal(UInt32 lesserLine,UInt32 lesserIndex,UInt32 greaterLine,UInt32 greaterIndex)
{
std::string firstLine="";
std::string lastLine="";
std::string intermediateLines="";
PlainDocumentLeafElementRefPtr temp1 = dynamic_cast<PlainDocumentLeafElement*>(getLayoutManager()->getRootElement()->getElement(lesserLine));
std::string temp2 = temp1->getText();
if(lesserLine== greaterLine)
{
return temp2.substr(lesserIndex,greaterIndex-lesserIndex);
}
else
{
// get the first line
firstLine = temp2.substr(lesserIndex);
// get the last line
temp1 = dynamic_cast<PlainDocumentLeafElement*>(getLayoutManager()->getRootElement()->getElement(greaterLine));
temp2 = temp1->getText();
lastLine = temp2.substr(0,greaterIndex);
}
for(UInt32 i=lesserLine+1;i<greaterLine;i++)
{
PlainDocumentLeafElementRefPtr theElement = dynamic_cast<PlainDocumentLeafElement*>(getLayoutManager()->getRootElement()->getElement(i));
intermediateLines+=theElement->getText();
}
return firstLine + intermediateLines + lastLine;
}
示例2: 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));
}
}
示例3: 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);
}
}
}
示例4: drawHighlightBGInternal
void TextDomArea::drawHighlightBGInternal(Graphics * const TheGraphics, Real32 Opacity,UInt32 lesserLine,UInt32 lesserIndex,UInt32 greaterLine,UInt32 greaterIndex) const
{
for(UInt32 i=lesserLine+1;i<greaterLine;i++)
{
PlainDocumentLeafElementRefPtr theElement = dynamic_cast<PlainDocumentLeafElement*>(getLayoutManager()->getRootElement()->getElement(i));
if(theElement)
{
Pnt2f topLeft,bottomRight;
getFont()->getBounds(theElement->getText(),topLeft,bottomRight);
TheGraphics->drawRect(Pnt2f(getLayoutManager()->getGutterSpace() + getLayoutManager()->getGutterSeparation(),i*getLayoutManager()->getHeightOfLine()),Pnt2f(getLayoutManager()->getGutterSpace() + getLayoutManager()->getGutterSeparation()+ bottomRight.x(),(i+1)*getLayoutManager()->getHeightOfLine()),Color4f(0.7,0.7,0.95,1),Opacity);
}
}
if(lesserLine== greaterLine)
{
TheGraphics->drawRect(getLayoutManager()->getXYPosition(lesserLine,lesserIndex,true),getLayoutManager()->getXYPosition(greaterLine,greaterIndex,false),Color4f(0.7,0.7,0.95,1),Opacity);
}
else
{
// draw the first line
TheGraphics->drawRect(getLayoutManager()->getXYPosition(lesserLine,lesserIndex,true),getLayoutManager()->getEndXYPosition(lesserLine),Color4f(0.7,0.7,0.95,1),Opacity);
// draw the last line
TheGraphics->drawRect(getLayoutManager()->getStartXYPosition(greaterLine),getLayoutManager()->getXYPosition(greaterLine,greaterIndex,false),Color4f(0.7,0.7,0.95,1),Opacity);
}
}
示例5: 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;
}
示例6: getNumberOfLeadingSpaces
UInt32 FixedHeightLayoutManager::getNumberOfLeadingSpaces(UInt32 line)
{
if(line>=rootElement->getElementCount())return 0;
UInt32 count = 0;
PlainDocumentLeafElementRefPtr theElement = dynamic_cast<PlainDocumentLeafElement*>(rootElement->getElement(line));
std::string theString = theElement->getText();
for(UInt32 i=0;i<theString.size(),theString[i]==' ';i++)count++;
return count;
}
示例7: recalculateCaretPositions
void FixedHeightLayoutManager::recalculateCaretPositions(void)
{
// this function assumes that the caret index and line values are valid and computes the caret x and y positions directly
_CaretYPosition = /*getParentTextDomArea()->getPosition().y() + */_CaretLine * heightOfLine;
PlainDocumentLeafElementRefPtr theElement = dynamic_cast<PlainDocumentLeafElement*>(rootElement->getElement(_CaretLine));
Pnt2f topLeft,bottomRight;
std::string theSubstring = theElement->getText();
theSubstring = theSubstring.substr(0,_CaretIndex);
getParentTextDomArea()->getFont()->getBounds(theSubstring,topLeft,bottomRight);
_CaretXPosition = _GutterSpace + _GutterSeparation + bottomRight.x();
}
示例8: 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();
}
示例9: getEndXYPosition
Pnt2f FixedHeightLayoutManager::getEndXYPosition(UInt32 lineNumber) const
{
PlainDocumentLeafElementRefPtr theElement = dynamic_cast<PlainDocumentLeafElement*>(rootElement->getElement(lineNumber));
if(theElement)
{
Pnt2f topLeft,bottomRight;
getParentTextDomArea()->getFont()->getBounds(theElement->getText(),topLeft,bottomRight);
return Pnt2f(_GutterSpace + _GutterSeparation + bottomRight.x(),(lineNumber+1)*heightOfLine);
}
else
{
return Pnt2f(0,0);
}
}
示例10: 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;
}
示例11: DoIfLineLongerThanPreferredSize
void FixedHeightLayoutManager::DoIfLineLongerThanPreferredSize() const
{
PlainDocumentLeafElementRefPtr temp = dynamic_cast<PlainDocumentLeafElement*>(rootElement->getElement(_CaretLine));
Pnt2f topLeft,bottomRight;
getParentTextDomArea()->getFont()->getBounds(temp->getText(),topLeft,bottomRight);
Vec2f preferredSize = getParentTextDomArea()->getPreferredSize();
if(bottomRight.x() > preferredSize.x())preferredSize.setValues(bottomRight.x(),preferredSize.y());
getParentTextDomArea()->setPreferredSize(preferredSize);
}
示例12: 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];
}
}
示例13: 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));
}
示例14: calculateWidthOfLongestLine
Real32 FixedHeightLayoutManager::calculateWidthOfLongestLine(Element* const rootElement) const
{
Real32 finalWidth=0.0;
Real32 currentWidth;
for(UInt32 i=0;i<rootElement->getElementCount();i++)
{
PlainDocumentLeafElementRefPtr temp = dynamic_cast<PlainDocumentLeafElement*>(rootElement->getElement(i));
Pnt2f TopLeft, BottomRight;
getParentTextDomArea()->getFont()->getBounds(temp->getText(), TopLeft, BottomRight);
currentWidth = BottomRight.x() - TopLeft.x();
if(currentWidth > finalWidth)finalWidth = currentWidth;
}
return finalWidth + 15.0;
}
示例15: 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);
}
}