/////////////////////////////////////////////////////////////////////////
PainterInfo::PainterInfo(BufferView * bv, lyx::frontend::Painter & painter)
- : pain(painter), ltr_pos(false), change(), selected(false),
+ : pain(painter), ltr_pos(false), change(),
+ selected(false), selected_left(false), selected_right(false),
do_spellcheck(true), full_repaint(true), background_color(Color_background),
leftx(0), rightx(0)
{
Change change;
/// Whether the parent is selected as a whole
bool selected;
+ /// Whether the left/right margins are selected
+ bool selected_left, selected_right;
/// Whether the spell checker is enabled for the parent
bool do_spellcheck;
/// True when it can be assumed that the screen has been cleared
bool full_repaint;
/// Current background color
ColorCode background_color;
+ /// The left and right position of current line (inside margins).
/// Useful for drawing display math numbering
int leftx, rightx;
};
void RowPainter::paintInset(Row::Element const & e) const
{
- // Handle selection
+ // Handle selection (first left/right, then middle).
+ pi_.selected_left = pi_.selected
+ || (row_.isRTL() ? row_.end_margin_sel : row_.begin_margin_sel);
+ pi_.selected_right = pi_.selected
+ || (row_.isRTL() ? row_.begin_margin_sel : row_.end_margin_sel);
bool const pi_selected = pi_.selected;
Cursor const & cur = pi_.base.bv->cursor();
if (cur.selection() && cur.text() == &text_
dim.wid, dim.asc + dim.des, backgroundColor(pi));
return;
}
- // If there are numbers, the margins around the (displayed)
- // equation have to be cleared.
- if (numberedType())
- pi.pain.fillRectangle(pi.leftx, y - dim.asc,
- pi.rightx - pi.leftx, dim.height(), pi.background_color);
+
pi.pain.fillRectangle(x + 1, y - dim.asc + 1, dim.wid - 2,
- dim.asc + dim.des - 1, pi.backgroundColor(this));
+ dim.height() - 1, pi.backgroundColor(this));
}
}
// First draw the numbers
- ColorCode color = pi.selected && lyxrc.use_system_colors
- ? Color_selectiontext : standardColor();
- bool const really_change_color = pi.base.font.color() == Color_none;
- Changer dummy0 = really_change_color ? pi.base.font.changeColor(color)
- : noChange();
if (numberedType()) {
BufferParams::MathNumber const math_number = buffer().params().getMathNumber();
for (row_type row = 0; row < nrows(); ++row) {
Dimension dimnl;
mathed_string_dim(pi.base.font, nl, dimnl);
if (math_number == BufferParams::LEFT) {
+ ColorCode const col = pi.selected_left
+ ? Color_selectiontext
+ : pi.base.font.color();
+ Changer dummy0 = pi.base.font.changeColor(col);
if (dimnl.wid > x - pi.leftx)
yy += rowinfo(row).descent + dimnl.asc;
+ pi.pain.fillRectangle(pi.leftx, yy - dimnl.asc,
+ dimnl.width(), dimnl.height(),
+ pi.selected_left ? Color_selection : pi.background_color);
pi.draw(pi.leftx, yy, nl);
} else {
+ ColorCode const col = pi.selected_right
+ ? Color_selectiontext
+ : pi.base.font.color();
+ Changer dummy0 = pi.base.font.changeColor(col);
if (dimnl.wid > pi.rightx - x - dim.wid)
yy += rowinfo(row).descent + dimnl.asc;
+ pi.pain.fillRectangle(pi.rightx - dimnl.wid, yy - dimnl.asc,
+ dimnl.width(), dimnl.height(),
+ pi.selected_right ? Color_selection : pi.background_color);
pi.draw(pi.rightx - dimnl.wid, yy, nl);
}
}
}
// Then the equations
+ ColorCode color = pi.selected && lyxrc.use_system_colors
+ ? Color_selectiontext : standardColor();
+ bool const really_change_color = pi.base.font.color() == Color_none;
+ Changer dummy0 = really_change_color ? pi.base.font.changeColor(color)
+ : noChange();
Changer dummy1 = pi.base.changeFontSet(standardFont());
Changer dummy2 = pi.base.font.changeStyle(display() ? DISPLAY_STYLE
: TEXT_STYLE);