]> git.lyx.org Git - lyx.git/blob - src/insets/insetbox.h
unify API for insets export
[lyx.git] / src / insets / insetbox.h
1 // -*- C++ -*-
2 /**
3  * \file insetbox.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Angus Leeming
8  * \author Martin Vermeer
9  *
10  * Full author contact details are available in file CREDITS.
11  */
12
13 #ifndef INSETBOX_H
14 #define INSETBOX_H
15
16
17 #include "insetcollapsable.h"
18 #include "lyxlength.h"
19 #include "support/translator.h"
20
21
22 struct InsetBoxParams {
23         ///
24         InsetBoxParams(std::string const &);
25         ///
26         void write(std::ostream & os) const;
27         ///
28         void read(LyXLex & lex);
29         ///
30         std::string type;
31         /// Use a parbox (true) or minipage (false)
32         bool use_parbox;
33         /// Do we have an inner parbox or minipage to format paragraphs to
34         /// columnwidth?
35         bool inner_box;
36         ///
37         LyXLength width;
38         /// "special" widths, see usrguide.dvi ยง3.5
39         std::string special;
40         ///
41         char pos;
42         ///
43         char hor_pos;
44         ///
45         char inner_pos;
46         ///
47         LyXLength height;
48         ///
49         std::string height_special;
50 };
51
52
53 /** The fbox/fancybox inset
54
55 */
56 class InsetBox : public InsetCollapsable {
57 public:
58         ///
59         InsetBox(BufferParams const &, std::string const &);
60         /// Copy constructor
61         InsetBox(InsetBox const &);
62         ///
63         ~InsetBox();
64         ///
65         virtual std::auto_ptr<InsetBase> clone() const;
66         ///
67         std::string const editMessage() const;
68         ///
69         InsetOld::Code lyxCode() const { return InsetOld::BOX_CODE; }
70         ///
71         void write(Buffer const &, std::ostream &) const;
72         ///
73         void read(Buffer const & buf, LyXLex & lex);
74         ///
75         void setButtonLabel();
76         ///
77         void metrics(MetricsInfo &, Dimension &) const;
78         /// show the Box dialog
79         bool showInsetDialog(BufferView * bv) const;
80         ///
81         int latex(Buffer const &, std::ostream &,
82                         LatexRunParams const &) const;
83         ///
84         int linuxdoc(Buffer const &, std::ostream &,
85                      LatexRunParams const &) const;
86         ///
87         int docbook(Buffer const &, std::ostream &,
88                     LatexRunParams const &) const;
89         ///
90         int ascii(Buffer const &, std::ostream &,
91                   LatexRunParams const & runparams) const;
92         ///
93         void validate(LaTeXFeatures &) const;
94         ///
95         InsetBoxParams const & params() const { return params_; }
96         ///
97         enum BoxType {
98                 Frameless,
99                 Boxed,
100                 ovalbox,
101                 Ovalbox,
102                 Shadowbox,
103                 Doublebox
104         };
105 protected:
106         ///
107         virtual
108         DispatchResult
109         priv_dispatch(FuncRequest const &, idx_type &, pos_type &);
110 private:
111         friend class InsetBoxParams;
112
113         /// used by the constructors
114         void init();
115         ///
116         InsetBoxParams params_;
117 };
118
119
120 namespace {
121
122 typedef Translator<std::string, InsetBox::BoxType> BoxTranslator;
123 BoxTranslator const & boxtranslator();
124 BoxTranslator const & boxtranslator_loc();
125
126 } // anon
127
128
129 #include "mailinset.h"
130
131 class InsetBoxMailer : public MailInset {
132 public:
133         ///
134         InsetBoxMailer(InsetBox & inset);
135         ///
136         virtual InsetBase & inset() const { return inset_; }
137         ///
138         virtual std::string const & name() const { return name_; }
139         ///
140         virtual std::string const inset2string(Buffer const &) const;
141         ///
142         static std::string const params2string(InsetBoxParams const &);
143         ///
144         static void string2params(std::string const &, InsetBoxParams &);
145
146 private:
147         ///
148         static std::string const name_;
149         ///
150         InsetBox & inset_;
151 };
152
153 #endif // INSET_BOX_H