]> git.lyx.org Git - lyx.git/blob - src/insets/insetbranch.h
Introduce wide streams. This fixes the remaining problems of plain text
[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         virtual lyx::docstring 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 docbook(Buffer const &, std::ostream &,
60                     OutputParams const & runparams) const;
61         ///
62         int plaintext(Buffer const &, lyx::odocstream &,
63                   OutputParams const & runparams) const;
64         ///
65         void validate(LaTeXFeatures &) const;
66         ///
67         InsetBranchParams const & params() const { return params_; }
68         ///
69         void setParams(InsetBranchParams const & params) { params_ = params; }
70
71         /** \returns true if params_.branch is listed as 'selected' in
72             \c buffer. This handles the case of child documents.
73          */
74         bool isBranchSelected(Buffer const & buffer) const;
75         ///
76         bool getStatus(LCursor &, FuncRequest const &, FuncStatus &) const;
77
78 protected:
79         InsetBranch(InsetBranch const &);
80         virtual void doDispatch(LCursor & cur, FuncRequest & cmd);
81 private:
82         friend class InsetBranchParams;
83
84         virtual std::auto_ptr<InsetBase> doClone() const;
85
86         /// used by the constructors
87         void init();
88         ///
89         InsetBranchParams params_;
90 };
91
92 #include "mailinset.h"
93
94 class InsetBranchMailer : public MailInset {
95 public:
96         ///
97         InsetBranchMailer(InsetBranch & inset);
98         ///
99         virtual InsetBase & inset() const { return inset_; }
100         ///
101         virtual std::string const & name() const { return name_; }
102         ///
103         virtual std::string const inset2string(Buffer const &) const;
104         ///
105         static std::string const params2string(InsetBranchParams const &);
106         ///
107         static void string2params(std::string const &, InsetBranchParams &);
108
109 private:
110         ///
111         static std::string const name_;
112         ///
113         InsetBranch & inset_;
114 };
115
116
117
118 #endif