]> git.lyx.org Git - lyx.git/blob - src/insets/InsetSpace.h
Fix bug #6315: counters in insets that don't produce output have ghost values.
[lyx.git] / src / insets / InsetSpace.h
1 // -*- C++ -*-
2 /**
3  * \file InsetSpace.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Asger Alstrup Nielsen
8  * \author Jean-Marc Lasgouttes
9  * \author Lars Gullik Bjønnes
10  * \author Jürgen Spitzmüller
11  *
12  * Full author contact details are available in file CREDITS.
13  */
14
15 #ifndef INSET_SPACE_H
16 #define INSET_SPACE_H
17
18 #include "Inset.h"
19 #include "Length.h"
20
21
22 namespace lyx {
23
24 class LaTeXFeatures;
25
26 struct InsetSpaceParams {
27         /// The different kinds of spaces we support
28         enum Kind {
29                 /// Normal space ('\ ')
30                 NORMAL,
31                 /// Protected (no break) space ('~')
32                 PROTECTED,
33                 /// Thin space ('\,')
34                 THIN,
35                 /// Medium space ('\:')
36                 MEDIUM,
37                 /// Thick space ('\;')
38                 THICK,
39                 /// \quad (1em)
40                 QUAD,
41                 /// \qquad (2em)
42                 QQUAD,
43                 /// \enskip (0.5em unbreakable)
44                 ENSPACE,
45                 /// \enspace (0.5em breakable)
46                 ENSKIP,
47                 /// Negative thin space ('\negthinspace')
48                 NEGTHIN,
49                 /// Negative medium space ('\negmedspace')
50                 NEGMEDIUM,
51                 /// Negative thick space ('\negthickspace')
52                 NEGTHICK,
53                 /// rubber length
54                 HFILL,
55                 /// \hspace*{\fill}
56                 HFILL_PROTECTED,
57                 /// rubber length, filled with dots
58                 DOTFILL,
59                 /// rubber length, filled with a rule
60                 HRULEFILL,
61                 /// rubber length, filled with a left arrow
62                 LEFTARROWFILL,
63                 /// rubber length, filled with a right arrow
64                 RIGHTARROWFILL,
65                 // rubber length, filled with an up brace
66                 UPBRACEFILL,
67                 // rubber length, filled with a down brace
68                 DOWNBRACEFILL,
69                 /// \hspace{length}
70                 CUSTOM,
71                 /// \hspace*{length}
72                 CUSTOM_PROTECTED
73         };
74         ///
75         InsetSpaceParams(bool m = false) : kind(NORMAL), math(m) {}
76         ///
77         void write(std::ostream & os) const;
78         ///
79         void read(Lexer & lex);
80         ///
81         Kind kind;
82         ///
83         GlueLength length;
84         /**
85          * Whether these params are to be used in mathed.
86          * This determines the set of valid kinds.
87          */
88         bool math;
89 };
90
91
92 ///  Used to insert different kinds of spaces
93 class InsetSpace : public Inset
94 {
95 public:
96         ///
97         InsetSpace() : Inset(0) {}
98         ///
99         explicit InsetSpace(InsetSpaceParams const & par);
100         ///
101         InsetSpaceParams const & params() const { return params_; }
102         ///
103         InsetSpaceParams::Kind kind() const;
104
105         ///
106         static void string2params(std::string const &, InsetSpaceParams &);
107         ///
108         static std::string params2string(InsetSpaceParams const &);
109         ///
110         GlueLength length() const;
111
112         ///
113         docstring toolTip(BufferView const & bv, int x, int y) const;
114         ///
115         void metrics(MetricsInfo &, Dimension &) const;
116         ///
117         void draw(PainterInfo & pi, int x, int y) const;
118         ///
119         void write(std::ostream &) const;
120         /// Will not be used when lyxf3
121         void read(Lexer & lex);
122         ///
123         int latex(odocstream &, OutputParams const &) const;
124         ///
125         int plaintext(odocstream &, OutputParams const &) const;
126         ///
127         int docbook(odocstream &, OutputParams const &) const;
128         ///
129         docstring xhtml(XHTMLStream &, OutputParams const &) const;
130         ///
131         void validate(LaTeXFeatures & features) const;
132         /// the string that is passed to the TOC
133         void tocString(odocstream &) const;
134         ///
135         bool hasSettings() const { return true; }
136         ///
137         InsetCode lyxCode() const { return SPACE_CODE; }
138         /// is this an expandible space (rubber length)?
139         bool isStretchableSpace() const;
140
141         // should this inset be handled like a normal charater
142         bool isChar() const { return true; }
143         /// is this equivalent to a letter?
144         bool isLetter() const { return false; }
145         /// is this equivalent to a space (which is BTW different from
146         // a line separator)?
147         bool isSpace() const { return true; }
148         ///
149         docstring contextMenu(BufferView const & bv, int x, int y) const;
150         ///
151         bool clickable(int /* x */, int /* y */) const { return true; }
152 protected:
153         ///
154         Inset * clone() const { return new InsetSpace(*this); }
155         ///
156         void doDispatch(Cursor & cur, FuncRequest & cmd);
157 public:
158         ///
159         bool getStatus(Cursor & cur, FuncRequest const & cmd, FuncStatus &) const;
160
161 private:
162         ///
163         InsetSpaceParams params_;
164 };
165
166
167 } // namespace lyx
168
169 #endif // INSET_SPACE_H