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


C++ Justification类代码示例

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


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

示例1: jassert

//==============================================================================
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: justificationToCode

    String justificationToCode (Justification justification)
    {
        switch (justification.getFlags())
        {
            case Justification::centred:                return "Justification::centred";
            case Justification::centredLeft:            return "Justification::centredLeft";
            case Justification::centredRight:           return "Justification::centredRight";
            case Justification::centredTop:             return "Justification::centredTop";
            case Justification::centredBottom:          return "Justification::centredBottom";
            case Justification::topLeft:                return "Justification::topLeft";
            case Justification::topRight:               return "Justification::topRight";
            case Justification::bottomLeft:             return "Justification::bottomLeft";
            case Justification::bottomRight:            return "Justification::bottomRight";
            case Justification::left:                   return "Justification::left";
            case Justification::right:                  return "Justification::right";
            case Justification::horizontallyCentred:    return "Justification::horizontallyCentred";
            case Justification::top:                    return "Justification::top";
            case Justification::bottom:                 return "Justification::bottom";
            case Justification::verticallyCentred:      return "Justification::verticallyCentred";
            case Justification::horizontallyJustified:  return "Justification::horizontallyJustified";
            default:                                    break;
        }

        jassertfalse;
        return "Justification (" + String (justification.getFlags()) + ")";
    }
开发者ID:EthanZuo,项目名称:JUCE,代码行数:26,代码来源:jucer_CodeHelpers.cpp

示例3: f

//------------------------------------------------------------------------------
void MiscPreferences::drawGroupComponentOutline(Graphics& g,
												int width,
												int height,
                                             	const String& text,
                                             	const Justification& position)
{
    const float textH = 15.0f;
    const float indent = 3.0f;
    const float textEdgeGap = 4.0f;
    float cs = 5.0f;

    Font f (textH, Font::bold);

    Path p;
    float x = indent;
    float y = f.getAscent() - 3.0f;
    float w = width - x * 2.0f;
    float h = height - y  - indent;
    cs = jmin (cs, w * 0.5f, h * 0.5f);
    const float cs2 = 2.0f * cs;

    float textW = jlimit (0.0f, f.getStringWidth (text) + textEdgeGap * 2.0f, w - cs2);
    float textX = cs + textEdgeGap;

    if (position.testFlags (Justification::verticallyCentred))
        textX = cs + (w - cs2 - textW) * 0.5f;
    else if (position.testFlags (Justification::right))
        textX = w - cs - textW - textEdgeGap;

    p.startNewSubPath (x + textX + textW, y);
    p.lineTo (x + w - cs, y);

    p.addArc (x + w - cs2, y, cs2, cs2, 0, float_Pi * 0.5f);
    p.lineTo (x + w, y + h - cs);

    p.addArc (x + w - cs2, y + h - cs2, cs2, cs2, float_Pi * 0.5f, float_Pi);
    p.lineTo (x + cs, y + h);

    p.addArc (x, y + h - cs2, cs2, cs2, float_Pi, float_Pi * 1.5f);
    p.lineTo (x, y + cs);

    p.addArc (x, y, cs2, cs2, float_Pi * 1.5f, float_Pi * 2.0f);
    p.lineTo (x + textX, y);

    g.setColour (textColour);
    g.strokePath (p, PathStrokeType (2.0f));

    g.setColour (textColour);
    g.setFont (f);
    g.drawText (text,
                roundFloatToInt (x + textX), 0,
                roundFloatToInt (textW),
                roundFloatToInt (textH),
                Justification::centred, true);
}
开发者ID:moddevices,项目名称:mod-iso,代码行数:56,代码来源:MiscPreferences.cpp

示例4: boundsRect

AffineTransform Path::getTransformToScaleToFit (const float x, const float y,
                                                const float w, const float h,
                                                const bool preserveProportions,
                                                Justification justification) const
{
    Rectangle<float> boundsRect (getBounds());

    if (preserveProportions)
    {
        if (w <= 0 || h <= 0 || boundsRect.isEmpty())
            return AffineTransform::identity;

        float newW, newH;
        const float srcRatio = boundsRect.getHeight() / boundsRect.getWidth();

        if (srcRatio > h / w)
        {
            newW = h / srcRatio;
            newH = h;
        }
        else
        {
            newW = w;
            newH = w * srcRatio;
        }

        float newXCentre = x;
        float newYCentre = y;

        if (justification.testFlags (Justification::left))          newXCentre += newW * 0.5f;
        else if (justification.testFlags (Justification::right))    newXCentre += w - newW * 0.5f;
        else                                                        newXCentre += w * 0.5f;

        if (justification.testFlags (Justification::top))           newYCentre += newH * 0.5f;
        else if (justification.testFlags (Justification::bottom))   newYCentre += h - newH * 0.5f;
        else                                                        newYCentre += h * 0.5f;

        return AffineTransform::translation (boundsRect.getWidth()  * -0.5f - boundsRect.getX(),
                                             boundsRect.getHeight() * -0.5f - boundsRect.getY())
                    .scaled (newW / boundsRect.getWidth(),
                             newH / boundsRect.getHeight())
                    .translated (newXCentre, newYCentre);
    }
    else
    {
        return AffineTransform::translation (-boundsRect.getX(), -boundsRect.getY())
                    .scaled (w / boundsRect.getWidth(),
                             h / boundsRect.getHeight())
                    .translated (x, y);
    }
}
开发者ID:410pfeliciano,项目名称:plugin-GUI,代码行数:51,代码来源:juce_Path.cpp

