]> git.lyx.org Git - lyx.git/blob - src/insets/InsetBox.h
e8ea613efd06e505ed75e1a85c0f48141577c2c1
[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  * \author Uwe Stöhr
10  *
11  * Full author contact details are available in file CREDITS.
12  */
13
14 #ifndef INSETBOX_H
15 #define INSETBOX_H
16
17 #include "InsetCollapsable.h"
18 #include "Length.h"
19
20
21 namespace lyx {
22
23 class InsetBoxParams
24 {
25 public:
26         ///
27         InsetBoxParams(std::string const &);
28         ///
29         void write(std::ostream & os) const;
30         ///
31         void read(Lexer & lex);
32
33         ///
34         std::string type;
35         /// Is there a parbox?
36         bool use_parbox;
37         /// Is there a makebox?
38         bool use_makebox;
39         /// Do we have an inner parbox or minipage to format paragraphs to
40         /// columnwidth?
41         bool inner_box;
42         ///
43         Length width;
44         /// "special" widths, see usrguide.dvi §3.5
45         std::string special;
46         ///
47         char pos;
48         ///
49         char hor_pos;
50         ///
51         char inner_pos;
52         ///
53         Length height;
54         ///
55         std::string height_special;
56         ///
57         Length thickness;
58         ///
59         Length separation;
60         ///
61         Length shadowsize;
62 };
63
64
65
66 ///////////////////////////////////////////////////////////////////////
67 //
68 // The fbox/fancybox inset
69 //
70 ///////////////////////////////////////////////////////////////////////
71
72
73 class InsetBox : public InsetCollapsable
74 {
75 public:
76         ///
77         enum BoxType {
78                 Frameless,
79                 Boxed,
80                 Framed,
81                 ovalbox,
82                 Ovalbox,
83                 Shadowbox,
84                 Shaded,
85                 Doublebox
86         };
87         ///
88         InsetBox(Buffer *, std::string const &);
89
90         ///
91         static std::string params2string(InsetBoxParams const &);
92         ///
93         static void string2params(std::string const &, InsetBoxParams &);
94         ///
95         InsetBoxParams const & params() const { return params_; }
96
97         /// \name Public functions inherited from Inset class
98         //@{
99         ///
100         InsetCode lyxCode() const { return BOX_CODE; }
101         ///
102         docstring layoutName() const;
103         ///
104         void write(std::ostream &) const;
105         ///
106         void read(Lexer & lex);
107         ///
108         void metrics(MetricsInfo &, Dimension &) const;
109         ///
110         DisplayType display() const { return Inline; }
111         ///
112         ColorCode backgroundColor(PainterInfo const &) const;
113         ///
114         bool allowParagraphCustomization(idx_type = 0) const { return !forcePlainLayout(); }
115         ///
116         bool allowMultiPar() const;
117         ///
118         bool forcePlainLayout(idx_type = 0) const;
119         ///
120         bool neverIndent() const { return true; }
121         ///
122         bool inheritFont() const { return false; }
123         ///
124         void latex(otexstream &, OutputParams const &) const;
125         ///
126         int plaintext(odocstringstream & ods, OutputParams const & op,
127                       size_t max_length = INT_MAX) const;
128         ///
129         int docbook(odocstream &, OutputParams const &) const;
130         ///
131         docstring xhtml(XHTMLStream &, OutputParams const &) const;
132         ///
133         void validate(LaTeXFeatures &) const;
134         ///
135         bool hasFixedWidth() const;
136         ///
137         std::string contextMenuName() const;
138         //@}
139
140         /// \name Public functions inherited from InsetCollapsable class
141         //@{
142         ///
143         void setButtonLabel();
144         //@}
145
146 protected:
147         /// \name Protected functions inherited from Inset class
148         //@{
149         ///
150         bool getStatus(Cursor &, FuncRequest const &, FuncStatus &) const;
151         ///
152         void doDispatch(Cursor & cur, FuncRequest & cmd);
153         ///
154         Inset * clone() const { return new InsetBox(*this); }
155         //@}
156
157 private:
158         /// used by the constructors
159         void init();
160
161         ///
162         friend class InsetBoxParams;
163         InsetBoxParams params_;
164 };
165
166 } // namespace lyx
167
168 #endif // INSETBOX_H