]> git.lyx.org Git - lyx.git/blob - src/insets/insetlatexaccent.h
3609675bdfe7c2e7a214811e1247b167a85692c3
[lyx.git] / src / insets / insetlatexaccent.h
1 // -*- C++ -*-
2 /**
3  * \file insetlatexaccent.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Lars Gullik Bjønnes
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 #ifndef INSET_LATEX_ACCENT_H
13 #define INSET_LATEX_ACCENT_H
14
15 #include "inset.h"
16
17 class Dimension;
18
19
20 /** Insertion of accents
21
22   Proper handling of accented characters.
23   This is class is supposed to handle all LaTeX accents, it
24   is also possible that the class will change a bit so that
25   it also can handle other special characters (e.g. Hstroke)
26   Initiated by Ivan Schreter, later modified by Lgb.
27   */
28 class InsetLatexAccent : public InsetOld {
29 public:
30         ///
31         InsetLatexAccent();
32         ///
33         explicit
34         InsetLatexAccent(std::string const & str);
35         ///
36         void metrics(MetricsInfo &, Dimension &) const;
37         ///
38         void draw(PainterInfo & pi, int x, int y) const;
39         ///
40         int lbearing(LyXFont const & font) const;
41         ///
42         int rbearing(LyXFont const & font) const;
43         ///
44         bool displayISO8859_9(PainterInfo & pi, int x, int y) const;
45         ///
46         void write(Buffer const &, std::ostream &) const;
47         ///
48         void read(Buffer const &, LyXLex & lex);
49         ///
50         int latex(Buffer const &, std::ostream &,
51                   LatexRunParams const &) const;
52         ///
53         int ascii(Buffer const &, std::ostream &,
54                   LatexRunParams const &) const;
55         ///
56         int linuxdoc(Buffer const &, std::ostream &,
57                      LatexRunParams const &) const;
58         ///
59         int docbook(Buffer const &, std::ostream &,
60                     LatexRunParams const &) const;
61         ///
62         bool directWrite() const;
63         ///
64         virtual std::auto_ptr<InsetBase> clone() const;
65         ///
66         InsetOld::Code lyxCode()const;
67         ///
68         inline bool canDisplay();
69         // should this inset be handled like a normal charater
70         bool isChar() const { return true; }
71
72         /// all the accent types
73         enum ACCENT_TYPES{
74                 ///
75                 ACUTE, // 0
76                 ///
77                 GRAVE,
78                 ///
79                 MACRON,
80                 ///
81                 TILDE,
82                 ///
83                 UNDERBAR,
84                 ///
85                 CEDILLA, // 5
86                 ///
87                 UNDERDOT,
88                 ///
89                 CIRCLE,
90                 ///
91                 TIE,
92                 ///
93                 BREVE,
94                 ///
95                 CARON, // 10
96                 ///
97                 SPECIAL_CARON,
98                 ///
99                 HUNGARIAN_UMLAUT,
100                 ///
101                 UMLAUT,
102                 ///
103                 DOT,
104                 ///
105                 CIRCUMFLEX, // 15
106                 ///
107                 OGONEK,
108                 ///
109                 DOT_LESS_I,
110                 ///
111                 DOT_LESS_J, // 18
112                 ///
113                 lSLASH,
114                 ///
115                 LSLASH
116         };
117 private:
118         friend std::ostream & operator<<(std::ostream &, ACCENT_TYPES);
119         /// Check if we know the modifier and can display it ok on screen.
120         void checkContents();
121         ///
122         void drawAccent(PainterInfo const & pi, int x, int y, char accent) const;
123         ///
124         std::string contents;
125         /// can display as proper char
126         bool  candisp;
127         /// modifier type
128         ACCENT_TYPES  modtype;
129
130         /// remove dot from 'i' and 'j' or transform l, L into lslash, LSLaSH
131         bool  remdot;
132         /// add something to ascent - accent at the top
133         bool  plusasc;
134         /// add something to descent - underlined char
135         bool  plusdesc;
136         /// international char
137         mutable char  ic;
138 };
139
140
141 bool InsetLatexAccent::canDisplay()
142 {
143         return candisp;
144 }
145
146 #endif