]> git.lyx.org Git - lyx.git/blob - src/insets/InsetIPAMacro.h
Move Lexer to support/ directory (and lyx::support namespace)
[lyx.git] / src / insets / InsetIPAMacro.h
1 // -*- C++ -*-
2 /**
3  * \file InsetIPAMacro.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Jürgen Spitzmüller
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 #ifndef INSET_IPAMACRO_H
13 #define INSET_IPAMACRO_H
14
15
16 #include "Inset.h"
17 #include "InsetCollapsible.h"
18
19
20 namespace lyx {
21
22 class LaTeXFeatures;
23
24 class InsetIPADecoParams
25 {
26 public:
27         enum Type {
28                 Toptiebar,
29                 Bottomtiebar
30         };
31         ///
32         InsetIPADecoParams();
33         ///
34         void write(std::ostream & os) const;
35         ///
36         void read(support::Lexer & lex);
37         ///
38         Type type;
39 };
40
41 /////////////////////////////////////////////////////////////////////////
42 //
43 // InsetIPADeco
44 //
45 /////////////////////////////////////////////////////////////////////////
46
47 /// Used to insert IPA decorations
48 class InsetIPADeco : public InsetCollapsible
49 {
50 public:
51         ///
52         InsetIPADeco(Buffer *, std::string const &);
53         ///
54         ~InsetIPADeco();
55         ///
56         static std::string params2string(InsetIPADecoParams const &);
57         ///
58         static void string2params(std::string const &, InsetIPADecoParams &);
59         ///
60         InsetIPADecoParams const & params() const { return params_; }
61 private:
62         ///
63         InsetCode lyxCode() const override { return IPADECO_CODE; }
64         ///
65         docstring layoutName() const override;
66         ///
67         void metrics(MetricsInfo &, Dimension &) const override;
68         ///
69         void draw(PainterInfo & pi, int x, int y) const override;
70         ///
71         void write(std::ostream &) const override;
72         ///
73         void read(support::Lexer & lex) override;
74         ///
75         bool neverIndent() const override { return true; }
76         ///
77         void latex(otexstream &, OutputParams const &) const override;
78         ///
79         int plaintext(odocstringstream & ods, OutputParams const & op,
80                       size_t max_length = INT_MAX) const override;
81         ///
82         void docbook(XMLStream &, OutputParams const &) const override;
83         ///
84         docstring xhtml(XMLStream &, OutputParams const &) const override;
85         ///
86         bool getStatus(Cursor &, FuncRequest const &, FuncStatus &) const override;
87         ///
88         void doDispatch(Cursor & cur, FuncRequest & cmd) override;
89         ///
90         void validate(LaTeXFeatures & features) const override;
91         ///
92         bool allowSpellCheck() const override { return false; }
93         ///
94         bool insetAllowed(InsetCode code) const override;
95         ///
96         docstring toolTip(BufferView const & bv, int x, int y) const override;
97         ///
98         Inset * clone() const override { return new InsetIPADeco(*this); }
99         /// used by the constructors
100         void init();
101         ///
102         friend class InsetIPADecoParams;
103
104         ///
105         InsetIPADecoParams params_;
106 };
107
108
109 /////////////////////////////////////////////////////////////////////////
110 //
111 // InsetIPAChar
112 //
113 /////////////////////////////////////////////////////////////////////////
114
115 ///  Used to insert special IPA chars that are not available in unicode
116 class InsetIPAChar : public Inset {
117 public:
118
119         /// The different kinds of special chars we support
120         enum Kind {
121                 /// falling tone mark
122                 TONE_FALLING,
123                 /// rising tone mark
124                 TONE_RISING,
125                 /// high-rising tone mark
126                 TONE_HIGH_RISING,
127                 /// low-rising tone mark
128                 TONE_LOW_RISING,
129                 /// high rising-falling tone mark
130                 TONE_HIGH_RISING_FALLING
131         };
132
133         ///
134         InsetIPAChar() : Inset(0), kind_(TONE_FALLING) {}
135         ///
136         explicit InsetIPAChar(Kind k);
137         ///
138         Kind kind() const;
139         ///
140         void metrics(MetricsInfo &, Dimension &) const override;
141         ///
142         void draw(PainterInfo & pi, int x, int y) const override;
143         ///
144         void write(std::ostream &) const override;
145         /// Will not be used when lyxf3
146         void read(support::Lexer & lex) override;
147         ///
148         void latex(otexstream &, OutputParams const &) const override;
149         ///
150         int plaintext(odocstringstream & ods, OutputParams const & op,
151                       size_t max_length = INT_MAX) const override;
152         ///
153         void docbook(XMLStream &, OutputParams const &) const override;
154         ///
155         docstring xhtml(XMLStream &, OutputParams const &) const override;
156         ///
157         bool findUsesToString() const override { return true; }
158         ///
159         void toString(odocstream &) const override;
160         ///
161         void forOutliner(docstring &, size_t const, bool const) const override;
162         ///
163         InsetCode lyxCode() const override { return IPACHAR_CODE; }
164         /// We don't need \begin_inset and \end_inset
165         bool directWrite() const override { return true; }
166         ///
167         void validate(LaTeXFeatures &) const override;
168
169         /// should this inset be handled like a normal character?
170         bool isChar() const override { return true; }
171         /// is this equivalent to a letter?
172         bool isLetter() const override { return true; }
173 private:
174         Inset * clone() const override { return new InsetIPAChar(*this); }
175
176         /// And which kind is this?
177         Kind kind_;
178 };
179
180
181 } // namespace lyx
182
183 #endif