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