]> git.lyx.org Git - lyx.git/commitdiff
remove lowercase, better layout handling and some variable renameing
authorLars Gullik Bjønnes <larsbj@gullik.org>
Sun, 3 Mar 2002 20:25:07 +0000 (20:25 +0000)
committerLars Gullik Bjønnes <larsbj@gullik.org>
Sun, 3 Mar 2002 20:25:07 +0000 (20:25 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@3648 a592a061-630c-0410-9148-cb99ea01b6c8

35 files changed:
lib/layouts/hollywood.layout
src/BufferView_pimpl.C
src/buffer.C
src/bufferlist.C
src/insets/insetcaption.C
src/insets/insetcaption.h
src/insets/insetcollapsable.C
src/insets/insetcollapsable.h
src/insets/insetert.C
src/insets/insetert.h
src/insets/insetfloat.C
src/insets/insetfloat.h
src/insets/insetfoot.C
src/insets/insetfoot.h
src/insets/insetfootlike.C
src/insets/insetfootlike.h
src/insets/insetmarginal.C
src/insets/insetmarginal.h
src/insets/insetminipage.C
src/insets/insetminipage.h
src/insets/insetnote.C
src/insets/insetnote.h
src/insets/insettabular.C
src/insets/insettext.C
src/insets/insettext.h
src/lyxlayout.C
src/lyxtext.h
src/lyxtextclass.C
src/paragraph.C
src/screen.C
src/tabular-old.C
src/tabular.C
src/tabular.h
src/text.C
src/text2.C

index 753d9813221854a716f25b1a2bd071eed0eb98f5..10a76d072e6615e8a59799a792837b6b7a2fa411 100644 (file)
@@ -34,6 +34,7 @@ DefaultFont
   Color                 None
 EndFont
 
+DefaultStyle   Dialogue
 
 # Dialogue style definition. Actor dialog
 Style Dialogue
index a7afbd8b2a8367f9cbcb2774801c5b370416cb52..74dd4ca64847bde7a345ca41b43d46cba09c5614 100644 (file)
@@ -214,7 +214,7 @@ void BufferView::Pimpl::buffer(Buffer * b)
                        updateScreen();
                        updateScrollbar();
                }
-               bv_->text->first = screen_->topCursorVisible(bv_->text);
+               bv_->text->first_y = screen_->topCursorVisible(bv_->text);
                owner_->updateMenubar();
                owner_->updateToolbar();
                // Similarly, buffer-dependent dialogs should be updated or
@@ -368,7 +368,7 @@ int BufferView::Pimpl::resizeCurrentBuffer()
                // remake the inset locking
                bv_->theLockingInset(the_locking_inset);
        }
-       bv_->text->first = screen_->topCursorVisible(bv_->text);
+       bv_->text->first_y = screen_->topCursorVisible(bv_->text);
 #if 0
        buffer_->resizeInsets(bv_);
 #endif
@@ -408,7 +408,7 @@ void BufferView::Pimpl::updateScrollbar()
 
        if (text_height <= work_height) {
                workarea_.setScrollbarBounds(0.0, 0.0);
-               current_scrollbar_value = bv_->text->first;
+               current_scrollbar_value = bv_->text->first_y;
                workarea_.setScrollbar(current_scrollbar_value, 1.0);
                return;
        }
@@ -430,9 +430,9 @@ void BufferView::Pimpl::updateScrollbar()
                workarea_.setScrollbarIncrements(lineh);
                old_lineh = lineh;
        }
-       if (current_scrollbar_value != bv_->text->first
+       if (current_scrollbar_value != bv_->text->first_y
            || slider_size != old_slider_size) {
-               current_scrollbar_value = bv_->text->first;
+               current_scrollbar_value = bv_->text->first_y;
                workarea_.setScrollbar(current_scrollbar_value, slider_size);
                old_slider_size = slider_size;
        }
@@ -462,8 +462,8 @@ void BufferView::Pimpl::scrollCB(double value)
        LyXText * vbt = bv_->text;
  
        int const height = vbt->defaultHeight();
-       int const first = static_cast<int>((bv_->text->first + height));
-       int const last = static_cast<int>((bv_->text->first + workarea_.height() - height));
+       int const first = static_cast<int>((bv_->text->first_y + height));
+       int const last = static_cast<int>((bv_->text->first_y + workarea_.height() - height));
 
        if (vbt->cursor.y() < first)
                vbt->setCursorFromCoordinates(bv_, 0, first);
@@ -558,7 +558,7 @@ void BufferView::Pimpl::workAreaMotionNotify(int x, int y, unsigned int state)
                bv_->theLockingInset()->
                        insetMotionNotify(bv_,
                                          x - start_x,
-                                         y - cursor.y() + bv_->text->first,
+                                         y - cursor.y() + bv_->text->first_y,
                                          state);
                return;
        }
@@ -571,7 +571,7 @@ void BufferView::Pimpl::workAreaMotionNotify(int x, int y, unsigned int state)
  
        screen_->hideCursor();
 
-       bv_->text->setCursorFromCoordinates(bv_, x, y + bv_->text->first);
+       bv_->text->setCursorFromCoordinates(bv_, x, y + bv_->text->first_y);
       
        if (!bv_->text->selection.set())
                update(bv_->text, BufferView::UPDATE); // Maybe an empty line was deleted
@@ -621,7 +621,7 @@ void BufferView::Pimpl::workAreaButtonPress(int xpos, int ypos,
                selection_possible = true;
        screen_->hideCursor();
 
-       int const screen_first = bv_->text->first;
+       int const screen_first = bv_->text->first_y;
        
        // Middle button press pastes if we have a selection
        bool paste_internally = false;
@@ -941,7 +941,7 @@ Inset * BufferView::Pimpl::checkInsetHit(LyXText * text, int & x, int & y)
        if (!screen_.get())
                return 0;
   
-       int y_tmp = y + text->first;
+       int y_tmp = y + text->first_y;
  
        LyXCursor cursor;
        text->setCursorFromCoordinates(bv_, cursor, x, y_tmp);
@@ -1142,9 +1142,9 @@ void BufferView::Pimpl::cursorPrevious(LyXText * text)
        if (!text->cursor.row()->previous())
                return;
        
-       int y = text->first;
+       int y = text->first_y;
        if (text->inset_owner)
-               y += bv_->text->first;
+               y += bv_->text->first_y;
        Row * cursorrow = text->cursor.row();
        text->setCursorFromCoordinates(bv_, bv_->text->cursor.x_fix(), y);
        finishUndo();
@@ -1168,7 +1168,7 @@ void BufferView::Pimpl::cursorNext(LyXText * text)
        if (!text->cursor.row()->next())
                return;
        
-       int y = text->first + workarea_.height();
+       int y = text->first_y + workarea_.height();
 //     if (text->inset_owner)
 //             y += bv_->text->first;
        text->getRowNearY(y);
@@ -2743,11 +2743,11 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument)
        break;
        
        case LFUN_INSET_TEXT:
-               insertAndEditInset(new InsetText);
+               insertAndEditInset(new InsetText(buffer_->params));
                break;
        
        case LFUN_INSET_ERT:
-               insertAndEditInset(new InsetERT);
+               insertAndEditInset(new InsetERT(buffer_->params));
                break;
        
        case LFUN_INSET_EXTERNAL:
@@ -2755,25 +2755,26 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument)
                break;
        
        case LFUN_INSET_FOOTNOTE:
-               insertAndEditInset(new InsetFoot);
+               insertAndEditInset(new InsetFoot(buffer_->params));
                break;
 
        case LFUN_INSET_MARGINAL:
-               insertAndEditInset(new InsetMarginal);
+               insertAndEditInset(new InsetMarginal(buffer_->params));
                break;
 
        case LFUN_INSET_MINIPAGE:
-               insertAndEditInset(new InsetMinipage);
+               insertAndEditInset(new InsetMinipage(buffer_->params));
                break;
 
        case LFUN_INSERT_NOTE:
