]> git.lyx.org Git - lyx.git/blob - src/insets/InsetQuotes.h
fa9c26b0acaf5848c3cab5688b8938835880fdb9
[lyx.git] / src / insets / InsetQuotes.h
1 // -*- C++ -*-
2 /**
3  * \file InsetQuotes.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Jean-Marc Lasgouttes
8  *  \author Jürgen Spitzmüller
9  *
10  * Full author contact details are available in file CREDITS.
11  */
12
13 #ifndef INSET_QUOTES_H
14 #define INSET_QUOTES_H
15
16 #include "Inset.h"
17
18 #include "support/docstring.h"
19
20
21 namespace lyx {
22
23 /** Quotes.
24   Used for the various quotes. German, English, French, all either
25   double or single **/
26 class InsetQuotesParams {
27 public:
28         ///
29         enum QuoteStyle {
30                 ///
31                 EnglishQuotes,
32                 ///
33                 SwedishQuotes,
34                 ///
35                 GermanQuotes,
36                 ///
37                 PolishQuotes,
38                 ///
39                 SwissQuotes,
40                 ///
41                 DanishQuotes,
42                 ///
43                 PlainQuotes,
44                 ///
45                 BritishQuotes,
46                 ///
47                 SwedishGQuotes,
48                 ///
49                 FrenchQuotes,
50                 ///
51                 FrenchINQuotes,
52                 ///
53                 RussianQuotes,
54                 ///
55                 CJKQuotes,
56                 ///
57                 CJKAngleQuotes,
58                 ///
59                 DynamicQuotes
60         };
61         ///
62         enum QuoteSide {
63                 ///
64                 OpeningQuote,
65                 ///
66                 ClosingQuote
67         };
68         ///
69         enum QuoteLevel {
70                 ///
71                 SecondaryQuotes,
72                 ///
73                 PrimaryQuotes
74         };
75         /// Returns the unicode character of a given quote
76         char_type getQuoteChar(QuoteStyle const &, QuoteLevel const &,
77                                QuoteSide const &) const;
78         /// Returns a map of quotation marks
79         std::map<std::string, docstring> getTypes() const;
80         ///
81         docstring getLaTeXQuote(char_type c, std::string const &) const;
82         ///
83         docstring getHTMLQuote(char_type c) const;
84         /// Returns a label suitable for dialog and menu
85         docstring const getGuiLabel(QuoteStyle const & qs);
86         ///
87         int stylescount() const;
88 };
89
90 ///
91 extern InsetQuotesParams quoteparams;
92
93 /** Quotes.
94   Used for the various quotes. German, English, French, all either
95   double or single **/
96 class InsetQuotes : public Inset
97 {
98 public:
99         /** The constructor works like this:
100           \begin{itemize}
101             \item fls <- french single quote left
102             \item grd <- german double quote right
103             \item etc.
104           \end{itemize}
105           */
106         explicit InsetQuotes(Buffer * buf, std::string const & str = "eld");
107         /// Direct access to inner/outer quotation marks
108         InsetQuotes(Buffer * buf, char_type c, InsetQuotesParams::QuoteLevel level,
109                     std::string const & side = std::string(),
110                     std::string const & style = std::string());
111         ///
112         docstring layoutName() const;
113         ///
114         void metrics(MetricsInfo &, Dimension &) const;
115         ///
116         void draw(PainterInfo & pi, int x, int y) const;
117         ///
118         void write(std::ostream &) const;
119         ///
120         void read(Lexer & lex);
121         ///
122         bool getStatus(Cursor &, FuncRequest const &, FuncStatus &) const;
123         ///
124         void latex(otexstream &, OutputParams const &) const;
125         ///
126         int plaintext(odocstringstream & ods, OutputParams const & op,
127                       size_t max_length = INT_MAX) const;
128         ///
129         int docbook(odocstream &, OutputParams const &) const;
130         ///
131         docstring xhtml(XHTMLStream &, OutputParams const &) const;
132
133         /// 
134         void toString(odocstream &) const;
135         ///
136         void forOutliner(docstring &, size_t const maxlen, bool const) const;
137
138         /// Update the contextual information of this inset
139         void updateBuffer(ParIterator const &, UpdateType);
140
141         ///
142         void validate(LaTeXFeatures &) const;
143         ///
144         std::string contextMenuName() const;
145         ///
146         InsetCode lyxCode() const { return QUOTE_CODE; }
147         /// should this inset be handled like a normal character
148         bool isChar() const { return true; }
149
150         /// Returns the current quote type
151         std::string getType() const;
152
153 private:
154         ///
155         Inset * clone() const { return new InsetQuotes(*this); }
156
157         /// Decide whether we need left or right quotation marks
158         void setSide(char_type c);
159         ///
160         void parseString(std::string const &,
161                          bool const allow_wildcards = false);
162         ///
163         docstring displayString() const;
164         ///
165         docstring getQuoteEntity() const;
166         ///
167         InsetQuotesParams::QuoteStyle getStyle(std::string const &);
168
169         ///
170         InsetQuotesParams::QuoteStyle style_;
171         ///
172         InsetQuotesParams::QuoteSide side_;
173         ///
174         InsetQuotesParams::QuoteLevel level_;
175         ///
176         InsetQuotesParams::QuoteStyle global_style_;
177         ///
178         std::string fontenc_;
179         /// Code of the contextual language
180         std::string context_lang_;
181         /// Is this in a pass-thru context?
182         bool pass_thru_;
183         /// Do we use fontspec?
184         bool fontspec_;
185         ///
186         friend class InsetQuotesParams;
187
188 protected:
189         /// \name Protected functions inherited from Inset class
190         //@{
191         ///
192         void doDispatch(Cursor & cur, FuncRequest & cmd);
193         //@}
194 };
195
196 } // namespace lyx
197
198 #endif