]> git.lyx.org Git - lyx.git/commitdiff
Few more update text-inset issues + some fixes, see ChangeLog.
authorJürgen Vigna <jug@sad.it>
Wed, 5 Jul 2000 14:57:48 +0000 (14:57 +0000)
committerJürgen Vigna <jug@sad.it>
Wed, 5 Jul 2000 14:57:48 +0000 (14:57 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@859 a592a061-630c-0410-9148-cb99ea01b6c8

36 files changed:
ChangeLog
src/BufferView_pimpl.C
src/insets/figinset.C
src/insets/figinset.h
src/insets/inset.C
src/insets/insetbib.C
src/insets/insetbutton.C
src/insets/insetbutton.h
src/insets/insetcollapsable.C
src/insets/insetcollapsable.h
src/insets/insetcommand.C
src/insets/inseterror.C
src/insets/inseterror.h
src/insets/insetgraphics.C
src/insets/insetgraphics.h
src/insets/insetinfo.C
src/insets/insetinfo.h
src/insets/insetlatexaccent.C
src/insets/insetlatexaccent.h
src/insets/insetquotes.C
src/insets/insetquotes.h
src/insets/insetspecialchar.C
src/insets/insetspecialchar.h
src/insets/insettabular.C
src/insets/insettabular.h
src/insets/insettext.C
src/insets/insettext.h
src/insets/lyxinset.h
src/lyxfunc.C
src/mathed/formula.C
src/mathed/formula.h
src/mathed/formulamacro.C
src/mathed/formulamacro.h
src/paragraph.C
src/screen.C
src/text.C

index 5d8546c13d65c086ffc57d4ccc4dbdd51f41c861..7a55ceaf21f8ccbd1edcb3b42bcf023c824abe52 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2000-07-05  Juergen Vigna  <jug@sad.it>
+
+       * src/insets/lyxinset.h: changed Painter & in ascent(), descent()
+       calls to BufferView *.
+
+       * src/insets/insettext.C (checkAndActivateInset): small fix non
+       HIGHLY_EDITABLE insets should not be entered by cursor-move-over!
+
+       * src/insets/insetcommand.C (Read): Fixed as insets should read till
+       their \end_inset token!
+
 2000-07-04  edscott  <edscott@imp.mx>
 
        * src/lyxrc.C, src/lyxrc.h, src/BufferView_pimpl.C,
index 4204726eff9265d2a79772c5c844e3a66ad3c2a6..aad1957478cf1178f350ee8aa44bbe621536c278 100644 (file)
@@ -45,7 +45,7 @@ extern BufferList bufferlist;
 extern char ascii_type;
 
 extern void sigchldhandler(pid_t pid, int * status);
-extern int bibitemMaxWidth(Painter &, LyXFont const &);
+extern int bibitemMaxWidth(BufferView *, LyXFont const &);
 
 
 static inline
@@ -861,10 +861,9 @@ void BufferView::Pimpl::workAreaButtonRelease(int x, int y,
 
        // Maybe we want to edit a bibitem ale970302
        if (bv_->text->cursor.par()->bibkey && x < 20 + 
-           bibitemMaxWidth(bv_->painter(),
-                           textclasslist
-                           .TextClass(buffer_->
-                                      params.textclass).defaultfont())) {
+           bibitemMaxWidth(bv_, textclasslist.
+                           TextClass(buffer_->
+                                     params.textclass).defaultfont())) {
                bv_->text->cursor.par()->bibkey->Edit(bv_, 0, 0, 0);
        }
 
@@ -904,16 +903,16 @@ Inset * BufferView::Pimpl::checkInsetHit(LyXText * text, int & x, int & y,
                int start_x, end_x;
 
                if (is_rtl) {
-                       start_x = cursor.x() - tmpinset->width(bv_->painter(), font);
+                       start_x = cursor.x() - tmpinset->width(bv_, font);
                        end_x = cursor.x();
                } else {
                        start_x = cursor.x();
-                       end_x = cursor.x() + tmpinset->width(bv_->painter(), font);
+                       end_x = cursor.x() + tmpinset->width(bv_, font);
                }
 
                if (x > start_x && x < end_x
-                   && y_tmp > cursor.y() - tmpinset->ascent(bv_->painter(), font)
-                   && y_tmp < cursor.y() + tmpinset->descent(bv_->painter(), font)) {
+                   && y_tmp > cursor.y() - tmpinset->ascent(bv_, font)
+                   && y_tmp < cursor.y() + tmpinset->descent(bv_, font)) {
 #if 0
                        if (move_cursor && (tmpinset != bv_->the_locking_inset))
 #endif
@@ -936,15 +935,15 @@ Inset * BufferView::Pimpl::checkInsetHit(LyXText * text, int & x, int & y,
                int start_x, end_x;
 
                if (!is_rtl) {
-                       start_x = cursor.x() - tmpinset->width(bv_->painter(), font);
+                       start_x = cursor.x() - tmpinset->width(bv_, font);
                        end_x = cursor.x();
                } else {
                        start_x = cursor.x();
-                       end_x = cursor.x() + tmpinset->width(bv_->painter(), font);
+                       end_x = cursor.x() + tmpinset->width(bv_, font);
                }
                if (x > start_x && x < end_x
-                   && y_tmp > cursor.y() - tmpinset->ascent(bv_->painter(), font)
-                   && y_tmp < cursor.y() + tmpinset->descent(bv_->painter(), font)) {
+                   && y_tmp > cursor.y() - tmpinset->ascent(bv_, font)
+                   && y_tmp < cursor.y() + tmpinset->descent(bv_, font)) {
 #if 0
                        if (move_cursor && (tmpinset != bv_->the_locking_inset))
 #endif
index e546f7edbb4a77a819e83c7fef44dbe6f08a166e..f4a836b6ad21a0893f89bd61abe116978719651d 100644 (file)
@@ -1016,19 +1016,19 @@ InsetFig::~InsetFig()
 }
 
 
-int InsetFig::ascent(Painter &, LyXFont const &) const
+int InsetFig::ascent(BufferView *, LyXFont const &) const
 {
        return hgh + 3;
 }
 
 
-int InsetFig::descent(Painter &, LyXFont const &) const
+int InsetFig::descent(BufferView *, LyXFont const &) const
 {
        return 1;
 }
 
 
-int InsetFig::width(Painter &, LyXFont const &) const
+int InsetFig::width(BufferView *, LyXFont const &) const
 {
        return wid + 2;
 }
@@ -1085,7 +1085,7 @@ void InsetFig::draw(BufferView * bv, LyXFont const & f,
                font.setSize(LyXFont::SIZE_TINY);
                pain.text(int(x + 8), baseline - 4, msg, strlen(msg), font);
        }
-       x += width(pain, font);    // ?
+       x += width(bv, font);    // ?
 }
 
 
index 28830c735e67af69b288be2d27842cc4788e7f95..b48d9235d2df810bf41085f73239aff84a06ebbd 100644 (file)
@@ -24,11 +24,11 @@ public:
        ///
        ~InsetFig();
        ///
-       int ascent(Painter &, LyXFont const & font) const;
+       int ascent(BufferView *, LyXFont const & font) const;
        ///
-       int descent(Painter &, LyXFont const & font) const;
+       int descent(BufferView *, LyXFont const & font) const;
        ///
-       int width(Painter &, LyXFont const & font) const;
+       int width(BufferView *, LyXFont const & font) const;
        ///
        void draw(BufferView *, LyXFont const &, int, float &, bool) const;
        ///
index 775921433e9afea85d8af2deb37a569acbd90df0..b63d267077812f9bbae83363e28d579250078a0f 100644 (file)
@@ -132,7 +132,7 @@ void UpdatableInset::Edit(BufferView * bv, int, int, unsigned int)
 
     scx = 0;
 
-    mx_scx = abs((width(bv->painter(), font) - bv->workWidth()) / 2);
+    mx_scx = abs((width(bv, font) - bv->workWidth()) / 2);
 }
 
 
index 8dceec8e52c0cb080acaf81a062d74855c99d390..bee2a4745eb9d2196199f99df34749dd08f71dff 100644 (file)
@@ -366,7 +366,7 @@ bool InsetBibtex::delDatabase(string const & db)
 
 
 // ale070405 This function maybe shouldn't be here. We'll fix this at 0.13.
-int bibitemMaxWidth(Painter & pain, LyXFont const & font)
+int bibitemMaxWidth(BufferView * bv, LyXFont const & font)
 {
        int w = 0;
        // Does look like a hack? It is! (but will change at 0.13)
@@ -374,7 +374,7 @@ int bibitemMaxWidth(Painter & pain, LyXFont const & font)
     
        while (par) {
                if (par->bibkey) {
-                       int wx = par->bibkey->width(pain, font);
+                       int wx = par->bibkey->width(bv, font);
                        if (wx > w) w = wx;
                }
                par = par->next;
@@ -384,7 +384,7 @@ int bibitemMaxWidth(Painter & pain, LyXFont const & font)
 
 
 // ale070405
-string bibitemWidest(Painter & pain)
+string bibitemWidest(BufferView * bv)
 {
        int w = 0;
        // Does look like a hack? It is! (but will change at 0.13)
@@ -394,7 +394,7 @@ string bibitemWidest(Painter & pain)
       
        while (par) {
                if (par->bibkey) {
-                       int wx = par->bibkey->width(pain, font);
+                       int wx = par->bibkey->width(bv, font);
                        if (wx > w) {
                                w = wx;
                                bkey = par->bibkey;
index 368604e5f0f3490f17b558a3b8f1044d6baf670e..d208918a18a784ec5f3d59ef7cda98d54152a2d1 100644 (file)
@@ -27,7 +27,7 @@ InsetButton::InsetButton()
 {
 }
 
-int InsetButton::ascent(Painter & pain, LyXFont const &) const
+int InsetButton::ascent(BufferView * bv, LyXFont const &) const
 {
        LyXFont font(LyXFont::ALL_SANE);
        font.decSize();
@@ -36,18 +36,18 @@ int InsetButton::ascent(Painter & pain, LyXFont const &) const
         string s = getScreenLabel();
        
         if (Editable()) {
-               pain.buttonText(0, 0, s, font,
-                               false, width, ascent, descent);
+               bv->painter().buttonText(0, 0, s, font,
+                                        false, width, ascent, descent);
        } else {
-               pain.rectText(0, 0, s, font,
-                             LColor::commandbg, LColor::commandframe,
-                             false, width, ascent, descent);
+               bv->painter().rectText(0, 0, s, font,
+                                      LColor::commandbg, LColor::commandframe,
+                                      false, width, ascent, descent);
        }
        return ascent;
 }
 
 
-int InsetButton::descent(Painter & pain, LyXFont const &) const
+int InsetButton::descent(BufferView * bv, LyXFont const &) const
 {
        LyXFont font(LyXFont::ALL_SANE);
        font.decSize();
@@ -56,18 +56,18 @@ int InsetButton::descent(Painter & pain, LyXFont const &) const
         string s = getScreenLabel();
        
         if (Editable()) {
-               pain.buttonText(0, 0, s, font,
-                               false, width, ascent, descent);
+               bv->painter().buttonText(0, 0, s, font,
+                                        false, width, ascent, descent);
        } else {
-               pain.rectText(0, 0, s, font,
-                             LColor::commandbg, LColor::commandframe,
-                             false, width, ascent, descent);
+               bv->painter().rectText(0, 0, s, font,
+                                  LColor::commandbg, LColor::commandframe,
+                                  false, width, ascent, descent);
        }
        return descent;
 }
 
 
-int InsetButton::width(Painter & pain, LyXFont const &) const
+int InsetButton::width(BufferView * bv, LyXFont const &) const
 {
        LyXFont font(LyXFont::ALL_SANE);
        font.decSize();
@@ -76,12 +76,12 @@ int InsetButton::width(Painter & pain, LyXFont const &) const
         string s = getScreenLabel();
        
         if (Editable()) {
-               pain.buttonText(0, 0, s, font,
-                               false, width, ascent, descent);
+               bv->painter().buttonText(0, 0, s, font,
+                                        false, width, ascent, descent);
        } else {
-               pain.rectText(0, 0, s, font,
-                             LColor::commandbg, LColor::commandframe,
-                             false, width, ascent, descent);
+               bv->painter().rectText(0, 0, s, font,
+                                      LColor::commandbg, LColor::commandframe,
+                                      false, width, ascent, descent);
        }
        return width + 4;
 }
index 056c3fe98da65b53f0973d38a95e09472810cc54..5ef251fc697a1b5aeab4e16436f0048a07b12660 100644 (file)
@@ -27,11 +27,11 @@ public:
        InsetButton();
 
        ///
-       int ascent(Painter &, LyXFont const &) const;
+       int ascent(BufferView *, LyXFont const &) const;
        ///
-       int descent(Painter &, LyXFont const &) const;
+       int descent(BufferView *, LyXFont const &) const;
        ///
-       int width(Painter &, LyXFont const &) const;
+       int width(BufferView *, LyXFont const &) const;
        ///
        void draw(BufferView *, LyXFont const &, int, float &, bool) const;
 
index 9e843c286220a31024032f61baed1a2e41dc7aa5..12156f891366d476bcd83c9a9969e2625c24bdfa 100644 (file)
@@ -27,6 +27,7 @@
 class LyXText;
 
 using std::ostream;
+using std::endl;
 
 InsetCollapsable::InsetCollapsable()
        : UpdatableInset()
@@ -79,9 +80,11 @@ void InsetCollapsable::Write(Buffer const * buf, ostream & os) const
 
 void InsetCollapsable::Read(Buffer const * buf, LyXLex & lex)
 {
+    string token;
+
     if (lex.IsOK()) {
        lex.next();
-        string token = lex.GetString();
+        token = lex.GetString();
        if (token == "collapsed") {
            lex.next();
            collapsed = lex.GetBool();
@@ -118,30 +121,30 @@ int InsetCollapsable::width_collapsed(Painter & pain, LyXFont const &) const
 }
 
 
-int InsetCollapsable::ascent(Painter & pain, LyXFont const & font) const
+int InsetCollapsable::ascent(BufferView * bv, LyXFont const & font) const
 {
     if (collapsed) 
-       return ascent_collapsed(pain, font);
+       return ascent_collapsed(bv->painter(), font);
     else 
-       return inset->ascent(pain, font) + TEXT_TO_TOP_OFFSET;
+       return inset->ascent(bv, font) + TEXT_TO_TOP_OFFSET;
 }
 
 
-int InsetCollapsable::descent(Painter & pain, LyXFont const & font) const
+int InsetCollapsable::descent(BufferView * bv, LyXFont const & font) const
 {
     if (collapsed) 
-       return descent_collapsed(pain, font);
+       return descent_collapsed(bv->painter(), font);
     else 
-       return inset->descent(pain, font) + TEXT_TO_BOTTOM_OFFSET;
+       return inset->descent(bv, font) + TEXT_TO_BOTTOM_OFFSET;
 }
 
 
-int InsetCollapsable::width(Painter & pain, LyXFont const & font) const
+int InsetCollapsable::width(BufferView * bv, LyXFont const & font) const
 {
     if (collapsed) 
        return widthCollapsed;
 
-    return inset->width(pain, font) + widthCollapsed;
+    return inset->width(bv, font) + widthCollapsed;
 }
 
 
@@ -170,11 +173,12 @@ void InsetCollapsable::draw(BufferView * bv, LyXFont const & f,
     }
 
     if (!cleared && ((inset->need_update == InsetText::FULL) ||
+                    (inset->need_update == InsetText::INIT) ||
                     (top_x!=int(x)) || (top_baseline!=baseline))) {
-       int w =  owner()? width(pain, f) : pain.paperWidth();
-       int h = ascent(pain,f) + descent(pain, f);
+       int w =  owner()? width(bv, f) : pain.paperWidth();
+       int h = ascent(bv,f) + descent(bv, f);
        int tx = (needFullRow() && !owner())? 0:int(x);
-       int ty = baseline - ascent(pain,f);
+       int ty = baseline - ascent(bv,f);
        
        if (ty < 0)
            ty = 0;
@@ -285,24 +289,25 @@ int InsetCollapsable::getMaxWidth(Painter & pain,
                                  UpdatableInset const * inset) const
 {
     int w;
-    if (owner())
-        w = static_cast<UpdatableInset*>(owner())->getMaxWidth(pain,inset);
-    else
-       w = pain.paperWidth();
+    w = UpdatableInset::getMaxWidth(pain,inset);
 
-    if (w < 0)
+    if (w < 0) {
        return w;
-
+    }
+    w -= widthCollapsed;
+    // should be at least 30 pixels !!!
+    if (w < 30)
+       w = 30;
     return w; // - top_x - widthCollapsed;
 }
 
-
+#if 0
 int InsetCollapsable::getMaxTextWidth(Painter & pain,
                                      UpdatableInset const * inset) const
 {
     return getMaxWidth(pain, inset) - widthCollapsed;
 }
-
+#endif
 
 void InsetCollapsable::update(BufferView * bv, LyXFont const & font,
                              bool dodraw)
@@ -316,8 +321,8 @@ void InsetCollapsable::update(BufferView * bv, LyXFont const & font,
                return;
        }
     }
-    if (oldWidth != width(bv->painter(), font)) {
-       oldWidth = width(bv->painter(), font);
+    if (oldWidth != width(bv, font)) {
+       oldWidth = width(bv, font);
        inset->deleteLyXText(bv);
        need_update = FULL;
        if (owner()) {
index 14174a00ca2958aa993b30eb3986a07fb80c28af..a7773f325f648512a077051ac566e7732bdcd853 100644 (file)
@@ -49,11 +49,11 @@ public:
     ///
     void Write(Buffer const *, std::ostream &) const;
     ///
-    int ascent(Painter &, LyXFont const &) const;
+    int ascent(BufferView *, LyXFont const &) const;
     ///
-    int descent(Painter &, LyXFont const &) const;
+    int descent(BufferView *, LyXFont const &) const;
     ///
-    int width(Painter &, LyXFont const & f) const;
+    int width(BufferView *, LyXFont const & f) const;
     ///
     void draw(BufferView *, const LyXFont &, int , float &, bool) const;
     ///
index 1595b884dc496e8fc94d2bf262887be9ffe5e2fe..ed02526b3702dc917d26687ba4dfedf25e0b8bd4 100644 (file)
@@ -107,11 +107,23 @@ void InsetCommand::scanCommand(string const & cmd)
 // This function will not be necessary when lyx3
 void InsetCommand::Read(Buffer const *, LyXLex & lex)
 {    
+       string token;
+
        if (lex.EatLine()) {
-               string t = lex.GetString();
-               scanCommand(t);
+               token = lex.GetString();
+               scanCommand(token);
        } else
                lex.printError("InsetCommand: Parse error: `$$Token'");
+       while (lex.IsOK()) {
+               lex.nextToken();
+               token = lex.GetString();
+               if (token == "\\end_inset")
+                       break;
+       }
+       if (token != "\\end_inset") {
+               lex.printError("Missing \\end_inset at this point. "
+                              "Read: `$$Token'");
+       }
 }
 
 
index 493a01de20a2979daec85d26563cba7b8dfc8b43..59bbcc2fb085ef2e477b1ab9ac0936e82bc1173a 100644 (file)
@@ -48,7 +48,7 @@ InsetError::~InsetError()
 }
 
 
-int InsetError::ascent(Painter &, LyXFont const & font) const
+int InsetError::ascent(BufferView *, LyXFont const & font) const
 {
        LyXFont efont;
        efont.setSize(font.size()).decSize();
@@ -56,7 +56,7 @@ int InsetError::ascent(Painter &, LyXFont const & font) const
 }
 
 
-int InsetError::descent(Painter &, LyXFont const & font) const
+int InsetError::descent(BufferView *, LyXFont const & font) const
 {
        LyXFont efont;
        efont.setSize(font.size()).decSize();
@@ -64,7 +64,7 @@ int InsetError::descent(Painter &, LyXFont const & font) const
 }
 
 
-int InsetError::width(Painter &, LyXFont const & font) const
+int InsetError::width(BufferView *, LyXFont const & font) const
 {
        LyXFont efont;
        efont.setSize(font.size()).decSize();
@@ -82,17 +82,17 @@ void InsetError::draw(BufferView * bv, LyXFont const & font,
    
        // Draw as "Error" in a framed box
        x += 1;
-       pain.fillRectangle(int(x), baseline - ascent(pain, font) + 1,
-                         width(pain, font) - 2,
-                         ascent(pain, font) + descent(pain, font) - 2,
+       pain.fillRectangle(int(x), baseline - ascent(bv, font) + 1,
+                         width(bv, font) - 2,
+                         ascent(bv, font) + descent(bv, font) - 2,
                           LColor::insetbg);
-       pain.rectangle(int(x), baseline - ascent(pain, font) + 1,
-                      width(pain, font) - 2,
-                      ascent(pain, font) + descent(pain, font) - 2,
+       pain.rectangle(int(x), baseline - ascent(bv, font) + 1,
+                      width(bv, font) - 2,
+                      ascent(bv, font) + descent(bv, font) - 2,
                       LColor::error);
        pain.text(int(x + 2), baseline, _("Error"), efont);
 
-       x +=  width(pain, font) - 1;
+       x +=  width(bv, font) - 1;
 }
 
 
index eadf9fb513587d898f1f5d846bd31bd85e85d0a9..de7ccb67fadee51f522d354ea9e661fe7b769581 100644 (file)
@@ -36,11 +36,11 @@ public:
        ///
        ~InsetError();
        ///
-       int ascent(Painter &, LyXFont const & font) const;
+       int ascent(BufferView *, LyXFont const & font) const;
        ///
-       int descent(Painter &, LyXFont const & font) const;
+       int descent(BufferView *, LyXFont const & font) const;
        ///
-       int width(Painter &, LyXFont const & font) const;
+       int width(BufferView *, LyXFont const & font) const;
        ///
        void draw(BufferView *, LyXFont const &, int, float &, bool) const;
        ///
index 586934dd14934134ad9d177873eb245ad953af3a..40ee1688d06f1932f66a6e8f6981733c0edfc745 100644 (file)
@@ -111,21 +111,21 @@ InsetGraphics::InsetGraphics()
 {}
 
 
-int InsetGraphics::ascent(Painter &, LyXFont const &) const 
+int InsetGraphics::ascent(BufferView *, LyXFont const &) const 
 {
        
        return 100;
 }
 
 
-int InsetGraphics::descent(Painter &, LyXFont const &) const 
+int InsetGraphics::descent(BufferView *, LyXFont const &) const 
 {
        // this is not true if viewport is used and clip is not.
        return 1;
 }
 
 
-int InsetGraphics::width(Painter &, LyXFont const &) const 
+int InsetGraphics::width(BufferView *, LyXFont const &) const 
 {
        if (bb.isSet()) {
                return bb.urx - bb.llx;
@@ -141,9 +141,9 @@ void InsetGraphics::draw(BufferView * bv, LyXFont const & font,
 
        // This will draw the graphics. As for now we only draw a
        // placeholder rectangele.
-       pain.rectangle(int(x), baseline - ascent(pain, font),
-                      width(pain, font),
-                      ascent(pain, font) + descent(pain, font));
+       pain.rectangle(int(x), baseline - ascent(bv, font),
+                      width(bv, font),
+                      ascent(bv, font) + descent(bv, font));
 }
 
 
index e9cc6d563b3d66cd01bccf242e020f00a07592e8..16fba287f683ed07547d5fc04e7027108645d61d 100644 (file)
@@ -29,11 +29,11 @@ public:
        ///
        InsetGraphics();
        ///
-       int ascent(Painter &, LyXFont const &) const;
+       int ascent(BufferView *, LyXFont const &) const;
        ///
-       int descent(Painter &, LyXFont const &) const;
+       int descent(BufferView *, LyXFont const &) const;
        ///
-       int width(Painter &, LyXFont const &) const;
+       int width(BufferView *, LyXFont const &) const;
        ///
        void draw(BufferView *, LyXFont const &, int, float &, bool) const;
        ///
index 847f37492c543f13814198f96715fa73f76bb977..3a9fa245b15d8373a41f9b5c839086981084041d 100644 (file)
@@ -57,19 +57,19 @@ InsetInfo::~InsetInfo()
 }
 
 
-int InsetInfo::ascent(Painter &, LyXFont const & font) const
+int InsetInfo::ascent(BufferView *, LyXFont const & font) const
 {
        return lyxfont::maxAscent(font) + 1;
 }
 
 
-int InsetInfo::descent(Painter &, LyXFont const & font) const
+int InsetInfo::descent(BufferView *, LyXFont const & font) const
 {
        return lyxfont::maxDescent(font) + 1;
 }
 
 
-int InsetInfo::width(Painter &, LyXFont const & font) const
+int InsetInfo::width(BufferView *, LyXFont const & font) const
 {
        return 6 + lyxfont::width(_("Note"), font);
 }
@@ -86,17 +86,17 @@ void InsetInfo::draw(BufferView * bv, LyXFont const & f,
        
        // Draw as "Note" in a yellow box
        x += 1;
-       pain.fillRectangle(int(x), baseline - ascent(pain, font) + 1,
-                          width(pain, font) - 2,
-                          ascent(pain, font) + descent(pain, font) - 2,
+       pain.fillRectangle(int(x), baseline - ascent(bv, font) + 1,
+                          width(bv, font) - 2,
+                          ascent(bv, font) + descent(bv, font) - 2,
                           LColor::notebg);
-       pain.rectangle(int(x), baseline - ascent(pain, font) + 1,
-                      width(pain, font) - 2,
-                      ascent(pain, font) + descent(pain, font) - 2,
+       pain.rectangle(int(x), baseline - ascent(bv, font) + 1,
+                      width(bv, font) - 2,
+                      ascent(bv, font) + descent(bv, font) - 2,
                       LColor::noteframe);
        
        pain.text(int(x + 2), baseline, _("Note"), font);
-       x +=  width(pain, font) - 1;
+       x +=  width(bv, font) - 1;
 }
 
 
index 8898a874e46e7239752eb2168d02fa89ab2f69b8..30b3fcb020d90d03db18a47b121e189032dd8a19 100644 (file)
@@ -38,11 +38,11 @@ public:
        ///
        ~InsetInfo();
        ///
-       int ascent(Painter &, LyXFont const &) const;
+       int ascent(BufferView *, LyXFont const &) const;
        ///
-       int descent(Painter &, LyXFont const &) const;
+       int descent(BufferView *, LyXFont const &) const;
        ///
-       int width(Painter &, LyXFont const &) const;
+       int width(BufferView *, LyXFont const &) const;
        ///
        void draw(BufferView *, LyXFont const &, int, float &, bool) const;
        ///
index 9b74cd696b00b5c5b932272fa4ba5d5b2aafaf3e..bfefc9945c3d9eed33a179b1bd6c80f9bbcf482f 100644 (file)
@@ -255,7 +255,7 @@ void InsetLatexAccent::checkContents()
 }
 
 
-int InsetLatexAccent::ascent(Painter &, LyXFont const & font) const
+int InsetLatexAccent::ascent(BufferView *, LyXFont const & font) const
 {
        // This function is a bit too simplistix and is just a
        // "try to make a fit for all accents" approach, to
@@ -275,7 +275,7 @@ int InsetLatexAccent::ascent(Painter &, LyXFont const & font) const
 }
 
 
-int InsetLatexAccent::descent(Painter &, LyXFont const & font) const
+int InsetLatexAccent::descent(BufferView *, LyXFont const & font) const
 {
        int max;
        if (candisp) {
@@ -291,7 +291,7 @@ int InsetLatexAccent::descent(Painter &, LyXFont const & font) const
 }
 
 
-int InsetLatexAccent::width(Painter &, LyXFont const & font) const
+int InsetLatexAccent::width(BufferView *, LyXFont const & font) const
 {
        if (candisp)
                return lyxfont::width(ic, font);
@@ -312,7 +312,7 @@ int InsetLatexAccent::Rbearing(LyXFont const & font) const
 }
 
 
-bool InsetLatexAccent::DisplayISO8859_9(Painter & pain, LyXFont const & font,
+bool InsetLatexAccent::DisplayISO8859_9(BufferView * bv, LyXFont const & font,
                                        int baseline, 
                                        float & x) const
 {
@@ -346,8 +346,8 @@ bool InsetLatexAccent::DisplayISO8859_9(Painter & pain, LyXFont const & font,
        }
        if (tmpic != ic) {
                char ch = char(tmpic);
-               pain.text(int(x), baseline, ch, font);
-               x += width(pain, font);
+               bv->painter().text(int(x), baseline, ch, font);
+               x += width(bv, font);
                return true;
        }
        else
@@ -361,7 +361,7 @@ void InsetLatexAccent::draw(BufferView * bv, LyXFont const & font,
        Painter & pain = bv->painter();
 
        if (lyxrc.font_norm == "iso8859-9")
-               if (DisplayISO8859_9(pain, font, baseline, x))  
+               if (DisplayISO8859_9(bv, font, baseline, x))    
                        return;
        
        /* draw it! */ 
@@ -370,9 +370,9 @@ void InsetLatexAccent::draw(BufferView * bv, LyXFont const & font,
        // should also be considered.
        
        if (candisp) {
-               int asc = ascent(pain, font);
-               int desc = descent(pain, font);
-               int wid = width(pain, font);
+               int asc = ascent(bv, font);
+               int desc = descent(bv, font);
+               int wid = width(bv, font);
                float x2 = x + (Rbearing(font) - Lbearing(font)) / 2.0;
                float hg;
                int y;
@@ -412,7 +412,7 @@ void InsetLatexAccent::draw(BufferView * bv, LyXFont const & font,
                        // closer to the top of the dot-less 'i' or 'j'.
                        char tmpic = ic; // store the ic when we
                        ic = 'x';        // calculates the ascent of
-                       asc = ascent(pain, font); // the dot-less version (here: 'x')
+                       asc = ascent(bv, font); // the dot-less version (here: 'x')
                        ic = tmpic;      // set the orig ic back
                        y = baseline - asc; // update to new y coord.
                }
@@ -595,16 +595,16 @@ void InsetLatexAccent::draw(BufferView * bv, LyXFont const & font,
                }
        } else {
                pain.fillRectangle(int(x + 1),
-                                  baseline - ascent(pain, font) + 1,
-                                  width(pain, font) - 2,
-                                  ascent(pain, font)
-                                  + descent(pain, font) - 2);
-               pain.rectangle(int(x + 1), baseline - ascent(pain, font) + 1,
-                              width(pain, font) - 2,
-                              ascent(pain, font) + descent(pain, font) - 2);
+                                  baseline - ascent(bv, font) + 1,
+                                  width(bv, font) - 2,
+                                  ascent(bv, font)
+                                  + descent(bv, font) - 2);
+               pain.rectangle(int(x + 1), baseline - ascent(bv, font) + 1,
+                              width(bv, font) - 2,
+                              ascent(bv, font) + descent(bv, font) - 2);
                pain.text(int(x + 2), baseline, contents, font);
        }
-       x +=  width(pain, font);
+       x +=  width(bv, font);
 }
 
 
index 9a73aa3704578306c61c4bb0eb7c899a6e504723..3e116f6af094632fbc2ac8d52912b5b0c30f8a31 100644 (file)
@@ -35,11 +35,11 @@ public:
        explicit
        InsetLatexAccent(string const & string);
        ///
-       int ascent(Painter &, LyXFont const &) const;
+       int ascent(BufferView *, LyXFont const &) const;
        ///
-       int descent(Painter &, LyXFont const &) const;
+       int descent(BufferView *, LyXFont const &) const;
        ///
-       int width(Painter &, LyXFont const &) const;
+       int width(BufferView *, LyXFont const &) const;
        ///
        void draw(BufferView *, LyXFont const &, int, float &, bool) const;
        ///
@@ -47,7 +47,7 @@ public:
        ///
        int Rbearing(LyXFont const & font) const;
        ///
-       bool DisplayISO8859_9(Painter &, LyXFont const & font,
+       bool DisplayISO8859_9(BufferView *, LyXFont const & font,
                              int baseline, float & x) const;
        ///
        void Write(Buffer const *, std::ostream &) const;
index ab0adde855df64438e5eab2625e6650dd8ca365a..f0ae0ebc8ca0255e5e5da0cf2556a2831ee5d671 100644 (file)
@@ -159,19 +159,19 @@ string InsetQuotes::DispString() const
 }
 
 
-int InsetQuotes::ascent(Painter &, LyXFont const & font) const
+int InsetQuotes::ascent(BufferView *, LyXFont const & font) const
 {
        return lyxfont::maxAscent(font);
 }
 
 
-int InsetQuotes::descent(Painter &, LyXFont const & font) const
+int InsetQuotes::descent(BufferView *, LyXFont const & font) const
 {
        return lyxfont::maxDescent(font);
 }
 
 
-int InsetQuotes::width(Painter &, LyXFont const & font) const
+int InsetQuotes::width(BufferView *, LyXFont const & font) const
 {
        string text = DispString();
        int w = 0;
@@ -203,7 +203,7 @@ void InsetQuotes::draw(BufferView * bv, LyXFont const & font,
        string text = DispString();
 
        bv->painter().text(int(x), baseline, text, font);
-       x += width(bv->painter(), font);
+       x += width(bv, font);
 }
 
 
index cb8b4d9c103c138f17cb20776b54daa94277abd0..6445d0c4ba7078a978c09c24a920c01a5c7718bb 100644 (file)
@@ -72,11 +72,11 @@ public:
        InsetQuotes(char c, BufferParams const & params);
 
        ///
-       int ascent(Painter &, LyXFont const &) const;
+       int ascent(BufferView *, LyXFont const &) const;
        ///
-       int descent(Painter &, LyXFont const &) const;
+       int descent(BufferView *, LyXFont const &) const;
        ///
-       int width(Painter &, LyXFont const &) const;
+       int width(BufferView *, LyXFont const &) const;
        ///
        void draw(BufferView *, LyXFont const &, int, float &, bool) const;
        ///
index 172e0d4aaab69ea7f5fba03e541659502bb224de..48fa451654926ef6f221768d8f3b27fb15a746d5 100644 (file)
@@ -28,19 +28,19 @@ InsetSpecialChar::InsetSpecialChar(Kind k)
 {}
 
 
-int InsetSpecialChar::ascent(Painter &, LyXFont const & font) const
+int InsetSpecialChar::ascent(BufferView *, LyXFont const & font) const
 {
        return lyxfont::maxAscent(font);
 }
 
 
-int InsetSpecialChar::descent(Painter &, LyXFont const & font) const
+int InsetSpecialChar::descent(BufferView *, LyXFont const & font) const
 {
        return lyxfont::maxDescent(font);
 }
 
 
-int InsetSpecialChar::width(Painter &, LyXFont const & font) const
+int InsetSpecialChar::width(BufferView *, LyXFont const & font) const
 {
        switch (kind) {
        case HYPHENATION:
@@ -83,21 +83,21 @@ void InsetSpecialChar::draw(BufferView * bv, LyXFont const & f,
        {
                font.setColor(LColor::special);
                pain.text(int(x), baseline, "-", font);
-               x += width(pain, font);
+               x += width(bv, font);
                break;
        }
        case END_OF_SENTENCE:
        {
                font.setColor(LColor::special);
                pain.text(int(x), baseline, ".", font);
-               x += width(pain, font);
+               x += width(bv, font);
                break;
        }
        case LDOTS:
        {
                font.setColor(LColor::special);
                pain.text(int(x), baseline, ". . .", font);
-               x += width(pain, font);
+               x += width(bv, font);
                break;
        }
        case MENU_SEPARATOR:
@@ -114,12 +114,12 @@ void InsetSpecialChar::draw(BufferView * bv, LyXFont const & f,
                xp[3] = ox;     yp[3] = baseline;
                
                pain.lines(xp, yp, 4, LColor::special);
-               x += width(pain, font);
+               x += width(bv, font);
                break;
        }
        case PROTECTED_SEPARATOR:
        {
-               float w = width(pain, font);
+               float w = width(bv, font);
                int h = lyxfont::ascent('x', font);
                int xp[4], yp[4];
                
index cb696cd97e280ff18b4cdd4db15dd9a44b442894..9d99b0e62da3d7fb95e4a17ac766a3fd4344db8a 100644 (file)
@@ -44,11 +44,11 @@ public:
        explicit
        InsetSpecialChar(Kind k);
        ///
-       int ascent(Painter &, LyXFont const &) const;
+       int ascent(BufferView *, LyXFont const &) const;
        ///
-       int descent(Painter &, LyXFont const &) const;
+       int descent(BufferView *, LyXFont const &) const;
        ///
-       int width(Painter &, LyXFont const &) const;
+       int width(BufferView *, LyXFont const &) const;
        ///
        void draw(BufferView *, LyXFont const &, int, float &, bool) const;
        ///
index b9a6ba935fb630422de138a12b15a6ab7f0acb1b..8a5dfeb8756e97ba8f342c1bc21fa5a4f8535385 100644 (file)
@@ -131,19 +131,19 @@ void InsetTabular::Read(Buffer const * buf, LyXLex & lex)
 }
 
 
-int InsetTabular::ascent(Painter &, LyXFont const &) const
+int InsetTabular::ascent(BufferView *, LyXFont const &) const
 {
     return tabular->GetAscentOfRow(0);
 }
 
 
-int InsetTabular::descent(Painter &, LyXFont const &) const
+int InsetTabular::descent(BufferView *, LyXFont const &) const
 {
     return tabular->GetHeightOfTabular() - tabular->GetAscentOfRow(0);
 }
 
 
-int InsetTabular::width(Painter &, LyXFont const &) const
+int InsetTabular::width(BufferView *, LyXFont const &) const
 {
     return tabular->GetWidthOfTabular() + (2 * ADD_TO_TABULAR_WIDTH);
 }
@@ -161,10 +161,10 @@ void InsetTabular::draw(BufferView * bv, LyXFont const & font, int baseline,
     if (!cleared && ((need_update == INIT) || (need_update == FULL) ||
                     (top_x != int(x)) || (top_baseline != baseline))) {
 #if 1
-       int h = ascent(pain, font) + descent(pain, font);
+       int h = ascent(bv, font) + descent(bv, font);
        int tx = display()? 0:top_x;
-       int w =  tx? width(pain, font):pain.paperWidth();
-       int ty = baseline - ascent(pain, font);
+       int w =  tx? width(bv, font):pain.paperWidth();
+       int ty = baseline - ascent(bv, font);
        
        if (ty < 0)
            ty = 0;
@@ -221,7 +221,7 @@ void InsetTabular::draw(BufferView * bv, LyXFont const & font, int baseline,
                tabular->GetAdditionalHeight(cell+1);
        }
     }
-    x += width(pain, font);
+    x += width(bv, font);
     need_update = NONE;
 }
 
@@ -329,7 +329,7 @@ void InsetTabular::Edit(BufferView * bv, int x, int y, unsigned int button)
     locked = true;
     the_locking_inset = 0;
     inset_pos = inset_x = inset_y = 0;
-    setPos(bv->painter(), x, y);
+    setPos(bv, x, y);
     sel_pos_start = sel_pos_end = cursor.pos();
     sel_cell_start = sel_cell_end = actcell;
     bv->text->FinishUndo();
@@ -365,7 +365,7 @@ void InsetTabular::UpdateLocal(BufferView * bv, UpdateCodes what,
     need_update = what;
     bv->updateInset(this, mark_dirty);
     if (what != NONE)
-       resetPos(bv->painter());
+       resetPos(bv);
 }
 
 bool InsetTabular::LockInsetInInset(BufferView * bv, UpdatableInset * inset)
@@ -377,7 +377,7 @@ bool InsetTabular::LockInsetInInset(BufferView * bv, UpdatableInset * inset)
     if (inset == tabular->GetCellInset(actcell)) {
        lyxerr[Debug::INSETS] << "OK" << endl;
        the_locking_inset = tabular->GetCellInset(actcell);
-       resetPos(bv->painter());
+       resetPos(bv);
        inset_x = cursor.x() - top_x + tabular->GetBeginningOfTextInCell(actcell);
        inset_y = cursor.y();
        inset_pos = cursor.pos();
@@ -385,7 +385,7 @@ bool InsetTabular::LockInsetInInset(BufferView * bv, UpdatableInset * inset)
     } else if (the_locking_inset && (the_locking_inset == inset)) {
        if (cursor.pos() == inset_pos) {
            lyxerr[Debug::INSETS] << "OK" << endl;
-           resetPos(bv->painter());
+           resetPos(bv);
            inset_x = cursor.x() - top_x + tabular->GetBeginningOfTextInCell(actcell);
            inset_y = cursor.y();
        } else {
@@ -500,7 +500,7 @@ void InsetTabular::InsetButtonPress(BufferView * bv, int x, int y, int button)
 
     int ocell = actcell;
 
-    setPos(bv->painter(), x, y);
+    setPos(bv, x, y);
     sel_pos_start = sel_pos_end = cursor.pos();
     sel_cell_start = sel_cell_end = actcell;
 
@@ -538,7 +538,7 @@ void InsetTabular::InsetMotionNotify(BufferView * bv, int x, int y, int button)
            // int ocell = actcell,
            int old = sel_pos_end;
 
-       setPos(bv->painter(), x, y);
+       setPos(bv, x, y);
        sel_pos_end = cursor.pos();
        sel_cell_end = actcell;
        if (old != sel_pos_end)
@@ -571,7 +571,7 @@ UpdatableInset::RESULT InsetTabular::LocalDispatch(BufferView * bv, int action,
     if (((result=UpdatableInset::LocalDispatch(bv, action, arg)) == DISPATCHED)
        || (result == DISPATCHED_NOUPDATE)) {
 
-       resetPos(bv->painter());
+       resetPos(bv);
        return result;
     }
     result=DISPATCHED;
@@ -594,7 +594,7 @@ UpdatableInset::RESULT InsetTabular::LocalDispatch(BufferView * bv, int action,
         } else if (result == FINISHED) {
            if ((action == LFUN_RIGHT) || (action == -1)) {
                cursor.pos(inset_pos + 1);
-               resetPos(bv->painter());
+               resetPos(bv);
            }
            sel_pos_start = sel_pos_end = cursor.pos();
            sel_cell_start = sel_cell_end = actcell;
@@ -786,9 +786,9 @@ bool InsetTabular::calculate_dimensions_of_cells(BufferView * bv,
            ++cell;
            inset = tabular->GetCellInset(cell);
            inset->update(bv, font, dodraw);
-           maxAsc = max(maxAsc, inset->ascent(bv->painter(), font));
-           maxDesc = max(maxDesc, inset->descent(bv->painter(), font));
-           changed = tabular->SetWidthOfCell(cell, inset->width(bv->painter(), font)) || changed;
+           maxAsc = max(maxAsc, inset->ascent(bv, font));
+           maxDesc = max(maxDesc, inset->descent(bv, font));
+           changed = tabular->SetWidthOfCell(cell, inset->width(bv, font)) || changed;
        }
        changed = tabular->SetAscentOfRow(i, maxAsc + ADD_TO_HEIGHT) || changed;
        changed = tabular->SetDescentOfRow(i, maxDesc + ADD_TO_HEIGHT) || changed;
@@ -845,7 +845,7 @@ void InsetTabular::HideInsetCursor(BufferView * bv)
 }
 
 
-void InsetTabular::setPos(Painter & pain, int x, int y) const
+void InsetTabular::setPos(BufferView * bv, int x, int y) const
 {
        cursor.y(0);
        cursor.pos(0);
@@ -871,14 +871,14 @@ void InsetTabular::setPos(Painter & pain, int x, int y) const
        ++actcell,lx += tabular->GetWidthOfColumn(actcell) +
            tabular->GetAdditionalWidth(actcell - 1));
     cursor.pos(((actcell+1) * 2) - 1);
-    resetPos(pain);
+    resetPos(bv);
     if ((lx - (tabular->GetWidthOfColumn(actcell)/2)) < x) {
        cursor.x(lx + top_x - 2);
     } else {
        cursor.pos(cursor.pos() - 1);
        cursor.x(lx - tabular->GetWidthOfColumn(actcell) + top_x + 2);
     }
-    resetPos(pain);
+    resetPos(bv);
 }
 
 int InsetTabular::getCellXPos(int cell) const
@@ -895,7 +895,7 @@ int InsetTabular::getCellXPos(int cell) const
            ADD_TO_TABULAR_WIDTH);
 }
 
-void InsetTabular::resetPos(Painter & pain) const
+void InsetTabular::resetPos(BufferView * bv) const
 {
     if (!locked)
        return;
@@ -915,7 +915,7 @@ void InsetTabular::resetPos(Painter & pain) const
     cursor.x(getCellXPos(actcell) + 2);
     if (cursor.pos() % 2) {
        LyXFont font(LyXFont::ALL_SANE);
-       cursor.x(cursor.x() + tabular->GetCellInset(actcell)->width(pain,font) +
+       cursor.x(cursor.x() + tabular->GetCellInset(actcell)->width(bv,font) +
                tabular->GetBeginningOfTextInCell(actcell));
     }
     if ((!the_locking_inset ||
@@ -940,7 +940,7 @@ UpdatableInset::RESULT InsetTabular::moveRight(BufferView * bv, bool lock)
     } else {              // before the inset
        cursor.pos(cursor.pos() + 1);
     }
-    resetPos(bv->painter());
+    resetPos(bv);
     return DISPATCHED_NOUPDATE;
 }
 
@@ -959,7 +959,7 @@ UpdatableInset::RESULT InsetTabular::moveLeft(BufferView * bv, bool lock)
        if (ActivateCellInset(bv, 0, 0, 0, true))
            return DISPATCHED;
     }
-    resetPos(bv->painter());
+    resetPos(bv);
     return DISPATCHED_NOUPDATE;
 }
 
@@ -970,7 +970,7 @@ UpdatableInset::RESULT InsetTabular::moveUp(BufferView * bv)
     actcell = tabular->GetCellAbove(actcell);
     if (actcell == ocell) // we moved out of the inset
        return FINISHED;
-    resetPos(bv->painter());
+    resetPos(bv);
     return DISPATCHED_NOUPDATE;
 }
 
@@ -981,7 +981,7 @@ UpdatableInset::RESULT InsetTabular::moveDown(BufferView * bv)
     actcell = tabular->GetCellBelow(actcell);
     if (actcell == ocell) // we moved out of the inset
        return FINISHED;
-    resetPos(bv->painter());
+    resetPos(bv);
     return DISPATCHED_NOUPDATE;
 }
 
@@ -994,7 +994,7 @@ bool InsetTabular::moveNextCell(BufferView * bv)
     cursor.pos(cursor.pos() + 1);
     if (!cellstart(cursor.pos()))
        cursor.pos(cursor.pos() + 1);
-    resetPos(bv->painter());
+    resetPos(bv);
     return true;
 }
 
@@ -1007,7 +1007,7 @@ bool InsetTabular::movePrevCell(BufferView * bv)
     cursor.pos(cursor.pos() - 1);
     if (cellstart(cursor.pos()))
        cursor.pos(cursor.pos() - 1);
-    resetPos(bv->painter());
+    resetPos(bv);
     return true;
 }
 
@@ -1271,14 +1271,14 @@ bool InsetTabular::ActivateCellInset(BufferView * bv, int x, int y, int button,
     // reset the curor pos first!
     if (cursor.pos() % 2) { // behind the inset
        cursor.pos(cursor.pos() - 1);
-       resetPos(bv->painter());
+       resetPos(bv);
     }
     UpdatableInset * inset =
        static_cast<UpdatableInset*>(tabular->GetCellInset(actcell));
     LyXFont font(LyXFont::ALL_SANE);
     if (behind) {
-       x = inset->x() + inset->width(bv->painter(), font);
-       y = inset->descent(bv->painter(), font);
+       x = inset->x() + inset->width(bv, font);
+       y = inset->descent(bv, font);
     }
     inset_x = cursor.x() - top_x + tabular->GetBeginningOfTextInCell(actcell);
     inset_y = cursor.y();
@@ -1296,13 +1296,12 @@ bool InsetTabular::InsetHit(BufferView * bv, int x, int ) const
 
     if (cursor.pos() % 2) { // behind the inset
        return (((x + top_x) < cursor.x()) &&
-               ((x + top_x) > (cursor.x() - inset->width(bv->painter(),
+               ((x + top_x) > (cursor.x() - inset->width(bv,
                                                      LyXFont(LyXFont::ALL_SANE)))));
     } else {
        int x2 = cursor.x() + tabular->GetBeginningOfTextInCell(actcell);
        return ((x1 > x2) &&
-               (x1 < (x2 + inset->width(bv->painter(),
-                                        LyXFont(LyXFont::ALL_SANE)))));
+               (x1 < (x2 + inset->width(bv, LyXFont(LyXFont::ALL_SANE)))));
     }
 }
 
@@ -1349,7 +1348,7 @@ void InsetTabular::recomputeTextInsets(BufferView * bv, const LyXFont & font) co
            cell = tabular->GetCellNumber(i,j);
            inset = tabular->GetCellInset(cell);
            inset->update(bv, font);
-           tabular->SetWidthOfCell(cell, inset->width(bv->painter(), font));
+           tabular->SetWidthOfCell(cell, inset->width(bv, font));
        }
 //     cell = tabular->GetCellNumber(0, j);
 //     cx += tabular->GetWidthOfColumn(cell);
index 2cb39167ee47836390876e6f2d50b79dd1d8b69e..cab7644ae98a1f70921a0512bd523a4eb070480a 100644 (file)
@@ -83,11 +83,11 @@ public:
     ///
     void Write(Buffer const *, std::ostream &) const;
     ///
-    int ascent(Painter &, LyXFont const &) const;
+    int ascent(BufferView *, LyXFont const &) const;
     ///
-    int descent(Painter &, LyXFont const &) const;
+    int descent(BufferView *, LyXFont const &) const;
     ///
-    int width(Painter &, LyXFont const & f) const;
+    int width(BufferView *, LyXFont const & f) const;
     ///
     void draw(BufferView *, const LyXFont &, int , float &, bool) const;
     ///
@@ -173,7 +173,7 @@ private:
     ///
     void HideInsetCursor(BufferView *);
     ///
-    void setPos(Painter &, int x, int y) const;
+    void setPos(BufferView *, int x, int y) const;
     ///
     UpdatableInset::RESULT moveRight(BufferView *, bool lock=true);
     UpdatableInset::RESULT moveLeft(BufferView *, bool lock=true);
@@ -184,7 +184,7 @@ private:
     bool Delete();
     ///
     int getCellXPos(int cell) const;
-    void resetPos(Painter &) const;
+    void resetPos(BufferView *) const;
     ///
     void RemoveTabularRow();
     ///
index b4d5f4c34f903033655acd27df6720c42f35ae2c..f05a18873458e2d82c46ad87a650634bc2539389 100644 (file)
@@ -186,20 +186,28 @@ void InsetText::Read(Buffer const * buf, LyXLex & lex)
 }
 
 
-int InsetText::ascent(Painter &, LyXFont const &) const
+int InsetText::ascent(BufferView * bv, LyXFont const &) const
 {
+    long int y_temp = 0;
+    Row * row = TEXT(bv)->GetRowNearY(y_temp);
+    insetAscent = row->ascent_of_text() + TEXT_TO_INSET_OFFSET;
     return insetAscent;
 }
 
 
-int InsetText::descent(Painter &, LyXFont const &) const
+int InsetText::descent(BufferView * bv, LyXFont const &) const
 {
+    long int y_temp = 0;
+    Row * row = TEXT(bv)->GetRowNearY(y_temp);
+    insetDescent = TEXT(bv)->height - row->ascent_of_text() +
+       TEXT_TO_INSET_OFFSET;
     return insetDescent;
 }
 
 
-int InsetText::width(Painter &, LyXFont const &) const
+int InsetText::width(BufferView * bv, LyXFont const &) const
 {
+    insetWidth = TEXT(bv)->width + (2 * TEXT_TO_INSET_OFFSET);
     return insetWidth;
 }
 
@@ -211,9 +219,9 @@ int InsetText::textWidth(Painter & pain) const
 //     printf("WW1: %d\n",w);
        return w;
     }
-#if 0
+#if 1
     if (owner()) {
-       w = w - top_x; // + owner()->x();
+       w = w - top_x + owner()->x();
 //     printf("WW2: %d\n",w);
        return w; // - top_x + owner()->x();
     }
@@ -229,6 +237,9 @@ void InsetText::draw(BufferView * bv, LyXFont const & f,
 {
     Painter & pain = bv->painter();
 
+    xpos = x;
+    UpdatableInset::draw(bv, f, baseline, x, cleared);
+
     if (!cleared && ((need_update==FULL) || (top_x!=int(x)) ||
                     (top_baseline!=baseline))) {
        int w =  insetWidth;
@@ -245,25 +256,25 @@ void InsetText::draw(BufferView * bv, LyXFont const & f,
        cleared = true;
        need_update = FULL;
     }
-
     if (!cleared && (need_update == NONE))
        return;
 
-    xpos = x;
-    UpdatableInset::draw(bv, f, baseline, x, cleared);
+    if (top_x != int(x)) {
+       need_update = INIT;
+    }
+
     top_baseline = baseline;
     top_x = int(x);
-    top_y = baseline - ascent(pain, f);
-    last_width = width(pain, f);
-    last_height = ascent(pain, f) + descent(pain, f);
+    top_y = baseline - ascent(bv, f);
+    last_width = width(bv, f);
+    last_height = ascent(bv, f) + descent(bv, f);
 
     if (the_locking_inset && (cpar(bv) == inset_par) && (cpos(bv) == inset_pos)) {
        inset_x = cx(bv) - top_x + drawTextXOffset;
        inset_y = cy(bv) + drawTextYOffset;
     }
     if (!cleared && (need_update == CURSOR)) {
-       x += width(pain, f);
+       x += width(bv, f);
        need_update = NONE;
        return;
     }
@@ -295,7 +306,8 @@ void InsetText::draw(BufferView * bv, LyXFont const & f,
                           LColor::background);
     }
     x += insetWidth - TEXT_TO_INSET_OFFSET;
-    need_update = NONE;
+    if (need_update != INIT)
+       need_update = NONE;
 }
 
 
@@ -1063,10 +1075,12 @@ bool InsetText::checkAndActivateInset(BufferView * bv, bool behind)
        int x, y;
        Inset * inset =
            static_cast<UpdatableInset*>(cpar(bv)->GetInset(cpos(bv)));
+       if (!inset || inset->Editable() != Inset::HIGHLY_EDITABLE)
+           return false;
        LyXFont font = TEXT(bv)->GetFont(bv->buffer(), cpar(bv), cpos(bv));
        if (behind) {
-           x = inset->width(bv->painter(), font);
-           y = inset->descent(bv->painter(), font);
+           x = inset->width(bv, font);
+           y = inset->descent(bv, font);
        } else {
            x = y = 0;
        }
@@ -1108,7 +1122,10 @@ bool InsetText::checkAndActivateInset(BufferView * bv, int x, int y,
 
 int InsetText::getMaxWidth(Painter & pain, UpdatableInset const * inset) const
 {
-    return UpdatableInset::getMaxWidth(pain, inset) - (2*TEXT_TO_INSET_OFFSET);
+    int w = UpdatableInset::getMaxWidth(pain, inset);
+    if (w < 0)
+       return w;
+    return  w - (2*TEXT_TO_INSET_OFFSET);
 }
 
 
@@ -1220,7 +1237,7 @@ LyXText * InsetText::getLyXText(BufferView * bv) const
 }
 
 
-void InsetText::deleteLyXText(BufferView * bv)
+void InsetText::deleteLyXText(BufferView * bv) const
 {
     cache.erase(bv);
     /// then remove all LyXText in text-insets
index 8b46a131429c1267249ab6cb04365106c6601b7a..54efee5a404a4ab115e761d2721aeff008df95bb 100644 (file)
@@ -72,11 +72,11 @@ public:
     ///
     void Write(Buffer const *, std::ostream &) const;
     ///
-    int ascent(Painter &, LyXFont const &) const;
+    int ascent(BufferView *, LyXFont const &) const;
     ///
-    int descent(Painter &, LyXFont const &) const;
+    int descent(BufferView *, LyXFont const &) const;
     ///
-    int width(Painter &, LyXFont const & f) const;
+    int width(BufferView *, LyXFont const & f) const;
     ///
     int textWidth(Painter &) const;
     ///
@@ -153,7 +153,7 @@ public:
 //    LyXFont GetDrawFont(BufferView *, LyXParagraph *, int pos) const;
     ///
     LyXText * getLyXText(BufferView *) const;
-    void deleteLyXText(BufferView *);
+    void deleteLyXText(BufferView *) const;
 
     LyXParagraph * par;
     ///
@@ -214,9 +214,9 @@ private:
     ///
     mutable bool locked;
     ///
-    int insetAscent;
-    int insetDescent;
-    int insetWidth;
+    mutable int insetAscent;
+    mutable int insetDescent;
+    mutable int insetWidth;
     mutable int last_width;
     mutable int last_height;
     mutable int top_y;
index 68b69a6025f6fe57dfa934a449d575d6bbbc3c93..08184f30259954d4efafc3da53b08124efb8ee4a 100644 (file)
@@ -119,11 +119,11 @@ public:
        ///
        virtual ~Inset() {}
        ///
-       virtual int ascent(Painter &, LyXFont const &) const = 0;
+       virtual int ascent(BufferView *, LyXFont const &) const = 0;
        ///
-       virtual int descent(Painter &, LyXFont const &) const = 0;
+       virtual int descent(BufferView *, LyXFont const &) const = 0;
        ///
-       virtual int width(Painter &, LyXFont const &) const = 0;
+       virtual int width(BufferView *, LyXFont const &) const = 0;
        ///
        virtual void draw(BufferView *, LyXFont const &,
                          int baseline, float & x, bool cleared) const = 0;
index 8d2ca3f1ed8556e1b63ffe23413839945580960c..219fac53cbda2cb5d4dd520432645235def383fb 100644 (file)
@@ -1398,8 +1398,9 @@ string LyXFunc::Dispatch(int ac,
                                                    txt->cursor.par(),
                                                    txt->cursor.pos());
                        tmpinset->Edit(owner->view(),
-                                      tmpinset->x() + tmpinset->width(owner->view()->painter(),font),
-                                      tmpinset->descent(owner->view()->painter(),font),
+                                      tmpinset->x() +
+                                      tmpinset->width(owner->view(),font),
+                                      tmpinset->descent(owner->view(),font),
                                       0);
                        break;
                }
index 20d63d56eba247fc4ff294ee620a8fd7cdb63d1b..267a00452c0d5f8ef761cc485d971ae43944e146 100644 (file)
@@ -383,19 +383,19 @@ void InsetFormula::Read(Buffer const *, LyXLex & lex)
 }
 
 
-int InsetFormula::ascent(Painter &, LyXFont const &) const
+int InsetFormula::ascent(BufferView *, LyXFont const &) const
 {
    return par->Ascent() + ((disp_flag) ? 8 : 1);
 }
 
 
-int InsetFormula::descent(Painter &, LyXFont const &) const
+int InsetFormula::descent(BufferView *, LyXFont const &) const
 {
    return par->Descent() + ((disp_flag) ? 8 : 1);
 }
 
 
-int InsetFormula::width(Painter &, LyXFont const & f) const
+int InsetFormula::width(BufferView *, LyXFont const & f) const
 {
     lfont_size = f.size();
     par->Metrics();
@@ -428,7 +428,7 @@ void InsetFormula::draw(BufferView * bv, LyXFont const & f,
        } else {
                par->draw(pain, int(x), baseline);
        }
-       x += float(width(pain, font));
+       x += float(width(bv, font));
        
        if (par->GetType() == LM_OT_PARN || par->GetType() == LM_OT_MPARN) {
                LyXFont wfont = WhichFont(LM_TC_BF, par->size);
index 41da55bfe6b34595d842070bb7d6eb028979bfe6..b2406d0578b8c4f4bb554ec6240a602e3cf46736 100644 (file)
@@ -41,11 +41,11 @@ public:
        ///
        ~InsetFormula();
        ///
-       int ascent(Painter &, LyXFont const &) const;
+       int ascent(BufferView *, LyXFont const &) const;
        ///
-       int descent(Painter &, LyXFont const &) const;
+       int descent(BufferView *, LyXFont const &) const;
        ///
-       int width(Painter &, LyXFont const &) const;
+       int width(BufferView *, LyXFont const &) const;
        ///
        void draw(BufferView *,LyXFont const &, int, float &, bool) const;
        ///
index 1ab86ff732f51377823ea193616b37e94d11390e..8707a2922df323bddbccd22c3e7ce352ae91bf85 100644 (file)
@@ -114,7 +114,7 @@ void InsetFormulaMacro::Read(Buffer const *, LyXLex & lex)
 }
 
 
-int InsetFormulaMacro::ascent(Painter & pain, LyXFont const & f) const
+int InsetFormulaMacro::ascent(BufferView * pain, LyXFont const & f) const
 {
     if (opened) {
        tmacro->update();
@@ -124,7 +124,7 @@ int InsetFormulaMacro::ascent(Painter & pain, LyXFont const & f) const
 }
 
 
-int InsetFormulaMacro::descent(Painter & pain, LyXFont const & f) const
+int InsetFormulaMacro::descent(BufferView * pain, LyXFont const & f) const
 {
     if (opened) {
        tmacro->update();
@@ -134,11 +134,11 @@ int InsetFormulaMacro::descent(Painter & pain, LyXFont const & f) const
 }
 
 
-int InsetFormulaMacro::width(Painter & pain, LyXFont const & f) const
+int InsetFormulaMacro::width(BufferView * bv, LyXFont const & f) const
 {
     if (opened) {
        tmacro->update();
-       return InsetFormula::width(pain, f);
+       return InsetFormula::width(bv, f);
     }
     string ilabel(_("Macro: "));
     ilabel += name;
@@ -159,9 +159,9 @@ void InsetFormulaMacro::draw(BufferView * bv, LyXFont const & f,
        } else {
                font.setColor(LColor::math);
                
-               int y = baseline - ascent(pain, font) + 1;
-               int w = width(pain, font) - 2;
-               int h = (ascent(pain, font) + descent(pain, font) - 2);
+               int y = baseline - ascent(bv, font) + 1;
+               int w = width(bv, font) - 2;
+               int h = (ascent(bv, font) + descent(bv, font) - 2);
 
        
                pain.fillRectangle(int(x), y, w, h, LColor::mathbg);
@@ -170,7 +170,7 @@ void InsetFormulaMacro::draw(BufferView * bv, LyXFont const & f,
                string s(_("Macro: "));
                s += name;
                pain.text(int(x + 2), baseline, s, font);
-               x +=  width(pain, font) - 1;
+               x +=  width(bv, font) - 1;
        }
 }
 
index 2ae57cb6eeaa5e898b02afe96e2ce20146e1b83e..f77aca9ca8ce66f8ad2b68cc9f2018d990d7a7c8 100644 (file)
@@ -37,11 +37,11 @@ public:
        ///
        ~InsetFormulaMacro();
        ///
-       int ascent(Painter &, LyXFont const &) const;
+       int ascent(BufferView *, LyXFont const &) const;
        ///
-       int descent(Painter &, LyXFont const &) const;
+       int descent(BufferView *, LyXFont const &) const;
        ///
-       int width(Painter &, LyXFont const &) const;
+       int width(BufferView *, LyXFont const &) const;
        ///
        void draw(BufferView *,LyXFont const &, int, float &, bool) const;
        ///
index 34f9ee929304b128e137f08bd987998c6b01e4c5..6c2042c2d878f84d98f012e08c5059e4a204e97b 100644 (file)
@@ -50,7 +50,7 @@ int tex_code_break_column = 72;  // needs non-zero initialization. set later.
 // this is a bad idea, but how can LyXParagraph find its buffer to get
 // parameters? (JMarc)
 extern BufferView * current_view;
-extern string bibitemWidest(Painter &);
+extern string bibitemWidest(BufferView *);
 
 // this is a minibuffer
 static char minibuffer_char;
@@ -3650,7 +3650,7 @@ LyXParagraph * LyXParagraph::TeXEnvironment(Buffer const * buf,
                } else if (style.labeltype == LABEL_BIBLIO) {
                        // ale970405
                        os << "\\begin{" << style.latexname() << "}{"
-                          <<  bibitemWidest(current_view->painter())
+                          <<  bibitemWidest(current_view)
                           << "}\n";
                } else if (style.latextype == LATEX_ITEM_ENVIRONMENT) {
 #ifdef FANCY_FOOTNOTE_CODE
index 804ebcb8374882c775f11219b21258018a2a0025..929ffe28a6b89275dfda52e9e317027a867c46c0 100644 (file)
@@ -382,9 +382,9 @@ void LyXScreen::Update(LyXText * text, int y_offset, int x_offset)
                long y = max(text->refresh_y - long(text->first), 0L);
                int height;
                if (text->inset_owner)
-                       height = text->inset_owner->ascent(owner.owner()->painter(),
-                                                           text->real_current_font)
-                               + text->inset_owner->descent(owner.owner()->painter(),
+                       height = text->inset_owner->ascent(owner.owner(),
+                                                          text->real_current_font)
+                               + text->inset_owner->descent(owner.owner(),
                                                             text->real_current_font);
                else
                        height = owner.height();
index daa91a2abaec8acf377eda5328005c8ca88f1825..e49f673f5846efedcddaaa5df506d06396af499a 100644 (file)
@@ -43,7 +43,7 @@ using std::endl;
 using std::pair;
 
 static const int LYX_PAPER_MARGIN = 20;
-extern int bibitemMaxWidth(Painter &, LyXFont const &);
+extern int bibitemMaxWidth(BufferView *, LyXFont const &);
 
 
 int LyXText::workWidth(BufferView * bview) const
@@ -181,7 +181,7 @@ int LyXText::SingleWidth(BufferView * bview, LyXParagraph * par,
                Inset * tmpinset = par->GetInset(pos);
                if (tmpinset) {
                        tmpinset->update(bview, font);
-                       return tmpinset->width(bview->painter(), font);
+                       return tmpinset->width(bview, font);
                } else
                        return 0;
 
@@ -849,8 +849,7 @@ int LyXText::LeftMargin(BufferView * bview, Row const * row) const
                                                  .defaultfont());
                else if (layout.labeltype == LABEL_BIBLIO) {
                        // ale970405 Right width for bibitems
-                       x += bibitemMaxWidth(bview->painter(),
-                                            textclasslist
+                       x += bibitemMaxWidth(bview,textclasslist
                                             .TextClass(bview->buffer()->params
                                                        .textclass)
                                             .defaultfont());
@@ -1401,9 +1400,9 @@ void LyXText::SetHeightOfRow(BufferView * bview, Row * row_ptr) const
                   tmpinset = row_ptr->par()->GetInset(pos);
                   if (tmpinset) {
                           tmpinset->update(bview, tmpfont);
-                          asc = tmpinset->ascent(bview->painter(), tmpfont);
-                          desc = tmpinset->descent(bview->painter(), tmpfont);
-                          maxwidth += tmpinset->width(bview->painter(), tmpfont);
+                          asc = tmpinset->ascent(bview, tmpfont);
+                          desc = tmpinset->descent(bview, tmpfont);
+                          maxwidth += tmpinset->width(bview, tmpfont);
                           maxasc = max(maxasc, asc);
                           maxdesc = max(maxdesc, desc);
                   }
@@ -3798,16 +3797,16 @@ void LyXText::GetVisibleRow(BufferView * bview, int y_offset, int x_offset,
        } else if (clear_area) {
                int w;
                if (inset_owner)
-                       w = inset_owner->width(bview->painter(), font);
+                       w = inset_owner->width(bview, font);
                else
                        w = ww;
                pain.fillRectangle(x_offset, y_offset, w, row_ptr->height());
        } else if (inset != 0) {
-               int h = row_ptr->baseline() - inset->ascent(pain, font);
+               int h = row_ptr->baseline() - inset->ascent(bview, font);
                if (h > 0) {
                        int w;
                        if (inset_owner)
-                               w = inset_owner->width(bview->painter(), font);
+                               w = inset_owner->width(bview, font);
                        else
                                w = ww;
                        pain.fillRectangle(x_offset, y_offset, w, h);
@@ -4326,7 +4325,7 @@ void LyXText::GetVisibleRow(BufferView * bview, int y_offset, int x_offset,
                                        + lyxfont::width(layout.labelsep, font);
                        else
                                tmpx = x - lyxfont::width(layout.labelsep, font)
-                                       - row_ptr->par()->bibkey->width(bview->painter(), font);
+                                       - row_ptr->par()->bibkey->width(bview, font);
                        row_ptr->par()->bibkey->draw(bview, font,
                                                   y_offset + row_ptr->baseline(), 
                                                   tmpx, clear_area);