On Wed, Aug 27, 2003 at 10:12:43AM +0200, Alfredo Braunstein wrote: > Andre Poenitz wrote: > > > Do you see a fix or should we revert? > > What about InsetOld::sizeChanged doing what insetgraphics::statusChanged > does now, and replace all calls of BufferView::updateInset for > InsetOld::sizeChanged? > Should I prepare a patch?
Yes, please. I'll attach a 'revert' patch in case this fails... Andre' [PS: Math is also broken as far as I can tell...] -- Those who desire to give up Freedom in order to gain Security, will not have, nor do they deserve, either one. (T. Jefferson or B. Franklin or both...)
Index: lyxrow_funcs.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lyxrow_funcs.C,v retrieving revision 1.13 retrieving revision 1.12 diff -u -p -r1.13 -r1.12 --- lyxrow_funcs.C 26 Aug 2003 10:33:55 -0000 1.13 +++ lyxrow_funcs.C 23 Aug 2003 00:16:14 -0000 1.12 @@ -64,6 +64,23 @@ pos_type lastPos(Paragraph const & par, } +namespace { + +bool nextRowIsAllInset(Paragraph const & par, pos_type last) +{ + if (last + 1 >= par.size()) + return false; + + if (!par.isInset(last + 1)) + return false; + + InsetOld const * i = par.getInset(last + 1); + return i->needFullRow() || i->display(); +} + +} // anon namespace + + pos_type lastPrintablePos(Paragraph const & par, RowList::iterator rit) { pos_type const last = lastPos(par, rit); @@ -71,6 +88,9 @@ pos_type lastPrintablePos(Paragraph cons // if this row is an end of par, just act like lastPos() if (isParEnd(par, rit)) return last; + + if (!nextRowIsAllInset(par, last) && par.isSeparator(last)) + return last - 1; return last; } Index: lyxtext.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lyxtext.h,v retrieving revision 1.224 retrieving revision 1.223 diff -u -p -r1.224 -r1.223 --- lyxtext.h 26 Aug 2003 10:33:55 -0000 1.224 +++ lyxtext.h 25 Aug 2003 10:24:25 -0000 1.223 @@ -127,7 +127,7 @@ public: void setFont(LyXFont const &, bool toggleall = false); /// rebreaks all paragaphs between the given pars. - int redoParagraphs(ParagraphList::iterator begin, + void redoParagraphs(ParagraphList::iterator begin, ParagraphList::iterator end); /// rebreaks the given par void redoParagraph(ParagraphList::iterator pit); @@ -135,8 +135,8 @@ public: /// rebreaks the cursor par void redoParagraph(); private: - /// rebreaks the given par, return max row width - int redoParagraphInternal(ParagraphList::iterator pit); + /// rebreaks the given par + void redoParagraphInternal(ParagraphList::iterator pit); public: /// Index: paragraph.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/paragraph.C,v retrieving revision 1.305 retrieving revision 1.303 diff -u -p -r1.305 -r1.303 --- paragraph.C 26 Aug 2003 16:36:51 -0000 1.305 +++ paragraph.C 23 Aug 2003 00:16:14 -0000 1.303 @@ -66,7 +66,7 @@ using lyx::pos_type; Paragraph::Paragraph() - : y(0), pimpl_(new Paragraph::Pimpl(this)) + : pimpl_(new Paragraph::Pimpl(this)) { enumdepth = 0; itemdepth = 0; @@ -75,7 +75,7 @@ Paragraph::Paragraph() Paragraph::Paragraph(Paragraph const & lp) - : y(0), pimpl_(new Paragraph::Pimpl(*lp.pimpl_, this)) + : pimpl_(new Paragraph::Pimpl(*lp.pimpl_, this)) { enumdepth = 0; itemdepth = 0; @@ -90,6 +90,8 @@ Paragraph::Paragraph(Paragraph const & l for (; it != end; ++it) { // currently we hold Inset*, not InsetBase* it->inset = static_cast<InsetOld*>(it->inset->clone().release()); + // tell the new inset who is the boss now + it->inset->parOwner(this); } } @@ -117,6 +119,8 @@ void Paragraph::operator=(Paragraph cons InsetList::iterator end = insetlist.end(); for (; it != end; ++it) { it->inset = static_cast<InsetOld*>(it->inset->clone().release()); + // tell the new inset who is the boss now + it->inset->parOwner(this); } } Index: paragraph_pimpl.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/paragraph_pimpl.C,v retrieving revision 1.76 retrieving revision 1.75 diff -u -p -r1.76 -r1.75 --- paragraph_pimpl.C 26 Aug 2003 16:36:52 -0000 1.76 +++ paragraph_pimpl.C 23 Aug 2003 00:16:23 -0000 1.75 @@ -331,6 +331,7 @@ void Paragraph::Pimpl::insertInset(pos_t // Add a new entry in the insetlist. owner_->insetlist.insert(inset, pos); + inset->parOwner(owner_); if (inset_owner) inset->setOwner(inset_owner); Index: text.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/text.C,v retrieving revision 1.431 retrieving revision 1.430 diff -u -p -r1.431 -r1.430 --- text.C 26 Aug 2003 10:33:55 -0000 1.431 +++ text.C 25 Aug 2003 10:24:25 -0000 1.430 @@ -69,8 +69,6 @@ extern int const CHANGEBAR_MARGIN = 10; /// left margin extern int const LEFT_MARGIN = PAPER_MARGIN + CHANGEBAR_MARGIN; - - int bibitemMaxWidth(BufferView *, LyXFont const &); @@ -445,7 +443,15 @@ bool LyXText::isBoundary(Buffer const * int LyXText::leftMargin(ParagraphList::iterator pit, Row const & row) const -{ +{ + InsetOld * ins; + + if (row.pos() < pit->size()) + if (pit->getChar(row.pos()) == Paragraph::META_INSET && + (ins = pit->getInset(row.pos())) && + (ins->needFullRow() || ins->display())) + return LEFT_MARGIN; + LyXTextClass const & tclass = bv()->buffer()->params.getLyXTextClass(); LyXLayout_ptr const & layout = pit->layout(); @@ -622,6 +628,14 @@ int LyXText::leftMargin(ParagraphList::i int LyXText::rightMargin(ParagraphList::iterator pit, Buffer const & buf, Row const & row) const { + InsetOld * ins; + + if (row.pos() < pit->size()) + if ((pit->getChar(row.pos()) == Paragraph::META_INSET) && + (ins = pit->getInset(row.pos())) && + (ins->needFullRow() || ins->display())) + return PAPER_MARGIN; + LyXTextClass const & tclass = buf.params.getLyXTextClass(); LyXLayout_ptr const & layout = pit->layout(); @@ -669,8 +683,7 @@ pos_type LyXText::rowBreakPoint(Paragrap Row const & row) const { // maximum pixel width of a row. - int width = workWidth() - - rightMargin(pit, *bv()->buffer(), row); + int width = workWidth() - rightMargin(pit, *bv()->buffer(), row); // inset->textWidth() returns -1 via workWidth(), // but why ? @@ -699,6 +712,7 @@ pos_type LyXText::rowBreakPoint(Paragrap // pixel width since last breakpoint int chunkwidth = 0; + bool fullrow = false; pos_type i = pos; @@ -737,12 +751,14 @@ pos_type LyXText::rowBreakPoint(Paragrap chunkwidth += thiswidth; InsetOld * in = pit->isInset(i) ? pit->getInset(i) : 0; + fullrow = in && (in->display() || in->needFullRow()); // break before a character that will fall off // the right of the row if (x >= width) { - // if no break before, break here - if (point == last || chunkwidth >= (width - left)) { + // if no break before or we are at an inset + // that will take up a row, break here + if (point == last || fullrow || chunkwidth >= (width - left)) { if (pos < i) point = i - 1; else @@ -760,7 +776,24 @@ pos_type LyXText::rowBreakPoint(Paragrap continue; } - continue; + if (!fullrow) + continue; + + // full row insets start at a new row + if (i == pos) { + if (pos < last - 1) { + point = i; + if (pit->isLineSeparator(i + 1)) + ++point; + } else { + // to avoid extra rows + point = last; + } + } else { + point = i - 1; + } + + return point; } if (point == last && x >= width) { @@ -775,7 +808,7 @@ pos_type LyXText::rowBreakPoint(Paragrap // manual labels cannot be broken in LaTeX. But we // want to make our on-screen rendering of footnotes // etc. still break - if (body_pos && point < body_pos) + if (!fullrow && body_pos && point < body_pos) point = body_pos - 1; return point; @@ -1469,7 +1502,15 @@ void LyXText::prepareToPrint(ParagraphLi } else { align = pit->params().align(); } + + // center displayed insets InsetOld * inset = 0; + if (rit->pos() < pit->size() + && pit->isInset(rit->pos()) + && (inset = pit->getInset(rit->pos())) + && (inset->display())) // || (inset->scroll() < 0))) + align = (inset->lyxCode() == InsetOld::MATHMACRO_CODE) + ? LYX_ALIGN_BLOCK : LYX_ALIGN_CENTER; // ERT insets should always be LEFT ALIGNED on screen inset = pit->inInset(); if (inset && inset->owner() && @@ -1480,15 +1521,18 @@ void LyXText::prepareToPrint(ParagraphLi switch (align) { case LYX_ALIGN_BLOCK: - { + { int const ns = numberOfSeparators(*pit, rit); - RowList::iterator next_row = boost::next(rit); + RowList::iterator next_row = boost::next(rit); if (ns && next_row != pit->rows.end() - && !pit->isNewline(next_row->pos() - 1) + && !pit->isNewline(next_row->pos() - 1) + && !(pit->isInset(next_row->pos()) + && pit->getInset(next_row->pos()) + && pit->getInset(next_row->pos())->display()) ) { - fill_separator = w / ns; - } else if (is_rtl) { + fill_separator = w / ns; + } else if (is_rtl) { x += w; } break; Index: text2.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/text2.C,v retrieving revision 1.448 retrieving revision 1.446 diff -u -p -r1.448 -r1.446 --- text2.C 26 Aug 2003 16:36:52 -0000 1.448 +++ text2.C 25 Aug 2003 10:24:25 -0000 1.446 @@ -544,7 +544,7 @@ void LyXText::setFont(LyXFont const & fo } -int LyXText::redoParagraphInternal(ParagraphList::iterator pit) +void LyXText::redoParagraphInternal(ParagraphList::iterator pit) { RowList::iterator rit = pit->rows.begin(); RowList::iterator end = pit->rows.end(); @@ -571,35 +571,26 @@ int LyXText::redoParagraphInternal(Parag pit->rows.push_back(row); } - int par_width = 0; - // set height and fill and width of rows - int const ww = workWidth(); + // set height and fill of rows for (rit = pit->rows.begin(); rit != end; ++rit) { - int const f = fill(pit, rit, ww); - int const w = ww - f; - par_width = std::max(par_width, w); - rit->fill(f); - rit->width(w); + rit->fill(fill(pit, rit, workWidth())); prepareToPrint(pit, rit); setHeightOfRow(pit, rit); height += rit->height(); } //lyxerr << "redoParagraph: " << pit->rows.size() << " rows\n"; - return par_width; } -int LyXText::redoParagraphs(ParagraphList::iterator start, +// rebreaks all paragraphs between the specified pars +// This function is needed after SetLayout and SetFont etc. +void LyXText::redoParagraphs(ParagraphList::iterator start, ParagraphList::iterator end) { - int pars_width = 0; - for ( ; start != end; ++start) { - int par_width = redoParagraphInternal(start); - pars_width = std::max(par_width, pars_width); - } + for ( ; start != end; ++start) + redoParagraphInternal(start); updateRowPositions(); - return pars_width; } @@ -629,7 +620,7 @@ void LyXText::metrics(MetricsInfo & mi, ///height = 0; //anchor_y_ = 0; - width = redoParagraphs(ownerParagraphs().begin(), ownerParagraphs().end()); + redoParagraphs(ownerParagraphs().begin(), ownerParagraphs().end()); // final dimension dim.asc = firstRow()->ascent_of_text(); @@ -1003,10 +994,9 @@ void LyXText::setCounter(Buffer const * isOK = true; break; } else { - Paragraph const * owner = &ownerPar(*buf, in); tmppit = ownerParagraphs().begin(); for ( ; tmppit != end; ++tmppit) - if (&*tmppit == owner) + if (&*tmppit == in->parOwner()) break; } } @@ -1366,6 +1356,16 @@ void LyXText::setCursor(LyXCursor & cur, // same paragraph and there is a previous row then put the cursor on // the end of the previous row cur.iy(y + row->baseline()); + if (row != pit->rows.begin() + && pos + && pos < pit->size() + && pit->getChar(pos) == Paragraph::META_INSET) { + InsetOld * ins = pit->getInset(pos); + if (ins && (ins->needFullRow() || ins->display())) { + --row; + y -= row->height(); + } + } // y is now the beginning of the cursor row y += row->baseline(); @@ -1632,6 +1632,33 @@ void LyXText::setCursorFromCoordinates(i } +namespace { + + /** + * return true if the cursor given is at the end of a row, + * and the next row is filled by an inset that spans an entire + * row. + */ + bool beforeFullRowInset(LyXText & lt, LyXCursor const & cur) + { + RowList::iterator row = lt.getRow(cur); + RowList::iterator next = boost::next(row); + + if (next == cur.par()->rows.end() || next->pos() != cur.pos()) + return false; + + if (cur.pos() == cur.par()->size() || !cur.par()->isInset(cur.pos())) + return false; + + InsetOld const * inset = cur.par()->getInset(cur.pos()); + if (inset->needFullRow() || inset->display()) + return true; + + return false; + } +} + + void LyXText::setCursorFromCoordinates(LyXCursor & cur, int x, int y) { // Get the row first. @@ -1646,9 +1673,17 @@ void LyXText::setCursorFromCoordinates(L cur.x(x); cur.y(y + rit->baseline()); - cur.iy(cur.y()); - cur.ix(cur.x()); - + if (beforeFullRowInset(*this, cur)) { + pos_type const last = lastPrintablePos(*pit, rit); + RowList::iterator next_rit = rit; + ParagraphList::iterator next_pit = pit; + nextRow(next_pit, next_rit); + cur.ix(int(getCursorX(pit, next_rit, cur.pos(), last, bound))); + cur.iy(y + rit->height() + next_rit->baseline()); + } else { + cur.iy(cur.y()); + cur.ix(cur.x()); + } cur.boundary(bound); } Index: frontends/ChangeLog =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/ChangeLog,v retrieving revision 1.215 retrieving revision 1.214 diff -u -p -r1.215 -r1.214 --- frontends/ChangeLog 26 Aug 2003 13:46:58 -0000 1.215 +++ frontends/ChangeLog 19 Aug 2003 16:46:47 -0000 1.214 @@ -1,6 +1,3 @@ -2003-08-26 Alfredo Braunstein <[EMAIL PROTECTED]> - - * screen.C (redraw): remove an uneeded updateRowPositions 2003-08-19 André Pönitz <[EMAIL PROTECTED]> Index: frontends/screen.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/screen.C,v retrieving revision 1.66 retrieving revision 1.65 diff -u -p -r1.66 -r1.65 --- frontends/screen.C 26 Aug 2003 13:46:58 -0000 1.66 +++ frontends/screen.C 23 Aug 2003 00:16:34 -0000 1.65 @@ -296,6 +296,7 @@ void LyXScreen::redraw(BufferView & bv) workarea().getPainter().start(); + bv.text->updateRowPositions(); hideCursor(); int const y = paintText(bv, *bv.text); Index: insets/inset.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/inset.C,v retrieving revision 1.109 retrieving revision 1.108 diff -u -p -r1.109 -r1.108 --- insets/inset.C 26 Aug 2003 16:36:53 -0000 1.109 +++ insets/inset.C 23 Aug 2003 00:16:49 -0000 1.108 @@ -38,17 +38,17 @@ unsigned int InsetOld::inset_id = 0; InsetOld::InsetOld() : InsetBase(), top_x(0), top_baseline(0), scx(0), - id_(inset_id++), owner_(0), + id_(inset_id++), owner_(0), par_owner_(0), background_color_(LColor::inherit) {} InsetOld::InsetOld(InsetOld const & in) : InsetBase(), - top_x(0), top_baseline(0), scx(0), - id_(in.id_), owner_(0), + top_x(0), top_baseline(0), scx(0), id_(in.id_), owner_(0), name_(in.name_), background_color_(in.background_color_) -{} +{ +} bool InsetOld::directWrite() const Index: insets/inset.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/inset.h,v retrieving revision 1.113 retrieving revision 1.111 diff -u -p -r1.113 -r1.111 --- insets/inset.h 26 Aug 2003 16:36:53 -0000 1.113 +++ insets/inset.h 23 Aug 2003 00:16:49 -0000 1.111 @@ -198,6 +198,14 @@ public: /// returns true to override begin and end inset in file virtual bool directWrite() const; + /// Returns true if the inset should be centered alone + virtual bool display() const { return false; } + /// Changes the display state of the inset + virtual void display(bool) {} + /// + /// returns true if this inset needs a row on it's own + /// + virtual bool needFullRow() const { return false; } /// void setInsetName(string const & s) { name_ = s; } /// @@ -207,6 +215,10 @@ public: /// UpdatableInset * owner() const { return owner_; } /// + void parOwner(Paragraph * par) { par_owner_ = par; } + /// + Paragraph * parOwner() const { return par_owner_; } + /// void setBackgroundColor(LColor::color); /// LColor::color backgroundColor() const; @@ -326,6 +338,8 @@ protected: private: /// UpdatableInset * owner_; + /// the paragraph in which this inset has been inserted + Paragraph * par_owner_; /// string name_; /// Index: insets/insetbibtex.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetbibtex.C,v retrieving revision 1.20 retrieving revision 1.19 diff -u -p -r1.20 -r1.19 --- insets/insetbibtex.C 26 Aug 2003 10:33:58 -0000 1.20 +++ insets/insetbibtex.C 23 Aug 2003 00:16:50 -0000 1.19 @@ -11,7 +11,6 @@ #include <config.h> #include "insetbibtex.h" -#include "metricsinfo.h" #include "buffer.h" #include "BufferView.h" #include "debug.h" @@ -52,20 +51,6 @@ InsetBibtex::~InsetBibtex() std::auto_ptr<InsetBase> InsetBibtex::clone() const { return std::auto_ptr<InsetBase>(new InsetBibtex(*this)); -} - -void InsetBibtex::metrics(MetricsInfo & mi, Dimension & dim) const -{ - InsetCommand::metrics(mi, dim); - center_indent_ = (mi.base.textwidth - dim.wid) / 2; - dim.wid = mi.base.textwidth; - dim_ = dim; -} - - -void InsetBibtex::draw(PainterInfo & pi, int x, int y) const -{ - InsetCommand::draw(pi, x + center_indent_, y); } Index: insets/insetbibtex.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetbibtex.h,v retrieving revision 1.19 retrieving revision 1.18 diff -u -p -r1.19 -r1.18 --- insets/insetbibtex.h 26 Aug 2003 10:33:58 -0000 1.19 +++ insets/insetbibtex.h 23 Aug 2003 00:16:50 -0000 1.18 @@ -26,10 +26,6 @@ public: ~InsetBibtex(); /// std::auto_ptr<InsetBase> clone() const; - /// - void metrics(MetricsInfo &, Dimension &) const; - /// - void draw(PainterInfo & pi, int x, int y) const; /// small wrapper for the time being virtual dispatch_result localDispatch(FuncRequest const & cmd); /// @@ -50,9 +46,8 @@ public: bool addDatabase(string const &); /// bool delDatabase(string const &); -private: /// - mutable unsigned int center_indent_; + bool display() const { return true; } }; #endif // INSET_BIBTEX_H Index: insets/insetbranch.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetbranch.C,v retrieving revision 1.4 retrieving revision 1.2 diff -u -p -r1.4 -r1.2 --- insets/insetbranch.C 26 Aug 2003 15:27:31 -0000 1.4 +++ insets/insetbranch.C 23 Aug 2003 00:16:50 -0000 1.2 @@ -33,6 +33,7 @@ using std::auto_ptr; void InsetBranch::init() { setInsetName("Branch"); + setButtonLabel(); } @@ -105,6 +106,19 @@ void InsetBranch::setButtonLabel() } else setBackgroundColor(LColor::background); setLabelFont(font); +} + + +void InsetBranch::metrics(MetricsInfo & mi, Dimension & dim) const +{ + InsetCollapsable::metrics(mi, dim); + dim_ = dim; +} + + +void InsetBranch::draw(PainterInfo & pi, int x, int y) const +{ + InsetCollapsable::draw(pi, x, y); } Index: insets/insetbranch.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetbranch.h,v retrieving revision 1.3 retrieving revision 1.2 diff -u -p -r1.3 -r1.2 --- insets/insetbranch.h 26 Aug 2003 10:33:58 -0000 1.3 +++ insets/insetbranch.h 23 Aug 2003 00:16:50 -0000 1.2 @@ -54,6 +54,10 @@ public: /// void setButtonLabel(); /// + void metrics(MetricsInfo & mi, Dimension & dim) const; + /// + void draw(PainterInfo & pi, int x, int y) const; + /// bool showInsetDialog(BufferView *) const; /// dispatch_result localDispatch(FuncRequest const &); Index: insets/insetcaption.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetcaption.h,v retrieving revision 1.19 retrieving revision 1.18 diff -u -p -r1.19 -r1.18 --- insets/insetcaption.h 26 Aug 2003 17:52:35 -0000 1.19 +++ insets/insetcaption.h 23 Aug 2003 00:16:50 -0000 1.18 @@ -28,6 +28,8 @@ public: /// virtual bool display() const; /// + virtual bool needFullRow() const; + /// virtual InsetOld::Code lyxCode() const; /// virtual string const editMessage() const; @@ -45,6 +47,13 @@ public: inline bool InsetCaption::display() const +{ + return true; +} + + +inline +bool InsetCaption::needFullRow() const { return true; } Index: insets/insetcollapsable.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetcollapsable.h,v retrieving revision 1.120 retrieving revision 1.119 diff -u -p -r1.120 -r1.119 --- insets/insetcollapsable.h 26 Aug 2003 10:33:58 -0000 1.120 +++ insets/insetcollapsable.h 23 Aug 2003 00:16:50 -0000 1.119 @@ -66,6 +66,8 @@ public: /// void insetUnlock(BufferView *); /// + bool needFullRow() const { return isOpen(); } + /// bool lockInsetInInset(BufferView *, UpdatableInset *); /// bool unlockInsetInInset(BufferView *, UpdatableInset *, Index: insets/insetenv.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetenv.h,v retrieving revision 1.14 retrieving revision 1.13 diff -u -p -r1.14 -r1.13 --- insets/insetenv.h 26 Aug 2003 17:52:35 -0000 1.14 +++ insets/insetenv.h 23 Aug 2003 00:16:50 -0000 1.13 @@ -40,6 +40,8 @@ public: bool isTextInset() const { return true; } /// LyXLayout_ptr const & layout() const; + /// + bool needFullRow() const { return true; } /** returns true if, when outputing LaTeX, font changes should be closed before generating this inset. This is needed for insets that may contain several paragraphs */ Index: insets/insetert.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetert.C,v retrieving revision 1.149 retrieving revision 1.148 diff -u -p -r1.149 -r1.148 --- insets/insetert.C 26 Aug 2003 10:33:58 -0000 1.149 +++ insets/insetert.C 23 Aug 2003 00:16:50 -0000 1.148 @@ -12,7 +12,6 @@ #include "insetert.h" #include "insettext.h" -#include "metricsinfo.h" #include "buffer.h" #include "BufferView.h" @@ -556,10 +555,6 @@ void InsetERT::metrics(MetricsInfo & mi, inset.metrics(mi, dim); else InsetCollapsable::metrics(mi, dim); - // Make it stand out on its own as it is code, not part of running - // text: - if (isOpen() && !inlined()) - dim.wid = mi.base.textwidth; dim_ = dim; } Index: insets/insetert.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetert.h,v retrieving revision 1.83 retrieving revision 1.82 diff -u -p -r1.83 -r1.82 --- insets/insetert.h 26 Aug 2003 10:33:58 -0000 1.83 +++ insets/insetert.h 23 Aug 2003 00:16:50 -0000 1.82 @@ -80,7 +80,9 @@ public: /// bool checkInsertChar(LyXFont &); /// - // these are needed here because of the label/inlined functionallity + // this are needed here because of the label/inlined functionallity + /// + bool needFullRow() const { return status_ == Open; } /// bool isOpen() const { return status_ == Open || status_ == Inlined; } /// Index: insets/insetfloatlist.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetfloatlist.C,v retrieving revision 1.38 retrieving revision 1.37 diff -u -p -r1.38 -r1.37 --- insets/insetfloatlist.C 26 Aug 2003 10:33:58 -0000 1.38 +++ insets/insetfloatlist.C 23 Aug 2003 00:16:51 -0000 1.37 @@ -12,7 +12,6 @@ #include "insetfloatlist.h" #include "FloatList.h" -#include "metricsinfo.h" #include "LaTeXFeatures.h" #include "lyxlex.h" #include "BufferView.h" @@ -95,21 +94,6 @@ void InsetFloatList::read(Buffer const * lex.printError("Missing \\end_inset at this point. " "Read: `$$Token'"); } -} - - -void InsetFloatList::metrics(MetricsInfo & mi, Dimension & dim) const -{ - InsetCommand::metrics(mi, dim); - center_indent_ = (mi.base.textwidth - dim.wid) / 2; - dim.wid = mi.base.textwidth; - dim_ = dim; -} - - -void InsetFloatList::draw(PainterInfo & pi, int x, int y) const -{ - InsetCommand::draw(pi, x + center_indent_, y); } Index: insets/insetfloatlist.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetfloatlist.h,v retrieving revision 1.28 retrieving revision 1.27 diff -u -p -r1.28 -r1.27 --- insets/insetfloatlist.h 26 Aug 2003 10:33:58 -0000 1.28 +++ insets/insetfloatlist.h 23 Aug 2003 00:16:51 -0000 1.27 @@ -30,16 +30,14 @@ public: return std::auto_ptr<InsetBase>(new InsetFloatList(getCmdName())); } /// - void metrics(MetricsInfo &, Dimension &) const; - /// - void draw(PainterInfo & pi, int x, int y) const; - /// dispatch_result localDispatch(FuncRequest const & cmd); /// string const getScreenLabel(Buffer const *) const; /// EDITABLE editable() const { return IS_EDITABLE; } /// + bool display() const { return true; } + /// InsetOld::Code lyxCode() const; /// void write(Buffer const *, std::ostream &) const; @@ -56,9 +54,6 @@ public: int ascii(Buffer const *, std::ostream &, int linelen) const; /// void validate(LaTeXFeatures & features) const; -private: - /// - mutable unsigned int center_indent_; }; #endif Index: insets/insetfoot.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetfoot.C,v retrieving revision 1.63 retrieving revision 1.62 diff -u -p -r1.63 -r1.62 --- insets/insetfoot.C 26 Aug 2003 16:36:53 -0000 1.63 +++ insets/insetfoot.C 23 Aug 2003 00:16:51 -0000 1.62 @@ -23,7 +23,8 @@ // the following are needed just to get the layout of the enclosing // paragraph. This seems a bit too much to me (JMarc) #include "lyxlayout.h" -#include "paragraph_funcs.h" +#include "buffer.h" +#include "paragraph.h" using std::ostream; @@ -62,8 +63,9 @@ int InsetFoot::latex(Buffer const * buf, LatexRunParams const & runparams_in) const { LatexRunParams runparams = runparams_in; - if (buf) { - runparams.moving_arg |= ownerPar(*buf, this).layout()->intitle; + if (buf && parOwner()) { + LyXLayout_ptr const & layout = parOwner()->layout(); + runparams.moving_arg |= layout->intitle; } os << "%\n\\footnote{"; Index: insets/insetfootlike.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetfootlike.C,v retrieving revision 1.26 retrieving revision 1.24 diff -u -p -r1.26 -r1.24 --- insets/insetfootlike.C 26 Aug 2003 18:39:22 -0000 1.26 +++ insets/insetfootlike.C 23 Aug 2003 00:16:51 -0000 1.24 @@ -11,7 +11,6 @@ #include <config.h> #include "insetfootlike.h" -#include "metricsinfo.h" #include "lyxfont.h" #include "buffer.h" #include "lyxtext.h" @@ -40,15 +39,6 @@ InsetFootlike::InsetFootlike(InsetFootli font.decSize(); font.setColor(LColor::collapsable); setLabelFont(font); -} - - -void InsetFootlike::metrics(MetricsInfo & mi, Dimension & dim) const -{ - InsetCollapsable::metrics(mi, dim); - if (isOpen()) - dim.wid = mi.base.textwidth; - dim_ = dim; } Index: insets/insetfootlike.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetfootlike.h,v retrieving revision 1.19 retrieving revision 1.18 diff -u -p -r1.19 -r1.18 --- insets/insetfootlike.h 26 Aug 2003 10:33:58 -0000 1.19 +++ insets/insetfootlike.h 23 Aug 2003 00:16:51 -0000 1.18 @@ -24,8 +24,6 @@ public: /// InsetFootlike(InsetFootlike const &); /// - void metrics(MetricsInfo &, Dimension &) const; - /// void write(Buffer const * buf, std::ostream & os) const; /// bool insetAllowed(InsetOld::Code) const; Index: insets/insetgraphics.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetgraphics.C,v retrieving revision 1.199 retrieving revision 1.198 diff -u -p -r1.199 -r1.198 --- insets/insetgraphics.C 26 Aug 2003 14:50:16 -0000 1.199 +++ insets/insetgraphics.C 23 Aug 2003 00:16:51 -0000 1.198 @@ -68,8 +68,6 @@ TODO #include "Lsstream.h" #include "lyxlex.h" #include "lyxrc.h" -#include "paragraph_funcs.h" -#include "lyxtext.h" #include "frontends/Alert.h" #include "frontends/Dialogs.h" @@ -170,10 +168,8 @@ InsetGraphics::~InsetGraphics() void InsetGraphics::statusChanged() { BufferView * bv = graphic_->view(); - if (bv) { - bv->text->redoParagraph(outerPar(*bv->buffer(), this)); + if (bv) bv->updateInset(); - } } Index: insets/insetinclude.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetinclude.C,v retrieving revision 1.136 retrieving revision 1.135 diff -u -p -r1.136 -r1.135 --- insets/insetinclude.C 26 Aug 2003 10:33:58 -0000 1.136 +++ insets/insetinclude.C 23 Aug 2003 00:16:51 -0000 1.135 @@ -242,6 +242,12 @@ void InsetInclude::read(Buffer const *, } +bool InsetInclude::display() const +{ + return !(params_.flag == INPUT); +} + + string const InsetInclude::getScreenLabel(Buffer const *) const { string temp; @@ -524,11 +530,6 @@ void InsetInclude::metrics(MetricsInfo & } button_.metrics(mi, dim); } - if (params_.flag == INPUT) - center_indent_ = 0; - else - center_indent_ = (mi.base.textwidth - dim.wid) / 2; - dim.wid = mi.base.textwidth; dim_ = dim; } @@ -537,14 +538,14 @@ void InsetInclude::draw(PainterInfo & pi { cache(pi.base.bv); if (!preview_->previewReady()) { - button_.draw(pi, x + center_indent_, y); + button_.draw(pi, x, y); return; } if (!preview_->monitoring()) preview_->startMonitoring(); - pi.pain.image(x + center_indent_, y - dim_.asc, dim_.wid, dim_.height(), + pi.pain.image(x, y - dim_.asc, dim_.wid, dim_.height(), *(preview_->pimage()->image())); } Index: insets/insetinclude.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetinclude.h,v retrieving revision 1.78 retrieving revision 1.77 diff -u -p -r1.78 -r1.77 --- insets/insetinclude.h 26 Aug 2003 10:33:58 -0000 1.78 +++ insets/insetinclude.h 23 Aug 2003 00:16:52 -0000 1.77 @@ -102,6 +102,9 @@ public: /// void validate(LaTeXFeatures &) const; + /// take up a whole row if we're not type INPUT + bool display() const; + /// return true if the file is or got loaded. bool loadIfNeeded() const; @@ -132,7 +135,6 @@ private: /// cache mutable bool set_label_; mutable ButtonRenderer button_; - mutable unsigned int center_indent_; }; Index: insets/insetindex.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetindex.C,v retrieving revision 1.44 retrieving revision 1.43 diff -u -p -r1.44 -r1.43 --- insets/insetindex.C 26 Aug 2003 10:33:58 -0000 1.44 +++ insets/insetindex.C 23 Aug 2003 00:16:52 -0000 1.43 @@ -11,7 +11,6 @@ #include "insetindex.h" -#include "metricsinfo.h" #include "BufferView.h" #include "funcrequest.h" #include "frontends/LyXView.h" @@ -42,21 +41,6 @@ InsetIndex::~InsetIndex() string const InsetIndex::getScreenLabel(Buffer const *) const { return _("Idx"); -} - - -void InsetPrintIndex::metrics(MetricsInfo & mi, Dimension & dim) const -{ - InsetCommand::metrics(mi, dim); - center_indent_ = (mi.base.textwidth - dim.wid) / 2; - dim.wid = mi.base.textwidth; - dim_ = dim; -} - - -void InsetPrintIndex::draw(PainterInfo & pi, int x, int y) const -{ - InsetCommand::draw(pi, x + center_indent_, y); } Index: insets/insetindex.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetindex.h,v retrieving revision 1.43 retrieving revision 1.41 diff -u -p -r1.43 -r1.41 --- insets/insetindex.h 26 Aug 2003 17:52:35 -0000 1.43 +++ insets/insetindex.h 23 Aug 2003 00:16:52 -0000 1.41 @@ -59,16 +59,13 @@ public: /// EDITABLE editable() const { return NOT_EDITABLE; } /// + bool display() const { return true; } + /// InsetOld::Code lyxCode() const; /// string const getScreenLabel(Buffer const *) const; /// - void metrics(MetricsInfo &, Dimension &) const; - /// - void draw(PainterInfo & pi, int x, int y) const; -private: - /// - mutable unsigned int center_indent_; + virtual bool needFullRow() const { return true; } }; #endif Index: insets/insetminipage.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetminipage.h,v retrieving revision 1.52 retrieving revision 1.51 diff -u -p -r1.52 -r1.51 --- insets/insetminipage.h 26 Aug 2003 10:33:58 -0000 1.52 +++ insets/insetminipage.h 23 Aug 2003 00:16:52 -0000 1.51 @@ -78,6 +78,8 @@ public: string const editMessage() const; /// bool insetAllowed(InsetOld::Code) const; + /// + bool needFullRow() const { return false; } /** returns true if, when outputing LaTeX, font changes should be closed before generating this inset. This is needed for insets that may contain several paragraphs */ Index: insets/insetnewline.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetnewline.C,v retrieving revision 1.13 retrieving revision 1.12 diff -u -p -r1.13 -r1.12 --- insets/insetnewline.C 26 Aug 2003 16:36:53 -0000 1.13 +++ insets/insetnewline.C 23 Aug 2003 00:16:52 -0000 1.12 @@ -18,10 +18,7 @@ #include "paragraph.h" #include "lyxtext.h" #include "metricsinfo.h" -#include "paragraph_funcs.h" - #include "support/LOstream.h" - #include "frontends/Painter.h" #include "frontends/font_metrics.h" @@ -86,8 +83,7 @@ void InsetNewline::draw(PainterInfo & pi int const asc = font_metrics::maxAscent(pi.base.font); // hack, and highly dubious - lyx::pos_type pos = ownerPar(*pi.base.bv->buffer(), this) - .getPositionOfInset(this); + lyx::pos_type pos = parOwner()->getPositionOfInset(this); bool const ltr_pos = (pi.base.bv->text->bidi_level(pos) % 2 == 0); int xp[3]; Index: insets/insetnote.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetnote.C,v retrieving revision 1.41 retrieving revision 1.40 diff -u -p -r1.41 -r1.40 --- insets/insetnote.C 26 Aug 2003 10:33:58 -0000 1.41 +++ insets/insetnote.C 23 Aug 2003 00:16:52 -0000 1.40 @@ -15,7 +15,6 @@ #include "Lsstream.h" #include "insetnote.h" -#include "metricsinfo.h" #include "gettext.h" #include "lyxfont.h" #include "language.h" @@ -111,18 +110,6 @@ void InsetNote::setButtonLabel() } -void InsetNote::metrics(MetricsInfo & mi, Dimension & dim) const -{ - InsetCollapsable::metrics(mi, dim); - // Contrary to Greyedout, these cannot be construed as part of the - // running text: make them stand on their own - if (params_.type == "Note" || params_.type == "Comment") - if (!collapsed_) - dim.wid = mi.base.textwidth; - dim_ = dim; -} - - bool InsetNote::showInsetDialog(BufferView * bv) const { InsetNoteMailer("note", const_cast<InsetNote &>(*this)).showDialog(bv); @@ -185,11 +172,11 @@ int InsetNote::latex(Buffer const * buf, if (pt == "Comment") { os << "%\n\\end{comment}\n"; - i += 4; + i += 3; } else if (pt == "Greyedout") { os << "%\n\\end{lyxgreyedout}\n"; - i += 4; - } + i += 2; + } return i; } Index: insets/insetnote.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetnote.h,v retrieving revision 1.29 retrieving revision 1.28 diff -u -p -r1.29 -r1.28 --- insets/insetnote.h 26 Aug 2003 10:33:58 -0000 1.29 +++ insets/insetnote.h 23 Aug 2003 00:16:52 -0000 1.28 @@ -53,8 +53,6 @@ public: void setButtonLabel(); /// dispatch_result InsetNote::localDispatch(FuncRequest const &); - /// - void metrics(MetricsInfo &, Dimension &) const; /// show the note dialog bool showInsetDialog(BufferView * bv) const; /// Index: insets/insetquotes.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetquotes.C,v retrieving revision 1.102 retrieving revision 1.101 diff -u -p -r1.102 -r1.101 --- insets/insetquotes.C 26 Aug 2003 16:36:53 -0000 1.102 +++ insets/insetquotes.C 23 Aug 2003 00:16:52 -0000 1.101 @@ -24,11 +24,8 @@ #include "lyxrc.h" #include "paragraph.h" #include "metricsinfo.h" -#include "paragraph_funcs.h" - #include "frontends/font_metrics.h" #include "frontends/Painter.h" - #include "support/LAssert.h" #include "support/lstrings.h" @@ -257,7 +254,7 @@ int InsetQuotes::latex(Buffer const * bu LatexRunParams const & runparams) const { // How do we get the local language here?? - lyx::pos_type curr_pos = ownerPar(*buf, this).getPositionOfInset(this); + lyx::pos_type curr_pos = parOwner()->getPositionOfInset(this); Assert(curr_pos != -1); #warning FIXME. We _must_ find another way to get the language. (Lgb) Index: insets/insettabular.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insettabular.C,v retrieving revision 1.329 retrieving revision 1.328 diff -u -p -r1.329 -r1.328 --- insets/insettabular.C 26 Aug 2003 16:36:53 -0000 1.329 +++ insets/insettabular.C 23 Aug 2003 00:16:53 -0000 1.328 @@ -32,7 +32,6 @@ #include "undo_funcs.h" #include "WordLangTuple.h" #include "metricsinfo.h" -#include "paragraph_funcs.h" #include "frontends/Alert.h" #include "frontends/Dialogs.h" @@ -1095,7 +1094,7 @@ int InsetTabular::latex(Buffer const * b int InsetTabular::ascii(Buffer const * buf, ostream & os, int ll) const { if (ll > 0) - return tabular.ascii(buf, os, ownerPar(*buf, this).params().depth(), + return tabular.ascii(buf, os, (int)parOwner()->params().depth(), false, 0); return tabular.ascii(buf, os, 0, false, 0); } @@ -2246,7 +2245,7 @@ bool InsetTabular::copySelection(BufferV ostringstream os; paste_tabular->ascii(bv->buffer(), os, - ownerPar(*bv->buffer(), this).params().depth(), true, '\t'); + (int)parOwner()->params().depth(), true, '\t'); bv->stuffClipboard(STRCONV(os.str())); return true; } Index: insets/insettext.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insettext.C,v retrieving revision 1.485 retrieving revision 1.483 diff -u -p -r1.485 -r1.483 --- insets/insettext.C 26 Aug 2003 14:50:16 -0000 1.485 +++ insets/insettext.C 23 Aug 2003 00:16:55 -0000 1.483 @@ -663,7 +663,6 @@ InsetOld::RESULT InsetText::localDispatc if (!checkAndActivateInset(bv, cmd.x, tmp_y, mouse_button::none)) { text_.setCursorFromCoordinates(cmd.x - drawTextXOffset, cmd.y + dim_.asc); - text_.cursor.x(text_.cursor.x()); text_.cursor.x_fix(text_.cursor.x()); } } Index: insets/insettheorem.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insettheorem.C,v retrieving revision 1.20 retrieving revision 1.19 diff -u -p -r1.20 -r1.19 --- insets/insettheorem.C 26 Aug 2003 10:33:59 -0000 1.20 +++ insets/insettheorem.C 23 Aug 2003 00:16:55 -0000 1.19 @@ -12,7 +12,6 @@ #include "insettheorem.h" -#include "metricsinfo.h" #include "gettext.h" #include "lyxfont.h" #include "BufferView.h" @@ -63,20 +62,6 @@ InsetBase * InsetTheorem::clone() const result->collapsed_ = collapsed_; return result; -} - -void InsetTheorem::metrics(MetricsInfo & mi, Dimension & dim) const -{ - InsetCollapsable::metrics(mi, dim); - center_indent_ = (mi.base.textwidth - dim.wid) / 2; - dim.wid = mi.base.textwidth; - dim_ = dim; -} - - -void InsetTOC::draw(PainterInfo & pi, int x, int y) const -{ - InsetCollapsable::draw(pi, x + center_indent_, y); } Index: insets/insettheorem.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insettheorem.h,v retrieving revision 1.19 retrieving revision 1.18 diff -u -p -r1.19 -r1.18 --- insets/insettheorem.h 26 Aug 2003 10:33:59 -0000 1.19 +++ insets/insettheorem.h 23 Aug 2003 00:16:55 -0000 1.18 @@ -29,17 +29,12 @@ public: /// Inset::Code lyxCode() const { return Inset::THEOREM_CODE; } /// - void metrics(MetricsInfo &, Dimension &) const; - /// - void draw(PainterInfo & pi, int x, int y) const; + bool display() const { return true; } /// int latex(Buffer const *, std::ostream &, LatexRunParams const &) const; /// string const editMessage() const; -private: - /// - mutable unsigned int center_indent_; }; #endif Index: insets/insettoc.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insettoc.C,v retrieving revision 1.49 retrieving revision 1.48 diff -u -p -r1.49 -r1.48 --- insets/insettoc.C 26 Aug 2003 10:33:59 -0000 1.49 +++ insets/insettoc.C 23 Aug 2003 00:16:55 -0000 1.48 @@ -54,21 +54,6 @@ InsetOld::Code InsetTOC::lyxCode() const } -void InsetTOC::metrics(MetricsInfo & mi, Dimension & dim) const -{ - InsetCommand::metrics(mi, dim); - center_indent_ = (mi.base.textwidth - dim.wid) / 2; - dim.wid = mi.base.textwidth; - dim_ = dim; -} - - -void InsetTOC::draw(PainterInfo & pi, int x, int y) const -{ - InsetCommand::draw(pi, x + center_indent_, y); -} - - dispatch_result InsetTOC::localDispatch(FuncRequest const & cmd) { switch (cmd.action) { Index: insets/insettoc.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insettoc.h,v retrieving revision 1.46 retrieving revision 1.45 diff -u -p -r1.46 -r1.45 --- insets/insettoc.h 26 Aug 2003 10:33:59 -0000 1.46 +++ insets/insettoc.h 23 Aug 2003 00:16:56 -0000 1.45 @@ -14,7 +14,6 @@ #include "insetcommand.h" -#include "metricsinfo.h" /** Used to insert table of contents */ @@ -29,16 +28,14 @@ public: return std::auto_ptr<InsetBase>(new InsetTOC(params())); } /// - void metrics(MetricsInfo &, Dimension &) const; - /// - void draw(PainterInfo & pi, int x, int y) const; - /// dispatch_result localDispatch(FuncRequest const & cmd); /// string const getScreenLabel(Buffer const *) const; /// EDITABLE editable() const { return IS_EDITABLE; } /// + bool display() const { return true; } + /// InsetOld::Code lyxCode() const; /// int ascii(Buffer const *, std::ostream &, int linelen) const; @@ -46,9 +43,6 @@ public: int linuxdoc(Buffer const *, std::ostream &) const; /// int docbook(Buffer const *, std::ostream &, bool mixcont) const; -private: - /// - mutable unsigned int center_indent_; }; #endif Index: mathed/formula.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/formula.C,v retrieving revision 1.280 retrieving revision 1.279 diff -u -p -r1.280 -r1.279 --- mathed/formula.C 26 Aug 2003 11:06:04 -0000 1.280 +++ mathed/formula.C 19 Aug 2003 13:00:53 -0000 1.279 @@ -234,7 +234,7 @@ void InsetFormula::draw(PainterInfo & pi //p.pain.rectangle(x, y - a, w, h, LColor::mathframe); } - par_->draw(p, x + offset_, y); + par_->draw(p, x, y); } xo_ = x; @@ -287,14 +287,6 @@ void InsetFormula::metrics(MetricsInfo & dim.asc += 1; dim.des += 1; } - - if (display()) { - offset_ = (m.base.textwidth - dim.wid) / 2; - dim.wid = m.base.textwidth; - } else { - offset_ = 0; - } - dim_ = dim; }