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"
20 class InsetBranchParams {
23 explicit InsetBranchParams(docstring const & b = docstring())
26 void write(std::ostream & os) const;
28 void read(Lexer & lex);
34 /////////////////////////////////////////////////////////////////////////
38 /////////////////////////////////////////////////////////////////////////
40 /// The Branch inset for alternative, conditional output.
42 class InsetBranch : public InsetCollapsable
46 InsetBranch(Buffer const &, InsetBranchParams const &);
51 static std::string params2string(InsetBranchParams const &);
53 static void string2params(std::string const &, InsetBranchParams &);
57 docstring editMessage() const;
59 InsetCode lyxCode() const { return BRANCH_CODE; }
61 void write(std::ostream &) const;
63 void read(Lexer & lex);
65 void setButtonLabel();
67 ColorCode backgroundColor() const;
69 bool showInsetDialog(BufferView *) const;
71 int latex(odocstream &, OutputParams const &) const;
73 int plaintext(odocstream &, OutputParams const &) const;
75 int docbook(odocstream &, OutputParams const &) const;
77 void textString(odocstream &) const;
79 void validate(LaTeXFeatures &) const;
81 void addToToc(DocIterator const &);
83 InsetBranchParams const & params() const { return params_; }
85 void setParams(InsetBranchParams const & params) { params_ = params; }
87 virtual bool usePlainLayout() { return false; }
89 /** \returns true if params_.branch is listed as 'selected' in
90 \c buffer. This handles the case of child documents.
92 bool isBranchSelected() const;
94 * Is the content of this inset part of the output document?
96 * Note that Branch insets are only considered part of the
97 * document when they are selected.
99 bool producesOutput() const { return isBranchSelected(); }
101 bool getStatus(Cursor &, FuncRequest const &, FuncStatus &) const;
103 bool isMacroScope() const;
105 docstring toolTip(BufferView const & bv, int x, int y) const;
107 bool usePlainLayout() const { return false; }
109 void doDispatch(Cursor & cur, FuncRequest & cmd);
111 docstring name() const { return from_ascii("Branch"); }
113 Inset * clone() const { return new InsetBranch(*this); }
116 friend class InsetBranchParams;
118 InsetBranchParams params_;