X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Finsets%2FInsetBranch.h;h=391f2475f06765971a9d4d69afb324b5bef05943;hb=22e6659780390a19174d1bf896317a5baf9e40d7;hp=a214ef9e730281df0619c389c7adcb4f9898649c;hpb=db8c16d554ebb1dcb319e44d318572de6eff024b;p=lyx.git diff --git a/src/insets/InsetBranch.h b/src/insets/InsetBranch.h index a214ef9e73..391f2475f0 100644 --- a/src/insets/InsetBranch.h +++ b/src/insets/InsetBranch.h @@ -12,36 +12,54 @@ #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(BufferParams const &, InsetBranchParams const &); + InsetBranch(Buffer *, InsetBranchParams const &); + + /// + static std::string params2string(InsetBranchParams const &); + /// + static void string2params(std::string const &, InsetBranchParams &); /// - ~InsetBranch(); + docstring branch() const { return params_.branch; } /// - docstring editMessage() const; + void rename(docstring const & newname) { params_.branch = newname; } + /// + InsetBranchParams const & params() const { return params_; } + +private: /// InsetCode lyxCode() const { return BRANCH_CODE; } /// @@ -49,75 +67,61 @@ public: /// void read(Lexer & lex); /// - void setButtonLabel(); - /// - virtual ColorCode backgroundColor() const; + docstring const buttonLabel(BufferView const &) const; /// - bool showInsetDialog(BufferView *) const; + ColorCode backgroundColor(PainterInfo const &) const; /// - int latex(odocstream &, OutputParams const &) const; + void latex(otexstream &, OutputParams const &) const; /// - int plaintext(odocstream &, OutputParams const &) const; + int plaintext(odocstringstream & ods, OutputParams const & op, + size_t max_length = INT_MAX) const; /// int docbook(odocstream &, OutputParams const &) const; /// - void textString(odocstream &) const; + docstring xhtml(XHTMLStream &, OutputParams const &) const; + /// + void toString(odocstream &) const; + /// + void forOutliner(docstring &, size_t const, bool const) const; /// void validate(LaTeXFeatures &) const; /// - InsetBranchParams const & params() const { return params_; } + std::string contextMenuName() const; + /// + void updateBuffer(ParIterator const & it, UpdateType utype); /// 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. + \c buffer. \p child only checks within child documents. */ - bool isBranchSelected() const; + 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; /// bool getStatus(Cursor &, FuncRequest const &, FuncStatus &) const; /// - virtual void updateLabels(ParIterator const &); - /// bool isMacroScope() const; /// docstring toolTip(BufferView const & bv, int x, int y) const; -protected: /// - InsetBranch(InsetBranch const &); + bool usePlainLayout() const { return false; } /// - virtual void doDispatch(Cursor & cur, FuncRequest & cmd); + void doDispatch(Cursor & cur, FuncRequest & cmd); /// - docstring name() const { return from_ascii("Branch"); } -private: - friend class InsetBranchParams; - - virtual Inset * clone() const; - + docstring layoutName() const { return from_ascii("Branch:") + branch(); } /// - InsetBranchParams params_; -}; - + Inset * clone() const { return new InsetBranch(*this); } -class InsetBranchMailer : public MailInset { -public: - /// - InsetBranchMailer(InsetBranch & inset); - /// - virtual Inset & inset() const { return inset_; } /// - virtual std::string const & name() const { return name_; } - /// - virtual std::string const inset2string(Buffer const &) const; - /// - static std::string const params2string(InsetBranchParams const &); - /// - static void string2params(std::string const &, InsetBranchParams &); - -private: - /// - static std::string const name_; + friend class InsetBranchParams; /// - InsetBranch & inset_; + InsetBranchParams params_; }; } // namespace lyx