On Mon, Aug 25, 2003 at 01:37:50AM +0100, John Levon spake thusly: > > On Mon, Aug 25, 2003 at 12:33:17AM +0300, Martin Vermeer wrote: > > > It depends on adding a member to LyXText describing the extra indent > > This is absolutely not the right way to go here IMHO. Consider: the > lyxtext already knows how much width it can possibly expand into; the > lyxtext also knows where it's going to place the start of the inset.
How? (i.e., where is this info?) > There is no need for any further information at all. See my previous > mails concerning this subject. Which previous mails? Your recent mails are not on this at all IIRC. > The (or at least my) final is to *never* call rowBreakPoint from anywher > other than LyXText::metrics(). All row list construction are rebreaking > would be done from there. Makes sense. > Can we please just have the basic needFullRow-killer patch applied first > ? OK, OK... patch attached, have to run now > regards > john - Martin
Index: ChangeLog =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/ChangeLog,v retrieving revision 1.1518 diff -u -p -r1.1518 ChangeLog --- ChangeLog 23 Aug 2003 00:25:50 -0000 1.1518 +++ ChangeLog 25 Aug 2003 04:51:15 -0000 @@ -1,3 +1,11 @@ +2003-08-25 Martin Vermeer <[EMAIL PROTECTED]> + + * lyxrow_funcs.C: + * lyxtext.h: + * text.C: + * text2.C: eliminates the needFullRow/display() stuff + altogether, putting the logic in metrics/draw in the insets. + 2003-08-22 Angus Leeming <[EMAIL PROTECTED]> * *.[Ch]: clean-up of licence and author blurbs. Index: lyxrow_funcs.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lyxrow_funcs.C,v retrieving revision 1.12 diff -u -p -r1.12 lyxrow_funcs.C --- lyxrow_funcs.C 23 Aug 2003 00:16:14 -0000 1.12 +++ lyxrow_funcs.C 25 Aug 2003 04:51:15 -0000 @@ -64,23 +64,6 @@ 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); @@ -88,9 +71,6 @@ 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.222 diff -u -p -r1.222 lyxtext.h --- lyxtext.h 23 Aug 2003 00:16:14 -0000 1.222 +++ lyxtext.h 25 Aug 2003 04:51:15 -0000 @@ -127,10 +128,11 @@ public: void setFont(LyXFont const &, bool toggleall = false); /// rebreaks all paragaphs between the given pars. - void redoParagraphs(ParagraphList::iterator begin, + /// returns the widest row found (before justification) + unsigned int redoParagraphs(ParagraphList::iterator begin, ParagraphList::iterator end); /// rebreaks the given par - void redoParagraph(ParagraphList::iterator pit); + unsigned int redoParagraph(ParagraphList::iterator pit); /// rebreaks the cursor par void redoParagraph(); Index: text.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/text.C,v retrieving revision 1.429 diff -u -p -r1.429 text.C --- text.C 23 Aug 2003 00:16:28 -0000 1.429 +++ text.C 25 Aug 2003 04:51:15 -0000 @@ -69,6 +69,8 @@ extern int const CHANGEBAR_MARGIN = 10; /// left margin extern int const LEFT_MARGIN = PAPER_MARGIN + CHANGEBAR_MARGIN; + + int bibitemMaxWidth(BufferView *, LyXFont const &); @@ -443,15 +445,7 @@ 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(); @@ -628,14 +622,6 @@ 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(); @@ -683,7 +669,8 @@ 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 ? @@ -712,7 +699,6 @@ pos_type LyXText::rowBreakPoint(Paragrap // pixel width since last breakpoint int chunkwidth = 0; - bool fullrow = false; pos_type i = pos; @@ -751,14 +737,12 @@ 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 or we are at an inset - // that will take up a row, break here - if (point == last || fullrow || chunkwidth >= (width - left)) { + // if no break before, break here + if (point == last || chunkwidth >= (width - left)) { if (pos < i) point = i - 1; else @@ -776,24 +760,7 @@ pos_type LyXText::rowBreakPoint(Paragrap 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; + continue; } if (point == last && x >= width) { @@ -808,7 +775,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 (!fullrow && body_pos && point < body_pos) + if (body_pos && point < body_pos) point = body_pos - 1; return point; @@ -1502,15 +1469,7 @@ 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() && @@ -1521,18 +1480,15 @@ 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->isInset(next_row->pos()) - && pit->getInset(next_row->pos()) - && pit->getInset(next_row->pos())->display()) + && !pit->isNewline(next_row->pos() - 1) ) { - 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.445 diff -u -p -r1.445 text2.C --- text2.C 23 Aug 2003 00:16:32 -0000 1.445 +++ text2.C 25 Aug 2003 04:51:15 -0000 @@ -546,15 +546,20 @@ void LyXText::setFont(LyXFont const & fo // rebreaks all paragraphs between the specified pars // This function is needed after SetLayout and SetFont etc. -void LyXText::redoParagraphs(ParagraphList::iterator start, +// Returns the longest row length (before fill) found. +unsigned int LyXText::redoParagraphs(ParagraphList::iterator start, ParagraphList::iterator end) { - for ( ; start != end; ++start) - redoParagraph(start); + unsigned int pars_width = 0; + for ( ; start != end; ++start) { + unsigned int par_width = redoParagraph(start); + pars_width = std::max(par_width, pars_width); + } + return pars_width; } -void LyXText::redoParagraph(ParagraphList::iterator pit) +unsigned int LyXText::redoParagraph(ParagraphList::iterator pit) { RowList::iterator rit = pit->rows.begin(); RowList::iterator end = pit->rows.end(); @@ -581,15 +586,22 @@ void LyXText::redoParagraph(ParagraphLis pit->rows.push_back(row); } - // set height and fill of rows + unsigned int par_width = 0; + // set height and fill and width of rows for (rit = pit->rows.begin(); rit != end; ++rit) { - rit->fill(fill(pit, rit, workWidth())); + unsigned int ww = workWidth(); + int f = fill(pit, rit, ww); + unsigned int w = ww - f; + par_width = std::max(par_width, w); + rit->fill(f); + rit->width(w); prepareToPrint(pit, rit); setHeightOfRow(pit, rit); height += rit->height(); } //lyxerr << "redoParagraph: " << pit->rows.size() << " rows\n"; + return par_width; } @@ -612,7 +624,7 @@ void LyXText::metrics(MetricsInfo & mi, ///height = 0; //anchor_y_ = 0; - redoParagraphs(ownerParagraphs().begin(), ownerParagraphs().end()); + width = redoParagraphs(ownerParagraphs().begin(), ownerParagraphs().end()); updateRowPositions(); // final dimension @@ -1347,16 +1359,6 @@ 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(); @@ -1623,33 +1625,6 @@ 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. @@ -1662,17 +1637,9 @@ void LyXText::setCursorFromCoordinates(L cur.x(x); cur.y(y + rit->baseline()); - 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.iy(cur.y()); + cur.ix(cur.x()); + cur.boundary(bound); } Index: insets/ChangeLog =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/ChangeLog,v retrieving revision 1.796 diff -u -p -r1.796 ChangeLog --- insets/ChangeLog 19 Aug 2003 16:46:47 -0000 1.796 +++ insets/ChangeLog 25 Aug 2003 04:51:16 -0000 @@ -1,3 +1,22 @@ +2003-08-25 Martin Vermeer <[EMAIL PROTECTED]> + + * insets/inset.h: + * insets/insetbibtex.[Ch]: + * insets/insetbranch.[Ch]: + * insets/insetcollapsable.h: + * insets/insetert.[Ch]: + * insets/insetfloatlist.[Ch]: + * insets/insetfootlike.[Ch]: + * insets/insetinclude.[Ch]: + * insets/insetindex.[Ch]: + * insets/insetindex.h: + * insets/insetminipage.h: + * insets/insetnote.[Ch]: + * insets/insettext.C: + * insets/insettheorem.[Ch]: + * insets/insettoc.[Ch]: eliminates the needFullRow/display() stuff + altogether, putting the logic in metrics/draw in the insets.=20 + Draws short single row insets with more or less realistic metrics. 2003-08-19 André Pönitz <[EMAIL PROTECTED]> Index: insets/inset.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/inset.h,v retrieving revision 1.111 diff -u -p -r1.111 inset.h --- insets/inset.h 23 Aug 2003 00:16:49 -0000 1.111 +++ insets/inset.h 25 Aug 2003 04:51:16 -0000 @@ -198,14 +198,6 @@ 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; } /// Index: insets/insetbibtex.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetbibtex.C,v retrieving revision 1.19 diff -u -p -r1.19 insetbibtex.C --- insets/insetbibtex.C 23 Aug 2003 00:16:50 -0000 1.19 +++ insets/insetbibtex.C 25 Aug 2003 04:51:16 -0000 @@ -11,6 +11,7 @@ #include <config.h> #include "insetbibtex.h" +#include "metricsinfo.h" #include "buffer.h" #include "BufferView.h" #include "debug.h" @@ -51,6 +52,20 @@ 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.18 diff -u -p -r1.18 insetbibtex.h --- insets/insetbibtex.h 23 Aug 2003 00:16:50 -0000 1.18 +++ insets/insetbibtex.h 25 Aug 2003 04:51:16 -0000 @@ -26,6 +26,10 @@ 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); /// @@ -46,8 +50,9 @@ public: bool addDatabase(string const &); /// bool delDatabase(string const &); +private: /// - bool display() const { return true; } + mutable unsigned int center_indent_; }; #endif // INSET_BIBTEX_H Index: insets/insetbranch.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetbranch.C,v retrieving revision 1.2 diff -u -p -r1.2 insetbranch.C --- insets/insetbranch.C 23 Aug 2003 00:16:50 -0000 1.2 +++ insets/insetbranch.C 25 Aug 2003 04:51:16 -0000 @@ -109,19 +109,6 @@ void InsetBranch::setButtonLabel() } -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); -} - - bool InsetBranch::showInsetDialog(BufferView * bv) const { InsetBranchMailer("branch", const_cast<InsetBranch &>(*this)).showDialog(bv); Index: insets/insetbranch.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetbranch.h,v retrieving revision 1.2 diff -u -p -r1.2 insetbranch.h --- insets/insetbranch.h 23 Aug 2003 00:16:50 -0000 1.2 +++ insets/insetbranch.h 25 Aug 2003 04:51:16 -0000 @@ -54,10 +54,6 @@ 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/insetcollapsable.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetcollapsable.h,v retrieving revision 1.119 diff -u -p -r1.119 insetcollapsable.h --- insets/insetcollapsable.h 23 Aug 2003 00:16:50 -0000 1.119 +++ insets/insetcollapsable.h 25 Aug 2003 04:51:16 -0000 @@ -66,8 +66,6 @@ public: /// void insetUnlock(BufferView *); /// - bool needFullRow() const { return isOpen(); } - /// bool lockInsetInInset(BufferView *, UpdatableInset *); /// bool unlockInsetInInset(BufferView *, UpdatableInset *, Index: insets/insetert.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetert.C,v retrieving revision 1.148 diff -u -p -r1.148 insetert.C --- insets/insetert.C 23 Aug 2003 00:16:50 -0000 1.148 +++ insets/insetert.C 25 Aug 2003 04:51:16 -0000 @@ -12,6 +12,7 @@ #include "insetert.h" #include "insettext.h" +#include "metricsinfo.h" #include "buffer.h" #include "BufferView.h" @@ -555,6 +556,10 @@ 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.82 diff -u -p -r1.82 insetert.h --- insets/insetert.h 23 Aug 2003 00:16:50 -0000 1.82 +++ insets/insetert.h 25 Aug 2003 04:51:16 -0000 @@ -80,9 +80,7 @@ public: /// bool checkInsertChar(LyXFont &); /// - // this are needed here because of the label/inlined functionallity - /// - bool needFullRow() const { return status_ == Open; } + // these are needed here because of the label/inlined functionallity /// 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.37 diff -u -p -r1.37 insetfloatlist.C --- insets/insetfloatlist.C 23 Aug 2003 00:16:51 -0000 1.37 +++ insets/insetfloatlist.C 25 Aug 2003 04:51:16 -0000 @@ -12,6 +12,7 @@ #include "insetfloatlist.h" #include "FloatList.h" +#include "metricsinfo.h" #include "LaTeXFeatures.h" #include "lyxlex.h" #include "BufferView.h" @@ -94,6 +95,21 @@ 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.27 diff -u -p -r1.27 insetfloatlist.h --- insets/insetfloatlist.h 23 Aug 2003 00:16:51 -0000 1.27 +++ insets/insetfloatlist.h 25 Aug 2003 04:51:16 -0000 @@ -30,14 +30,16 @@ 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; @@ -54,6 +56,9 @@ public: int ascii(Buffer const *, std::ostream &, int linelen) const; /// void validate(LaTeXFeatures & features) const; +private: + /// + mutable unsigned int center_indent_; }; #endif Index: insets/insetfootlike.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetfootlike.C,v retrieving revision 1.24 diff -u -p -r1.24 insetfootlike.C --- insets/insetfootlike.C 23 Aug 2003 00:16:51 -0000 1.24 +++ insets/insetfootlike.C 25 Aug 2003 04:51:16 -0000 @@ -11,6 +11,7 @@ #include <config.h> #include "insetfootlike.h" +#include "metricsinfo.h" #include "lyxfont.h" #include "buffer.h" #include "lyxtext.h" @@ -39,6 +40,15 @@ 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.18 diff -u -p -r1.18 insetfootlike.h --- insets/insetfootlike.h 23 Aug 2003 00:16:51 -0000 1.18 +++ insets/insetfootlike.h 25 Aug 2003 04:51:16 -0000 @@ -24,6 +24,8 @@ 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/insetinclude.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetinclude.C,v retrieving revision 1.135 diff -u -p -r1.135 insetinclude.C --- insets/insetinclude.C 23 Aug 2003 00:16:51 -0000 1.135 +++ insets/insetinclude.C 25 Aug 2003 04:51:16 -0000 @@ -242,12 +242,6 @@ void InsetInclude::read(Buffer const *, } -bool InsetInclude::display() const -{ - return !(params_.flag == INPUT); -} - - string const InsetInclude::getScreenLabel(Buffer const *) const { string temp; @@ -530,6 +524,11 @@ 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; } @@ -538,14 +537,14 @@ void InsetInclude::draw(PainterInfo & pi { cache(pi.base.bv); if (!preview_->previewReady()) { - button_.draw(pi, x, y); + button_.draw(pi, x + center_indent_, y); return; } if (!preview_->monitoring()) preview_->startMonitoring(); - pi.pain.image(x, y - dim_.asc, dim_.wid, dim_.height(), + pi.pain.image(x + center_indent_, 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.77 diff -u -p -r1.77 insetinclude.h --- insets/insetinclude.h 23 Aug 2003 00:16:52 -0000 1.77 +++ insets/insetinclude.h 25 Aug 2003 04:51:16 -0000 @@ -102,9 +102,6 @@ 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; @@ -135,6 +132,7 @@ 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.43 diff -u -p -r1.43 insetindex.C --- insets/insetindex.C 23 Aug 2003 00:16:52 -0000 1.43 +++ insets/insetindex.C 25 Aug 2003 04:51:16 -0000 @@ -11,6 +11,7 @@ #include "insetindex.h" +#include "metricsinfo.h" #include "BufferView.h" #include "funcrequest.h" #include "frontends/LyXView.h" @@ -41,6 +42,21 @@ 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.41 diff -u -p -r1.41 insetindex.h --- insets/insetindex.h 23 Aug 2003 00:16:52 -0000 1.41 +++ insets/insetindex.h 25 Aug 2003 04:51:16 -0000 @@ -59,13 +59,18 @@ public: /// EDITABLE editable() const { return NOT_EDITABLE; } /// - bool display() const { return true; } - /// InsetOld::Code lyxCode() const; /// string const getScreenLabel(Buffer const *) const; /// - virtual bool needFullRow() const { return true; } + //virtual bool needFullRow() const { return true; } + /// + void metrics(MetricsInfo &, Dimension &) const; + /// + void draw(PainterInfo & pi, int x, int y) const; +private: + /// + mutable unsigned int center_indent_; }; #endif Index: insets/insetminipage.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetminipage.h,v retrieving revision 1.51 diff -u -p -r1.51 insetminipage.h --- insets/insetminipage.h 23 Aug 2003 00:16:52 -0000 1.51 +++ insets/insetminipage.h 25 Aug 2003 04:51:16 -0000 @@ -78,8 +78,6 @@ 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/insetnote.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetnote.C,v retrieving revision 1.40 diff -u -p -r1.40 insetnote.C --- insets/insetnote.C 23 Aug 2003 00:16:52 -0000 1.40 +++ insets/insetnote.C 25 Aug 2003 04:51:16 -0000 @@ -15,6 +15,7 @@ #include "Lsstream.h" #include "insetnote.h" +#include "metricsinfo.h" #include "gettext.h" #include "lyxfont.h" #include "language.h" @@ -110,6 +111,18 @@ 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); @@ -172,11 +185,11 @@ int InsetNote::latex(Buffer const * buf, if (pt == "Comment") { os << "%\n\\end{comment}\n"; - i += 3; + i += 4; } else if (pt == "Greyedout") { os << "%\n\\end{lyxgreyedout}\n"; - i += 2; - } + i += 4; + } return i; } Index: insets/insetnote.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetnote.h,v retrieving revision 1.28 diff -u -p -r1.28 insetnote.h --- insets/insetnote.h 23 Aug 2003 00:16:52 -0000 1.28 +++ insets/insetnote.h 25 Aug 2003 04:51:16 -0000 @@ -53,6 +53,8 @@ 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/insettext.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insettext.C,v retrieving revision 1.483 diff -u -p -r1.483 insettext.C --- insets/insettext.C 23 Aug 2003 00:16:55 -0000 1.483 +++ insets/insettext.C 25 Aug 2003 04:51:16 -0000 @@ -247,7 +247,7 @@ void InsetText::metrics(MetricsInfo & mi int InsetText::textWidth() const { - return textwidth_; + return textwidth_; } @@ -663,6 +663,7 @@ 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.19 diff -u -p -r1.19 insettheorem.C --- insets/insettheorem.C 23 Aug 2003 00:16:55 -0000 1.19 +++ insets/insettheorem.C 25 Aug 2003 04:51:16 -0000 @@ -12,6 +12,7 @@ #include "insettheorem.h" +#include "metricsinfo.h" #include "gettext.h" #include "lyxfont.h" #include "BufferView.h" @@ -62,6 +63,20 @@ 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.18 diff -u -p -r1.18 insettheorem.h --- insets/insettheorem.h 23 Aug 2003 00:16:55 -0000 1.18 +++ insets/insettheorem.h 25 Aug 2003 04:51:16 -0000 @@ -29,12 +29,17 @@ public: /// Inset::Code lyxCode() const { return Inset::THEOREM_CODE; } /// - bool display() const { return true; } + void metrics(MetricsInfo &, Dimension &) const; + /// + void draw(PainterInfo & pi, int x, int y) const; /// 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.48 diff -u -p -r1.48 insettoc.C --- insets/insettoc.C 23 Aug 2003 00:16:55 -0000 1.48 +++ insets/insettoc.C 25 Aug 2003 04:51:16 -0000 @@ -54,6 +54,21 @@ 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.45 diff -u -p -r1.45 insettoc.h --- insets/insettoc.h 23 Aug 2003 00:16:56 -0000 1.45 +++ insets/insettoc.h 25 Aug 2003 04:51:16 -0000 @@ -14,6 +14,7 @@ #include "insetcommand.h" +#include "metricsinfo.h" /** Used to insert table of contents */ @@ -28,14 +29,16 @@ 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; @@ -43,6 +46,9 @@ public: int linuxdoc(Buffer const *, std::ostream &) const; /// int docbook(Buffer const *, std::ostream &, bool mixcont) const; +private: + /// + mutable unsigned int center_indent_; }; #endif
pgp00000.pgp
Description: PGP signature