]> git.lyx.org Git - lyx.git/blob - src/RowPainter.cpp
Revert "Fix display of a math hull inset in a tight inset"
[lyx.git] / src / RowPainter.cpp
1 /**
2  * \file RowPainter.cpp
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author various
7  * \author John Levon
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 #include <config.h>
13
14 #include "RowPainter.h"
15
16 #include "Buffer.h"
17 #include "CoordCache.h"
18 #include "Cursor.h"
19 #include "BufferParams.h"
20 #include "BufferView.h"
21 #include "Bullet.h"
22 #include "Changes.h"
23 #include "Language.h"
24 #include "Layout.h"
25 #include "LyXRC.h"
26 #include "Row.h"
27 #include "MetricsInfo.h"
28 #include "Paragraph.h"
29 #include "ParagraphList.h"
30 #include "ParagraphParameters.h"
31 #include "Text.h"
32 #include "TextMetrics.h"
33
34 #include "frontends/FontMetrics.h"
35 #include "frontends/Painter.h"
36
37 #include "support/debug.h"
38 #include "support/gettext.h"
39 #include "support/lassert.h"
40
41 #include <algorithm>
42
43 using namespace std;
44
45 namespace lyx {
46
47 using frontend::Painter;
48 using frontend::FontMetrics;
49
50
51 RowPainter::RowPainter(PainterInfo & pi,
52         Text const & text, Row const & row, int x, int y)
53         : pi_(pi), text_(text),
54           tm_(pi_.base.bv->textMetrics(&text)),
55           row_(row), par_(text.paragraphs()[row.pit()]),
56           xo_(x), yo_(y)
57 {
58         x_ = row_.left_margin + xo_;
59
60         //lyxerr << "RowPainter: x: " << x_ << " xo: " << xo_ << " yo: " << yo_ << endl;
61         //row_.dump();
62
63         LBUFERR(row.pit() >= 0);
64         LBUFERR(row.pit() < int(text.paragraphs().size()));
65 }
66
67
68 FontInfo RowPainter::labelFont(bool end) const
69 {
70         FontInfo f = tm_.labelDisplayFont(row_.pit()).fontInfo();
71         // selected text?
72         if ((end ? row_.end_margin_sel : row_.begin_margin_sel)
73             || pi_.selected)
74                 f.setPaintColor(Color_selectiontext);
75         return f;
76 }
77
78
79 // If you want to debug inset metrics uncomment the following line:
80 //#define DEBUG_METRICS
81 // This draws green lines around each inset.
82
83
84 void RowPainter::paintInset(Row::Element const & e) const
85 {
86         // Handle selection (first left/right, then middle).
87         pi_.selected_left = pi_.selected
88                             || (row_.isRTL() ? row_.end_margin_sel : row_.begin_margin_sel);
89         pi_.selected_right = pi_.selected
90                              || (row_.isRTL() ? row_.begin_margin_sel : row_.end_margin_sel);
91         bool const pi_selected = pi_.selected;
92         Cursor const & cur = pi_.base.bv->cursor();
93         if (cur.selection() && cur.text() == &text_
94                 && cur.normalAnchor().text() == &text_)
95                 pi_.selected = row_.sel_beg <= e.pos && row_.sel_end > e.pos;
96
97         LASSERT(e.inset, return);
98         // Backup full_repaint status because some insets (InsetTabular)
99         // requires a full repaint
100         bool const pi_full_repaint = pi_.full_repaint;
101         bool const pi_do_spellcheck = pi_.do_spellcheck;
102         Change const pi_change = pi_.change;
103
104         pi_.base.font = e.inset->inheritFont() ? e.font.fontInfo() :
105                 pi_.base.bv->buffer().params().getFont().fontInfo();
106         pi_.base.outer_font = e.font.fontInfo();
107         pi_.ltr_pos = !e.font.isVisibleRightToLeft();
108         pi_.change = pi_.change.changed() ? pi_.change : e.change;
109         pi_.do_spellcheck &= e.inset->allowSpellCheck();
110
111         int const x1 = int(x_);
112         pi_.base.bv->coordCache().insets().add(e.inset, x1, yo_);
113         // insets are painted completely. Recursive
114         // FIXME: it is wrong to completely paint the background
115         // if we want to do single row painting.
116         e.inset->drawBackground(pi_, x1, yo_);
117         e.inset->drawSelection(pi_, x1, yo_);
118         e.inset->draw(pi_, x1, yo_);
119         paintTextDecoration(e);
120
121         // Restore full_repaint status.
122         pi_.full_repaint = pi_full_repaint;
123         pi_.change = pi_change;
124         pi_.do_spellcheck = pi_do_spellcheck;
125         pi_.selected = pi_selected;
126
127 #ifdef DEBUG_METRICS
128         Dimension const & dim = pi_.base.bv->coordCache().insets().dim(e.inset);
129         int const x2 = x1 + dim.wid;
130         int const y1 = yo_ + dim.des;
131         int const y2 = yo_ - dim.asc;
132         pi_.pain.line(x1, y1, x1, y2, Color_green);
133         pi_.pain.line(x1, y1, x2, y1, Color_green);
134         pi_.pain.line(x2, y1, x2, y2, Color_green);
135         pi_.pain.line(x1, y2, x2, y2, Color_green);
136 #endif
137 }
138
139
140 void RowPainter::paintLanguageMarkings(Row::Element const & e) const
141 {
142         paintForeignMark(e);
143         paintNoSpellingMark(e);
144 }
145
146
147 void RowPainter::paintForeignMark(Row::Element const & e) const
148 {
149         Language const * lang = e.font.language();
150         if (!lyxrc.mark_foreign_language)
151                 return;
152         if (lang == latex_language)
153                 return;
154         if (lang == pi_.base.bv->buffer().params().language)
155                 return;
156
157         int const desc = e.inset ? e.dim.descent() : 0;
158         int const y = yo_ + min(3 * pi_.base.solidLineOffset() / 2 + desc,
159                                 row_.descent() - 1);
160         pi_.pain.line(int(x_), y, int(x_ + e.full_width() - 1), y, Color_language,
161                       Painter::line_solid, pi_.base.solidLineThickness());
162 }
163
164
165 void RowPainter::paintNoSpellingMark(Row::Element const & e) const
166 {
167         //if (!lyxrc.mark_no_spelling)
168         //      return;
169         if (e.font.language() == latex_language)
170                 return;
171         if (e.font.fontInfo().nospellcheck() != FONT_ON)
172                 return;
173
174         // We at the same voffset than the misspelled mark, since
175         // these two are mutually exclusive
176         int const desc = e.inset ? e.dim.descent() : 0;
177         int y = yo_ + pi_.base.solidLineOffset() + desc
178                 + pi_.base.solidLineThickness()
179                 + (e.change.changed() ? pi_.base.solidLineThickness() + 1 : 0)
180                 + 1;
181         // Make sure that the mark does not go below the row rectangle
182         y = min(y, yo_ + row_.descent() - 1);
183
184         pi_.pain.line(int(x_), y, int(x_ + e.full_width()), y, Color_language,
185                       Painter::line_onoffdash, pi_.base.solidLineThickness());
186 }
187
188
189 void RowPainter::paintMisspelledMark(Row::Element const & e) const
190 {
191         if (e.font.fontInfo().nospellcheck() == FONT_ON)
192                 return;
193         // if changed the misspelled marker gets placed slightly lower than normal
194         // to avoid drawing at the same vertical offset
195         FontMetrics const & fm = theFontMetrics(e.font);
196         int const thickness = max(fm.lineWidth(), 2);
197         int y = yo_ + pi_.base.solidLineOffset() + pi_.base.solidLineThickness()
198                 + (e.change.changed() ? pi_.base.solidLineThickness() + 1 : 0)
199                 + 1 + thickness / 2;
200         // Make sure that the mark does not go below the row rectangle
201         y = min(y, yo_ + row_.descent() - 1);
202
203         //FIXME: this could be computed only once, it is probably not costly.
204         // check for cursor position
205         // don't draw misspelled marker for words at cursor position
206         // we don't want to disturb the process of text editing
207         DocIterator const nw = pi_.base.bv->cursor().newWord();
208         pos_type cpos = -1;
209         if (!nw.empty() && par_.id() == nw.paragraph().id()) {
210                 cpos = nw.pos();
211                 if (cpos > 0 && cpos == par_.size() && !par_.isWordSeparator(cpos-1))
212                         --cpos;
213                 else if (cpos > 0 && par_.isWordSeparator(cpos))
214                         --cpos;
215         }
216
217         pos_type pos = e.pos;
218         while (pos < e.pos + pos_type(e.str.length())) {
219                 if (!par_.isMisspelled(pos)) {
220                         ++pos;
221                         continue;
222                 }
223
224                 FontSpan const & range = par_.getSpellRange(pos);
225
226                 // Skip element which are being edited
227                 if (range.contains(cpos)) {
228                         // the range includes the last element
229                         pos = range.last + 1;
230                         continue;
231                 }
232
233                 int x1 = fm.pos2x(e.str, range.first - e.pos,
234                                   e.isRTL(), e.extra);
235                 int x2 = fm.pos2x(e.str, min(range.last - e.pos + 1,
236                                                                          pos_type(e.str.length())),
237                                                                          e.isRTL(), e.extra);
238                 if (x1 > x2)
239                         swap(x1, x2);
240
241                 pi_.pain.line(int(x_ + x1), y, int(x_ + x2), y,
242                               Color_error,
243                               Painter::line_onoffdash, thickness);
244                 pos = range.last + 1;
245         }
246 }
247
248
249 void RowPainter::paintStringAndSel(Row::Element const & e) const
250 {
251         // at least part of text selected?
252         bool const some_sel = (e.endpos >= row_.sel_beg && e.pos < row_.sel_end)
253                 || pi_.selected;
254         // all the text selected?
255         bool const all_sel = (e.pos >= row_.sel_beg && e.endpos < row_.sel_end)
256                 || pi_.selected;
257
258         if (all_sel || e.change.changed()) {
259                 Font copy = e.font;
260                 Color const col = e.change.changed() ? e.change.color()
261                                                      : Color_selectiontext;
262                 copy.fontInfo().setPaintColor(col);
263                 pi_.pain.text(int(x_), yo_, e.str, copy, e.extra, e.full_width());
264         } else if (!some_sel) {
265                 pi_.pain.text(int(x_), yo_, e.str, e.font, e.extra, e.full_width());
266         } else {
267                 pi_.pain.text(int(x_), yo_, e.str, e.font, Color_selectiontext,
268                               max(row_.sel_beg, e.pos) - e.pos,
269                               min(row_.sel_end, e.endpos) - e.pos,
270                               e.extra, e.full_width());
271         }
272 }
273
274
275 void RowPainter::paintTextDecoration(Row::Element const & e) const
276 {
277         // element selected?
278         bool const sel = (e.pos >= row_.sel_beg && e.endpos <= row_.sel_end)
279                 || pi_.selected;
280         FontInfo copy = e.font.fontInfo();
281         if (sel || e.change.changed()) {
282                 Color const col = e.change.changed() ? e.change.color()
283                                                      : Color_selectiontext;
284                 copy.setPaintColor(col);
285         }
286         pi_.pain.textDecoration(copy, int(x_), yo_, int(e.full_width()));
287 }
288
289
290 void RowPainter::paintChange(Row::Element const & e) const
291 {
292         e.change.paintCue(pi_, x_, yo_, x_ + e.full_width(), e.font.fontInfo());
293 }
294
295
296 void RowPainter::paintChangeBar() const
297 {
298         int const x = pi_.base.bv->leftMargin() - pi_.base.bv->zoomedPixels(7);
299         Dimension const & cdim = row_.contents_dim();
300         pi_.pain.fillRectangle(x, yo_ - cdim.ascent(),
301                                3, cdim.height(), Color_changebar);
302 }
303
304
305 void RowPainter::paintAppendix() const
306 {
307         // only draw the appendix frame once (for the main text)
308         if (!par_.params().appendix() || !text_.isMainText())
309                 return;
310
311         int y = yo_ - row_.ascent();
312
313         if (par_.params().startOfAppendix())
314                 y += 2 * defaultRowHeight();
315
316         pi_.pain.line(1, y, 1, yo_ + row_.height(), Color_appendix);
317         pi_.pain.line(tm_.width() - 2, y, tm_.width() - 2, yo_ + row_.height(), Color_appendix);
318 }
319
320
321 void RowPainter::paintDepthBar() const
322 {
323         depth_type const depth = par_.getDepth();
324         ParagraphList const & pars = text_.paragraphs();
325
326         if (depth <= 0)
327                 return;
328
329         depth_type prev_depth = 0;
330         if (!tm_.isFirstRow(row_)) {
331                 pit_type pit2 = row_.pit();
332                 if (row_.pos() == 0)
333                         --pit2;
334                 prev_depth = pars[pit2].getDepth();
335         }
336
337         depth_type next_depth = 0;
338         if (!tm_.isLastRow(row_)) {
339                 pit_type pit2 = row_.pit();
340                 if (row_.endpos() >= pars[pit2].size())
341                         ++pit2;
342                 next_depth = pars[pit2].getDepth();
343         }
344
345         for (depth_type i = 1; i <= depth; ++i) {
346                 int const w = nestMargin() / 5;
347                 int x = int(xo_) + w * i;
348                 // only consider the changebar space if we're drawing outermost text
349                 if (text_.isMainText())
350                         x += pi_.base.bv->leftMargin() - changebarMargin();
351
352                 int const starty = yo_ - row_.ascent();
353                 int const h =  row_.height() - 1 - (i - next_depth - 1) * 3;
354
355                 pi_.pain.line(x, starty, x, starty + h, Color_depthbar);
356
357                 if (i > prev_depth)
358                         pi_.pain.fillRectangle(x, starty, w, 2, Color_depthbar);
359                 if (i > next_depth)
360                         pi_.pain.fillRectangle(x, starty + h, w, 2, Color_depthbar);
361         }
362 }
363
364
365 void RowPainter::paintAppendixStart(int y) const
366 {
367         FontInfo pb_font = sane_font;
368         pb_font.setColor(Color_appendix);
369         pb_font.decSize();
370
371         int w = 0;
372         int a = 0;
373         int d = 0;
374
375         docstring const label = _("Appendix");
376         theFontMetrics(pb_font).rectText(label, w, a, d);
377
378         int const text_start = int(xo_ + (tm_.width() - w) / 2);
379         int const text_end = text_start + w;
380
381         pi_.pain.rectText(text_start, y + d, label, pb_font, Color_none, Color_none);
382
383         pi_.pain.line(int(xo_ + 1), y, text_start, y, Color_appendix);
384         pi_.pain.line(text_end, y, int(xo_ + tm_.width() - 2), y, Color_appendix);
385 }
386
387
388 void RowPainter::paintTooLargeMarks(bool const left, bool const right) const
389 {
390         int const lwid = pi_.base.dottedLineThickness();
391         Dimension const & cdim = row_.contents_dim();
392         if (left) {
393                 int const x = pi_.base.bv->leftMargin() - lwid;
394                 pi_.pain.line(x, yo_ - cdim.ascent(), x, yo_ + cdim.descent(),
395                               Color_scroll, Painter::line_onoffdash, lwid);
396         }
397         if (right) {
398                 int const x = pi_.base.bv->workWidth() - pi_.base.bv->rightMargin();
399                 pi_.pain.line(x, yo_ - cdim.ascent(), x, yo_ + cdim.descent(),
400                               Color_scroll, Painter::line_onoffdash, lwid);
401         }
402 }
403
404
405 void RowPainter::paintFirst() const
406 {
407         Layout const & layout = par_.layout();
408
409         // start of appendix?
410         if (par_.params().startOfAppendix())
411             paintAppendixStart(yo_ - row_.ascent() + 2 * defaultRowHeight());
412
413         bool const is_first =
414                 text_.isFirstInSequence(row_.pit()) || !layout.isParagraphGroup();
415         //lyxerr << "paintFirst: " << par_.id() << " is_seq: " << is_seq << endl;
416
417         if (layout.labelIsInline()
418             && (layout.labeltype != LABEL_STATIC || is_first))
419                 paintLabel();
420         else if (is_first && layout.labelIsAbove())
421                 paintTopLevelLabel();
422 }
423
424
425 void RowPainter::paintLabel() const
426 {
427         docstring const & str = par_.labelString();
428         if (str.empty())
429                 return;
430
431         // different font for label separation and string
432         Layout const & layout = par_.layout();
433         FontInfo const font = labelFont(false);
434         FontMetrics const & fm = theFontMetrics(font);
435         FontInfo lfont = font;
436
437         // bullet?
438         if (layout.labeltype == LABEL_ITEMIZE && par_.itemdepth < 4) {
439                 // get label font size from document properties
440                 lfont.setSize(pi_.base.bv->buffer().params().user_defined_bullet(par_.itemdepth).getFontSize());
441                 // realize to avoid assertion
442                 lfont.realize(sane_font);
443         }
444
445         FontMetrics const & lfm = theFontMetrics(lfont);
446
447         int const x = row_.isRTL() ? row_.width() + fm.width(layout.labelsep)
448                                    : row_.left_margin - fm.width(layout.labelsep) - lfm.width(str);
449
450         pi_.pain.text(int(xo_) + x, yo_, str, lfont);
451 }
452
453
454 void RowPainter::paintTopLevelLabel() const
455 {
456         BufferParams const & bparams = pi_.base.bv->buffer().params();
457         ParagraphParameters const & pparams = par_.params();
458         Layout const & layout = par_.layout();
459         FontInfo const font = labelFont(false);
460         docstring const str = par_.labelString();
461         if (str.empty())
462                 return;
463
464         double spacing_val = 1.0;
465         if (!pparams.spacing().isDefault())
466                 spacing_val = pparams.spacing().getValue();
467         else
468                 spacing_val = bparams.spacing().getValue();
469
470         FontMetrics const & fm = theFontMetrics(font);
471
472         int const labeladdon = int(fm.maxHeight()
473                 * layout.spacing.getValue() * spacing_val);
474
475         int maxdesc =
476                 int(fm.maxDescent() * layout.spacing.getValue() * spacing_val
477                 + (layout.labelbottomsep * defaultRowHeight()));
478
479         double x = x_;
480         if (layout.labeltype == LABEL_CENTERED) {
481                 // The 'size + 1' is weird, but it makes sure that we get the
482                 // left margin of non-first row.
483                 int leftm = tm_.leftMargin(row_.pit(), par_.size() + 1);
484                 int rightm = tm_.rightMargin(row_.pit());
485                 if (row_.isRTL())
486                         swap(leftm, rightm);
487                 /* Currently, x points at row_.left_margin (which contains the
488                  * indent). First remove that, and then center the title with
489                  * respect to the left and right margins.
490                  */
491                 x += leftm - row_.left_margin + (tm_.width() - leftm -rightm) / 2
492                         - fm.width(str) / 2;
493         } else if (row_.isRTL()) {
494                 x = xo_ + tm_.width() - row_.right_margin - fm.width(str);
495         }
496         pi_.pain.text(int(x), yo_ - maxdesc - labeladdon, str, font);
497 }
498
499
500 void RowPainter::paintLast() const
501 {
502         int const endlabel = text_.getEndLabel(row_.pit());
503         switch (endlabel) {
504         case END_LABEL_BOX:
505         case END_LABEL_FILLED_BOX: {
506                 FontInfo font = labelFont(true);
507                 if (font.realColor() != Color_selectiontext)
508                         font.setPaintColor(Color_eolmarker);
509                 FontMetrics const & fm = theFontMetrics(font);
510                 int const size = int(0.75 * fm.maxAscent());
511                 int const y = yo_ - size;
512
513                 // If needed, move the box a bit to avoid overlapping with text.
514                 int x = 0;
515                 if (row_.isRTL()) {
516                         int const normal_x = nestMargin() + changebarMargin();
517                         x = min(normal_x, row_.left_margin - size - Inset::textOffset(pi_.base.bv));
518                 } else {
519                         int const normal_x = tm_.width() - row_.right_margin
520                                 - size - Inset::textOffset(pi_.base.bv);
521                         x = max(normal_x, row_.width());
522                 }
523
524                 if (endlabel == END_LABEL_BOX)
525                         pi_.pain.rectangle(int(xo_) + x, y, size, size, font.realColor());
526                 else
527                         pi_.pain.fillRectangle(int(xo_) + x, y, size, size, font.realColor());
528                 break;
529         }
530
531         case END_LABEL_STATIC: {
532                 FontInfo const font = labelFont(true);
533                 FontMetrics const & fm = theFontMetrics(font);
534                 docstring const & str = par_.layout().endlabelstring();
535                 double const x = row_.isRTL() ? row_.left_margin - fm.width(str) : row_.width();
536                 pi_.pain.text(xo_ + x, yo_, str, font);
537                 break;
538         }
539
540         case END_LABEL_NO_LABEL:
541                 break;
542         }
543 }
544
545
546 void RowPainter::paintOnlyInsets()
547 {
548         for (Row::Element const & e : row_) {
549                 if (e.type == Row::INSET) {
550                         paintInset(e);
551                         // The markings of foreign languages
552                         // and of text ignored for spellchecking
553                         paintLanguageMarkings(e);
554                         // change tracking (not for insets that handle it themselves)
555                         if (!e.inset->canPaintChange(*pi_.base.bv))
556                                 paintChange(e);
557                 }
558
559                 x_ += e.full_width();
560         }
561 }
562
563
564 void RowPainter::paintText()
565 {
566         for (Row::Element const & e : row_) {
567                 switch (e.type) {
568                 case Row::STRING:
569                 case Row::VIRTUAL:
570                         paintStringAndSel(e);
571
572                         // Paint the spelling marks if enabled.
573                         if (lyxrc.spellcheck_continuously && pi_.do_spellcheck && !pi_.pain.isNull())
574                                 paintMisspelledMark(e);
575                         break;
576
577                 case Row::INSET:
578                         paintInset(e);
579                         break;
580
581                 case Row::SPACE:
582                 case Row::MARGINSPACE:
583                         paintTextDecoration(e);
584                 }
585
586                 // The markings of foreign languages
587                 // and of text ignored for spellchecking
588                 paintLanguageMarkings(e);
589
590                 // change tracking (not for insets that handle it themselves)
591                 if (e.type != Row::INSET || ! e.inset->canPaintChange(*pi_.base.bv))
592                         paintChange(e);
593
594                 x_ += e.full_width();
595         }
596 }
597
598
599 void RowPainter::paintSelection() const
600 {
601         if (!row_.selection())
602                 return;
603
604         int const y1 = yo_ - row_.contents_dim().asc;
605         int const y2 = yo_ + row_.contents_dim().des;
606
607         // The top selection
608         if (row_.begin_margin_sel)
609                 pi_.pain.fillRectangle(int(xo_), yo_ - row_.ascent(),
610                                        tm_.width(), row_.ascent() - row_.contents_dim().asc,
611                                        Color_selection);
612
613         // The left margin selection
614         if (row_.isRTL() ? row_.end_margin_sel : row_.begin_margin_sel)
615                 pi_.pain.fillRectangle(int(xo_), y1, row_.left_margin, y2 - y1,
616                                        Color_selection);
617
618         // go through row and draw from RTL boundary to RTL boundary
619         double x = xo_ + row_.left_margin;
620         for (auto const & e : row_) {
621                 // These are the same tests as in paintStringAndSel, except
622                 // that all_sel has an additional clause that triggers for end
623                 // of paragraph markers. The clause was not used in
624                 // paintStringAndSel to avoid changing the drawing color.
625                 // at least part of text selected?
626                 bool const some_sel = (e.endpos >= row_.sel_beg && e.pos < row_.sel_end)
627                         || pi_.selected;
628                 // all the text selected?
629                 bool const all_sel = (e.pos >= row_.sel_beg && e.endpos < row_.sel_end)
630                     || (e.isVirtual() && e.pos == row_.endpos() && row_.end_margin_sel)
631                     || pi_.selected;
632
633                 if (all_sel) {
634                         // the 3rd argument is written like that to avoid rounding issues
635                         pi_.pain.fillRectangle(int(x), y1,
636                                                int(x + e.full_width()) - int(x), y2 - y1,
637                                                Color_selection);
638                 } else if (some_sel) {
639                         pos_type const from = min(max(row_.sel_beg, e.pos), e.endpos);
640                         pos_type const to = max(min(row_.sel_end, e.endpos), e.pos);
641                         double x1 = e.pos2x(from);
642                         double x2 = e.pos2x(to);
643                         if (x1 > x2)
644                                 swap(x1, x2);
645                         // the 3rd argument is written like that to avoid rounding issues
646                         pi_.pain.fillRectangle(int(x + x1), y1, int(x2 + x) - int(x1 + x),
647                                                y2 - y1, Color_selection);
648                 }
649                 x += e.full_width();
650         }
651
652         // the right margin selection
653         if (row_.isRTL() ? row_.begin_margin_sel : row_.end_margin_sel)
654                 pi_.pain.fillRectangle(int(x), y1,
655                                        int(xo_ + tm_.width()) - int(x), y2 - y1,
656                                        Color_selection);
657         // The bottom selection
658         if (row_.end_margin_sel)
659                 pi_.pain.fillRectangle(int(xo_), yo_ + row_.contents_dim().des,
660                                        tm_.width(), row_.descent() - row_.contents_dim().des,
661                                        Color_selection);
662 }
663
664
665 void RowPainter::paintBookmark(int num) const
666 {
667         BufferView const * bv = pi_.base.bv;
668         FontInfo fi = bv->buffer().params().getFont().fontInfo();
669         FontMetrics const & fm = theFontMetrics(fi);
670         fi.setColor(Color_bookmark);
671         // ❶ U+2776 DINGBAT NEGATIVE CIRCLED DIGIT ONE
672         char_type const ch = 0x2775 + num;
673         int const x = row_.isRTL()
674                 ? bv->workWidth() - bv->rightMargin() + (bv->defaultMargin() - fm.width(ch)) / 2
675                 : bv->leftMargin() - (bv->defaultMargin() + fm.width(ch)) / 2;
676         pi_.pain.text(x, yo_, ch, fi);
677 }
678
679
680 } // namespace lyx