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