]> git.lyx.org Git - lyx.git/blob - src/insets/InsetBox.h
f9ab46c67deb1bedfceb4889053164e319ab5be3
[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         enum BoxType {
62                 Frameless,
63                 Boxed,
64                 Framed,
65                 ovalbox,
66                 Ovalbox,
67                 Shadowbox,
68                 Shaded,
69                 Doublebox
70         };
71         ///
72         InsetBox(Buffer const &, std::string const &);
73         ///
74         ~InsetBox();
75 private:
76         ///
77         friend class InsetBoxParams;
78         friend class InsetBoxMailer;
79         ///
80         docstring editMessage() const;
81         ///
82         InsetCode lyxCode() const { return BOX_CODE; }
83         ///
84         docstring name() const;
85         ///
86         void write(std::ostream &) const;
87         ///
88         void read(Lexer & lex);
89         ///
90         void setButtonLabel();
91         ///
92         void metrics(MetricsInfo &, Dimension &) const;
93         /// show the Box dialog
94         bool showInsetDialog(BufferView * bv) const;
95         ///
96         DisplayType display() const { return Inline; }
97         //FIXME Is this the one we want? or is it:
98         //allowParagraphCustomization(idx_type)?
99         ///
100         bool forceEmptyLayout() const;
101         ///
102         bool neverIndent() const { return true; }
103         ///
104         bool noFontChange() const { return true; }
105         ///
106         int latex(odocstream &, OutputParams const &) const;
107         ///
108         int plaintext(odocstream &, OutputParams const &) const;
109         ///
110         int docbook(odocstream &, OutputParams const &) const;
111         ///
112         void validate(LaTeXFeatures &) const;
113         ///
114         InsetBoxParams const & params() const { return params_; }
115         ///
116         bool getStatus(Cursor &, FuncRequest const &, FuncStatus &) const;
117         ///
118         void doDispatch(Cursor & cur, FuncRequest & cmd);
119         /// Is the width forced to some value?
120         bool hasFixedWidth() const;
121         ///
122         Inset * clone() const { return new InsetBox(*this); }
123         /// used by the constructors
124         void init();
125
126         ///
127         InsetBoxParams params_;
128 };
129
130
131 class InsetBoxMailer : public MailInset {
132 public:
133         ///
134         InsetBoxMailer(InsetBox & inset);
135         ///
136         virtual Inset & 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
154 } // namespace lyx
155
156 #endif // INSET_BOX_H