4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
7 * \author Martin Vermeer
9 * Full author contact details are available in file CREDITS.
15 #include "InsetCollapsible.h"
19 class InsetBranchParams {
22 explicit InsetBranchParams(docstring const & b = docstring())
23 : branch(b), inverted(false) {}
24 InsetBranchParams(docstring const & b, bool i)
25 : branch(b), inverted(i) {}
27 void write(std::ostream & os) const;
29 void read(Lexer & lex);
37 /////////////////////////////////////////////////////////////////////////
41 /////////////////////////////////////////////////////////////////////////
43 /// The Branch inset for alternative, conditional output.
45 class InsetBranch : public InsetCollapsible
49 InsetBranch(Buffer *, InsetBranchParams const &);
52 static std::string params2string(InsetBranchParams const &);
54 static void string2params(std::string const &, InsetBranchParams &);
56 docstring branch() const { return params_.branch; }
58 void rename(docstring const & newname) { params_.branch = newname; }
60 InsetBranchParams const & params() const { return params_; }
64 InsetCode lyxCode() const override { return BRANCH_CODE; }
66 void write(std::ostream &) const override;
68 void read(Lexer & lex) override;
70 docstring const buttonLabel(BufferView const &) const override;
72 ColorCode backgroundColor(PainterInfo const &) const override;
74 void latex(otexstream &, OutputParams const &) const override;
76 int plaintext(odocstringstream & ods, OutputParams const & op,
77 size_t max_length = INT_MAX) const override;
79 void docbook(XMLStream &, OutputParams const &) const override;
81 docstring xhtml(XMLStream &, OutputParams const &) const override;
83 void toString(odocstream &) const override;
85 void forOutliner(docstring &, size_t const, bool const) const override;
87 void validate(LaTeXFeatures &) const override;
89 std::string contextMenuName() const override;
91 void updateBuffer(ParIterator const & it, UpdateType utype, bool const deleted = false) override;
93 /** \returns true if params_.branch is listed as 'selected' in
94 \c buffer. \p child only checks within child documents.
96 bool isBranchSelected(bool const child = false) const;
98 * Is the content of this inset part of the output document?
100 * Note that Branch insets are considered part of the
101 * document when they are selected XOR inverted.
103 bool producesOutput() const override;
105 bool getStatus(Cursor &, FuncRequest const &, FuncStatus &) const override;
107 bool isMacroScope() const override;
109 docstring toolTip(BufferView const & bv, int x, int y) const override;
111 bool usePlainLayout() const override { return false; }
113 void doDispatch(Cursor & cur, FuncRequest & cmd) override;
115 docstring layoutName() const override { return from_ascii("Branch:") + branch(); }
117 Inset * clone() const override { return new InsetBranch(*this); }
120 friend class InsetBranchParams;
122 InsetBranchParams params_;