]> git.lyx.org Git - lyx.git/blob - src/insets/insetlatexaccent.h
5fb848120c9a584a2bfa12c21db33e7f5b77518c
[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 #include "support/types.h"
17
18 class Dimension;
19
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 InsetOld {
30 public:
31         ///
32         InsetLatexAccent();
33         ///
34         explicit 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                   OutputParams const &) const;
52         ///
53         int plaintext(Buffer const &, std::ostream &,
54                   OutputParams const &) const;
55         ///
56         int linuxdoc(Buffer const &, std::ostream &,
57                      OutputParams const &) const;
58         ///
59         int docbook(Buffer const &, std::ostream &,
60                     OutputParams const &) const;
61         /// the string that is passed to the TOC
62         virtual int textString(Buffer const &, std::ostream & os,
63                 OutputParams const &) const;
64         ///
65         bool directWrite() const;
66         ///
67         InsetBase::Code lyxCode()const;
68         ///
69         inline bool canDisplay();
70         // should this inset be handled like a normal charater
71         bool isChar() const { return true; }
72
73         /// is this equivalent to a letter?
74         virtual bool isLetter() const { return candisp; }
75
76         /// all the accent types
77         enum ACCENT_TYPES{
78                 ///
79                 ACUTE, // 0
80                 ///
81                 GRAVE,
82                 ///
83                 MACRON,
84                 ///
85                 TILDE,
86                 ///
87                 UNDERBAR,
88                 ///
89                 CEDILLA, // 5
90                 ///
91                 UNDERDOT,
92                 ///
93                 CIRCLE,
94                 ///
95                 TIE,
96                 ///
97                 BREVE,
98                 ///
99                 CARON, // 10
100                 ///
101                 SPECIAL_CARON,
102                 ///
103                 HUNGARIAN_UMLAUT,
104                 ///
105                 UMLAUT,
106                 ///
107                 DOT,
108                 ///
109                 CIRCUMFLEX, // 15
110                 ///
111                 OGONEK,
112                 ///
113                 DOT_LESS_I,
114                 ///
115                 DOT_LESS_J, // 18
116                 ///
117                 lSLASH,
118                 ///
119                 LSLASH
120         };
121 private:
122         friend std::ostream & operator<<(std::ostream &, ACCENT_TYPES);
123
124         virtual std::auto_ptr<InsetBase> doClone() const;
125
126         /// Check if we know the modifier and can display it ok on screen.
127         void checkContents();
128         ///
129         void drawAccent(PainterInfo const & pi, int x, int y, lyx::char_type accent) const;
130         ///
131         std::string contents;
132         /// can display as proper char
133         bool  candisp;
134         /// modifier type
135         ACCENT_TYPES  modtype;
136
137         /// remove dot from 'i' and 'j' or transform l, L into lslash, LSLaSH
138         bool  remdot;
139         /// add something to ascent - accent at the top
140         bool  plusasc;
141         /// add something to descent - underlined char
142         bool  plusdesc;
143         /// international char
144         mutable char  ic;
145 };
146
147
148 bool InsetLatexAccent::canDisplay()
149 {
150         return candisp;
151 }
152
153 #endif