示例5: Apply

    TRef<IObject> Apply(ObjectStack& stack)
    {
        TRef<StringValue> pstring; CastTo(pstring, (IObject*)stack.Pop());
        TRef<ColorValue>  pcolor;  CastTo(pcolor, (IObject*)stack.Pop());

        TRef<PointValue> ppointSize;
        WinPoint ptSize;
        if (stack.GetCount() > 0)
            {
            CastTo(ppointSize, (IObject*)stack.Pop());
            ptSize = WinPoint(
                (int)ppointSize->GetValue().X(),
                (int)ppointSize->GetValue().Y()
                );
            }

        Justification justification = JustifyLeft();
        if (stack.GetCount() > 0)
        {
            TRef<Number> pjustify = Number::Cast((IObject*)stack.Pop());
            justification.SetWord((DWORD)pjustify->GetValue());
        }

        TRef<IEngineFont> pfont = TrekResources::SmallFont();

        if (stack.GetCount() > 0)
        {
            TRef<FontValue> pfontLocal;  CastTo(pfontLocal,  (IObject*)stack.Pop());
            pfont = pfontLocal->GetValue();
        }

        bool bRightClip = false;
        if (stack.GetCount() > 0)
            bRightClip = GetBoolean((IObject*)stack.Pop());

        TRef<StringValuePane> ppane;

        if (ppointSize)
        {
            if (bRightClip)
                justification = JustifyLeftClipRight();

            ppane = new StringValuePane(pstring, pcolor, pfont, ptSize, justification);
        }
        else
            ppane = new StringValuePane(pstring, pcolor, pfont);

        return (Pane*)ppane;
    }
开发者ID:borgified,项目名称:Allegiance,代码行数:49,代码来源:trekmdl.cpp

示例6: bb

void GlyphArrangement::addLinesWithLineBreaks (const String& text, const Font& f,
                                               float x, float y, float width, float height, Justification layout)
{
    GlyphArrangement ga;
    ga.addJustifiedText (f, text, x, y, width, layout);

    const Rectangle<float> bb (ga.getBoundingBox (0, -1, false));

    float dy = y - bb.getY();

    if (layout.testFlags (Justification::verticallyCentred))   dy += (height - bb.getHeight()) * 0.5f;
    else if (layout.testFlags (Justification::bottom))         dy += (height - bb.getHeight());

    ga.moveRangeOfGlyphs (0, -1, 0.0f, dy);

    glyphs.addArray (ga.glyphs);
}
开发者ID:JordanTHarris,项目名称:Painter,代码行数:17,代码来源:juce_GlyphArrangement.cpp

示例7: setTextLabelPosition

//==============================================================================
void GroupComponent::setTextLabelPosition (const Justification& newJustification)
{
    if (justification.getFlags() != newJustification.getFlags())
    {
        justification = newJustification;
        repaint();
    }
}
开发者ID:alessandropetrolati,项目名称:juced,代码行数:9,代码来源:juce_GroupComponent.cpp

示例8: jassert

void GlyphArrangement::justifyGlyphs (const int startIndex, const int num,
                                      const float x, const float y, const float width, const float height,
                                      const Justification& justification)
{
    jassert (num >= 0 && startIndex >= 0);

    if (glyphs.size() > 0 && num > 0)
    {
        const Rectangle<float> bb (getBoundingBox (startIndex, num, ! justification.testFlags (Justification::horizontallyJustified
                                                                                                | Justification::horizontallyCentred)));
        float deltaX = 0.0f;

        if (justification.testFlags (Justification::horizontallyJustified))
            deltaX = x - bb.getX();
        else if (justification.testFlags (Justification::horizontallyCentred))
            deltaX = x + (width - bb.getWidth()) * 0.5f - bb.getX();
        else if (justification.testFlags (Justification::right))
            deltaX = (x + width) - bb.getRight();
        else
            deltaX = x - bb.getX();

        float deltaY = 0.0f;

        if (justification.testFlags (Justification::top))
            deltaY = y - bb.getY();
        else if (justification.testFlags (Justification::bottom))
            deltaY = (y + height) - bb.getBottom();
        else
            deltaY = y + (height - bb.getHeight()) * 0.5f - bb.getY();

        moveRangeOfGlyphs (startIndex, num, deltaX, deltaY);

        if (justification.testFlags (Justification::horizontallyJustified))
        {
            int lineStart = 0;
            float baseY = glyphs.getUnchecked (startIndex)->getBaselineY();

            int i;
            for (i = 0; i < num; ++i)
            {
                const float glyphY = glyphs.getUnchecked (startIndex + i)->getBaselineY();

                if (glyphY != baseY)
                {
                    spreadOutLine (startIndex + lineStart, i - lineStart, width);

                    lineStart = i;
                    baseY = glyphY;
                }
            }

            if (i > lineStart)
                spreadOutLine (startIndex + lineStart, i - lineStart, width);
        }
    }
}
开发者ID:EQ4,项目名称:editor,代码行数:56,代码来源:juce_GlyphArrangement.cpp

