void InsetMathChar::draw(PainterInfo & pi, int x, int y) const { //lyxerr << "drawing '" << char_ << "' font: " << pi.base.fontname << endl; int const em = mathed_char_width(pi.base.font, 'M'); if (isBinaryOp(char_)) x += static_cast<int>(0.25*em+0.5); else if (char_ == '\'') x += static_cast<int>(0.0833*em+0.5); #if 1 if (char_ == '=' && has_math_fonts) { FontSetChanger dummy(pi.base, "cmr"); pi.draw(x, y, char_); } else if ((char_ == '>' || char_ == '<') && has_math_fonts) { FontSetChanger dummy(pi.base, "cmm"); pi.draw(x, y, char_); } else if (!slanted(char_) && pi.base.fontname == "mathnormal") { ShapeChanger dummy(pi.base.font, UP_SHAPE); pi.draw(x, y, char_); } else { pi.draw(x, y, char_); } #else drawChar(pain, font_, x, y, char_); #endif }
void InsetMathSpecialChar::draw(PainterInfo & pi, int x, int y) const { if (pi.base.fontname == "mathnormal") { ShapeChanger dummy(pi.base.font, UP_SHAPE); pi.draw(x, y, char_); } else { pi.draw(x, y, char_); } }
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); }
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)); }
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)); }
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; }
void InsetMathSymbol::draw(PainterInfo & pi, int x, int y) const { //lyxerr << "metrics: symbol: '" << sym_->name // << "' in font: '" << sym_->inset // << "' drawn as: '" << sym_->draw // << "'" << endl; int const em = mathed_char_width(pi.base.font, 'M'); if (isRelOp()) x += static_cast<int>(0.25*em+0.5); else x += static_cast<int>(0.0833*em+0.5); FontSetChanger dummy(pi.base, sym_->inset.c_str()); pi.draw(x, y - h_, sym_->draw); }
void InsetCaption::draw(PainterInfo & pi, int x, int y) const { // We must draw the label, we should get the label string // from the enclosing float inset. // The question is: Who should draw the label, the caption inset, // the text inset or the paragraph? // We should also draw the float number (Lgb) // Answer: the text inset (in buffer_funcs.cpp: setCaption). FontInfo tmpfont = pi.base.font; pi.base.font = pi.base.bv->buffer().params().getFont().fontInfo(); pi.base.font.setColor(pi.textColor(pi.base.font.color()).baseColor); int const xx = x + TEXT_TO_INSET_OFFSET; pi.pain.text(xx, y, full_label_, pi.base.font); InsetText::draw(pi, x + labelwidth_, y); pi.base.font = tmpfont; }
void InsetMathNumber::draw(PainterInfo & pi, int x, int y) const { pi.draw(x, y, str_); }
void InsetMathString::draw(PainterInfo & pi, int x, int y) const { pi.draw(x, y, str_); }