]> git.lyx.org Git - lyx.git/commitdiff
Fix the painting of the labels of InsetCaption insets.
authorVincent van Ravesteijn <vfr@lyx.org>
Wed, 1 Dec 2010 00:32:30 +0000 (00:32 +0000)
committerVincent van Ravesteijn <vfr@lyx.org>
Wed, 1 Dec 2010 00:32:30 +0000 (00:32 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@36639 a592a061-630c-0410-9148-cb99ea01b6c8

src/insets/InsetCaption.cpp
src/insets/InsetCaption.h

index a1b084fe4766362963a63abd32f56ade768b64eb..b857af4848cdc274c9f8d9a066f9948ca80c610a 100644 (file)
@@ -32,6 +32,7 @@
 #include "OutputParams.h"
 #include "Paragraph.h"
 #include "TextClass.h"
+#include "TextMetrics.h"
 #include "TocBackend.h"
 
 #include "frontends/FontMetrics.h"
@@ -140,6 +141,15 @@ void InsetCaption::metrics(MetricsInfo & mi, Dimension & dim) const
 }
 
 
+void InsetCaption::drawBackground(PainterInfo & pi, int x, int y) const
+{
+       TextMetrics & tm = pi.base.bv->textMetrics(&text());
+       int const h = tm.height() + 2 * TEXT_TO_INSET_OFFSET;
+       int const yy = y - TEXT_TO_INSET_OFFSET - tm.ascent();
+       pi.pain.fillRectangle(x, yy, labelwidth_, h, Color_red);
+}
+
+
 void InsetCaption::draw(PainterInfo & pi, int x, int y) const
 {
        // We must draw the label, we should get the label string
@@ -153,7 +163,8 @@ void InsetCaption::draw(PainterInfo & pi, int x, int y) const
        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);
-       pi.pain.text(x, y, full_label_, pi.base.font);
+       int const xx = x + TEXT_TO_INSET_OFFSET;
+       pi.pain.text(xx, y, full_label_, pi.base.font);
        InsetText::draw(pi, x + labelwidth_, y);
        pi.base.font = tmpfont;
 }
index 708f0223be472b073631b6022152783f167a6566..6499e0b895fa03443a1e477204803a1002555446 100644 (file)
@@ -52,6 +52,8 @@ private:
        bool descendable(BufferView const &) const { return true; }
        ///
        void metrics(MetricsInfo & mi, Dimension & dim) const;
+       ///     
+       void drawBackground(PainterInfo & pi, int x, int y) const;
        ///
        void draw(PainterInfo & pi, int x, int y) const;
        ///