On Fri, Feb 11, 2005 at 06:42:01PM +0100, [EMAIL PROTECTED] wrote:
> http://bugzilla.lyx.org/show_bug.cgi?id=1804
> 
>            Summary: inlined ERTs can have zero width
>            Product: LyX
>            Version: 1.4.0cvs
>           Platform: Other
>         OS/Version: other
>             Status: NEW
>           Severity: normal
>           Priority: P2
>          Component: insettext
>         AssignedTo: [EMAIL PROTECTED]
>         ReportedBy: [EMAIL PROTECTED]
>          QAContact: [EMAIL PROTECTED]
> 
> 
> Zero width objects are hard to play with. We need some buffer so they can be
> seen, and manipulated.

Patch attached. It's the same as for #1801

Please apply.


--- bufferview_funcs.C.orig     2005-02-13 07:43:47.000000000 +0100
+++ bufferview_funcs.C  2005-02-13 07:43:52.000000000 +0100
@@ -174,7 +174,8 @@
                y += par.rows()[rit].height();
        y += par.rows()[par.pos2row(sl.pos())].ascent();
        x += dit.bottom().text()->cursorX(dit.bottom());
-       return Point(x,y);
+       --x;
+       return Point(x, y);
 }
 
 
--- insets/insettext.h.orig     2005-02-13 07:47:41.000000000 +0100
+++ insets/insettext.h  2005-02-13 07:47:44.000000000 +0100
@@ -165,6 +165,8 @@
        int frame_color_;
        ///
        mutable lyx::pit_type old_pit;
+       ///
+       static int border_;
 public:
        ///
        mutable LyXText text_;
--- insets/insettext.C.orig     2005-02-12 17:38:49.000000000 +0100
+++ insets/insettext.C  2005-02-13 07:39:59.000000000 +0100
@@ -70,6 +70,9 @@
 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() : text_(0)
+InsetText::InsetText()
+       : text_(0)
 {}
 
 
@@ -168,9 +172,14 @@
 {
        //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 @@
        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::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::getCursorPos(CursorSlice const & sl, int & x, int & y) const
 {
-       x = text_.cursorX(sl);
+       x = text_.cursorX(sl) + border_;
        y = text_.cursorY(sl);
 }
 


----- End forwarded message -----

-- 

Reply via email to