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 docstring const buttonLabel(BufferView const & bv) const;
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 int xhtml(odocstream &, OutputParams const &) const;
79 void tocString(odocstream &) const;
81 void validate(LaTeXFeatures &) const;
83 docstring contextMenu(BufferView const &, int, int) const;
85 void addToToc(DocIterator const &);
87 InsetBranchParams const & params() const { return params_; }
89 void setParams(InsetBranchParams const & params) { params_ = params; }
91 virtual bool usePlainLayout() { return false; }
93 /** \returns true if params_.branch is listed as 'selected' in
94 \c buffer. This handles the case of child documents.
96 bool isBranchSelected() const;
98 * Is the content of this inset part of the output document?
100 * Note that Branch insets are only considered part of the
101 * document when they are selected.
103 bool producesOutput() const { return isBranchSelected(); }
105 bool getStatus(Cursor &, FuncRequest const &, FuncStatus &) const;
107 bool isMacroScope() const;
109 docstring toolTip(BufferView const & bv, int x, int y) const;
111 bool usePlainLayout() const { return false; }
113 void doDispatch(Cursor & cur, FuncRequest & cmd);
115 docstring name() const { return from_ascii("Branch"); }
117 Inset * clone() const { return new InsetBranch(*this); }
120 friend class InsetBranchParams;
122 InsetBranchParams params_;