On Friday 14 June 2002 2:53 pm, Martin Vermeer wrote:
> On Fri, Jun 14, 2002 at 02:26:56PM +0100, Angus Leeming wrote:
> > > Yes! This compiles.
> > >
> > > But does it do what it should? The idea is that somewhere you call
> > > InsetSection::insetShortTitle with an argument ins containing the text
> > > you want to be in the short title (sub-) inset. And then it should
> > > create such an inset.
> >
> > It creates an instance of InsetShortTitle.
> >
> > InsetSection should have a member variable
> >     InsetShortTitle ist_;
> >
> > Then, your method becomes:
> >     void setShortTitle(InsetText const & inset) {
> >             ist_ = inset;
> >     }
> >
> > Now, you've stored it you can create other methods to draw it.
> >
> > Angus
>
> No quite, though. What you need is
>
>  void insetShortTitle(InsetText const & ins) {
>         ist_(ins);
>     }
>
> in public, and
>
>     InsetShortTitle ist_(InsetText const &);
>
> in private. The parentheses are necessary in both places to get it to
> compile. So ist_ is a (function-like) method and should be called as
> one.
>
> Hmmm... but how do you use this thingy somewhere else? As I see it,
> nothing is leaving the insetShortTitle method, and ist_ only helps you
> generate an InsetShortTitle from a given text inset. It's not a data
> thing.
>
> Should insetShortTitle have a return value?
>
> Anyway, thanks! Learning all the time.
>
> Martin

I see that you and I are a little confused. I thought this is what you wanted.

class InsetSection {
public:
        void setShortTitle(InsetText const & inset)
        {
                ist_ = inset;
        }

        void drawShortTitle() const
        {
                ist_.draw();
        }
private:
        /** A holder of the short title data. This InsetSection class
             tells it when to draw, hide etc. See InsetCollapsable for an inset
                 that controls how a Button and an InsetText are displayed.
        */
        InsetShortTitle ist_;
};

class InsetShortTitle {
public:
        InsetShortTitle(InsetText const & inset)
        {
                // does whatever it needs to create from InsetText 
                ...
        }
        void draw() const;
}




Reply via email to