On Wed, Nov 02, 2005 at 09:14:21AM +0100, Georg Baum wrote: > Martin Vermeer wrote: > > > On Tue, Nov 01, 2005 at 09:23:05PM +0100, Lars Gullik Bjønnes wrote: > >> I am not sure that I like this, especially at this stage in the > >> endgame of 1.4.0cvs. > >> > >> Shouldn't all insets have dimensions? In that case Dimension should > >> be in the base. (and I'd like to see NVI used for the methods). > > MathDimInset had a dim_ member in 1.3. I am sure that it was removed for a > reason. See also the comment in insetbase.h about data members.
Yes, I saw that. But as Lars remarked, all insets have dimensions. > > OK. Happy to oblige, once I understand it :-) > > > > NVI = Nonvirtual Interface Idiom? Could you elaborate with an example? > > Look at InsetBase::dispatch() and InsetBase::doDispatch(). dispatch is the > nonvirtual method that is visible to the outside world, and it calls the > virtual doDispatch method to do the work. > > >> What is the _minimal_ solution that will work just ok, for 1.4.x? > > IMHO the minimal solution is the original patch without the changes to > insetbase.h and a bugzilla entry requesting to make the dimension methods > of InsetBase abstract. OK. Lars, can I check the original one in (without 42 :-) ? Attached again for reference. - Martin
Index: mathed/math_kerninset.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_kerninset.C,v retrieving revision 1.32 diff -u -p -r1.32 math_kerninset.C --- mathed/math_kerninset.C 3 Oct 2005 12:16:34 -0000 1.32 +++ mathed/math_kerninset.C 31 Oct 2005 18:58:35 -0000 @@ -42,9 +42,16 @@ auto_ptr<InsetBase> MathKernInset::doClo void MathKernInset::metrics(MetricsInfo & mi, Dimension & dim) const { - dim.wid = wid_.inPixels(0, mathed_char_width(mi.base.font, 'M')); + wid_pix_ = wid_.inPixels(0, mathed_char_width(mi.base.font, 'M')); + dim.wid = wid_pix_; dim.asc = 0; dim.des = 0; +} + + +int MathKernInset::width() const +{ + return wid_pix_; } Index: mathed/math_kerninset.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_kerninset.h,v retrieving revision 1.20 diff -u -p -r1.20 math_kerninset.h --- mathed/math_kerninset.h 23 Nov 2004 23:04:50 -0000 1.20 +++ mathed/math_kerninset.h 31 Oct 2005 18:58:35 -0000 @@ -35,9 +35,14 @@ public: void write(WriteStream & os) const; /// void normalize(NormalStream & ns) const; + /// + int width() const; private: virtual std::auto_ptr<InsetBase> doClone() const; /// width in em LyXLength wid_; + /// in pixels + mutable int wid_pix_; + }; #endif
pgpnaBm5WDu3V.pgp
Description: PGP signature