4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
7 * \author Asger Alstrup Nielsen
8 * \author Jean-Marc Lasgouttes
9 * \author Lars Gullik Bjønnes
10 * \author Jürgen Spitzmüller
12 * Full author contact details are available in file CREDITS.
21 #include "MailInset.h"
28 class InsetSpaceParams {
30 /// The different kinds of spaces we support
32 /// Normal space ('\ ')
34 /// Protected (no break) space ('~')
42 /// \enspace (0.5em unbreakable)
44 /// \enspace (0.5em breakable)
46 /// Negative thin space ('\negthinspace')
52 /// rubber length, filled with dots
54 /// rubber length, filled with a rule
62 InsetSpaceParams() : kind(NORMAL), length(Length()) {}
64 void write(std::ostream & os) const;
66 void read(Lexer & lex);
73 /// Used to insert different kinds of spaces
74 class InsetSpace : public Inset {
83 InsetSpace(InsetSpaceParams par);
85 InsetSpaceParams params() const { return params_; }
87 InsetSpaceParams::Kind kind() const;
89 Length length() const;
91 docstring toolTip(BufferView const & bv, int x, int y) const;
93 void metrics(MetricsInfo &, Dimension &) const;
95 void draw(PainterInfo & pi, int x, int y) const;
97 void write(std::ostream &) const;
98 /// Will not be used when lyxf3
99 void read(Lexer & lex);
101 int latex(odocstream &, OutputParams const &) const;
103 int plaintext(odocstream &, OutputParams const &) const;
105 int docbook(odocstream &, OutputParams const &) const;
106 /// the string that is passed to the TOC
107 void textString(odocstream &) const;
109 InsetCode lyxCode() const { return SPACE_CODE; }
110 /// is this an expandible space (rubber length)?
111 bool isStretchableSpace() const;
113 // should this inset be handled like a normal charater
114 bool isChar() const { return true; }
115 /// is this equivalent to a letter?
116 bool isLetter() const { return false; }
117 /// is this equivalent to a space (which is BTW different from
118 // a line separator)?
119 bool isSpace() const { return true; }
121 virtual Inset * clone() const { return new InsetSpace(*this); }
123 void doDispatch(Cursor & cur, FuncRequest & cmd);
126 InsetSpaceParams params_;
130 class InsetSpaceMailer : public MailInset {
133 InsetSpaceMailer(InsetSpace & inset);
135 virtual Inset & inset() const { return inset_; }
137 virtual std::string const & name() const { return name_; }
139 virtual std::string const inset2string(Buffer const &) const;
141 static void string2params(std::string const &, InsetSpaceParams &);
143 static std::string const params2string(InsetSpaceParams const &);
146 static std::string const name_;
154 #endif // INSET_SPACE_H