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 "InsetCollapsable.h"
19 class InsetBranchParams {
22 explicit InsetBranchParams(docstring const & b = docstring())
25 void write(std::ostream & os) const;
27 void read(Lexer & lex);
33 /////////////////////////////////////////////////////////////////////////
37 /////////////////////////////////////////////////////////////////////////
39 /// The Branch inset for alternative, conditional output.
41 class InsetBranch : public InsetCollapsable
45 InsetBranch(Buffer *, InsetBranchParams const &);
48 static std::string params2string(InsetBranchParams const &);
50 static void string2params(std::string const &, InsetBranchParams &);
52 docstring branch() const { return params_.branch; }
54 void rename(docstring const & newname) { params_.branch = newname; }
58 InsetCode lyxCode() const { return BRANCH_CODE; }
60 void write(std::ostream &) const;
62 void read(Lexer & lex);
64 docstring const buttonLabel(BufferView const & bv) const;
66 ColorCode backgroundColor(PainterInfo const &) const;
68 void latex(otexstream &, OutputParams const &) const;
70 int plaintext(odocstringstream & ods, OutputParams const & op,
71 size_t max_length = INT_MAX) const;
73 int docbook(odocstream &, OutputParams const &) const;
75 docstring xhtml(XHTMLStream &, OutputParams const &) const;
77 void toString(odocstream &) const;
79 void forOutliner(docstring &, size_t const, bool const) const;
81 void validate(LaTeXFeatures &) const;
83 std::string contextMenuName() const;
85 void addToToc(DocIterator const & di, bool output_active,
86 UpdateType utype) const;
88 InsetBranchParams const & params() const { return params_; }
90 void setParams(InsetBranchParams const & params) { params_ = params; }
92 /** \returns true if params_.branch is listed as 'selected' in
93 \c buffer. \p child only checks within child documents.
95 bool isBranchSelected(bool const child = false) const;
97 * Is the content of this inset part of the output document?
99 * Note that Branch insets are only considered part of the
100 * document when they are selected.
102 bool producesOutput() const { return isBranchSelected(); }
104 bool getStatus(Cursor &, FuncRequest const &, FuncStatus &) const;
106 bool isMacroScope() const;
108 docstring toolTip(BufferView const & bv, int x, int y) const;
110 bool usePlainLayout() const { return false; }
112 void doDispatch(Cursor & cur, FuncRequest & cmd);
114 docstring layoutName() const { return from_ascii("Branch:") + branch(); }
116 Inset * clone() const { return new InsetBranch(*this); }
119 friend class InsetBranchParams;
121 InsetBranchParams params_;