Example #1
0
/**
 * Draws the paper border (for print previews).
 * This function can ONLY be called from within a paintEvent because it will
 * use the painter
 *
 * @see drawIt()
 */
void RS_GraphicView::drawPaper(RS_Painter *painter) {

	if (!container) {
		return;
	}

	RS_Graphic* graphic = container->getGraphic();
	if (graphic->getPaperScale()<1.0e-6) {
		return;
	}

	// draw paper:
	// RVT_PORT rewritten from     painter->setPen(Qt::gray);
	painter->setPen(QColor(Qt::gray));

	RS_Vector pinsbase = graphic->getPaperInsertionBase();
	RS_Vector size = graphic->getPaperSize();
	double scale = graphic->getPaperScale();

	RS_Vector v1 = toGui((RS_Vector(0,0)-pinsbase)/scale);
	RS_Vector v2 = toGui((size-pinsbase)/scale);

	// gray background:
	painter->fillRect(0,0, getWidth(), getHeight(),
					  RS_Color(200,200,200));

	// shadow
	painter->fillRect(
				(int)(v1.x)+6, (int)(v1.y)+6,
				(int)((v2.x-v1.x)), (int)((v2.y-v1.y)),
				RS_Color(64,64,64));

	// border:
	painter->fillRect(
				(int)(v1.x), (int)(v1.y),
				(int)((v2.x-v1.x)), (int)((v2.y-v1.y)),
				RS_Color(64,64,64));

	// paper
	painter->fillRect(
				(int)(v1.x)+1, (int)(v1.y)-1,
				(int)((v2.x-v1.x))-2, (int)((v2.y-v1.y))+2,
				RS_Color(255,255,255));

}