]> git.lyx.org Git - lyx.git/blob - src/insets/InsetBox.h
use bald pointers in clone()
[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 #include "InsetCollapsable.h"
17 #include "Length.h"
18 #include "MailInset.h"
19
20
21 namespace lyx {
22
23 class InsetBoxParams {
24 public:
25         ///
26         InsetBoxParams(std::string const &);
27         ///
28         void write(std::ostream & os) const;
29         ///
30         void read(Lexer & lex);
31         ///
32         std::string type;
33         /// Use a parbox (true) or minipage (false)
34         bool use_parbox;
35         /// Do we have an inner parbox or minipage to format paragraphs to
36         /// columnwidth?
37         bool inner_box;
38         ///
39         Length width;
40         /// "special" widths, see usrguide.dvi ยง3.5
41         std::string special;
42         ///
43         char pos;
44         ///
45         char hor_pos;
46         ///
47         char inner_pos;
48         ///
49         Length height;
50         ///
51         std::string height_special;
52 };
53
54
55 /** The fbox/fancybox inset
56
57 */
58 class InsetBox : public InsetCollapsable {
59 public:
60         ///
61         InsetBox(BufferParams const &, std::string const &);
62         ///
63         ~InsetBox();
64         ///
65         virtual docstring const editMessage() const;
66         ///
67         Inset::Code lyxCode() const { return Inset::BOX_CODE; }
68         ///
69         void write(Buffer const &, std::ostream &) const;
70         ///
71         void read(Buffer const & buf, Lexer & lex);
72         ///
73         void setButtonLabel();
74         ///
75         bool metrics(MetricsInfo &, Dimension &) const;
76         /// show the Box dialog
77         bool showInsetDialog(BufferView * bv) const;
78         ///
79         DisplayType display() const { return Inline; }
80         ///
81         bool forceDefaultParagraphs(idx_type) const;
82         ///
83         bool neverIndent(Buffer const &) const { return true; }
84         ///
85         bool noFontChange() const { return true; }
86         ///
87         int latex(Buffer const &, odocstream &, OutputParams const &) const;
88         ///
89         int plaintext(Buffer const &, odocstream &, OutputParams const &) const;
90         ///
91         int docbook(Buffer const &, odocstream &, OutputParams const &) const;
92         ///
93         void validate(LaTeXFeatures &) const;
94         ///
95         InsetBoxParams const & params() const { return params_; }
96         ///
97         bool getStatus(Cursor &, FuncRequest const &, FuncStatus &) const;
98         ///
99         enum BoxType {
100                 Frameless,
101                 Boxed,
102                 ovalbox,
103                 Ovalbox,
104                 Shadowbox,
105                 Doublebox
106         };
107 protected:
108         InsetBox(InsetBox const &);
109         virtual void doDispatch(Cursor & cur, FuncRequest & cmd);
110         /// Is the width forced to some value?
111         virtual bool hasFixedWidth() const;
112         ///
113         virtual docstring name() const { return from_ascii("Box"); }
114 private:
115         friend class InsetBoxParams;
116
117         virtual Inset * clone() const;
118
119         /// used by the constructors
120         void init();
121         ///
122         InsetBoxParams params_;
123 };
124
125
126 class InsetBoxMailer : public MailInset {
127 public:
128         ///
129         InsetBoxMailer(InsetBox & inset);
130         ///
131         virtual Inset & inset() const { return inset_; }
132         ///
133         virtual std::string const & name() const { return name_; }
134         ///
135         virtual std::string const inset2string(Buffer const &) const;
136         ///
137         static std::string const params2string(InsetBoxParams const &);
138         ///
139         static void string2params(std::string const &, InsetBoxParams &);
140
141 private:
142         ///
143         static std::string const name_;
144         ///
145         InsetBox & inset_;
146 };
147
148
149 } // namespace lyx
150
151 #endif // INSET_BOX_H