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.
20 #include "support/Length.h"
27 struct InsetSpaceParams {
28 /// The different kinds of spaces we support
30 /// Normal space ('\ ')
32 /// Protected (no break) space ('~')
34 /// Visible ("open box") space ('\textvisiblespace')
38 /// Medium space ('\:')
40 /// Thick space ('\;')
46 /// \enspace (0.5em unbreakable)
48 /// \enskip (0.5em breakable)
50 /// Negative thin space ('\negthinspace')
52 /// Negative medium space ('\negmedspace')
54 /// Negative thick space ('\negthickspace')
60 /// rubber length, filled with dots
62 /// rubber length, filled with a rule
64 /// rubber length, filled with a left arrow
66 /// rubber length, filled with a right arrow
68 // rubber length, filled with an up brace
70 // rubber length, filled with a down brace
78 explicit InsetSpaceParams(bool m = false) : kind(NORMAL), math(m) {}
80 void write(std::ostream & os) const;
82 void read(Lexer & lex);
88 * Whether these params are to be used in mathed.
89 * This determines the set of valid kinds.
95 /// Used to insert different kinds of spaces
96 class InsetSpace : public Inset
100 InsetSpace() : Inset(0) {}
102 explicit InsetSpace(InsetSpaceParams const & params);
104 InsetSpaceParams const & params() const { return params_; }
106 InsetSpaceParams::Kind kind() const;
109 static void string2params(std::string const &, InsetSpaceParams &);
111 static std::string params2string(InsetSpaceParams const &);
113 GlueLength length() const;
116 docstring toolTip(BufferView const & bv, int x, int y) const override;
117 /// unprotected spaces allow line breaking after them
118 RowFlags rowFlags() const override;
120 void metrics(MetricsInfo &, Dimension &) const override;
122 void draw(PainterInfo & pi, int x, int y) const override;
124 void write(std::ostream &) const override;
125 /// Will not be used when lyxf3
126 void read(Lexer & lex) override;
128 void latex(otexstream &, OutputParams const &) const override;
130 int plaintext(odocstringstream & ods, OutputParams const & op,
131 size_t max_length = INT_MAX) const override;
133 void docbook(XMLStream &, OutputParams const &) const override;
135 docstring xhtml(XMLStream &, OutputParams const &) const override;
137 void validate(LaTeXFeatures & features) const override;
139 void toString(odocstream &) const override;
141 void forOutliner(docstring &, size_t const, bool const) const override;
143 bool hasSettings() const override { return true; }
145 bool clickable(BufferView const &, int, int) const override { return true; }
147 InsetCode lyxCode() const override { return SPACE_CODE; }
148 /// does this inset try to use all available space (like \\hfill does)?
149 bool isHfill() const override;
150 /// should this inset be handled like a normal character?
151 bool isChar() const override { return true; }
152 /// is this equivalent to a letter?
153 bool isLetter() const override { return false; }
154 /// is this equivalent to a space (which is BTW different from
155 // a line separator)?
156 bool isSpace() const override { return true; }
158 std::string contextMenuName() const override;
161 Inset * clone() const override { return new InsetSpace(*this); }
163 void doDispatch(Cursor & cur, FuncRequest & cmd) override;
166 bool getStatus(Cursor & cur, FuncRequest const & cmd, FuncStatus &) const override;
170 InsetSpaceParams params_;
176 #endif // INSET_SPACE_H