コード例 #1
0
ファイル: InsetFormulaMacro.cpp プロジェクト: djmitche/lyx
void InsetFormulaMacro::draw(PainterInfo & p, int x, int y) const
{
	// label
	Font font = p.base.font;
	font.setColor(Color_math);

	PainterInfo pi(p.base.bv, p.pain);
	pi.base.style = LM_ST_TEXT;
	pi.base.font  = font;

	int const a = y - dim_.asc + 1;
	int const w = dim_.wid - 2;
	int const h = dim_.height() - 2;

	// Color_mathbg used to be "AntiqueWhite" but is "linen" now, too
	pi.pain.fillRectangle(x, a, w, h, Color_mathmacrobg);
	pi.pain.rectangle(x, a, w, h, Color_mathframe);

	// FIXME
#if 0
	Cursor & cur = p.base.bv->cursor();
	if (cur.isInside(this))
		cur.drawSelection(pi);
#endif

	pi.pain.text(x + 2, y, prefix(), font);

	// body
	tmpl()->draw(pi,
		x + theFontMetrics(p.base.font).width(prefix()) + 5,
		y);

	setPosCache(pi, x, y);
}
コード例 #2
0
ファイル: InsetMathDelim.cpp プロジェクト: 315234/lyx-retina
void InsetMathDelim::draw(PainterInfo & pi, int x, int y) const
{
	Dimension const dim = dimension(*pi.base.bv);
	int const b = y - dim.asc;
	cell(0).draw(pi, x + dw_ + 4, y);
	mathed_draw_deco(pi, x + 4, b, dw_, dim.height(), left_);
	mathed_draw_deco(pi, x + dim.width() - dw_ - 4,
		b, dw_, dim.height(), right_);
	setPosCache(pi, x, y);
}
コード例 #3
0
ファイル: InsetPreview.cpp プロジェクト: 315234/lyx-retina
void InsetPreview::draw(PainterInfo & pi, int x, int y) const
{
	use_preview_ = previewState(pi.base.bv);

	if (use_preview_) {
		// one pixel gap in front
		preview_->draw(pi, x + 1 + TEXT_TO_INSET_OFFSET, y);
		setPosCache(pi, x, y);
		return;
	}
	InsetText::draw(pi, x, y);
}
コード例 #4
0
ファイル: InsetMathBig.cpp プロジェクト: apex-hughin/LyX
void InsetMathBig::draw(PainterInfo & pi, int x, int y) const
{
	Dimension const dim = dimension(*pi.base.bv);
	// mathed_draw_deco does not use the leading backslash, so remove it
	// (but don't use ltrim if this is the backslash delimiter).
	// Replace \| by \Vert (equivalent in LaTeX), since mathed_draw_deco
	// would treat it as |.
	docstring const delim = (delim_ == "\\|") ?  from_ascii("Vert") :
		(delim_ == "\\\\") ? from_ascii("\\") : support::ltrim(delim_, "\\");
	mathed_draw_deco(pi, x + 1, y - dim.ascent(), 4, dim.height(),
			 delim);
	setPosCache(pi, x, y);
}
コード例 #5
0
void Inset::drawMarkers2(PainterInfo & pi, int x, int y) const
{
	ColorCode pen_color = mouseHovered(pi.base.bv) || editing(pi.base.bv)?
		Color_mathframe : Color_mathcorners;

	drawMarkers(pi, x, y);
	Dimension const dim = dimension(*pi.base.bv);
	int const t = x + dim.width() - 1;
	int const a = y - dim.ascent();
	pi.pain.line(x, a + 3, x, a, pen_color);
	pi.pain.line(t, a + 3, t, a, pen_color);
	pi.pain.line(x, a, x + 3, a, pen_color);
	pi.pain.line(t - 3, a, t, a, pen_color);
	setPosCache(pi, x, y);
}
コード例 #6
0
void CommandInset::draw(PainterInfo & pi, int x, int y) const
{
	button_.draw(pi, x, y);
	setPosCache(pi, x, y);
}
コード例 #7
0
ファイル: InsetMathFrac.cpp プロジェクト: bsjung/Lyx
void InsetMathFrac::draw(PainterInfo & pi, int x, int y) const
{
	setPosCache(pi, x, y);
	Dimension const dim = dimension(*pi.base.bv);
	Dimension const dim0 = cell(0).dimension(*pi.base.bv);
	if (kind_ == UNIT || (kind_ == UNITFRAC && nargs() == 3)) {
		if (nargs() == 1) {
			ShapeChanger dummy2(pi.base.font, UP_SHAPE);
			cell(0).draw(pi, x + 1, y);
		} else if (nargs() == 2) {
			cell(0).draw(pi, x + 1, y);
			ShapeChanger dummy2(pi.base.font, UP_SHAPE);
			cell(1).draw(pi, x + dim0.width() + 5, y);
		} else {
			cell(2).draw(pi, x + 1, y);
			ShapeChanger dummy2(pi.base.font, UP_SHAPE);
			FracChanger dummy(pi.base);
			Dimension const dim1 = cell(1).dimension(*pi.base.bv);
			Dimension const dim2 = cell(2).dimension(*pi.base.bv);
			int xx = x + dim2.wid + 5;
			cell(0).draw(pi, xx + 2, 
					 y - dim0.des - 5);
			cell(1).draw(pi, xx  + dim0.width() + 5, 
					 y + dim1.asc / 2);
		}
	} else {
		FracChanger dummy(pi.base);
		Dimension const dim1 = cell(1).dimension(*pi.base.bv);
		int m = x + dim.wid / 2;
		if (kind_ == NICEFRAC) {
			cell(0).draw(pi, x + 2,
					y - dim0.des - 5);
			cell(1).draw(pi, x + dim0.width() + 5,
					y + dim1.asc / 2);
		} else if (kind_ == UNITFRAC) {
			ShapeChanger dummy2(pi.base.font, UP_SHAPE);
			cell(0).draw(pi, x + 2,	y - dim0.des - 5);
			cell(1).draw(pi, x + dim0.width() + 5, y + dim1.asc / 2);
		} else if (kind_ == FRAC || kind_ == ATOP || kind_ == OVER) {
			cell(0).draw(pi, m - dim0.wid / 2, y - dim0.des - 2 - 5);
			cell(1).draw(pi, m - dim1.wid / 2, y + dim1.asc + 2 - 5);
		} else if (kind_ == TFRAC) {
			// tfrac is in always in text size
			StyleChanger dummy2(pi.base, LM_ST_SCRIPT);
			cell(0).draw(pi, m - dim0.wid / 2, y - dim0.des - 2 - 5);
			cell(1).draw(pi, m - dim1.wid / 2, y + dim1.asc + 2 - 5);
		} else {
			// \cfrac and \dfrac are always in display size
			StyleChanger dummy2(pi.base, LM_ST_DISPLAY);
			if (kind_ == CFRAC || kind_ == DFRAC)
				cell(0).draw(pi, m - dim0.wid / 2, y - dim0.des - 2 - 5);
			else if (kind_ == CFRACLEFT)
				cell(0).draw(pi, x + 2, y - dim0.des - 2 - 5);
			else if (kind_ == CFRACRIGHT)
				cell(0).draw(pi, x + dim.wid - dim0.wid - 2,
					y - dim0.des - 2 - 5);
			cell(1).draw(pi, m - dim1.wid / 2, y + dim1.asc + 2 - 5);
		}
	}
	if (kind_ == NICEFRAC || kind_ == UNITFRAC) {
		// Diag line:
		int xx = x;
		if (nargs() == 3)
			xx += cell(2).dimension(*pi.base.bv).wid + 5;
		pi.pain.line(xx + dim0.wid,
				y + dim.des - 2,
				xx + dim0.wid + 5,
				y - dim.asc + 2, pi.base.font.color());
	}
	if (kind_ == FRAC || kind_ == CFRAC || kind_ == CFRACLEFT
		|| kind_ == CFRACRIGHT || kind_ == DFRAC
		|| kind_ == TFRAC || kind_ == OVER)
		pi.pain.line(x + 1, y - 5,
				x + dim.wid - 2, y - 5, pi.base.font.color());
	drawMarkers(pi, x, y);
}