Exemplo n.º 1
0
void WMeasurePaintDevice::drawImage(const WRectF& rect,
				    const std::string& imageUri,
				    int imgWidth, int imgHeight,
				    const WRectF& sourceRect)
{
  expandBounds(rect);
}
Exemplo n.º 2
0
void WMeasurePaintDevice::drawPath(const WPainterPath& path)
{
  if (path.isEmpty())
    return;

  expandBounds(path.controlPointRect());
}
Exemplo n.º 3
0
void WMeasurePaintDevice::drawText(const WRectF& rect,
				   WFlags<AlignmentFlag> flags,
				   TextFlag textFlag, const WString& text,
				   const WPointF *clipPoint)
{
  if (clipPoint && painter()) {
    if (!painter()->clipPathTransform().map(painter()->clipPath())
	  .isPointInPath(painter()->worldTransform().map(*clipPoint)))
      return;
  }

  double w = 0, h = 0;
  WString line = text;

  WFontMetrics fm = fontMetrics();

  for (;;) {
    WTextItem t = measureText(line, rect.width(),
			      textFlag == TextWordWrap ? true : false);

    h += fm.height();
    w = std::max(w, t.width());

    if (t.text() == line)
      break;
    else
      line = WString
	::fromUTF8(line.toUTF8().substr(t.text().toUTF8().length()));
  }

  AlignmentFlag horizontalAlign = flags & AlignHorizontalMask;
  AlignmentFlag verticalAlign = flags & AlignVerticalMask;

  double x, y;

  switch (horizontalAlign) {
  case AlignLeft:
    x = rect.left(); break;
  case AlignCenter:
    x = rect.left() + (rect.width() - w) / 2; break;
  case AlignRight:
  default:
    x = rect.right() - w; break;
  }

  switch (verticalAlign) {
  case AlignTop:
    y = rect.top(); break;
  case AlignMiddle:
    y = rect.top() + (rect.height() - h) / 2; break;
  case AlignBottom:
  default:
    y = rect.bottom() - h; break;
  }

  expandBounds(WRectF(x, y, w, h));
}
Exemplo n.º 4
0
void WMeasurePaintDevice::drawArc(const WRectF& rect, double startAngle,
				  double spanAngle)
{
  WPainterPath p;

  double r = std::max(rect.width(), rect.height()) / 2;
  double cx = rect.center().x();
  double cy = rect.center().y();
  p.arcMoveTo(cx, cy, r, startAngle);
  p.arcTo(cx, cy, r, startAngle, spanAngle);

  expandBounds(p.controlPointRect());
}
Exemplo n.º 5
0
void WMeasurePaintDevice::drawLine(double x1, double y1, double x2, double y2)
{
  expandBounds(WRectF(x1, y1, x2-x1, y2-y1));
}
Exemplo n.º 6
0
void WMeasurePaintDevice::drawPath(const WPainterPath& path)
{
  expandBounds(path.controlPointRect());
}