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 /// \enskip (0.5em unbreakable)
47 /// \enspace (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;
117 void metrics(MetricsInfo &, Dimension &) const;
119 void draw(PainterInfo & pi, int x, int y) const;
121 void write(std::ostream &) const;
122 /// Will not be used when lyxf3
123 void read(Lexer & lex);
125 void latex(otexstream &, OutputParams const &) const;
127 int plaintext(odocstringstream & ods, OutputParams const & op,
128 size_t max_length = INT_MAX) const;
130 int docbook(odocstream &, OutputParams const &) const;
132 docstring xhtml(XHTMLStream &, OutputParams const &) const;
134 void validate(LaTeXFeatures & features) const;
136 void toString(odocstream &) const;
138 void forOutliner(docstring &, size_t const, bool const) const;
140 bool hasSettings() const { return true; }
142 bool clickable(BufferView const &, int, int) const { return true; }
144 InsetCode lyxCode() const { return SPACE_CODE; }
145 /// does this inset try to use all available space (like \\hfill does)?
146 bool isHfill() const;
147 /// should this inset be handled like a normal character?
148 bool isChar() const { return true; }
149 /// is this equivalent to a letter?
150 bool isLetter() const { return false; }
151 /// is this equivalent to a space (which is BTW different from
152 // a line separator)?
153 bool isSpace() const { return true; }
155 std::string contextMenuName() const;
158 Inset * clone() const { return new InsetSpace(*this); }
160 void doDispatch(Cursor & cur, FuncRequest & cmd);
163 bool getStatus(Cursor & cur, FuncRequest const & cmd, FuncStatus &) const;
167 InsetSpaceParams params_;
173 #endif // INSET_SPACE_H