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