On Fri, Mar 10, 2006 at 04:13:47PM +0100, Georg Baum wrote: > Martin Vermeer wrote: > > > On Fri, 2006-03-10 at 15:54 +0100, Jean-Marc Lasgouttes wrote: > > > >> Small note: I do not like the following much > >> > >> +bool isTrueTextInset(InsetBase * in) > >> +{ > >> + // Math and tabular insets have isTextInset = true, though they are > >> + // not derived from InsetText. Paint them fully > >> + return (in && in->isTextInset() && in->asMathInset() == 0 > >> + && in->lyxCode() != InsetBase::TABULAR_CODE); > >> +} > >> + > >> + > > > > Join the club. > > > >> Isn't there another way? > > > > A method in the inset (base inset) itself? > > Please not if possible. Do you know why math insets return isTextInset() == > true? Maybe this can be changed?
Actually I would like to bring up this alternative once again. A method (derivesFromTextInset?) implemented in insetbase.h returning false, and re-implemented in insettext returning true. This is much more robust than the current solution against possible future changes in the inset landscape. Imagine someone adds a new inset type that (like tabular) can contain texts yet does not derive from insettext. Then we would have to add a condition to the above method, which is essentially un-guessable. A built-in timebomb. The alternative solution proposed -- if you want to know if an inset derives from textinset, just ask it -- would simply keep working right. What do you say? - Martin
pgpJzNQCn4Qmh.pgp
Description: PGP signature