示例9: 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

示例10: justified

static Rectangle<int> justified (Justification justification,
                                 const Rectangle<int>& space,
                                 const Rectangle<int>& item)
{
  int itemX = item.getX();
  int itemY = item.getY();
  int itemW = item.getWidth();
  int itemH = item.getHeight();

  justification.applyToRectangle (itemX, itemY, itemW, itemH,
    space.getX(), space.getY(), space.getWidth(), space.getHeight());

  return Rectangle<int> (itemX, itemY, itemW, itemH);
}
开发者ID:lucem,项目名称:VFLib,代码行数:14,代码来源:ColouredImageMaskFacade.cpp

示例11:

void DrawableText::ValueTreeWrapper::setJustification (const Justification& newJustification, UndoManager* undoManager)
{
    state.setProperty (justification, newJustification.getFlags(), undoManager);
}
开发者ID:randi2kewl,项目名称:ShoutOut,代码行数:4,代码来源:juce_DrawableText.cpp

示例12: jmin

void GlyphArrangement::splitLines (const String& text, Font font, int startIndex,
                                   float x, float y, float width, float height, int maximumLines,
                                   float lineWidth, Justification layout, float minimumHorizontalScale)
{
    const int length = text.length();
    const int originalStartIndex = startIndex;
    int numLines = 1;

    if (length <= 12 && ! text.containsAnyOf (" -\t\r\n"))
        maximumLines = 1;

    maximumLines = jmin (maximumLines, length);

    while (numLines < maximumLines)
    {
        ++numLines;

        const float newFontHeight = height / (float) numLines;

        if (newFontHeight < font.getHeight())
        {
            font.setHeight (jmax (8.0f, newFontHeight));

            removeRangeOfGlyphs (startIndex, -1);
            addLineOfText (font, text, x, y);

            lineWidth = glyphs.getReference (glyphs.size() - 1).getRight()
                            - glyphs.getReference (startIndex).getLeft();
        }

        // Try to estimate the point at which there are enough lines to fit the text,
        // 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;
                }
//.........这里部分代码省略.........
开发者ID:JordanTHarris,项目名称:Painter,代码行数:101,代码来源:juce_GlyphArrangement.cpp

示例13: addLineOfText

void GlyphArrangement::addJustifiedText (const Font& font,
                                         const String& text,
                                         float x, float y,
                                         const float maxLineWidth,
                                         Justification horizontalLayout)
{
    int lineStartIndex = glyphs.size();
    addLineOfText (font, text, x, y);

    const float originalY = y;

    while (lineStartIndex < glyphs.size())
    {
        int i = lineStartIndex;

        if (glyphs.getReference(i).getCharacter() != '\n'
              && glyphs.getReference(i).getCharacter() != '\r')
            ++i;

        const float lineMaxX = glyphs.getReference (lineStartIndex).getLeft() + maxLineWidth;
        int lastWordBreakIndex = -1;

        while (i < glyphs.size())
        {
            const PositionedGlyph& pg = glyphs.getReference (i);
            const juce_wchar c = pg.getCharacter();

            if (c == '\r' || c == '\n')
            {
                ++i;

                if (c == '\r' && i < glyphs.size()
                     && glyphs.getReference(i).getCharacter() == '\n')
                    ++i;

                break;
            }

            if (pg.isWhitespace())
            {
                lastWordBreakIndex = i + 1;
            }
            else if (pg.getRight() - 0.0001f >= lineMaxX)
            {
                if (lastWordBreakIndex >= 0)
                    i = lastWordBreakIndex;

                break;
            }

            ++i;
        }

        const float currentLineStartX = glyphs.getReference (lineStartIndex).getLeft();
        float currentLineEndX = currentLineStartX;

        for (int j = i; --j >= lineStartIndex;)
        {
            if (! glyphs.getReference (j).isWhitespace())
            {
                currentLineEndX = glyphs.getReference (j).getRight();
                break;
            }
        }

        float deltaX = 0.0f;

        if (horizontalLayout.testFlags (Justification::horizontallyJustified))
            spreadOutLine (lineStartIndex, i - lineStartIndex, maxLineWidth);
        else if (horizontalLayout.testFlags (Justification::horizontallyCentred))
            deltaX = (maxLineWidth - (currentLineEndX - currentLineStartX)) * 0.5f;
        else if (horizontalLayout.testFlags (Justification::right))
            deltaX = maxLineWidth - (currentLineEndX - currentLineStartX);

        moveRangeOfGlyphs (lineStartIndex, i - lineStartIndex,
                           x + deltaX - currentLineStartX, y - originalY);

        lineStartIndex = i;

        y += font.getHeight();
    }
}
开发者ID:JordanTHarris,项目名称:Painter,代码行数:82,代码来源:juce_GlyphArrangement.cpp


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