This moves the 'spurious' bibitem*Width() functions closer to the place where they are used.
Ok? [And no, this won't fix the bibitem issue (yet), John] Andre' -- 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: paragraph_funcs.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/paragraph_funcs.C,v retrieving revision 1.44 diff -u -p -r1.44 paragraph_funcs.C --- paragraph_funcs.C 29 May 2003 01:13:16 -0000 1.44 +++ paragraph_funcs.C 2 Jun 2003 16:55:02 -0000 @@ -34,11 +34,9 @@ #include "insets/insethfill.h" #include "insets/inseterror.h" #include "insets/insetnewline.h" - -extern string bibitemWidest(Buffer const *); +#include "frontends/font_metrics.h" using lyx::pos_type; -//using lyx::layout_type; using std::endl; using std::ostream; @@ -311,6 +309,40 @@ TeXDeeper(Buffer const * buf, return par; } + +namespace { + +string const bibitemWidest(Buffer const * buffer) +{ + int w = 0; + // Does look like a hack? It is! (but will change at 0.13) + // And now we are at 1.4.0 .. (Andre) + + InsetBibitem const * bitem = 0; + LyXFont font; + + ParagraphList::const_iterator it = buffer->paragraphs.begin(); + ParagraphList::const_iterator end = buffer->paragraphs.end(); + + for (; it != end; ++it) { + if (it->bibitem()) { + int const wx = + font_metrics::width(it->bibitem()->getBibLabel(), + font); + if (wx > w) { + w = wx; + bitem = it->bibitem(); + } + } + } + + if (bitem && !bitem->getBibLabel().empty()) + return bitem->getBibLabel(); + + return "99"; +} + +} ParagraphList::iterator TeXEnvironment(Buffer const * buf, Index: text.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/text.C,v retrieving revision 1.365 diff -u -p -r1.365 text.C --- text.C 28 May 2003 16:36:53 -0000 1.365 +++ text.C 2 Jun 2003 16:55:03 -0000 @@ -36,6 +36,7 @@ #include "lyxrow_funcs.h" #include "insets/insettext.h" +#include "insets/insetbibitem.h" #include "support/textutils.h" #include "support/LAssert.h" @@ -57,8 +58,6 @@ extern int const CHANGEBAR_MARGIN = 10; /// left margin extern int const LEFT_MARGIN = PAPER_MARGIN + CHANGEBAR_MARGIN; -extern int bibitemMaxWidth(BufferView *, LyXFont const &); - BufferView * LyXText::bv() { @@ -518,6 +517,22 @@ bool LyXText::isBoundary(Buffer const * ? bidi_level(pos) % 2 : par.isRightToLeftPar(buf->params); return rtl != rtl2; +} + + +int bibitemMaxWidth(BufferView * bv, LyXFont const & font) +{ + int w = 0; + ParagraphList::iterator it = bv->buffer()->paragraphs.begin(); + ParagraphList::iterator end = bv->buffer()->paragraphs.end(); + for (; it != end; ++it) { + if (it->bibitem()) { + int const wx = it->bibitem()->width(bv, font); + if (wx > w) + w = wx; + } + } + return w; } Index: text3.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/text3.C,v retrieving revision 1.79 diff -u -p -r1.79 text3.C --- text3.C 2 Jun 2003 14:19:29 -0000 1.79 +++ text3.C 2 Jun 2003 16:55:03 -0000 @@ -48,7 +48,6 @@ using std::vector; using lyx::pos_type; extern string current_layout; -extern int bibitemMaxWidth(BufferView *, LyXFont const &); // the selection possible is needed, that only motion events are // used, where the bottom press event was on the drawing area too Index: insets/insetbibitem.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetbibitem.C,v retrieving revision 1.14 diff -u -p -r1.14 insetbibitem.C --- insets/insetbibitem.C 28 May 2003 06:47:15 -0000 1.14 +++ insets/insetbibitem.C 2 Jun 2003 16:55:03 -0000 @@ -15,8 +15,6 @@ #include "funcrequest.h" #include "lyxlex.h" -#include "frontends/font_metrics.h" - #include "support/tostr.h" #include "support/lstrings.h" @@ -143,52 +141,3 @@ string const InsetBibitem::getScreenLabe return getContents() + " [" + getBibLabel() + ']'; } - -// ale070405 This function maybe shouldn't be here. We'll fix this at 0.13. -int bibitemMaxWidth(BufferView * bv, LyXFont const & font) -{ - int w = 0; - // Ha, now we are mainly at 1.2.0 and it is still here (Jug) - // Does look like a hack? It is! (but will change at 0.13) - ParagraphList::iterator it = bv->buffer()->paragraphs.begin(); - ParagraphList::iterator end = bv->buffer()->paragraphs.end(); - for (; it != end; ++it) { - if (it->bibitem()) { - int const wx = it->bibitem()->width(bv, font); - if (wx > w) - w = wx; - } - } - return w; -} - - -// ale070405 -string const bibitemWidest(Buffer const * buffer) -{ - int w = 0; - // Does look like a hack? It is! (but will change at 0.13) - - InsetBibitem const * bitem = 0; - LyXFont font; - - ParagraphList::const_iterator it = buffer->paragraphs.begin(); - ParagraphList::const_iterator end = buffer->paragraphs.end(); - - for (; it != end; ++it) { - if (it->bibitem()) { - int const wx = - font_metrics::width(it->bibitem()->getBibLabel(), - font); - if (wx > w) { - w = wx; - bitem = it->bibitem(); - } - } - } - - if (bitem && !bitem->getBibLabel().empty()) - return bitem->getBibLabel(); - - return "99"; -}