]> git.lyx.org Git - features.git/blob - src/insets/insetbranch.h
The 'Branches' mega-patch.
[features.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 #include "BranchList.h"
18
19  struct InsetBranchParams {
20         ///
21         void write(std::ostream & os) const;
22         ///
23         void read(LyXLex & lex);
24         ///
25         string branch;
26         /// Hack -- MV
27         BranchList branchlist;
28  };
29  
30  
31 /** The Branch inset for alternative, conditional output.
32
33 */
34 class InsetBranch : public InsetCollapsable {
35 public:
36         ///
37
38         
39         InsetBranch(BufferParams const &, string const &);
40         /// Copy constructor
41         InsetBranch(InsetBranch const &);
42         ///
43         ~InsetBranch();
44         ///
45         virtual std::auto_ptr<InsetBase> clone() const;
46         ///
47         string const editMessage() const;
48         ///
49         InsetOld::Code lyxCode() const { return InsetOld::BRANCH_CODE; }
50         ///
51         void write(Buffer const *, std::ostream &) const;
52         ///
53         void read(Buffer const * buf, LyXLex & lex);
54         ///
55         void setButtonLabel();
56         ///
57         void metrics(MetricsInfo & mi, Dimension & dim) const;
58         ///
59         void draw(PainterInfo & pi, int x, int y) const;
60         ///
61         bool showInsetDialog(BufferView *) const;
62         ///
63         dispatch_result localDispatch(FuncRequest const &);
64         ///
65         int latex(Buffer const *, std::ostream &,
66                         LatexRunParams const &) const;
67         ///
68         int linuxdoc(Buffer const *, std::ostream &) const;
69         ///
70         int docbook(Buffer const *, std::ostream &, bool) const;
71         ///
72         int ascii(Buffer const *, std::ostream &, int) const;
73         ///
74         void validate(LaTeXFeatures &) const;
75         ///
76         InsetBranchParams const & params() const { return params_; }
77         ///
78         void setParams(InsetBranchParams const & params) { params_ = params; }
79         
80 private:
81         friend class InsetBranchParams;
82
83         /// used by the constructors
84         void init();
85         ///
86         InsetBranchParams params_;
87 };
88
89 #include "mailinset.h"
90
91 class InsetBranchMailer : public MailInset {
92 public:
93         ///
94         InsetBranchMailer(string const & name, InsetBranch & inset);
95         ///
96         virtual InsetBase & inset() const { return inset_; }
97         ///
98         virtual string const & name() const { return name_; }
99         ///
100         virtual string const inset2string(Buffer const &) const;
101         ///
102         static string const params2string(string const &, InsetBranchParams const &);
103         ///
104         static void string2params(string const &, InsetBranchParams &);
105
106 private:
107         ///
108         string const name_;
109         ///
110         InsetBranch & inset_;
111 };
112
113
114
115 #endif