]> git.lyx.org Git - lyx.git/blob - src/insets/insetbranch.h
The speed patch: redraw only rows that have changed
[lyx.git] / src / insets / insetbranch.h
1 // -*- C++ -*-
2 /**
3  * \file insetbranch.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Martin Vermeer
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 #ifndef INSETBRANCH_H
13 #define INSETBRANCH_H
14
15
16 #include "insetcollapsable.h"
17
18 class Buffer;
19
20
21 class InsetBranchParams {
22 public:
23         explicit InsetBranchParams(std::string const & b = std::string())
24                 : branch(b) {}
25         ///
26         void write(std::ostream & os) const;
27         ///
28         void read(LyXLex & lex);
29         ///
30         std::string branch;
31 };
32
33
34 /** The Branch inset for alternative, conditional output.
35
36 */
37 class InsetBranch : public InsetCollapsable {
38 public:
39         ///
40         InsetBranch(BufferParams const &, InsetBranchParams const &);
41         ///
42         ~InsetBranch();
43         ///
44         std::string const editMessage() const;
45         ///
46         InsetBase::Code lyxCode() const { return InsetBase::BRANCH_CODE; }
47         ///
48         void write(Buffer const &, std::ostream &) const;
49         ///
50         void read(Buffer const & buf, LyXLex & lex);
51         ///
52         void setButtonLabel();
53         ///
54         bool showInsetDialog(BufferView *) const;
55         ///
56         int latex(Buffer const &, std::ostream &,
57                         OutputParams const &) const;
58         ///
59         int linuxdoc(Buffer const &, std::ostream &,
60                      OutputParams const &) const;
61         ///
62         int docbook(Buffer const &, std::ostream &,
63                     OutputParams const & runparams) const;
64         ///
65         int plaintext(Buffer const &, std::ostream &,
66                   OutputParams const & runparams) const;
67         ///
68         void validate(LaTeXFeatures &) const;
69         ///
70         InsetBranchParams const & params() const { return params_; }
71         ///
72         void setParams(InsetBranchParams const & params) { params_ = params; }
73
74         /** \returns true if params_.branch is listed as 'selected' in
75             \c buffer. This handles the case of child documents.
76          */
77         bool isBranchSelected(Buffer const & buffer) const;
78         ///
79         bool getStatus(LCursor &, FuncRequest const &, FuncStatus &) const;
80
81 protected:
82         InsetBranch(InsetBranch const &);
83         virtual void doDispatch(LCursor & cur, FuncRequest & cmd);
84 private:
85         friend class InsetBranchParams;
86
87         virtual std::auto_ptr<InsetBase> doClone() const;
88
89         /// used by the constructors
90         void init();
91         ///
92         InsetBranchParams params_;
93 };
94
95 #include "mailinset.h"
96
97 class InsetBranchMailer : public MailInset {
98 public:
99         ///
100         InsetBranchMailer(InsetBranch & inset);
101         ///
102         virtual InsetBase & inset() const { return inset_; }
103         ///
104         virtual std::string const & name() const { return name_; }
105         ///
106         virtual std::string const inset2string(Buffer const &) const;
107         ///
108         static std::string const params2string(InsetBranchParams const &);
109         ///
110         static void string2params(std::string const &, InsetBranchParams &);
111
112 private:
113         ///
114         static std::string const name_;
115         ///
116         InsetBranch & inset_;
117 };
118
119
120
121 #endif