On Tuesday 24 July 2001 15:42, Lars Gullik Bj�nnes wrote:
> Angus Leeming <[EMAIL PROTECTED]> writes:
>
> | I think that the following hierarchy fullfills all our needs with a
minimum
> | amout of code. Question is, are you all happy with it!
>
> I am not sure.
;-) Me neither. Hence the request for feedback. Thanks, Lars.
> | class EditableButton
[snip...]
> I'd like this to be non virtual.
Yes, sorry. I originally had a base Button class but decided it wasn't needed.
> and to have a
>
> public:
> string const & getScreenLabel() const {
> return label_;
> }
> protected:
> setScreenLabel(string const & lab) {
> label_ = lab;
> }
> private:
> string label;
> };
Good. Makes sense
> | template <class Button, class Base>
> | class InsetButton: public Button, public Base {
> | public:
> | virtual int ascent() const { return button.ascent(); }
> | virtual int descent() const { return button.descent(); }
> | virtual int width() const { return button.width(); }
> | virtual void draw() const { button.draw(); }
> | virtual EDITABLE editable() const { return button.editable(); }
> | private:
> | Button button;
> | };
>
> Is this template class really needed?
> What problem does it solve?
Not sure if it's really needed at all, but I was having difficulty mainly
with deriving it from Inset.
> // why not just: ?
>
> class InsetExternal : public EditableButton {
> };
>
> and let editablebutton derive from Inset?
Maybe. I'll think about it a bit more. All the convolution stems from all
these derivations.
> | // No longer derives from InsetButton. Leave this to the daughter
> | // classes as they are the ones deciding whether they're EDITABLE or not
> | class InsetCommand : public Inset {
> | public:
> | virtual string const getScreenLabel() const;
> | };
>
> InsetCommand does not have to derive from Inset.
> ...but InsetButton does...
Really? What about the basic Inset methods write(), read(), latex(), ascii(),
linuxdoc(), docbook(), ...
Anyway, more thought required. The basic idea of a button class is Ok, the
problem stems from having InsetButton I think. I'll sleep on it.
> | class InsetCollapsable : public UpdatableInset {
> | public:
> | /// Why public?
> | InsetText inset;
> |
> | virtual int ascent() const { return button.ascent(); }
> | virtual int descent() const
> | {
> | if (collapsed_)
> | return button.descent();
> |
> | return button.descent()
> | + inset.descent()
> | + inset.ascent()
> | + TEXT_TO_BOTTOM_OFFSET;
> | }
> |
> | virtual int width() const;
> | {
> | int widthButton = button.width();
> |
> | if (collapsed_)
> | return widthButton;
> |
> | return (inset.width(bv, font) > widthButton) ?
> | inset.width(bv, font) : widthButton;
> | }
> |
> | /// etc, etc, etc
> | virtual void draw() const;
> |
> | private:
> | Button button;
>
> Button?
> or EditableButton?
Well spotted. EditableButton
Thanks again,
Angus