]> git.lyx.org Git - features.git/blob - src/insets/InsetQuotes.h
Extend quote-insert
[features.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  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 #ifndef INSET_QUOTES_H
13 #define INSET_QUOTES_H
14
15 #include "Inset.h"
16
17 #include "support/docstring.h"
18
19
20 namespace lyx {
21
22 /** Quotes.
23   Used for the various quotes. German, English, French, all either
24   double or single **/
25 class InsetQuotes : public Inset
26 {
27 public:
28         ///
29         enum QuoteLanguage {
30                 ///
31                 EnglishQuotes,
32                 ///
33                 SwedishQuotes,
34                 ///
35                 GermanQuotes,
36                 ///
37                 PolishQuotes,
38                 ///
39                 FrenchQuotes,
40                 ///
41                 DanishQuotes
42         };
43         ///
44         enum QuoteSide {
45                 ///
46                 LeftQuote,
47                 ///
48                 RightQuote
49         };
50         ///
51         enum QuoteTimes {
52                 ///
53                 SingleQuotes,
54                 ///
55                 DoubleQuotes
56         };
57
58         /** The constructor works like this:
59           \begin{itemize}
60             \item fls <- french single quote left
61             \item grd <- german double quote right
62             \item etc.
63           \end{itemize}
64           */
65         explicit InsetQuotes(Buffer * buf, std::string const & str = "eld");
66         /// Direct access to inner/outer quotation marks
67         InsetQuotes(Buffer * buf, char_type c, QuoteTimes t,
68                     std::string const & s = std::string(),
69                     std::string const & l = std::string());
70         ///
71         docstring layoutName() const;
72         ///
73         void metrics(MetricsInfo &, Dimension &) const;
74         ///
75         void draw(PainterInfo & pi, int x, int y) const;
76         ///
77         void write(std::ostream &) const;
78         ///
79         void read(Lexer & lex);
80         ///
81         void latex(otexstream &, OutputParams const &) const;
82         ///
83         int plaintext(odocstringstream & ods, OutputParams const & op,
84                       size_t max_length = INT_MAX) const;
85         ///
86         int docbook(odocstream &, OutputParams const &) const;
87         ///
88         docstring xhtml(XHTMLStream &, OutputParams const &) const;
89
90         /// 
91         void toString(odocstream &) const;
92         ///
93         void forOutliner(docstring &, size_t const maxlen, bool const) const;
94
95         /// Update the contextual information of this inset
96         void updateBuffer(ParIterator const &, UpdateType);
97
98         ///
99         void validate(LaTeXFeatures &) const;
100         ///
101         InsetCode lyxCode() const { return QUOTE_CODE; }
102         /// should this inset be handled like a normal character
103         bool isChar() const { return true; }
104
105 private:
106         ///
107         Inset * clone() const { return new InsetQuotes(*this); }
108
109         /// Decide whether we need left or right quotation marks
110         void setSide(char_type c);
111         ///
112         void parseString(std::string const &);
113         ///
114         docstring displayString() const;
115         ///
116         docstring getQuoteEntity() const;
117         ///
118         QuoteLanguage getLanguage(std::string const &);
119
120         ///
121         QuoteLanguage language_;
122         ///
123         QuoteSide side_;
124         ///
125         QuoteTimes times_;
126         ///
127         std::string fontenc_;
128         /// Code of the contextual language
129         std::string context_lang_;
130         /// Is this in a pass-thru context?
131         bool pass_thru_;
132 };
133
134 } // namespace lyx
135
136 #endif