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