X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Finsets%2FInsetBranch.h;h=6106ce5a5c3babbd8923c8783d5e2a2d59cf9b6b;hb=997f0621c5346bb623cf86713c4fe1be0c941104;hp=8793602a2e1299bcea5305387d395a26e9d79929;hpb=82a738b853207f8f2cc93545c2125fdc673fffc0;p=lyx.git diff --git a/src/insets/InsetBranch.h b/src/insets/InsetBranch.h index 8793602a2e..6106ce5a5c 100644 --- a/src/insets/InsetBranch.h +++ b/src/insets/InsetBranch.h @@ -12,112 +12,114 @@ #ifndef INSETBRANCH_H #define INSETBRANCH_H -#include "InsetCollapsable.h" -#include "MailInset.h" - +#include "InsetCollapsible.h" namespace lyx { class InsetBranchParams { public: + /// explicit InsetBranchParams(docstring const & b = docstring()) - : branch(b) {} + : branch(b), inverted(false) {} + InsetBranchParams(docstring const & b, bool i) + : branch(b), inverted(i) {} /// void write(std::ostream & os) const; /// void read(Lexer & lex); /// docstring branch; + /// + bool inverted; }; -/** The Branch inset for alternative, conditional output. +///////////////////////////////////////////////////////////////////////// +// +// InsetBranch +// +///////////////////////////////////////////////////////////////////////// -*/ -class InsetBranch : public InsetCollapsable { +/// The Branch inset for alternative, conditional output. + +class InsetBranch : public InsetCollapsible +{ public: /// - InsetBranch(Buffer const &, InsetBranchParams const &); - /// - ~InsetBranch(); - /// - docstring editMessage() const; - /// - InsetCode lyxCode() const { return BRANCH_CODE; } - /// - void write(std::ostream &) const; - /// - void read(Lexer & lex); - /// - void setButtonLabel(); + InsetBranch(Buffer *, InsetBranchParams const &); + /// - virtual ColorCode backgroundColor() const; + static std::string params2string(InsetBranchParams const &); /// - bool showInsetDialog(BufferView *) const; + static void string2params(std::string const &, InsetBranchParams &); /// - int latex(odocstream &, OutputParams const &) const; + docstring branch() const { return params_.branch; } /// - int plaintext(odocstream &, OutputParams const &) const; + void rename(docstring const & newname) { params_.branch = newname; } /// - int docbook(odocstream &, OutputParams const &) const; + InsetBranchParams const & params() const { return params_; } + +private: /// - void textString(odocstream &) const; + InsetCode lyxCode() const override { return BRANCH_CODE; } /// - void validate(LaTeXFeatures &) const; + void write(std::ostream &) const override; /// - InsetBranchParams const & params() const { return params_; } + void read(Lexer & lex) override; /// - void setParams(InsetBranchParams const & params) { params_ = params; } - - /** \returns true if params_.branch is listed as 'selected' in - \c buffer. This handles the case of child documents. - */ - bool isBranchSelected() const; + docstring const buttonLabel(BufferView const &) const override; /// - bool getStatus(Cursor &, FuncRequest const &, FuncStatus &) const; + ColorCode backgroundColor(PainterInfo const &) const override; /// - virtual void updateLabels(ParIterator const &); + void latex(otexstream &, OutputParams const &) const override; /// - bool isMacroScope() const; + int plaintext(odocstringstream & ods, OutputParams const & op, + size_t max_length = INT_MAX) const override; /// - docstring toolTip(BufferView const & bv, int x, int y) const; + void docbook(XMLStream &, OutputParams const &) const override; /// - virtual bool useEmptyLayout() const { return false; } -protected: + docstring xhtml(XMLStream &, OutputParams const &) const override; /// - void doDispatch(Cursor & cur, FuncRequest & cmd); + void toString(odocstream &) const override; /// - docstring name() const { return from_ascii("Branch"); } -private: + void forOutliner(docstring &, size_t const, bool const) const override; /// - friend class InsetBranchParams; + void validate(LaTeXFeatures &) const override; /// - Inset * clone() const { return new InsetBranch(*this); } + std::string contextMenuName() const override; /// - InsetBranchParams params_; -}; + void updateBuffer(ParIterator const & it, UpdateType utype, bool const deleted = false) override; - -class InsetBranchMailer : public MailInset { -public: + /** \returns true if params_.branch is listed as 'selected' in + \c buffer. \p child only checks within child documents. + */ + bool isBranchSelected(bool const child = false) const; + /*! + * Is the content of this inset part of the output document? + * + * Note that Branch insets are considered part of the + * document when they are selected XOR inverted. + */ + bool producesOutput() const override; /// - InsetBranchMailer(InsetBranch & inset); + bool getStatus(Cursor &, FuncRequest const &, FuncStatus &) const override; /// - virtual Inset & inset() const { return inset_; } + bool isMacroScope() const override; /// - virtual std::string const & name() const { return name_; } + docstring toolTip(BufferView const & bv, int x, int y) const override; /// - virtual std::string const inset2string(Buffer const &) const; + bool usePlainLayout() const override { return false; } /// - static std::string const params2string(InsetBranchParams const &); + void doDispatch(Cursor & cur, FuncRequest & cmd) override; /// - static void string2params(std::string const &, InsetBranchParams &); + docstring layoutName() const override { return from_ascii("Branch:") + branch(); } + /// + Inset * clone() const override { return new InsetBranch(*this); } -private: /// - static std::string const name_; + friend class InsetBranchParams; /// - InsetBranch & inset_; + InsetBranchParams params_; }; } // namespace lyx