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