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


C++ Justification::getOnlyHorizontalFlags方法代码示例

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


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

示例1: drawSingleLineText

//==============================================================================
void Graphics::drawSingleLineText (const String& text, const int startX, const int baselineY,
                                   const Justification& justification) const
{
    if (text.isNotEmpty()
         && startX < context.getClipBounds().getRight())
    {
        GlyphArrangement arr;
        arr.addLineOfText (context.getFont(), text, (float) startX, (float) baselineY);

        // Don't pass any vertical placement flags to this method - they'll be ignored.
        jassert (justification.getOnlyVerticalFlags() == 0);

        const int flags = justification.getOnlyHorizontalFlags();

        if (flags != Justification::left)
        {
            float w = arr.getBoundingBox (0, -1, true).getWidth();

            if ((flags & (Justification::horizontallyCentred | Justification::horizontallyJustified)) != 0)
                w /= 2.0f;

            arr.draw (*this, AffineTransform::translation (-w, 0));
        }
        else
        {
            arr.draw (*this);
        }
    }
}
开发者ID:anthonyhuecouret,项目名称:argotlunar,代码行数:30,代码来源:juce_GraphicsContext.cpp

示例2: drawText

void FilterChart::drawText (Graphics &g,
                      const Point<int> ptOrigin,
                      const String text,
                      Justification just)
{
  const Font& font = g.getCurrentFont();
  const int w = font.getStringWidth(text);

  int x, y;

  if (just.getOnlyHorizontalFlags() & Justification::right)
    x = ptOrigin.getX() - w;
  else
    x = ptOrigin.getX();

  if (just.getOnlyVerticalFlags() & Justification::top)
    y = int (ptOrigin.getY() + font.getAscent() + 0.5);
  else
    y = ptOrigin.getY();

  g.drawSingleLineText (text, x, y);
}
开发者ID:EQ4,项目名称:DSPFiltersDemo,代码行数:22,代码来源:FilterChart.cpp

示例3: splitLines


//.........这里部分代码省略.........
        // allowing for unevenness in the lengths due to differently sized words.
        const float lineLengthUnevennessAllowance = 80.0f;

        if (numLines > (lineWidth + lineLengthUnevennessAllowance) / width || newFontHeight < 8.0f)
            break;
    }

    if (numLines < 1)
        numLines = 1;

    float lineY = y;
    float widthPerLine = lineWidth / numLines;

    for (int line = 0; line < numLines; ++line)
    {
        int i = startIndex;
        float lineStartX = glyphs.getReference (startIndex).getLeft();

        if (line == numLines - 1)
        {
            widthPerLine = width;
            i = glyphs.size();
        }
        else
        {
            while (i < glyphs.size())
            {
                lineWidth = (glyphs.getReference (i).getRight() - lineStartX);

                if (lineWidth > widthPerLine)
                {
                    // got to a point where the line's too long, so skip forward to find a
                    // good place to break it..
                    const int searchStartIndex = i;

                    while (i < glyphs.size())
                    {
                        if ((glyphs.getReference (i).getRight() - lineStartX) * minimumHorizontalScale < width)
                        {
                            if (glyphs.getReference (i).isWhitespace()
                                 || glyphs.getReference (i).getCharacter() == '-')
                            {
                                ++i;
                                break;
                            }
                        }
                        else
                        {
                            // can't find a suitable break, so try looking backwards..
                            i = searchStartIndex;

                            for (int back = 1; back < jmin (7, i - startIndex - 1); ++back)
                            {
                                if (glyphs.getReference (i - back).isWhitespace()
                                     || glyphs.getReference (i - back).getCharacter() == '-')
                                {
                                    i -= back - 1;
                                    break;
                                }
                            }

                            break;
                        }

                        ++i;
                    }

                    break;
                }

                ++i;
            }

            int wsStart = i;
            while (wsStart > 0 && glyphs.getReference (wsStart - 1).isWhitespace())
                --wsStart;

            int wsEnd = i;
            while (wsEnd < glyphs.size() && glyphs.getReference (wsEnd).isWhitespace())
                ++wsEnd;

            removeRangeOfGlyphs (wsStart, wsEnd - wsStart);
            i = jmax (wsStart, startIndex + 1);
        }

        i -= fitLineIntoSpace (startIndex, i - startIndex,
                               x, lineY, width, font.getHeight(), font,
                               layout.getOnlyHorizontalFlags() | Justification::verticallyCentred,
                               minimumHorizontalScale);

        startIndex = i;
        lineY += font.getHeight();

        if (startIndex >= glyphs.size())
            break;
    }

    justifyGlyphs (originalStartIndex, glyphs.size() - originalStartIndex,
                   x, y, width, height, layout.getFlags() & ~Justification::horizontallyJustified);
}
开发者ID:JordanTHarris,项目名称:Painter,代码行数:101,代码来源:juce_GlyphArrangement.cpp

