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 void edit(Cursor & cur, bool front,
110 EntryDirection entry_from = ENTRY_DIRECTION_IGNORE);
112 EDITABLE editable() const { return IS_EDITABLE; }
114 InsetCode lyxCode() const { return SPACE_CODE; }
115 /// is this an expandible space (rubber length)?
116 bool isStretchableSpace() const;
118 // should this inset be handled like a normal charater
119 bool isChar() const { return true; }
120 /// is this equivalent to a letter?
121 bool isLetter() const { return false; }
122 /// is this equivalent to a space (which is BTW different from
123 // a line separator)?
124 bool isSpace() const { return true; }
126 virtual docstring contextMenu(BufferView const & bv, int x, int y) const;
128 virtual Inset * clone() const { return new InsetSpace(*this); }
130 void doDispatch(Cursor & cur, FuncRequest & cmd);
132 bool getStatus(Cursor & cur, FuncRequest const & cmd, FuncStatus &) const;
135 InsetSpaceParams params_;
139 class InsetSpaceMailer : public MailInset {
142 InsetSpaceMailer(InsetSpace & inset);
144 virtual Inset & inset() const { return inset_; }
146 virtual std::string const & name() const { return name_; }
148 virtual std::string const inset2string(Buffer const &) const;
150 static void string2params(std::string const &, InsetSpaceParams &);
152 static std::string const params2string(InsetSpaceParams const &);
155 static std::string const name_;
163 #endif // INSET_SPACE_H