//============================================================================== 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); } } }
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); }