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