#7120 the painter expects a float as line_thickness_, simplify initial computation of line_thickness_ and line_offset_

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@36890 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Stephan Witt 2010-12-15 07:12:42 +00:00
parent 832d6cd7e1
commit ad76c66e33
2 changed files with 13 additions and 10 deletions

View File

@ -60,16 +60,19 @@ RowPainter::RowPainter(PainterInfo & pi,
row_(row), pit_(pit), par_(text.paragraphs()[pit]),
pm_(text_metrics_.parMetrics(pit)),
bidi_(bidi), change_(pi_.change_),
xo_(x), yo_(y), width_(text_metrics_.width())
xo_(x), yo_(y), width_(text_metrics_.width()),
line_thickness_(1.0), line_offset_(2)
{
// derive the line thickness from zoom factor
// the zoom is given in percent
double const scale_ = lyxrc.zoom / 100.0;
bidi_.computeTables(par_, pi_.base.bv->buffer(), row_);
// (increase thickness at 150%, 250% etc.)
line_thickness_ = scale_ < 1.0 ? 1.0 : int(scale_ + 0.5);
line_offset_ = int(1.5 * line_thickness_) + (scale_ < 1.0 ? 1 : 2);
if (lyxrc.zoom >= 100) {
// derive the line thickness from zoom factor
// the zoom is given in percent
// (increase thickness at 150%, 250% etc.)
line_thickness_ = (float)(int((lyxrc.zoom + 50) / 100.0));
// adjust line_offset_ too
line_offset_ = int(2 * line_thickness_) + 1;
}
x_ = row_.x + xo_;
@ -367,7 +370,7 @@ void RowPainter::paintMisspelledMark(double orig_x, bool changed)
{
// if changed the misspelled marker gets placed slightly lower than normal
// to avoid drawing at the same vertical offset
int const y = yo_ + (changed ? line_thickness_ + 1 : 0) + line_offset_;
int const y = yo_ + (changed ? int(line_thickness_ + 1.0) : 0) + line_offset_;
pi_.pain.line(int(orig_x), y, int(x_), y, Color_error,
Painter::line_onoffdash, line_thickness_);
}

View File

@ -104,7 +104,7 @@ private:
int const yo_; // current baseline
double x_;
int width_;
int line_thickness_;
float line_thickness_;
int line_offset_;
};