]> git.lyx.org Git - lyx.git/blob - src/insets/InsetSpace.h
This optional argument to the InsetCollapsable constructor
[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                 /// \quad (1em)
37                 QUAD,
38                 /// \qquad (2em)
39                 QQUAD,
40                 /// \enspace (0.5em unbreakable)
41                 ENSPACE,
42                 /// \enspace (0.5em breakable)
43                 ENSKIP,
44                 /// Negative thin space ('\negthinspace')
45                 NEGTHIN,
46                 /// rubber length
47                 HFILL,
48                 /// \hspace*{\fill}
49                 HFILL_PROTECTED,
50                 /// rubber length, filled with dots
51                 DOTFILL,
52                 /// rubber length, filled with a rule
53                 HRULEFILL,
54                 /// rubber length, filled with a left arrow
55                 LEFTARROWFILL,
56                 /// rubber length, filled with a right arrow
57                 RIGHTARROWFILL,
58                 // rubber length, filled with an up brace
59                 UPBRACEFILL,
60                 // rubber length, filled with a down brace
61                 DOWNBRACEFILL,
62                 /// \hspace{length}
63                 CUSTOM,
64                 /// \hspace*{length}
65                 CUSTOM_PROTECTED
66         };
67         ///
68         InsetSpaceParams() : kind(NORMAL), length(Length()) {}
69         ///
70         void write(std::ostream & os) const;
71         ///
72         void read(Lexer & lex);
73         ///
74         Kind kind;
75         ///
76         Length length;
77 };
78
79
80 ///  Used to insert different kinds of spaces
81 class InsetSpace : public Inset
82 {
83 public:
84         ///
85         InsetSpace() {}
86         ///
87         explicit InsetSpace(InsetSpaceParams const & par);
88         ///
89         InsetSpaceParams params() const { return params_; }
90         ///
91         InsetSpaceParams::Kind kind() const;
92         ///
93         ~InsetSpace();
94
95         ///
96         static void string2params(std::string const &, InsetSpaceParams &);
97         ///
98         static std::string params2string(InsetSpaceParams const &);
99         ///
100         Length length() const;
101
102 private:
103         ///
104         docstring toolTip(BufferView const & bv, int x, int y) const;
105         ///
106         void metrics(MetricsInfo &, Dimension &) const;
107         ///
108         void draw(PainterInfo & pi, int x, int y) const;
109         ///
110         void write(std::ostream &) const;
111         /// Will not be used when lyxf3
112         void read(Lexer & lex);
113         ///
114         int latex(odocstream &, OutputParams const &) const;
115         ///
116         int plaintext(odocstream &, OutputParams const &) const;
117         ///
118         int docbook(odocstream &, OutputParams const &) const;
119         /// the string that is passed to the TOC
120         void textString(odocstream &) const;
121         ///
122         void edit(Cursor & cur, bool front,
123                 EntryDirection entry_from = ENTRY_DIRECTION_IGNORE);
124         ///
125         EDITABLE editable() const { return IS_EDITABLE; }
126         ///
127         InsetCode lyxCode() const { return SPACE_CODE; }
128         /// is this an expandible space (rubber length)?
129         bool isStretchableSpace() const;
130
131         // should this inset be handled like a normal charater
132         bool isChar() const { return true; }
133         /// is this equivalent to a letter?
134         bool isLetter() const { return false; }
135         /// is this equivalent to a space (which is BTW different from
136         // a line separator)?
137         bool isSpace() const { return true; }
138         ///
139         docstring contextMenu(BufferView const & bv, int x, int y) const;
140         ///
141         Inset * clone() const { return new InsetSpace(*this); }
142         ///
143         void doDispatch(Cursor & cur, FuncRequest & cmd);
144         ///
145         bool getStatus(Cursor & cur, FuncRequest const & cmd, FuncStatus &) const;
146
147         ///
148         InsetSpaceParams params_;
149 };
150
151
152 } // namespace lyx
153
154 #endif // INSET_SPACE_H