-               insertAndEditInset(new InsetNote);
+               insertAndEditInset(new InsetNote(buffer_->params));
                break;
 
        case LFUN_INSET_FLOAT:
                // check if the float type exist
                if (floatList.typeExist(argument)) {
-                       insertAndEditInset(new InsetFloat(argument));
+                       insertAndEditInset(new InsetFloat(buffer_->params,
+                                                         argument));
                } else {
                        lyxerr << "Non-existent float type: "
                               << argument << endl;
@@ -2784,7 +2785,8 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument)
        {
                // check if the float type exist
                if (floatList.typeExist(argument)) {
-                       InsetFloat * new_inset = new InsetFloat(argument);
+                       InsetFloat * new_inset =
+                               new InsetFloat(buffer_->params, argument);
                        new_inset->wide(true);
                        if (insertInset(new_inset))
                                new_inset->edit(bv_);
@@ -2814,7 +2816,8 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument)
                if (bv_->theLockingInset()) {
                        lyxerr << "Locking inset code: "
                               << static_cast<int>(bv_->theLockingInset()->lyxCode());
-                       InsetCaption * new_inset = new InsetCaption;
+                       InsetCaption * new_inset =
+                               new InsetCaption(buffer_->params);
                        new_inset->setOwner(bv_->theLockingInset());
                        new_inset->setAutoBreakRows(true);
                        new_inset->setDrawFrame(0, InsetText::LOCKED);
index 7c12a2368448b0e7f35bf67d9f4f3a82e551cf80..3355eebfbfc101814cfa0e3ada5336eede29d054 100644 (file)
@@ -405,7 +405,8 @@ void Buffer::insertErtContents(Paragraph * par, int & pos, bool set_inactive)
        if (!ert_comp.contents.empty()) {
                lyxerr[Debug::INSETS] << "ERT contents:\n'"
                                      << ert_comp.contents << "'" << endl;
-               Inset * inset = new InsetERT(params.language, ert_comp.contents, true);
+               Inset * inset = new InsetERT(params, params.language,
+                                            ert_comp.contents, true);
                par->insertInset(pos++, inset, ert_comp.font);
                ert_comp.contents.erase();
        }
@@ -462,11 +463,14 @@ Buffer::parseSingleLyXformat2Token(LyXLex & lex, Paragraph *& par,
                insertErtContents(par, pos);
 #endif
                lex.eatLine();
-               string const layoutname = lowercase(lex.getString());
-               //lyxerr << "Looking for layout '"
-               // << layoutname << "'!" << endl;
-
-               //lyxerr << "Result: " << pp.first << "/" << pp.second << endl;
+               string const layoutname = lex.getString();
+               LyXTextClass const & tclass = textclasslist[params.textclass];
+               bool hasLayout = tclass.hasLayout(layoutname);
+               if (!hasLayout) {
+                       lyxerr << "Layout '" << layoutname << "' does not"
+                              << " exist in textclass '" << tclass.name()
+                              << "'." << endl;
+               }
                
 #ifndef NO_COMPABILITY
                if (compare_no_case(layoutname, "latex") == 0) {
@@ -565,28 +569,28 @@ Buffer::parseSingleLyXformat2Token(LyXLex & lex, Paragraph *& par,
                stringstream old_float;
                
                if (tmptok == "footnote") {
-                       inset = new InsetFoot;
+                       inset = new InsetFoot(params);
                        old_float << "collapsed true\n";
                } else if (tmptok == "margin") {
-                       inset = new InsetMarginal;
+                       inset = new InsetMarginal(params);
                        old_float << "collapsed true\n";
                } else if (tmptok == "fig") {
-                       inset = new InsetFloat("figure");
+                       inset = new InsetFloat(params, "figure");
                        old_float << "placement htbp\n"
                                  << "wide false\n"
                                  << "collapsed false\n";
                } else if (tmptok == "tab") {
-                       inset = new InsetFloat("table");
+                       inset = new InsetFloat(params, "table");
                        old_float << "placement htbp\n"
                                  << "wide false\n"
                                  << "collapsed false\n";
                } else if (tmptok == "alg") {
-                       inset = new InsetFloat("algorithm");
+                       inset = new InsetFloat(params, "algorithm");
                        old_float << "placement htbp\n"
                                  << "wide false\n"
                                  << "collapsed false\n";
                } else if (tmptok == "wide-fig") {
-                       inset = new InsetFloat("figure");
+                       inset = new InsetFloat(params, "figure");
                        //InsetFloat * tmp = new InsetFloat("figure");
                        //tmp->wide(true);
                        //inset = tmp;
@@ -594,7 +598,7 @@ Buffer::parseSingleLyXformat2Token(LyXLex & lex, Paragraph *& par,
                                  << "wide true\n"
                                  << "collapsed false\n";
                } else if (tmptok == "wide-tab") {
-                       inset = new InsetFloat("table");
+                       inset = new InsetFloat(params, "table");
                        //InsetFloat * tmp = new InsetFloat("table");
                        //tmp->wide(true);
                        //inset = tmp;
@@ -1249,7 +1253,7 @@ Buffer::parseSingleLyXformat2Token(LyXLex & lex, Paragraph *& par,
                                p->params().depth(parBeforeMinipage->params().depth());
                                parBeforeMinipage = p;
                        }
-                       InsetMinipage * mini = new InsetMinipage;
+                       InsetMinipage * mini = new InsetMinipage(params);
                        mini->pos(static_cast<InsetMinipage::Position>(par->params().pextraAlignment()));
                        mini->pageWidth(LyXLength(par->params().pextraWidth()));
                        if (!par->params().pextraWidthp().empty()) {
@@ -1330,7 +1334,7 @@ Buffer::parseSingleLyXformat2Token(LyXLex & lex, Paragraph *& par,
                if (!first_par || (first_par == par))
                        first_par = p;
 
-               InsetMinipage * mini = new InsetMinipage;
+               InsetMinipage * mini = new InsetMinipage(params);
                mini->pos(static_cast<InsetMinipage::Position>(minipar->params().pextraAlignment()));
                mini->pageWidth(LyXLength(minipar->params().pextraWidth()));
                if (!par->params().pextraWidthp().empty()) {
@@ -1496,26 +1500,26 @@ void Buffer::readInset(LyXLex & lex, Paragraph *& par,
                                              true);
                        alreadyread = true;
                } else if (tmptok == "Note") {
-                       inset = new InsetNote;
+                       inset = new InsetNote(params);
                } else if (tmptok == "Include") {
                        InsetCommandParams p("Include");
                        inset = new InsetInclude(p, *this);
                } else if (tmptok == "ERT") {
-                       inset = new InsetERT;
+                       inset = new InsetERT(params);
                } else if (tmptok == "Tabular") {
                        inset = new InsetTabular(*this);
                } else if (tmptok == "Text") {
-                       inset = new InsetText;
+                       inset = new InsetText(params);
                } else if (tmptok == "Foot") {
-                       inset = new InsetFoot;
+                       inset = new InsetFoot(params);
                } else if (tmptok == "Marginal") {
-                       inset = new InsetMarginal;
+                       inset = new InsetMarginal(params);
                } else if (tmptok == "Minipage") {
-                       inset = new InsetMinipage;
+                       inset = new InsetMinipage(params);
                } else if (tmptok == "Float") {
                        lex.next();
                        string tmptok = lex.getString();
-                       inset = new InsetFloat(tmptok);
+                       inset = new InsetFloat(params, tmptok);
 #if 0
                } else if (tmptok == "List") {
                        inset = new InsetList;
@@ -1523,7 +1527,7 @@ void Buffer::readInset(LyXLex & lex, Paragraph *& par,
                        inset = new InsetList;
 #endif
                } else if (tmptok == "Caption") {
-                       inset = new InsetCaption;
+                       inset = new InsetCaption(params);
                } else if (tmptok == "FloatList") {
                        inset = new InsetFloatList;
                }
@@ -1792,26 +1796,26 @@ string const Buffer::asciiParagraph(Paragraph const * par,
 #endif
                
        // First write the layout
-       string const & tmp = lowercase(par->layout());
-       if (tmp == "itemize") {
+       string const & tmp = par->layout();
+       if (compare_no_case(tmp, "itemize") == 0) {
                ltype = 1;
                ltype_depth = depth + 1;
-       } else if (tmp == "enumerate") {
+       } else if (compare_no_case(tmp, "enumerate") == 0) {
                ltype = 2;
                ltype_depth = depth + 1;
-       } else if (contains(tmp, "ection")) {
+       } else if (contains(lowercase(tmp), "ection")) {
                ltype = 3;
                ltype_depth = depth + 1;
-       } else if (contains(tmp, "aragraph")) {
+       } else if (contains(lowercase(tmp), "aragraph")) {
                ltype = 4;
                ltype_depth = depth + 1;
-       } else if (tmp == "description") {
+       } else if (compare_no_case(tmp, "description") == 0) {
                ltype = 5;
                ltype_depth = depth + 1;
-       } else if (tmp == "abstract") {
+       } else if (compare_no_case(tmp, "abstract") == 0) {
                ltype = 6;
                ltype_depth = 0;
-       } else if (tmp == "bibliography") {
+       } else if (compare_no_case(tmp, "bibliography") == 0) {
                ltype = 7;
                ltype_depth = 0;
        } else {
index 06ffaf43b197b81b938a91b8c50de25432528e75..894f069449588ce2dca23c20a5c0fb7a3ec8f5df 100644 (file)
@@ -31,6 +31,7 @@
 #include "LyXView.h"
 #include "vc-backend.h"
 #include "TextCache.h"
+#include "lyxtextclasslist.h"
 
 #include "frontends/Alert.h"
 
@@ -479,9 +480,11 @@ Buffer * BufferList::newFile(string const & name, string tname, bool isNamed)
                                   MakeDisplayPath(tname));
                        // no template, start with empty buffer
                        b->paragraph = new Paragraph;
+                       b->paragraph->layout(textclasslist[b->params.textclass].defaultLayoutName());
                }
        } else {  // start with empty buffer
                b->paragraph = new Paragraph;
+                       b->paragraph->layout(textclasslist[b->params.textclass].defaultLayoutName());
        }
 
        if (!lyxrc.new_ask_filename && !isNamed) {
index f1ba9df2deaec60738e83e180d931f365bd05bc7..1b9a601ce21577b6b5a2480433891c6a6ecbbba8 100644 (file)
@@ -27,8 +27,8 @@
 using std::ostream;
 using std::endl;
 
-InsetCaption::InsetCaption()
-       : InsetText()
+InsetCaption::InsetCaption(BufferParams const & bp)
+       : InsetText(bp)
 {
        setAutoBreakRows(true);
        setDrawFrame(0, InsetText::LOCKED);
index 27088e5e645c210f17297c6701910abf03d99dac..b97789eb52d729c92a0bd800ed9108e963333bc8 100644 (file)
@@ -24,7 +24,7 @@
 class InsetCaption : public InsetText {
 public:
        ///
-       InsetCaption();
+       InsetCaption(BufferParams const &);
        ///
        void write(Buffer const * buf, std::ostream & os) const;
        ///
index e4015dd1cf24a5d968aec31aeb854c53e016e80d..daa76e4db81402705cd7e8f3d83fdb3e4243f88e 100644 (file)
@@ -38,8 +38,8 @@ using std::max;
 class LyXText;
 
 
-InsetCollapsable::InsetCollapsable(bool collapsed)
-       : UpdatableInset(), collapsed_(collapsed), 
+InsetCollapsable::InsetCollapsable(BufferParams const & bp, bool collapsed)
+       : UpdatableInset(), collapsed_(collapsed), inset(bp),
          button_length(0), button_top_y(0), button_bottom_y(0),
          need_update(NONE), label("Label"),
 #if 0
@@ -56,8 +56,8 @@ InsetCollapsable::InsetCollapsable(bool collapsed)
 
 
 InsetCollapsable::InsetCollapsable(InsetCollapsable const & in, bool same_id)
-       : UpdatableInset(in, same_id), collapsed_(in.collapsed_), 
-         framecolor(in.framecolor), labelfont(in.labelfont),
+       : UpdatableInset(in, same_id), collapsed_(in.collapsed_),
+         framecolor(in.framecolor), labelfont(in.labelfont), inset(in.inset),
          button_length(0), button_top_y(0), button_bottom_y(0),
          need_update(NONE), label(in.label),
 #if 0
index 2880a32027d68186e0189bd50894f561504e5307..5af2ce5eda6ae0ebab2a94a195b63f060633321e 100644 (file)
@@ -42,7 +42,7 @@ public:
        ///
        static int const TEXT_TO_BOTTOM_OFFSET = 2;
        /// inset is initially collapsed if bool = true
-       InsetCollapsable(bool = false);
+       InsetCollapsable(BufferParams const &, bool = false);
        ///
        InsetCollapsable(InsetCollapsable const & in, bool same_id = false);
        ///
index 53ada70eb04ee9481f8942c3cd26c15d8fc6aff4..d1f4dbeee2a39c64ee9ed8b9d8ab036a3ce58363 100644 (file)
@@ -50,8 +50,8 @@ void InsetERT::init()
 }
 
 
-InsetERT::InsetERT(bool collapsed)
-       : InsetCollapsable(collapsed)
+InsetERT::InsetERT(BufferParams const & bp, bool collapsed)
+       : InsetCollapsable(bp, collapsed)
 {
        if (collapsed)
                status_ = Collapsed;
@@ -74,8 +74,9 @@ Inset * InsetERT::clone(Buffer const &, bool same_id) const
 }
 
 
-InsetERT::InsetERT(Language const * l, string const & contents, bool collapsed)
-       : InsetCollapsable(collapsed)
+InsetERT::InsetERT(BufferParams const & bp,
+                  Language const * l, string const & contents, bool collapsed)
+       : InsetCollapsable(bp, collapsed)
 {
        if (collapsed)
                status_ = Collapsed;
index f1537267c913c763f4d0f043ad45f797c60c1874..8c9c57ce54507ceb9de59745ce0ecea68b12294c 100644 (file)
@@ -41,13 +41,14 @@ public:
                Inlined
        };
        ///
-       InsetERT(bool collapsed=false);
+       InsetERT(BufferParams const &, bool collapsed = false);
        ///
        InsetERT(InsetERT const &, bool same_id = false);
        ///
        Inset * clone(Buffer const &, bool same_id = false) const;
        ///
-       InsetERT(Language const *, string const & contents, bool collapsed);
+       InsetERT(BufferParams const &,
+                Language const *, string const & contents, bool collapsed);
        ///
        ~InsetERT();
        ///
index e31523429f107f9da5c754b0923f0d5a92981d9b..40c4ebe947d374d9ca005ab57cbfacf1ffea76a0 100644 (file)
@@ -99,8 +99,8 @@ using std::endl;
 //
 // Lgb
 
-InsetFloat::InsetFloat(string const & type)
-       : InsetCollapsable(), wide_(false)
+InsetFloat::InsetFloat(BufferParams const & bp, string const & type)
+       : InsetCollapsable(bp), wide_(false)
 {
        string lab(_("float:"));
        lab += type;
index 42288867165ea0d8c375c0be49d8714023439b36..b9709328d90bf5b082700461f1b4e1f89472ace7 100644 (file)
@@ -27,7 +27,7 @@ class Painter;
 class InsetFloat : public InsetCollapsable {
 public:
        ///
-       InsetFloat(string const &);
+       InsetFloat(BufferParams const &, string const &);
        ///
        InsetFloat(InsetFloat const &, bool same_id = false);
        ///
index a2297b6cd9133aee05ea456eb6f32c6a1dc16b6e..5e1d870834540cb15e8575aca8849c775eedf8b7 100644 (file)
@@ -27,8 +27,8 @@
 using std::ostream;
 
 
-InsetFoot::InsetFoot()
-       : InsetFootlike()
+InsetFoot::InsetFoot(BufferParams const & bp)
+       : InsetFootlike(bp)
 {
        setLabel(_("foot"));
        setInsetName("Foot");
index 275a69c39e181e3ffab1b70309da930af526e53c..092f0e7f8f7c71180c5d532b1d029ba6d803d541 100644 (file)
@@ -27,7 +27,7 @@
 class InsetFoot : public InsetFootlike {
 public:
        ///
-       InsetFoot();
+       InsetFoot(BufferParams const &);
        ///
        InsetFoot(InsetFoot const &, bool same_id = false);
        ///
index fcbe711ba726fd024de2623296a59d577c1a6703..f401f78bf2ca1f403dd58e857fb0425e48cb9fe9 100644 (file)
@@ -24,8 +24,8 @@
 using std::ostream;
 
 
-InsetFootlike::InsetFootlike()
-       : InsetCollapsable()
+InsetFootlike::InsetFootlike(BufferParams const & bp)
+       : InsetCollapsable(bp)
 {
        LyXFont font(LyXFont::ALL_SANE);
        font.decSize();
index 1e678ff90997d4bf5e678633897697be8f035e82..e721632b2149de2b4578e41e881faf96d512f0bc 100644 (file)
@@ -28,7 +28,7 @@
 class InsetFootlike : public InsetCollapsable {
 public:
        ///
-       InsetFootlike();
+       InsetFootlike(BufferParams const &);
        ///
        InsetFootlike(InsetFootlike const &, bool same_id = false);
        ///
index 1a0eb1b5bece05e73a06a2be8b4033ca650be9d9..babd19772ff9d1323086415bf8b8a9ed1a54ff7a 100644 (file)
@@ -27,8 +27,8 @@
 using std::ostream;
 
 
-InsetMarginal::InsetMarginal()
-       : InsetFootlike()
+InsetMarginal::InsetMarginal(BufferParams const & bp)
+       : InsetFootlike(bp)
 {
        setLabel(_("margin"));
        setInsetName("Marginal");
index 10329a97127ffcede2b96d9332dcaa01a8f932df..cb7a6fca2f98c1ed8d2df2ad1a9cbaaf614db03d 100644 (file)
@@ -24,7 +24,7 @@
 class InsetMarginal : public InsetFootlike {
 public:
        ///
-       InsetMarginal();
+       InsetMarginal(BufferParams const &);
        ///
        InsetMarginal(InsetMarginal const &, bool same_id = false);
        ///
index 9d194680131eb4296f0b88d486e4d04e0250aa81..b01bd3b858a104f5d033dd3db0b4894f62c26783 100644 (file)
@@ -59,8 +59,8 @@ using std::endl;
 // have to output "" for minipages.
 // (Lgb)
 
-InsetMinipage::InsetMinipage()
-       : InsetCollapsable(), pos_(center),
+InsetMinipage::InsetMinipage(BufferParams const & bp)
+       : InsetCollapsable(bp), pos_(center),
          inner_pos_(inner_center), width_(100, LyXLength::PW)
 {
        setLabel(_("minipage"));
index e46de56167fbc2263ae4946be2709e6f69e2b040..b58a7b8cf91764fc21786e53124df93e199eadc1 100644 (file)
@@ -39,7 +39,7 @@ public:
                inner_stretch
        };
        ///
-       InsetMinipage();
+       InsetMinipage(BufferParams const &);
        ///
        InsetMinipage(InsetMinipage const &, bool same_id = false);
        ///
index da3c39bfd6449a9f938261ad331b4db4b86358aa..f8b3598c7d75cab15801086e1674d488fd988d98 100644 (file)
@@ -41,8 +41,8 @@ void InsetNote::init()
 }
 
 
-InsetNote::InsetNote()
-       : InsetCollapsable()
+InsetNote::InsetNote(BufferParams const & bp)
+       : InsetCollapsable(bp)
 {
        init();
 }
@@ -64,7 +64,7 @@ Inset * InsetNote::clone(Buffer const &, bool same_id) const
 // This constructor is used for reading old InsetInfo
 InsetNote::InsetNote(Buffer const * buf, string const & contents, 
                     bool collapsed)
-       : InsetCollapsable(collapsed)
+       : InsetCollapsable(buf->params, collapsed)
 {
        init();
 
index 5def38e637c8022609ac35f964508768045ad6e3..ed02318d088ff8a2dfa3a86cfac6b79921640c8e 100644 (file)
@@ -24,7 +24,7 @@
 class InsetNote : public InsetCollapsable {
 public:
        /// 
-       InsetNote();
+       InsetNote(BufferParams const &);
        ///
        InsetNote(InsetNote const &, bool same_id = false);
        ///
index 7f9ae0cf01b9cbf289de21f8a7a1c7c4abf4a5c2..ea5ee8aae5e6a93be59a9cf07b05319248104b68 100644 (file)
@@ -135,7 +135,7 @@ InsetTabular::InsetTabular(Buffer const & buf, int rows, int columns)
                rows = 1;
        if (columns <= 0)
                columns = 1;
-       tabular.reset(new LyXTabular(this, rows, columns));
+       tabular.reset(new LyXTabular(buf.params, this, rows, columns));
        // for now make it always display as display() inset
        // just for test!!!
        the_locking_inset = 0;
@@ -156,7 +156,8 @@ InsetTabular::InsetTabular(InsetTabular const & tab, Buffer const & buf,
                                                   bool same_id)
        : UpdatableInset(tab, same_id), buffer(&buf)
 {
-       tabular.reset(new LyXTabular(this, *(tab.tabular), same_id));
+       tabular.reset(new LyXTabular(buf.params,
+                                    this, *(tab.tabular), same_id));
        the_locking_inset = 0;
        old_locking_inset = 0;
        locked = false;
@@ -1037,10 +1038,10 @@ InsetTabular::localDispatch(BufferView * bv, kb_action action,
                }
                int column = actcol;
                unlockInsetInInset(bv, the_locking_inset);
-               if (bv->text->first + bv->painter().paperHeight() <
+               if (bv->text->first_y + bv->painter().paperHeight() <
                    (top_baseline + tabular->GetHeightOfTabular()))
                        {
-                               bv->scrollCB(bv->text->first + bv->painter().paperHeight());
+                               bv->scrollCB(bv->text->first_y + bv->painter().paperHeight());
                                code = FULL;
                                actcell = tabular->GetCellBelow(first_visible_cell) + column;
                        } else {
@@ -1059,7 +1060,7 @@ InsetTabular::localDispatch(BufferView * bv, kb_action action,
                int column = actcol;
                unlockInsetInInset(bv, the_locking_inset);
                if (top_baseline < 0) {
-                       bv->scrollCB(bv->text->first - bv->painter().paperHeight());
+                       bv->scrollCB(bv->text->first_y - bv->painter().paperHeight());
                        code = FULL;
                        if (top_baseline > 0)
                                actcell = column;
@@ -1148,7 +1149,8 @@ InsetTabular::localDispatch(BufferView * bv, kb_action action,
                        }
                        maxCols = max(cols, maxCols);
                        delete paste_tabular;
-                       paste_tabular = new LyXTabular(this, rows, maxCols);
+                       paste_tabular = new LyXTabular(bv->buffer()->params,
+                                                      this, rows, maxCols);
                        string::size_type op = 0;
                        int cell = 0;
                        int cells = paste_tabular->GetNumberOfCells();
@@ -1869,13 +1871,13 @@ void InsetTabular::tabularFeatures(BufferView * bv,
        case LyXTabular::APPEND_ROW:
                // append the row into the tabular
                unlockInsetInInset(bv, the_locking_inset);
-               tabular->AppendRow(actcell);
+               tabular->AppendRow(bv->buffer()->params, actcell);
                updateLocal(bv, INIT, true);
                break;
        case LyXTabular::APPEND_COLUMN:
                // append the column into the tabular
                unlockInsetInInset(bv, the_locking_inset);
-               tabular->AppendColumn(actcell);
+               tabular->AppendColumn(bv->buffer()->params, actcell);
                actcell = tabular->GetCellNumber(row, column);
                updateLocal(bv, INIT, true);
                break;
@@ -2426,7 +2428,8 @@ bool InsetTabular::copySelection(BufferView * bv)
        int const rows = sel_row_end - sel_row_start + 1;
 
        delete paste_tabular;
-       paste_tabular = new LyXTabular(this, *tabular); // rows, columns);
+       paste_tabular = new LyXTabular(bv->buffer()->params,
+                                      this, *tabular); // rows, columns);
        for (int i = 0; i < sel_row_start; ++i)
                paste_tabular->DeleteRow(0);
        while (paste_tabular->rows() > rows)
index f22c7cf84ed01192d1363747486308be32f285e3..db840f6b13bdf77d35a13b3f54b43cfd10789810 100644 (file)
@@ -135,11 +135,13 @@ InsetText::InnerCache::InnerCache(boost::shared_ptr<LyXText> t)
 }
 
 
-InsetText::InsetText()
+InsetText::InsetText(BufferParams const & bp)
        : UpdatableInset(), lt(0), in_update(false), do_resize(0),
          do_reinit(false)
 {
        par = new Paragraph;
+       par->layout(textclasslist[bp.textclass].defaultLayoutName());
+       
        init();
 }
 
@@ -445,7 +447,7 @@ void InsetText::draw(BufferView * bv, LyXFont const & f,
        }
        if (y_offset < 0)
                y_offset = y;
-       lt->first = first;
+       lt->first_y = first;
        if (cleared || (need_update&(INIT|FULL))) {
                int yf = y_offset;
                y = 0;
@@ -897,7 +899,7 @@ void InsetText::insetButtonPress(BufferView * bv, int x, int y, int button)
        mouse_y = y;
 
        int tmp_x = x - drawTextXOffset;
-       int tmp_y = y + insetAscent - getLyXText(bv)->first;
+       int tmp_y = y + insetAscent - getLyXText(bv)->first_y;
        Inset * inset = bv->checkInsetHit(getLyXText(bv), tmp_x, tmp_y);
 
        hideInsetCursor(bv);
@@ -1002,7 +1004,7 @@ bool InsetText::insetButtonRelease(BufferView * bv, int x, int y, int button)
                                                             button);
        }
        int tmp_x = x - drawTextXOffset;
-       int tmp_y = y + insetAscent - getLyXText(bv)->first;
+       int tmp_y = y + insetAscent - getLyXText(bv)->first_y;
        Inset * inset = bv->checkInsetHit(getLyXText(bv), tmp_x, tmp_y);
        bool ret = false;
        if (inset) {
@@ -1324,7 +1326,7 @@ InsetText::localDispatch(BufferView * bv,
                        // Derive layout number from given argument (string)
                        // and current buffer's textclass (number). */    
                        textclass_type tclass = bv->buffer()->params.textclass;
-                       string layout = lowercase(arg);
+                       string layout = arg;
                        bool hasLayout = textclasslist[tclass].hasLayout(layout);
 
                        // If the entry is obsolete, use the new one instead.
@@ -1333,7 +1335,7 @@ InsetText::localDispatch(BufferView * bv,
                                        textclasslist[tclass][layout].
                                        obsoleted_by();
                                if (!obs.empty()) 
-                                       layout = lowercase(obs);
+                                       layout = obs;
                        }
 
                        // see if we found the layout number:
@@ -2251,7 +2253,7 @@ void InsetText::resizeLyXText(BufferView * bv, bool force) const
        }
 
        if (bv->screen()) {
-               t->first = bv->screen()->topCursorVisible(t);
+               t->first_y = bv->screen()->topCursorVisible(t);
        }
        if (!owner()) {
                updateLocal(bv, FULL, false);
@@ -2291,7 +2293,7 @@ void InsetText::reinitLyXText() const
                        inset_y = cy(bv) + drawTextYOffset;
                }
                if (bv->screen()) {
-                       t->first = bv->screen()->topCursorVisible(t);
+                       t->first_y = bv->screen()->topCursorVisible(t);
                }
                if (!owner()) {
                        updateLocal(bv, FULL, false);
index 55aea7d4e9c7a4475aedc38886fe7c08c2c96fc3..91fe8da05baba4fe2d5e2dd1b6ea2cafcb2b2887 100644 (file)
@@ -30,6 +30,7 @@
 class Painter;
 class BufferView;
 class Buffer;
+class BufferParams;
 class LyXCursor;
 class LyXText;
 class LyXScreen;
@@ -73,7 +74,7 @@ public:
                ALWAYS
        };
        ///
-       InsetText();
+       InsetText(BufferParams const &);
        ///
        explicit
        InsetText(InsetText const &, bool same_id = false);
index bc9eda41079550b407ccd1b3c2162494b2d1108b..0fd63445cc3e80c19d84a4b21ec0b8e799253bb2 100644 (file)
@@ -180,12 +180,12 @@ bool LyXLayout::Read (LyXLex & lexrc, LyXTextClass const & tclass)
 
                case LT_COPYSTYLE:     // initialize with a known style
                        if (lexrc.next()) {
-                               string const style = lowercase(lexrc.getString());
+                               string const style = lexrc.getString();
                        
                                if (tclass.hasLayout(style)) {
-                                       string const tmpname = lowercase(name_);
+                                       string const tmpname = name_;
                                        this->operator=(tclass[style]);
-                                       name_ = lowercase(tmpname);
+                                       name_ = tmpname;
                                } else {
                                        lyxerr << "Cannot copy unknown style `" << style << "'" << endl;
                                        LyXTextClass::const_iterator it = tclass.begin();
@@ -203,7 +203,7 @@ bool LyXLayout::Read (LyXLex & lexrc, LyXTextClass const & tclass)
 
                case LT_OBSOLETEDBY:     // replace with a known style
                        if (lexrc.next()) {
-                               string const style = lowercase(lexrc.getString());
+                               string const style = lexrc.getString();
                                
                                if (tclass.hasLayout(style)) {
                                        string const tmpname = name_;
@@ -736,21 +736,17 @@ void LyXLayout::readSpacing(LyXLex & lexrc)
 
 string const & LyXLayout::name() const
 {
-       static string name_t;
-       name_t = lowercase(name_);
-       return name_t;
+       return name_;
 }
 
 
 void LyXLayout::setName(string const & n)
 {
-       name_ = lowercase(n);
+       name_ = n;
 }
 
 
 string const & LyXLayout::obsoleted_by() const
 {
-       static string obsoleted_by_t;
-       obsoleted_by_t = lowercase(obsoleted_by_);
-       return obsoleted_by_t;
+       return obsoleted_by_;
 }
index 89ffc10999321b2ca65ff95b87524d9cb8973d9a..18812862ca2d0f6c9ec31331ae8b444d34eeb880 100644 (file)
@@ -85,7 +85,7 @@ public:
        mutable LyXFont real_current_font;
        /// first visible pixel-row is set from LyXScreen!!!
        // unsigned is wrong here for text-insets!
-       int first;
+       int first_y;
        ///
        BufferView * bv_owner;
        ///
@@ -507,9 +507,10 @@ public:
 private:
        ///
        mutable Row * firstrow;
+
        ///
        mutable Row * lastrow;
-
+       
        /** Copybuffer for copy environment type.
          Asger has learned that this should be a buffer-property instead
          Lgb has learned that 'char' is a lousy type for non-characters
index cefc00a93b7540468a8708a3692662fb3a9d4099..7fdb478d96bb26b6b507b724ba2b70bb59bd7803 100644 (file)
@@ -172,14 +172,15 @@ bool LyXTextClass::Read(string const & filename, bool merge)
 
                case TC_DEFAULTSTYLE:
                        if (lexrc.next()) {
-                               string const name = subst(lowercase(lexrc.getString()), '_', ' ');
+                               string const name = subst(lexrc.getString(),
+                                                         '_', ' ');
                                defaultlayout_ = name;
                        }
                        break;
                        
                case TC_STYLE:
                        if (lexrc.next()) {
-                               string const name = subst(lowercase(lexrc.getString()),
+                               string const name = subst(lexrc.getString(),
                                                    '_', ' ');
                                if (hasLayout(name)) {
                                        LyXLayout & lay = operator[](name);
@@ -189,6 +190,13 @@ bool LyXTextClass::Read(string const & filename, bool merge)
                                        lay.setName(name);
                                        if (!(error = do_readStyle(lexrc, lay)))
                                                layoutlist.push_back(lay);
+                                       if (defaultlayout_.empty()) {
+                                               // We do not have a default
+                                               // layout yet, so we choose
+                                               // the first layout we
+                                               // encounter.
+                                               defaultlayout_ = name;
+                                       }
                                }
                        }
                        else {
@@ -199,7 +207,7 @@ bool LyXTextClass::Read(string const & filename, bool merge)
 
                case TC_NOSTYLE:
                        if (lexrc.next()) {
-                               string const style = subst(lowercase(lexrc.getString()),
+                               string const style = subst(lexrc.getString(),
                                                     '_', ' ');
                                if (!delete_layout(style))
                                        lyxerr << "Cannot delete style `" << style << "'" << endl;
@@ -487,7 +495,7 @@ string const & LyXTextClass::rightmargin() const
 
 bool LyXTextClass::hasLayout(string const & n) const
 {
-       string const name = (n.empty() ? defaultLayoutName() : lowercase(n));
+       string const name = (n.empty() ? defaultLayoutName() : n);
        
        return find_if(layoutlist.begin(), layoutlist.end(),
                       lyx::compare_memfun(&LyXLayout::name, name))
@@ -500,7 +508,7 @@ LyXLayout const & LyXTextClass::operator[](string const & n) const
        if (n.empty())
                lyxerr << "Operator[] called with empty n" << endl;
        
-       string const name = (n.empty() ? defaultLayoutName() : lowercase(n));
+       string const name = (n.empty() ? defaultLayoutName() : n);
        
        LayoutList::const_iterator cit =
                find_if(layoutlist.begin(),
@@ -525,7 +533,7 @@ LyXLayout & LyXTextClass::operator[](string const & n)
        if (n.empty())
                lyxerr << "Operator[] called with empty n" << endl;
 
-       string const name = (n.empty() ? defaultLayoutName() : lowercase(n));
+       string const name = (n.empty() ? defaultLayoutName() : n);
        
        LayoutList::iterator it =
                find_if(layoutlist.begin(),
@@ -545,10 +553,8 @@ LyXLayout & LyXTextClass::operator[](string const & n)
 }
 
 
-bool LyXTextClass::delete_layout(string const & n)
+bool LyXTextClass::delete_layout(string const & name)
 {
-       string const name = lowercase(n);
-
        if (name == defaultLayoutName())
                return false;
        
index e8fb22e4f3704611c1fea8887a5b5eb8860bf38f..bcc3eb9864240f454ecbe1ed5da11cf3df279b7f 100644 (file)
@@ -859,6 +859,8 @@ void Paragraph::breakParagraph(BufferParams const & bparams,
 {
        // create a new paragraph
        Paragraph * tmp = new Paragraph(this);
+       tmp->layout(layout());
+       
        // remember to set the inset_owner
        tmp->setInsetOwner(inInset());
        
index b76facc058abe6f18b866b6e1198f08b31494270..ee6202e32444494774208304b9a5aa9f310bbdd6 100644 (file)
@@ -115,19 +115,19 @@ void LyXScreen::drawFromTo(LyXText * text, BufferView * bv,
                            int y1, int y2, int y_offset, int x_offset,
                            bool internal)
 {
-       int y_text = text->first + y1;
+       int y_text = text->first_y + y1;
    
        // get the first needed row 
        Row * row = text->getRowNearY(y_text);
        // y_text is now the real beginning of the row
    
-       int y = y_text - text->first;
+       int y = y_text - text->first_y;
        // y1 is now the real beginning of row on the screen
        
        while (row != 0 && y < y2) {
                LyXText::text_status st = text->status();
                text->getVisibleRow(bv, y + y_offset,
-                                   x_offset, row, y + text->first);
+                                   x_offset, row, y + text->first_y);
                internal = internal && (st != LyXText::CHANGED_IN_DRAW);
                while (internal && text->status() == LyXText::CHANGED_IN_DRAW) {
                        if (text->fullRebreak(bv)) {
@@ -136,7 +136,7 @@ void LyXScreen::drawFromTo(LyXText * text, BufferView * bv,
                        }
                        text->status(bv, st);
                        text->getVisibleRow(bv, y + y_offset,
-                                           x_offset, row, y + text->first);
+                                           x_offset, row, y + text->first_y);
                }
                y += row->height();
                row = row->next();
@@ -156,7 +156,7 @@ void LyXScreen::drawFromTo(LyXText * text, BufferView * bv,
 void LyXScreen::drawOneRow(LyXText * text, BufferView * bv, Row * row,
                           int y_text, int y_offset, int x_offset)
 {
-       int const y = y_text - text->first + y_offset;
+       int const y = y_text - text->first_y + y_offset;
 
        if (((y + row->height()) > 0) &&
            ((y - row->height()) <= static_cast<int>(owner.height()))) {
@@ -166,12 +166,12 @@ void LyXScreen::drawOneRow(LyXText * text, BufferView * bv, Row * row,
                do {
                        bv->text->status(bv, st);
                        text->getVisibleRow(bv, y, x_offset, row,
-                                           y + text->first);
+                                           y + text->first_y);
                } while (!text->inset_owner &&
                         text->status() == LyXText::CHANGED_IN_DRAW);
                bv->text->status(bv, st);
 #else
-               text->getVisibleRow(bv, y, x_offset, row, y + text->first);
+               text->getVisibleRow(bv, y, x_offset, row, y + text->first_y);
 #endif
        }
        force_clear = false;
@@ -184,16 +184,17 @@ void LyXScreen::draw(LyXText * text, BufferView * bv, unsigned int y)
 {
        if (cursor_visible) hideCursor();
 
-       int const old_first = text->first;
+       int const old_first = text->first_y;
        bool internal = (text == bv->text);
-       text->first = y;
+       text->first_y = y;
 
        // is any optimiziation possible?
        if ((y - old_first) < owner.height()
            && (old_first - y) < owner.height())
        {
-               if (text->first < old_first) {
-                       drawFromTo(text, bv, 0, old_first - text->first, 0, 0, internal);
+               if (text->first_y < old_first) {
+                       drawFromTo(text, bv, 0,
+                                  old_first - text->first_y, 0, 0, internal);
                        XCopyArea (fl_get_display(),
                                   owner.getWin(),
                                   owner.getWin(),
@@ -201,31 +202,31 @@ void LyXScreen::draw(LyXText * text, BufferView * bv, unsigned int y)
                                   owner.xpos(),
                                   owner.ypos(),
                                   owner.workWidth(),
-                                  owner.height() - old_first + text->first,
+                                  owner.height() - old_first + text->first_y,
                                   owner.xpos(),
-                                  owner.ypos() + old_first - text->first
+                                  owner.ypos() + old_first - text->first_y
                                );
                        // expose the area drawn
                        expose(0, 0,
                               owner.workWidth(),
-                              old_first - text->first);
+                              old_first - text->first_y);
                } else  {
                        drawFromTo(text, bv,
-                                  owner.height() + old_first - text->first,
+                                  owner.height() + old_first - text->first_y,
                                   owner.height(), 0, 0, internal);
                        XCopyArea (fl_get_display(),
                                   owner.getWin(),
                                   owner.getWin(),
                                   gc_copy,
                                   owner.xpos(),
-                                  owner.ypos() + text->first - old_first,
+                                  owner.ypos() + text->first_y - old_first,
                                   owner.workWidth(),
-                                  owner.height() + old_first - text->first,
+                                  owner.height() + old_first - text->first_y,
                                   owner.xpos(),
                                   owner.ypos());
                        // expose the area drawn
-                       expose(0, owner.height() + old_first - text->first,
-                              owner.workWidth(), text->first - old_first);
+                       expose(0, owner.height() + old_first - text->first_y,
+                              owner.workWidth(), text->first_y - old_first);
                }
        } else {
                // make a dumb new-draw 
@@ -257,20 +258,20 @@ void LyXScreen::showCursor(LyXText const * text, BufferView const * bv)
 bool LyXScreen::fitManualCursor(LyXText * text, BufferView * bv,
                                int /*x*/, int y, int asc, int desc)
 {
-       int newtop = text->first;
+       int newtop = text->first_y;
   
-       if (y + desc - text->first >= static_cast<int>(owner.height()))
+       if (y + desc - text->first_y >= static_cast<int>(owner.height()))
                newtop = y - 3 * owner.height() / 4;  // the scroll region must be so big!!
-       else if (y - asc < static_cast<int>(text->first)
-               && text->first > 0) {
+       else if (y - asc < text->first_y
+               && text->first_y > 0) {
                newtop = y - owner.height() / 4;
        }
 
        newtop = max(newtop, 0); // can newtop ever be < 0? (Lgb)
   
-       if (newtop != static_cast<int>(text->first)) {
+       if (newtop != text->first_y) {
                draw(text, bv, newtop);
-               text->first = newtop;
+               text->first_y = newtop;
                return true;
        }
        return false;
@@ -283,8 +284,8 @@ void LyXScreen::showManualCursor(LyXText const * text, int x, int y,
        // Update the cursor color.
        setCursorColor();
        
-       int const y1 = max(y - text->first - asc, 0);
-       int const y_tmp = min(y - text->first + desc,
+       int const y1 = max(y - text->first_y - asc, 0);
+       int const y_tmp = min(y - text->first_y + desc,
                              static_cast<int>(owner.height()));
 
        // Secure against very strange situations
@@ -386,7 +387,7 @@ void LyXScreen::cursorToggle(BufferView * bv) const
 /* returns a new top so that the cursor is visible */ 
 unsigned int LyXScreen::topCursorVisible(LyXText const * text)
 {
-       int newtop = text->first;
+       int newtop = text->first_y;
 
        Row * row = text->cursor.row();
 
@@ -395,7 +396,7 @@ unsigned int LyXScreen::topCursorVisible(LyXText const * text)
                return max(newtop, 0);
        
        if (text->cursor.y() - row->baseline() + row->height()
-           - text->first >= owner.height()) {
+           - text->first_y >= owner.height()) {
                if (row->height() < owner.height()
                    && row->height() > owner.height() / 4) {
                        newtop = text->cursor.y()
@@ -408,14 +409,14 @@ unsigned int LyXScreen::topCursorVisible(LyXText const * text)
                }
                
        } else if (static_cast<int>((text->cursor.y()) - row->baseline()) <
-                  text->first && text->first > 0) {
+                  text->first_y && text->first_y > 0) {
                if (row->height() < owner.height()
                    && row->height() > owner.height() / 4) {
                        newtop = text->cursor.y() - row->baseline();
                } else {
                        // scroll up
                        newtop = text->cursor.y() - owner.height() / 2;
-                       newtop = min(newtop, int(text->first));
+                       newtop = min(newtop, text->first_y);
                }
        }
 
@@ -431,7 +432,7 @@ bool LyXScreen::fitCursor(LyXText * text, BufferView * bv)
 {
        // Is a change necessary?
        int const newtop = topCursorVisible(text);
-       bool const result = (newtop != text->first);
+       bool const result = (newtop != text->first_y);
        if (result)
                draw(text, bv, newtop);
        return result;
@@ -444,7 +445,7 @@ void LyXScreen::update(LyXText * text, BufferView * bv,
        switch (text->status()) {
        case LyXText::NEED_MORE_REFRESH:
        {
-               int const y = max(int(text->refresh_y - text->first), 0);
+               int const y = max(int(text->refresh_y - text->first_y), 0);
                drawFromTo(text, bv, y, owner.height(), y_offset, x_offset);
                text->refresh_y = 0;
                // otherwise this is called ONLY from BufferView_pimpl(update)
@@ -466,7 +467,7 @@ void LyXScreen::update(LyXText * text, BufferView * bv,
                        // or we should see to set this flag accordingly
                        if (text != bv->text)
                                text->status(bv, LyXText::UNCHANGED);
-                       expose(0, text->refresh_y - text->first + y_offset,
+                       expose(0, text->refresh_y - text->first_y + y_offset,
                                   owner.workWidth(), text->refresh_row->height());
                }
        }
@@ -490,21 +491,21 @@ void LyXScreen::toggleSelection(LyXText * text, BufferView * bv,
                max(static_cast<int>(text->selection.end.y()
                                     - text->selection.end.row()->baseline()
                                     + text->selection.end.row()->height()),
-                   text->first),
-               static_cast<int>(text->first + owner.height()));
+                   text->first_y),
+               static_cast<int>(text->first_y + owner.height()));
        int const top = min(
                max(static_cast<int>(text->selection.start.y() -
                                     text->selection.start.row()->baseline()),
-                   text->first),
-               static_cast<int>(text->first + owner.height()));
+                   text->first_y),
+               static_cast<int>(text->first_y + owner.height()));
 
        if (kill_selection)
                text->selection.set(false);
-       drawFromTo(text, bv, top - text->first, bottom - text->first,
+       drawFromTo(text, bv, top - text->first_y, bottom - text->first_y,
                   y_offset, x_offset);
-       expose(0, top - text->first,
+       expose(0, top - text->first_y,
               owner.workWidth(),
-              bottom - text->first - (top - text->first));
+              bottom - text->first_y - (top - text->first_y));
 }
   
    
@@ -521,13 +522,14 @@ void LyXScreen::toggleToggle(LyXText * text, BufferView * bv,
                - text->toggle_end_cursor.row()->baseline() 
                + text->toggle_end_cursor.row()->height();
        
-       int const bottom = min(max(bottom_tmp, text->first),
-                    static_cast<int>(text->first + owner.height()));
-       int const top = min(max(top_tmp, text->first),
-                 static_cast<int>(text->first + owner.height()));
+       int const bottom = min(max(bottom_tmp, text->first_y),
+                    static_cast<int>(text->first_y + owner.height()));
+       int const top = min(max(top_tmp, text->first_y),
+                 static_cast<int>(text->first_y + owner.height()));
 
-       drawFromTo(text, bv, top - text->first, bottom - text->first, y_offset,
+       drawFromTo(text, bv, top - text->first_y,
+                  bottom - text->first_y, y_offset,
                   x_offset);
-       expose(0, top - text->first, owner.workWidth(),
-              bottom - text->first - (top - text->first));
+       expose(0, top - text->first_y, owner.workWidth(),
+              bottom - text->first_y - (top - text->first_y));
 }
index 1ab944317f1bb06b43bec7bffbe08f3978431311..3e06db9a68b5a9111f0e9fd5a3318bc1753023a9 100644 (file)
@@ -13,7 +13,9 @@
 #include <config.h>
 
 #include "tabular.h"
+#include "buffer.h"
 #include "debug.h"
+
 #include "support/lstrings.h"
 #include "support/textutils.h"
 
@@ -159,7 +161,7 @@ void LyXTabular::ReadOld(Buffer const * buf, istream & is,
        return;
     if (!getTokenValue(line, "columns", columns_arg))
        return;
-    Init(rows_arg, columns_arg);
+    Init(buf->params, rows_arg, columns_arg);
     l_getline(is, line);
     if (!prefixIs(line, "<Features ")) {
        lyxerr << "Wrong tabular format (expected <Feture ...> got" <<
index de046eab704aa1c857b73908c6622541cd75f10e..e72d5ae0b626bfd1088f39da95d03f0eaa7615a6 100644 (file)
@@ -58,7 +58,8 @@ namespace {
 
 /// Define a few methods for the inner structs
 
-LyXTabular::cellstruct::cellstruct() 
+LyXTabular::cellstruct::cellstruct(BufferParams const & bg)
+       : inset(bg)
 {
        cellno = 0;
        width_of_cell = 0;
@@ -107,20 +108,22 @@ LyXTabular::lttype::lttype()
 
 
 /* konstruktor */
-LyXTabular::LyXTabular(InsetTabular * inset, int rows_arg, int columns_arg)
+LyXTabular::LyXTabular(BufferParams const & bp,
+                      InsetTabular * inset, int rows_arg, int columns_arg)
 {
        owner_ = inset;
        cur_cell = -1;
-       Init(rows_arg, columns_arg);
+       Init(bp, rows_arg, columns_arg);
 }
 
 
-LyXTabular::LyXTabular(InsetTabular * inset, LyXTabular const & lt,
+LyXTabular::LyXTabular(BufferParams const & bp,
+                      InsetTabular * inset, LyXTabular const & lt,
                        bool same_id)
 {
        owner_ = inset;
        cur_cell = -1;
-       Init(lt.rows_, lt.columns_, &lt);
+       Init(bp, lt.rows_, lt.columns_, &lt);
        // we really should change again to have InsetText as a pointer
        // and allocate it then we would not have to do this stuff all
        // double!
@@ -174,9 +177,10 @@ LyXTabular & LyXTabular::operator=(LyXTabular const & lt)
 }
 
 
-LyXTabular * LyXTabular::clone(InsetTabular * inset, bool same_id)
+LyXTabular * LyXTabular::clone(BufferParams const & bp,
+                              InsetTabular * inset, bool same_id)
 {
-       LyXTabular * result = new LyXTabular(inset, *this, same_id);
+       LyXTabular * result = new LyXTabular(bp, inset, *this, same_id);
 #if 0
        // don't know if this is good but I need to Clone also
        // the text-insets here, this is for the Undo-facility!
@@ -192,13 +196,14 @@ LyXTabular * LyXTabular::clone(InsetTabular * inset, bool same_id)
 
 
 /* activates all lines and sets all widths to 0 */ 
-void LyXTabular::Init(int rows_arg, int columns_arg, LyXTabular const * lt)
+void LyXTabular::Init(BufferParams const & bp,
+                     int rows_arg, int columns_arg, LyXTabular const * lt)
 {
        rows_ = rows_arg;
        columns_ = columns_arg;
        row_info = row_vector(rows_, rowstruct());
        column_info = column_vector(columns_, columnstruct());
-       cell_info = cell_vvector(rows_, cell_vector(columns_, cellstruct()));
+       cell_info = cell_vvector(rows_, cell_vector(columns_, cellstruct(bp)));
 
        if (lt) {
                operator=(*lt);
@@ -232,7 +237,7 @@ void LyXTabular::Init(int rows_arg, int columns_arg, LyXTabular const * lt)
 }
 
 
-void LyXTabular::AppendRow(int cell)
+void LyXTabular::AppendRow(BufferParams const & bp, int cell)
 {
        ++rows_;
    
@@ -241,14 +246,14 @@ void LyXTabular::AppendRow(int cell)
        row_vector::iterator rit = row_info.begin() + row;
        row_info.insert(rit, rowstruct());
        // now set the values of the row before
-       row_info[row] = row_info[row+1];
+       row_info[row] = row_info[row + 1];
 
 #if 0
        cell_vvector::iterator cit = cell_info.begin() + row;
-       cell_info.insert(cit, vector<cellstruct>(columns_, cellstruct()));
+       cell_info.insert(cit, vector<cellstruct>(columns_, cellstruct(bp)));
 #else
        cell_vvector c_info = cell_vvector(rows_, cell_vector(columns_,
-                                                                                                                 cellstruct()));
+                                                             cellstruct(bp)));
 
        for (int i = 0; i <= row; ++i) {
                for (int j = 0; j < columns_; ++j) {
@@ -281,17 +286,17 @@ void LyXTabular::DeleteRow(int row)
 }
 
 
-void LyXTabular::AppendColumn(int cell)
+void LyXTabular::AppendColumn(BufferParams const & bp, int cell)
 {
        ++columns_;
    
        cell_vvector c_info = cell_vvector(rows_, cell_vector(columns_,
-                                                                                                                 cellstruct()));
+                                                             cellstruct(bp)));
        int const column = column_of_cell(cell);
        column_vector::iterator cit = column_info.begin() + column + 1;
        column_info.insert(cit, columnstruct());
        // set the column values of the column before
-       column_info[column+1] = column_info[column];
+       column_info[column + 1] = column_info[column];
 
        for (int i = 0; i < rows_; ++i) {
                for (int j = 0; j <= column; ++j) {
@@ -1084,7 +1089,7 @@ void LyXTabular::Read(Buffer const * buf, LyXLex & lex)
        l_getline(is, line);
        if (!prefixIs(line, "<lyxtabular ")
                && !prefixIs(line, "<LyXTabular ")) {
-               OldFormatRead(lex, line);
+               OldFormatRead(buf->params, lex, line);
                return;
        }
 
@@ -1110,7 +1115,7 @@ void LyXTabular::setHeaderFooterRows(int hr, int fhr, int fr, int lfr)
                                row_info[--fhr].endfirsthead = true;
                                row_info[fhr].endhead = false;
                        }
-               } else if (row_info[fhr-1].endhead) {
+               } else if (row_info[fhr - 1].endhead) {
                        endfirsthead.empty = true;
                } else {
                        while((fhr > 0) && !row_info[--fhr].endhead) {
@@ -1130,7 +1135,7 @@ void LyXTabular::setHeaderFooterRows(int hr, int fhr, int fr, int lfr)
                                row_info[fr].endfoot = true;
                                row_info[fr].endfirsthead = false;
                        }
-               } else if (!row_info[fr-1].endhead && !row_info[fr-1].endfirsthead) {
+               } else if (!row_info[fr - 1].endhead && !row_info[fr - 1].endfirsthead) {
                        while((fr > 0) && !row_info[--fr].endhead &&
                                  !row_info[fr].endfirsthead)
                        {
@@ -1140,25 +1145,27 @@ void LyXTabular::setHeaderFooterRows(int hr, int fhr, int fr, int lfr)
        }
        // set lastfooter info
        if (lfr && (lfr < rows_)) {
-               if (row_info[lfr].endhead && row_info[lfr-1].endhead) {
+               if (row_info[lfr].endhead && row_info[lfr - 1].endhead) {
                        while((lfr > 0) && !row_info[--lfr].endhead) {
                                row_info[lfr].endlastfoot = true;
                                row_info[lfr].endhead = false;
                        }
                } else if (row_info[lfr].endfirsthead &&
-                                  row_info[lfr-1].endfirsthead)
+                                  row_info[lfr - 1].endfirsthead)
                {
                        while((lfr > 0) && !row_info[--lfr].endfirsthead) {
                                row_info[lfr].endlastfoot = true;
                                row_info[lfr].endfirsthead = false;
                        }
-               } else if (row_info[lfr].endfoot && row_info[lfr-1].endfoot) {
+               } else if (row_info[lfr].endfoot
+                          && row_info[lfr - 1].endfoot) {
                        while((lfr > 0) && !row_info[--lfr].endfoot) {
                                row_info[lfr].endlastfoot = true;
                                row_info[lfr].endfoot = false;
                        }
-               } else if (!row_info[fr-1].endhead && !row_info[fr-1].endfirsthead &&
-                                  !row_info[fr-1].endfoot)
+               } else if (!row_info[fr - 1].endhead
+                          && !row_info[fr - 1].endfirsthead &&
+                                  !row_info[fr - 1].endfoot)
                {
                        while((lfr > 0) &&
                                  !row_info[--lfr].endhead && !row_info[lfr].endfirsthead &&
@@ -1173,7 +1180,7 @@ void LyXTabular::setHeaderFooterRows(int hr, int fhr, int fr, int lfr)
 }
 
 void LyXTabular::ReadNew(Buffer const * buf, istream & is,
-                                                LyXLex & lex, string const & l, int const version)
+                        LyXLex & lex, string const & l, int const version)
 {
        string line(l);
        int rows_arg;
@@ -1182,7 +1189,7 @@ void LyXTabular::ReadNew(Buffer const * buf, istream & is,
        int columns_arg;
        if (!getTokenValue(line, "columns", columns_arg))
                return;
-       Init(rows_arg, columns_arg);
+       Init(buf->params, rows_arg, columns_arg);
        l_getline(is, line);
        if (!prefixIs(line, "<features")) {
                lyxerr << "Wrong tabular format (expected <features ...> got" <<
@@ -1294,7 +1301,8 @@ void LyXTabular::ReadNew(Buffer const * buf, istream & is,
 }
 
 
-void LyXTabular::OldFormatRead(LyXLex & lex, string const & fl)
+void LyXTabular::OldFormatRead(BufferParams const & bp,
+                              LyXLex & lex, string const & fl)
 {
        int version;
        int i;
@@ -1332,7 +1340,7 @@ void LyXTabular::OldFormatRead(LyXLex & lex, string const & fl)
                           >> rotate_arg >> a >> b >> c >> d;
                } else
                        is >> rows_arg >> columns_arg;
-               Init(rows_arg, columns_arg);
+               Init(bp, rows_arg, columns_arg);
                cont_row_info = vector<int>(rows_arg);
                SetLongTabular(is_long_tabular_arg);
                SetRotateTabular(rotate_arg);
@@ -1352,7 +1360,7 @@ void LyXTabular::OldFormatRead(LyXLex & lex, string const & fl)
        } else {
                is >> rows_arg >> columns_arg >> is_long_tabular_arg
                   >> rotate_arg >> a >> b >> c >> d;
-               Init(rows_arg, columns_arg);
+               Init(bp, rows_arg, columns_arg);
                cont_row_info = vector<int>(rows_arg);
                SetLongTabular(is_long_tabular_arg);
                SetRotateTabular(rotate_arg);
index 9352f0425884fd5915d51bb8c3bc423931853110..7a03f8fd95262e1a059f00f83bc6d9a7dac6d0e8 100644 (file)
@@ -178,16 +178,19 @@ public:
        
        /* konstruktor */
        ///
-       LyXTabular(InsetTabular *, int columns_arg, int rows_arg);
+       LyXTabular(BufferParams const &,
+                  InsetTabular *, int columns_arg, int rows_arg);
        ///
-       LyXTabular(InsetTabular *, LyXTabular const &, bool same_id = false);
+       LyXTabular(BufferParams const &,
+                  InsetTabular *, LyXTabular const &, bool same_id = false);
        ///
        explicit
        LyXTabular(Buffer const *, InsetTabular *, LyXLex & lex);
        ///
        LyXTabular & operator=(LyXTabular const &);
        ///
-       LyXTabular * clone(InsetTabular *, bool same_id = false);
+       LyXTabular * clone(BufferParams const &,
+                          InsetTabular *, bool same_id = false);
        
        /// Returns true if there is a topline, returns false if not
        bool TopLine(int cell, bool onlycolumn = false) const;
@@ -266,11 +269,11 @@ public:
        ///
        int GetBeginningOfTextInCell(int cell) const;
        ///
-       void AppendRow(int cell);
+       void AppendRow(BufferParams const &, int cell);
        ///
        void DeleteRow(int row);
        ///
-       void AppendColumn(int cell);
+       void AppendColumn(BufferParams const &, int cell);
        ///
        void DeleteColumn(int column);
        ///
@@ -290,7 +293,7 @@ public:
        ///
        void Read(Buffer const *, LyXLex &);
        ///
-       void OldFormatRead(LyXLex &, string const &);
+       void OldFormatRead(BufferParams const &, LyXLex &, string const &);
        ///
        int latex(Buffer const *, std::ostream &, bool, bool) const;
        ///
@@ -398,7 +401,7 @@ private:
        ///
        struct cellstruct {
                ///
-               cellstruct();
+               cellstruct(BufferParams const &);
                ///
                int cellno;
                ///
@@ -525,7 +528,8 @@ private:
        InsetTabular * owner_;
 
        ///
-       void Init(int columns_arg, int rows_arg, LyXTabular const * lt = 0);
+       void Init(BufferParams const &,
+                 int columns_arg, int rows_arg, LyXTabular const * lt = 0);
        ///
        void Reinit(bool reset_widths = true);
        ///
index 04152131f3762414206b422e0d75bd985a31f7cc..44c7a81e4f55a46c35fcb125228ee9da970a731a 100644 (file)
@@ -3826,6 +3826,7 @@ Row * LyXText::getRow(Paragraph * par, pos_type pos, int & y) const
 
 Row * LyXText::getRowNearY(int & y) const
 {
+#if 1
        // If possible we should optimize this method. (Lgb)
        Row * tmprow = firstrow;
        int tmpy = 0;
@@ -3836,7 +3837,53 @@ Row * LyXText::getRowNearY(int & y) const
        }
        
        y = tmpy;   // return the real y
+
+       lyxerr << "returned y = " << y << endl;
+       
        return tmprow;
+#else
+       // Search from the current cursor position.
+       
+       Row * tmprow = cursor.row();
+       int tmpy = cursor.y() - tmprow->baseline();
+
+       lyxerr << "cursor.y() = " << tmpy << endl;
+       lyxerr << "tmprow->height() = " << tmprow->height() << endl;
+       lyxerr << "tmprow->baseline() = " << tmprow->baseline() << endl;
+       lyxerr << "first = " << first << endl;
+       lyxerr << "y = " << y << endl;
+       
+       if (y < tmpy) {
+               lyxerr << "up" << endl;
+#if 0
+               while (tmprow && tmpy - tmprow->height() >= y) {
+                       tmpy -= tmprow->height();
+                       tmprow = tmprow->previous();
+               }
+#else
+               do {
+                       tmpy -= tmprow->height();
+                       tmprow = tmprow->previous();
+               } while (tmprow && tmpy - tmprow->height() >= y);
+#endif
+       } else if (y > tmpy) {
+               lyxerr << "down" << endl;
+               
+               while (tmprow->next() && tmpy + tmprow->height() <= y) {
+                       tmpy += tmprow->height();
+                       tmprow = tmprow->next();
+               }
+       } else {
+               lyxerr << "equal" << endl;
+       }
+       
+       y = tmpy; // return the real y
+
+       lyxerr << "returned y = " << y << endl;
+       
+       return tmprow;
+
+#endif
 }
 
 
index fab6665f652a685a8928d168620f1f9342677797..caed3ece552024c44af8e106d81da8d93c330068 100644 (file)
@@ -55,7 +55,7 @@ using lyx::pos_type;
 
 
 LyXText::LyXText(BufferView * bv)
-       : number_of_rows(0), height(0), width(0), first(0),
+       : number_of_rows(0), height(0), width(0), first_y(0),
          bv_owner(bv), inset_owner(0), the_locking_inset(0),
          need_break_row(0), refresh_y(0), refresh_row(0),
          status_(LyXText::UNCHANGED), firstrow(0), lastrow(0)
@@ -63,7 +63,7 @@ LyXText::LyXText(BufferView * bv)
 
 
 LyXText::LyXText(InsetText * inset)
-       :  number_of_rows(0),  height(0), width(0), first(0),
+       :  number_of_rows(0),  height(0), width(0), first_y(0),
           bv_owner(0), inset_owner(inset), the_locking_inset(0),
           need_break_row(0), refresh_y(0), refresh_row(0),
           status_(LyXText::UNCHANGED), firstrow(0), lastrow(0)
@@ -80,16 +80,20 @@ void LyXText::init(BufferView * bview, bool reinit)
                        delete firstrow;
                        firstrow = tmprow;
                }
-               lastrow = refresh_row = need_break_row = 0;
+
+               lastrow = 0;
+               refresh_row = 0;
+               need_break_row = 0;
                width = height = 0;
                copylayouttype.erase();
-               number_of_rows = first = refresh_y = 0;
+               number_of_rows = first_y = refresh_y = 0;
                status_ = LyXText::UNCHANGED;
        } else if (firstrow)
                return;
 
        Paragraph * par = ownerParagraph();
        current_font = getFont(bview->buffer(), par, 0);
+       
        while (par) {
                insertParagraph(bview, par, lastrow);
                par = par->next();