示例#1
0
void InsetText::draw(PainterInfo & pi, int x, int y) const
{
	TextMetrics & tm = pi.base.bv->textMetrics(&text_);

	int const w = tm.width() + TEXT_TO_INSET_OFFSET;
	int const yframe = y - TEXT_TO_INSET_OFFSET - tm.ascent();
	int const h = tm.height() + 2 * TEXT_TO_INSET_OFFSET;
	int const xframe = x + TEXT_TO_INSET_OFFSET / 2;
	bool change_drawn = false;
	if (pi.full_repaint)
			pi.pain.fillRectangle(xframe, yframe, w, h,
				pi.backgroundColor(this));

	{
		Changer dummy = make_change(pi.background_color,
		                            pi.backgroundColor(this, false));
		// The change tracking cue must not be inherited
		Changer dummy2 = make_change(pi.change_, Change());
		tm.draw(pi, x + TEXT_TO_INSET_OFFSET, y);
	}

	if (drawFrame_) {
		// Change color of the frame in tracked changes, like for tabulars.
		// Only do so if the color is not custom. But do so even if RowPainter
		// handles the strike-through already.
		Color c;
		if (pi.change_.changed()
		    // Originally, these are the colors with role Text, from role() in
		    // ColorCache.cpp.  The code is duplicated to avoid depending on Qt
		    // types, and also maybe it need not match in the future.
		    && (frameColor() == Color_foreground
		        || frameColor() == Color_cursor
		        || frameColor() == Color_preview
		        || frameColor() == Color_tabularline
		        || frameColor() == Color_previewframe)) {
			c = pi.change_.color();
			change_drawn = true;
		} else
			c = frameColor();
		pi.pain.rectangle(xframe, yframe, w, h, c);
	}

	if (canPaintChange(*pi.base.bv) && (!change_drawn || pi.change_.deleted()))
		// Do not draw the change tracking cue if already done by RowPainter and
		// do not draw the cue for INSERTED if the information is already in the
		// color of the frame
		pi.change_.paintCue(pi, xframe, yframe, xframe + w, yframe + h);
}
示例#2
0
void InsetCaption::drawBackground(PainterInfo & pi, int x, int y) const
{
	TextMetrics & tm = pi.base.bv->textMetrics(&text());
	int const h = tm.height() + 2 * TEXT_TO_INSET_OFFSET;
	int const yy = y - TEXT_TO_INSET_OFFSET - tm.ascent();
	pi.pain.fillRectangle(x, yy, labelwidth_, h, pi.backgroundColor(this));
}
示例#3
0
文件: Inset.cpp 项目: cburschka/lyx
void Inset::drawBackground(PainterInfo & pi, int x, int y) const
{
	if (pi.full_repaint && backgroundColor(pi) == Color_none)
		return;
	Dimension const dim = dimension(*pi.base.bv);
	pi.pain.fillRectangle(x, y - dim.asc, dim.wid, dim.asc + dim.des,
	                      pi.backgroundColor(this));
}
示例#4
0
void InsetText::draw(PainterInfo & pi, int x, int y) const
{
	TextMetrics & tm = pi.base.bv->textMetrics(&text_);

	if (drawFrame_ || pi.full_repaint) {
		int const w = tm.width() + TEXT_TO_INSET_OFFSET;
		int const yframe = y - TEXT_TO_INSET_OFFSET - tm.ascent();
		int const h = tm.height() + 2 * TEXT_TO_INSET_OFFSET;
		int const xframe = x + TEXT_TO_INSET_OFFSET / 2;
		if (pi.full_repaint)
			pi.pain.fillRectangle(xframe, yframe, w, h,
				pi.backgroundColor(this));

		if (drawFrame_)
			pi.pain.rectangle(xframe, yframe, w, h, frameColor());
	}
	ColorCode const old_color = pi.background_color;
	pi.background_color = pi.backgroundColor(this, false);

	tm.draw(pi, x + TEXT_TO_INSET_OFFSET, y);

	pi.background_color = old_color;
}