]> git.lyx.org Git - lyx.git/blob - src/insets/InsetBox.h
3ae2c6946e5a06aa892c0f43d697822d91013e2b
[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         InsetCode lyxCode() const { return BOX_CODE; }
68         ///
69         docstring name() const;
70         ///
71         void write(Buffer const &, std::ostream &) const;
72         ///
73         void read(Buffer const & buf, Lexer & 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         DisplayType display() const { return Inline; }
82         ///
83         bool forceDefaultParagraphs(idx_type) const;
84         ///
85         bool neverIndent(Buffer const &) const { return true; }
86         ///
87         bool noFontChange() const { return true; }
88         ///
89         bool isMacroScope(Buffer const & buf) const;
90         ///
91         int latex(Buffer const &, odocstream &, OutputParams const &) const;
92         ///
93         int plaintext(Buffer const &, odocstream &, OutputParams const &) const;
94         ///
95         int docbook(Buffer const &, odocstream &, OutputParams const &) const;
96         ///
97         void validate(LaTeXFeatures &) const;
98         ///
99         InsetBoxParams const & params() const { return params_; }
100         ///
101         bool getStatus(Cursor &, FuncRequest const &, FuncStatus &) const;
102         ///
103         enum BoxType {
104                 Frameless,
105                 Boxed,
106                 Framed,
107                 ovalbox,
108                 Ovalbox,
109                 Shadowbox,
110                 Shaded,
111                 Doublebox
112         };
113 protected:
114         InsetBox(InsetBox const &);
115         virtual void doDispatch(Cursor & cur, FuncRequest & cmd);
116         /// Is the width forced to some value?
117         virtual bool hasFixedWidth() const;
118 private:
119         friend class InsetBoxParams;
120
121         virtual Inset * clone() const;
122
123         /// used by the constructors
124         void init();
125         ///
126         InsetBoxParams params_;
127 };
128
129
130 class InsetBoxMailer : public MailInset {
131 public:
132         ///
133         InsetBoxMailer(InsetBox & inset);
134         ///
135         virtual Inset & inset() const { return inset_; }
136         ///
137         virtual std::string const & name() const { return name_; }
138         ///
139         virtual std::string const inset2string(Buffer const &) const;
140         ///
141         static std::string const params2string(InsetBoxParams const &);
142         ///
143         static void string2params(std::string const &, InsetBoxParams &);
144
145 private:
146         ///
147         static std::string const name_;
148         ///
149         InsetBox & inset_;
150 };
151
152
153 } // namespace lyx
154
155 #endif // INSET_BOX_H