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 bool findUsesToString() const override { return true; }
85 void toString(odocstream &) const override;
87 void forOutliner(docstring &, size_t const, bool const) const override;
89 void validate(LaTeXFeatures &) const override;
91 std::string contextMenuName() const override;
93 void updateBuffer(ParIterator const & it, UpdateType utype, bool const deleted = false) override;
95 /** \returns true if params_.branch is listed as 'selected' in
96 \c buffer. \p child only checks within child documents.
98 bool isBranchSelected(bool const child = false) const;
100 * Is the content of this inset part of the output document?
102 * Note that Branch insets are considered part of the
103 * document when they are selected XOR inverted.
105 bool producesOutput() const override;
107 bool getStatus(Cursor &, FuncRequest const &, FuncStatus &) const override;
109 bool isMacroScope() const override;
111 docstring toolTip(BufferView const & bv, int x, int y) const override;
113 bool usePlainLayout() const override { return false; }
115 void doDispatch(Cursor & cur, FuncRequest & cmd) override;
117 docstring layoutName() const override;
119 Inset * clone() const override { return new InsetBranch(*this); }
122 friend class InsetBranchParams;
124 InsetBranchParams params_;