]> git.lyx.org Git - features.git/commitdiff
fix bug 1798 (from Andr�)
authorGeorg Baum <Georg.Baum@post.rwth-aachen.de>
Tue, 15 Feb 2005 19:53:42 +0000 (19:53 +0000)
committerGeorg Baum <Georg.Baum@post.rwth-aachen.de>
Tue, 15 Feb 2005 19:53:42 +0000 (19:53 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@9640 a592a061-630c-0410-9148-cb99ea01b6c8

src/ChangeLog
src/bufferview_funcs.C
src/insets/ChangeLog
src/insets/insettext.C
src/insets/insettext.h

index 4c4d58568b9305db6e064c6e9adec9236a34e7ee..a07b6a14b494778a876727e5c26d4be856cc63ec 100644 (file)
@@ -3,6 +3,10 @@
        * rowpainter.C (paintText): Ensure that "paragraphs().size() - 1"
        can be used meaningfully in a comparison.
 
+2005-02-13  André Pönitz  <poenitz@gmx.net>
+
+       * bufferview_funcs.C (coordOffset): improve cursor drawing
+
 2005-02-13  André Pönitz  <poenitz@gmx.net>
 
        * Cursor.[Ch] (fixIfBroken): new method, try to fix a broken cursor
index 8032e6cdacd7c55662ea69db325edbe0e8da0aea..74688ae6b43e7459a1a77b96ba84d6f795005fa5 100644 (file)
@@ -174,7 +174,10 @@ Point coordOffset(DocIterator const & dit)
                y += par.rows()[rit].height();
        y += par.rows()[par.pos2row(sl.pos())].ascent();
        x += dit.bottom().text()->cursorX(dit.bottom());
-       return Point(x,y);
+       // The following correction should not be there at all.
+       // The cusor looks much better with the -1, though.
+       --x;
+       return Point(x, y);
 }
 
 
index 39254ffbf6c21a98774d93b50695f22c90ac6676..711a3381e4a7a7558b43411bd74c6f7943cb2835 100644 (file)
@@ -1,3 +1,9 @@
+2005-02-13  André Pönitz  <poenitz@gmx.net>
+
+       * insettext.[Ch] (border_): new 
+       * insettext.C (metrics, draw, drawFrame, clearInset, getCursorPos):
+       use border_
+
 2005-02-14  Angus Leeming  <leeming@lyx.org>
 
        * insetlatexaccent.C (draw): squash a couple of MSVC warnings
index f3c7a5450f573a39b106b5aa424797fe87615585..7de2edf1e1c80094d8cde29b2f207c2704f0214c 100644 (file)
@@ -70,6 +70,9 @@ using std::ostream;
 using std::vector;
 
 
+int InsetText::border_ = 2;
+
+
 InsetText::InsetText(BufferParams const & bp)
        : drawFrame_(false), frame_color_(LColor::insetframe), text_(0)
 {
@@ -92,7 +95,8 @@ InsetText::InsetText(InsetText const & in)
 }
 
 
-InsetText::InsetText() : text_(0)
+InsetText::InsetText()
+       : text_(0)
 {}
 
 
@@ -168,9 +172,14 @@ void InsetText::metrics(MetricsInfo & mi, Dimension & dim) const
 {
        //lyxerr << "InsetText::metrics: width: " << mi.base.textwidth << endl;
        setViewCache(mi.base.bv);
+       mi.base.textwidth -= 2 * border_;
        font_ = mi.base.font;
        text_.font_ = mi.base.font;
        text_.metrics(mi, dim);
+       dim.asc += border_;
+       dim.des += border_;
+       dim.wid += 2 * border_;
+       mi.base.textwidth += 2 * border_;
        dim_ = dim;
 }
 
@@ -185,10 +194,7 @@ void InsetText::draw(PainterInfo & pi, int x, int y) const
        bv->hideCursor();
 
        x += scroll();
-       //y -= text_.ascent();
-
-
-       text_.draw(pi, x, y);
+       text_.draw(pi, x + border_, y);
 
        if (drawFrame_)
                drawFrame(pi.pain, x, y);
@@ -206,18 +212,18 @@ void InsetText::drawSelection(PainterInfo & pi, int x, int y) const
 
 void InsetText::drawFrame(Painter & pain, int x, int y) const
 {
-       int const w = max(1, text_.width());
-       int const h = text_.height();
-       int const a = text_.ascent();
+       int const w = text_.width() + border_;
+       int const a = text_.ascent() + border_;
+       int const h = a + text_.descent() + border_;
        pain.rectangle(x, y - a, w, h, frameColor());
 }
 
 
 void InsetText::clearInset(Painter & pain, int x, int y) const
 {
-       int const w = text_.width();
-       int const h = text_.height();
-       int const a = text_.ascent();
+       int const w = text_.width() + border_;
+       int const a = text_.ascent() + border_;
+       int const h = a + text_.descent() + border_;
        pain.fillRectangle(x, y - a, w, h, backgroundColor());
 }
 
@@ -356,7 +362,7 @@ void InsetText::validate(LaTeXFeatures & features) const
 
 void InsetText::getCursorPos(CursorSlice const & sl, int & x, int & y) const
 {
-       x = text_.cursorX(sl);
+       x = text_.cursorX(sl) + border_;
        y = text_.cursorY(sl);
 }
 
index ad8664f1ab3abdcdb81b71dc0dcc06fa55cd2036..6a26d2672bd07efd6b0711625727926c9da8c15d 100644 (file)
@@ -165,6 +165,8 @@ private:
        int frame_color_;
        ///
        mutable lyx::pit_type old_pit;
+       ///
+       static int border_;
 public:
        ///
        mutable LyXText text_;