示例4: addFittedText


//.........这里部分代码省略.........
            }

            if (numLines < 1)
                numLines = 1;

            float lineY = y;
            float widthPerLine = lineWidth / numLines;
            int lastLineStartIndex = 0;

            for (int line = 0; line < numLines; ++line)
            {
                int i = startIndex;
                lastLineStartIndex = i;
                float lineStartX = glyphs.getUnchecked (startIndex)->getLeft();

                if (line == numLines - 1)
                {
                    widthPerLine = width;
                    i = glyphs.size();
                }
                else
                {
                    while (i < glyphs.size())
                    {
                        lineWidth = (glyphs.getUnchecked (i)->getRight() - lineStartX);

                        if (lineWidth > widthPerLine)
                        {
                            // got to a point where the line's too long, so skip forward to find a
                            // good place to break it..
                            const int searchStartIndex = i;

                            while (i < glyphs.size())
                            {
                                if ((glyphs.getUnchecked (i)->getRight() - lineStartX) * minimumHorizontalScale < width)
                                {
                                    if (glyphs.getUnchecked (i)->isWhitespace()
                                         || glyphs.getUnchecked (i)->getCharacter() == '-')
                                    {
                                        ++i;
                                        break;
                                    }
                                }
                                else
                                {
                                    // can't find a suitable break, so try looking backwards..
                                    i = searchStartIndex;

                                    for (int back = 1; back < jmin (5, i - startIndex - 1); ++back)
                                    {
                                        if (glyphs.getUnchecked (i - back)->isWhitespace()
                                             || glyphs.getUnchecked (i - back)->getCharacter() == '-')
                                        {
                                            i -= back - 1;
                                            break;
                                        }
                                    }

                                    break;
                                }

                                ++i;
                            }

                            break;
                        }

                        ++i;
                    }

                    int wsStart = i;
                    while (wsStart > 0 && glyphs.getUnchecked (wsStart - 1)->isWhitespace())
                        --wsStart;

                    int wsEnd = i;

                    while (wsEnd < glyphs.size() && glyphs.getUnchecked (wsEnd)->isWhitespace())
                        ++wsEnd;

                    removeRangeOfGlyphs (wsStart, wsEnd - wsStart);
                    i = jmax (wsStart, startIndex + 1);
                }

                i -= fitLineIntoSpace (startIndex, i - startIndex,
                                       x, lineY, width, font.getHeight(), font,
                                       layout.getOnlyHorizontalFlags() | Justification::verticallyCentred,
                                       minimumHorizontalScale);

                startIndex = i;
                lineY += font.getHeight();

                if (startIndex >= glyphs.size())
                    break;
            }

            justifyGlyphs (originalStartIndex, glyphs.size() - originalStartIndex,
                           x, y, width, height, layout.getFlags() & ~Justification::horizontallyJustified);
        }
    }
}
开发者ID:EQ4,项目名称:editor,代码行数:101,代码来源:juce_GlyphArrangement.cpp


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