]> git.lyx.org Git - lyx.git/blobdiff - src/insets/InsetCaption.cpp
Rename LATEX debug level to OUTFILE and use it for DocBook, HTML, and XML messages.
[lyx.git] / src / insets / InsetCaption.cpp
index f97fadef60150b37799c3e33eb1b9684b2926757..5373210a6dfc1af51da8aaf8c43950f8080804b6 100644 (file)
@@ -82,7 +82,8 @@ void InsetCaption::cursorPos(BufferView const & bv,
                CursorSlice const & sl, bool boundary, int & x, int & y) const
 {
        InsetText::cursorPos(bv, sl, boundary, x, y);
-       x += labelwidth_;
+       if (!rtl_)
+               x += labelwidth_;
 }
 
 
@@ -110,8 +111,6 @@ void InsetCaption::addToToc(DocIterator const & cpit, bool output_active,
 
 void InsetCaption::metrics(MetricsInfo & mi, Dimension & dim) const
 {
-       FontInfo tmpfont = mi.base.font;
-       mi.base.font = mi.base.bv->buffer().params().getFont().fontInfo();
        labelwidth_ = theFontMetrics(mi.base.font).width(full_label_);
        // add some space to separate the label from the inset text
        labelwidth_ += leftOffset(mi.base.bv) + rightOffset(mi.base.bv);
@@ -120,7 +119,6 @@ void InsetCaption::metrics(MetricsInfo & mi, Dimension & dim) const
        // Correct for button and label width
        mi.base.textwidth -= dim.wid;
        InsetText::metrics(mi, textdim);
-       mi.base.font = tmpfont;
        mi.base.textwidth += dim.wid;
        dim.des = max(dim.des - textdim.asc + dim.asc, textdim.des);
        dim.asc = textdim.asc;
@@ -133,6 +131,8 @@ void InsetCaption::drawBackground(PainterInfo & pi, int x, int y) const
        TextMetrics & tm = pi.base.bv->textMetrics(&text());
        int const h = tm.height() + topOffset(pi.base.bv) + bottomOffset(pi.base.bv);
        int const yy = y - topOffset(pi.base.bv) - tm.ascent();
+       if (rtl_)
+               x+= + dimension(*pi.base.bv).wid - labelwidth_;
        pi.pain.fillRectangle(x, yy, labelwidth_, h, pi.backgroundColor(this));
 }
 
@@ -147,16 +147,22 @@ void InsetCaption::draw(PainterInfo & pi, int x, int y) const
 
        // Answer: the text inset (in buffer_funcs.cpp: setCaption).
 
+       rtl_ = !pi.ltr_pos;
        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);
        if (is_deleted_)
                pi.base.font.setStrikeout(FONT_ON);
        else if (isChanged() && lyxrc.ct_additions_underlined)
                pi.base.font.setUnderbar(FONT_ON);
-       int const xx = x + leftOffset(pi.base.bv);
-       pi.pain.text(xx, y, full_label_, pi.base.font);
-       InsetText::draw(pi, x + labelwidth_, y);
+       int const lo = leftOffset(pi.base.bv);
+       if (rtl_) {
+               InsetText::draw(pi, x, y);
+               pi.pain.text(x + dimension(*pi.base.bv).wid - labelwidth_ + lo,
+                            y, full_label_, pi.base.font);
+       } else {
+               pi.pain.text(x + lo, y, full_label_, pi.base.font);
+               InsetText::draw(pi, x + labelwidth_, y);
+       }
        pi.base.font = tmpfont;
 }
 
@@ -432,10 +438,9 @@ void InsetCaption::updateBuffer(ParIterator const & it, UpdateType utype, bool c
                                sec += from_ascii(" ");
                        sec += bformat(from_ascii("(%1$s)"), labelstring);
                }
-               if (!sec.empty())
-                       full_label_ = bformat(from_ascii("%1$s %2$s: "), name, sec);
-               else
-                       full_label_ = bformat(from_ascii("%1$s #: "), name);
+               if (sec.empty())
+                       sec = from_ascii("#");
+               full_label_ = bformat(master.B_("%1$s %2$s: [[Caption label (ex. Figure 1: )]]"), name, sec);
        }
 
        // Do the real work now.