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


C++ ORORect::brush方法代码示例

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


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

示例1: renderPage


//.........这里部分代码省略.........
    QImage image = QImage(pageWidth, pageHeight, QImage::Format_RGB32);
    QPainter gPainter;
    if(gPainter.begin(&image))
      gPainter.fillRect(gPainter.viewport(), QColor(Qt::white));

    // Render Background
    if((!p->backgroundImage().isNull()) && (p->backgroundOpacity() != 0))
    {
      doBgWm = true;
      QPointF ps = p->backgroundPosition();
      QSizeF sz = p->backgroundSize();
      QRectF rc = QRectF(ps.x() * resolution, ps.y() * resolution, sz.width() * resolution, sz.height() * resolution);
      renderBackground(image, p->backgroundImage(), rc.toRect(),
        p->backgroundScale(), p->backgroundScaleMode(),
        p->backgroundAlign(), p->backgroundOpacity());
    }

    // Render Watermark
    if((!p->watermarkText().isEmpty()) && (p->watermarkOpacity() != 0))
    {
      doBgWm = true;
      renderWatermark(image, p->watermarkText(), p->watermarkFont(), p->watermarkOpacity(),
        ((pDocument->pageOptions().getMarginLeft() + pDocument->pageOptions().getMarginRight()) * resolution),
        ((pDocument->pageOptions().getMarginTop() + pDocument->pageOptions().getMarginBottom()) * resolution),
        pDocument->pageOptions().getMarginLeft() * resolution, pDocument->pageOptions().getMarginTop() * resolution);
    }

    if(doBgWm)
    {
      QRectF target(-printMarginWidth, -printMarginHeight, (painter->viewport().width() + printMarginWidth + printMarginWidth), (painter->viewport().height() + printMarginHeight + printMarginHeight));
      QRectF source(0, 0, image.width(), image.height());
      painter->drawImage(target, image, source);
    }
  }

  // Render Page Objects
  for(int i = 0; i < p->primitives(); i++)
  {
    OROPrimitive * prim = p->primitive(i);
    if(prim->type() == OROTextBox::TextBox)
    {
      OROTextBox * tb = (OROTextBox*)prim;
      QPointF ps = tb->position();
      QSizeF sz = tb->size();
      QRectF rc = QRectF(ps.x() * xDpi, ps.y() * yDpi, sz.width() * xDpi, sz.height() * yDpi);

      painter->save();
      painter->setFont(tb->font());
      painter->drawText(rc, tb->flags(), tb->text());
      painter->restore();
    }
    else if(prim->type() == OROLine::Line)
    {
      OROLine * ln = (OROLine*)prim;
      QPointF s = ln->startPoint();
      QPointF e = ln->endPoint();
      QPen pen(painter->pen());
      pen.setWidthF((ln->weight() / 100) * printResolution);

      painter->save();
      painter->setPen(pen);
      painter->drawLine(QLineF(s.x() * xDpi, s.y() * yDpi, e.x() * xDpi, e.y() * yDpi));
      painter->restore();
    }
    else if(prim->type() == OROImage::Image)
    {
      OROImage * im = (OROImage*)prim;
      QPointF ps = im->position();
      QSizeF sz = im->size();
      QRectF rc = QRectF(ps.x() * xDpi, ps.y() * yDpi, sz.width() * xDpi, sz.height() * yDpi);

      QImage img = im->image();
      if(im->scaled())
        img = img.scaled(rc.size().toSize(), (Qt::AspectRatioMode)im->aspectRatioMode(), (Qt::TransformationMode)im->transformationMode());

      QRectF sr = QRectF(QPointF(0.0, 0.0), rc.size().boundedTo(img.size()));
      painter->drawImage(rc.topLeft(), img, sr);
    }
    else if(prim->type() == ORORect::Rect)
    {
      ORORect * re = (ORORect*)prim;

      QPointF ps = re->position();
      QSizeF sz = re->size();
      QRectF rc = QRectF(ps.x() * xDpi, ps.y() * yDpi, sz.width() * xDpi, sz.height() * yDpi);
      QPen pen(re->pen());
      pen.setWidthF((re->weight() / 100) * printResolution);

      painter->save();
      painter->setPen(pen);
      painter->setBrush(re->brush());
      painter->drawRect(rc);
      painter->restore();
    }
    else
    {
      qDebug("unrecognized primitive type");
    }
  }
}
开发者ID:Wushaowei001,项目名称:xtuple,代码行数:101,代码来源:orprintrender.cpp


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