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')
50 /// rubber length, filled with dots
52 /// rubber length, filled with a rule
60 InsetSpaceParams() : kind(NORMAL), length(Length()) {}
62 void write(std::ostream & os) const;
64 void read(Lexer & lex);
71 /// Used to insert different kinds of spaces
72 class InsetSpace : public Inset {
81 InsetSpace(InsetSpaceParams par);
83 InsetSpaceParams params() const { return params_; }
85 InsetSpaceParams::Kind kind() const;
87 Length length() const;
89 docstring toolTip(BufferView const & bv, int x, int y) const;
91 void metrics(MetricsInfo &, Dimension &) const;
93 void draw(PainterInfo & pi, int x, int y) const;
95 void write(std::ostream &) const;
96 /// Will not be used when lyxf3
97 void read(Lexer & lex);
99 int latex(odocstream &, OutputParams const &) const;
101 int plaintext(odocstream &, OutputParams const &) const;
103 int docbook(odocstream &, OutputParams const &) const;
104 /// the string that is passed to the TOC
105 void textString(odocstream &) const;
107 InsetCode lyxCode() const { return SPACE_CODE; }
108 /// is this an expandible space (rubber length)?
109 bool isStretchableSpace() const;
111 // should this inset be handled like a normal charater
112 bool isChar() const { return true; }
113 /// is this equivalent to a letter?
114 bool isLetter() const { return false; }
115 /// is this equivalent to a space (which is BTW different from
116 // a line separator)?
117 bool isSpace() const { return true; }
119 virtual Inset * clone() const { return new InsetSpace(*this); }
121 void doDispatch(Cursor & cur, FuncRequest & cmd);
124 InsetSpaceParams params_;
128 class InsetSpaceMailer : public MailInset {
131 InsetSpaceMailer(InsetSpace & inset);
133 virtual Inset & inset() const { return inset_; }
135 virtual std::string const & name() const { return name_; }
137 virtual std::string const inset2string(Buffer const &) const;
139 static void string2params(std::string const &, InsetSpaceParams &);
141 static std::string const params2string(InsetSpaceParams const &);
144 static std::string const name_;
152 #endif // INSET_SPACE_H