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.
26 struct InsetSpaceParams {
27 /// The different kinds of spaces we support
29 /// Normal space ('\ ')
31 /// Protected (no break) space ('~')
33 /// Visible ("open box") space ('\textvisiblespace')
37 /// Medium space ('\:')
39 /// Thick space ('\;')
45 /// \enspace (0.5em unbreakable)
47 /// \enskip (0.5em breakable)
49 /// Negative thin space ('\negthinspace')
51 /// Negative medium space ('\negmedspace')
53 /// Negative thick space ('\negthickspace')
59 /// rubber length, filled with dots
61 /// rubber length, filled with a rule
63 /// rubber length, filled with a left arrow
65 /// rubber length, filled with a right arrow
67 // rubber length, filled with an up brace
69 // rubber length, filled with a down brace
77 explicit InsetSpaceParams(bool m = false) : kind(NORMAL), math(m) {}
79 void write(std::ostream & os) const;
81 void read(Lexer & lex);
87 * Whether these params are to be used in mathed.
88 * This determines the set of valid kinds.
94 /// Used to insert different kinds of spaces
95 class InsetSpace : public Inset
99 InsetSpace() : Inset(0) {}
101 explicit InsetSpace(InsetSpaceParams const & par);
103 InsetSpaceParams const & params() const { return params_; }
105 InsetSpaceParams::Kind kind() const;
108 static void string2params(std::string const &, InsetSpaceParams &);
110 static std::string params2string(InsetSpaceParams const &);
112 GlueLength length() const;
115 docstring toolTip(BufferView const & bv, int x, int y) const;
116 /// unprotected spaces allow line breaking after them
117 RowFlags rowFlags() const;
119 void metrics(MetricsInfo &, Dimension &) const;
121 void draw(PainterInfo & pi, int x, int y) const;
123 void write(std::ostream &) const;
124 /// Will not be used when lyxf3
125 void read(Lexer & lex);
127 void latex(otexstream &, OutputParams const &) const;
129 int plaintext(odocstringstream & ods, OutputParams const & op,
130 size_t max_length = INT_MAX) const;
132 void docbook(XMLStream &, OutputParams const &) const;
134 docstring xhtml(XMLStream &, OutputParams const &) const;
136 void validate(LaTeXFeatures & features) const;
138 void toString(odocstream &) const;
140 void forOutliner(docstring &, size_t const, bool const) const;
142 bool hasSettings() const { return true; }
144 bool clickable(BufferView const &, int, int) const { return true; }
146 InsetCode lyxCode() const { return SPACE_CODE; }
147 /// does this inset try to use all available space (like \\hfill does)?
148 bool isHfill() const;
149 /// should this inset be handled like a normal character?
150 bool isChar() const { return true; }
151 /// is this equivalent to a letter?
152 bool isLetter() const { return false; }
153 /// is this equivalent to a space (which is BTW different from
154 // a line separator)?
155 bool isSpace() const { return true; }
157 std::string contextMenuName() const;
160 Inset * clone() const { return new InsetSpace(*this); }
162 void doDispatch(Cursor & cur, FuncRequest & cmd);
165 bool getStatus(Cursor & cur, FuncRequest const & cmd, FuncStatus &) const;
169 InsetSpaceParams params_;
175 #endif // INSET_SPACE_H