当前位置: 首页>>代码示例>>C++>>正文


C++ TextLine::AppendFittingCharacters方法代码示例

本文整理汇总了C++中TextLine::AppendFittingCharacters方法的典型用法代码示例。如果您正苦于以下问题:C++ TextLine::AppendFittingCharacters方法的具体用法?C++ TextLine::AppendFittingCharacters怎么用?C++ TextLine::AppendFittingCharacters使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TextLine的用法示例。


在下文中一共展示了TextLine::AppendFittingCharacters方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: PopulateTextLinesImpl

        void MultiLineTextLayer::PopulateTextLinesImpl(const Real MaxWidth)
        {
            //if( MaxWidth <= 0 )
            //    return;

            Whole LineIndex = 0;
            Boole NewLineDetected = false;
            TextLine* CurrLine = this->GetOrCreateTextLine(LineIndex);
            if( HorizontalOrder == UI::TO_Left_To_Right ) {
                CharacterIterator Start = this->Characters.begin();
                CharacterIterator End = this->Characters.begin();
                const CharacterIterator CharEnd = this->Characters.end();

                do{
                    if( (*Start)->IsWhiteSpace() ) {
                        // Find the next non-whitespace character.
                        while( End != CharEnd )
                        {
                            if( (*End)->IsNewLine() ) {
                                NewLineDetected = true;
                                ++End;
                                break;
                            }else if( !(*End)->IsWhiteSpace() ) {
                                break;
                            }

                            ++End;
                        }

                        // We got our range, append what we can.
                        CharacterIterator Result = CurrLine->AppendFittingCharacters(Start,End,MaxWidth);
                        if( Result != End || NewLineDetected ) {
                            CurrLine = this->GetOrCreateTextLine(++LineIndex);
                            End = CurrLine->AppendFittingCharacters(Result,End,MaxWidth);
                            if( Start == End ) {
                                // If these are the same, then we lack the space to append anything.
                                break;
                            }
                        }
                        // Clear out the newline for the next iteration.
                        NewLineDetected = false;
                    }else{
                        // Find the next whitespace character.
                        while( End != CharEnd )
                        {
                            if( (*End)->IsWhiteSpace() )
                                break;

                            ++End;
                        }

                        // We got our range, so lets try to insert it.
                        if( !CurrLine->AppendCharacters(Start,End,MaxWidth) )
                        {
                            // If we failed to insert, get the next line and try again.
                            CurrLine = this->GetOrCreateTextLine(++LineIndex);
                            if( !CurrLine->AppendCharacters(Start,End,MaxWidth) ) {
                                End = CurrLine->AppendFittingCharacters(Start,End,MaxWidth);
                                if( Start == End ) {
                                    // If these are the same, then we lack the space to append anything.
                                    break;
                                }
                            }
                        }
                    }
                    Start = End;
                }while( Start != CharEnd );
            }
            else if( HorizontalOrder == UI::TO_Right_To_Left )
            {
                CharacterIterator Start = --this->Characters.end();
                CharacterIterator End = --this->Characters.end();
                const CharacterIterator CharEnd = --this->Characters.begin();

                CharacterIteratorPair AppendPair;

                do{
                    if( (*End)->IsWhiteSpace() ) {
                        // Find the next non-whitespace character.
                        while( Start != CharEnd )
                        {
                            if( (*Start)->IsNewLine() ) {
                                NewLineDetected = true;
                                ++Start;
                                break;
                            }else if( !(*Start)->IsWhiteSpace() ) {
                                break;
                            }

                            ++Start;
                        }

                        AppendPair.first = Start;
                        AppendPair.second = End;
                        ++AppendPair.first;
                        ++AppendPair.second;

                        // We got our range, append what we can.
                        CharacterIterator Result = CurrLine->AppendFittingCharacters(AppendPair,MaxWidth);
                        if( Result != Start || NewLineDetected ) {
//.........这里部分代码省略.........
开发者ID:,项目名称:,代码行数:101,代码来源:


注:本文中的TextLine::AppendFittingCharacters方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。