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