]> git.lyx.org Git - lyx.git/blob - src/insets/insetlatexaccent.h
This commit is a big rework of the FontLoader/FontMetrics interaction. Only Qt4 for...
[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         bool displayISO8859_9(PainterInfo & pi, int x, int y) const;
41         ///
42         void write(Buffer const &, std::ostream &) const;
43         ///
44         void read(Buffer const &, LyXLex & lex);
45         ///
46         int latex(Buffer const &, std::ostream &,
47                   OutputParams const &) const;
48         ///
49         int plaintext(Buffer const &, std::ostream &,
50                   OutputParams const &) const;
51         ///
52         int docbook(Buffer const &, std::ostream &,
53                     OutputParams const &) const;
54         /// the string that is passed to the TOC
55         virtual int textString(Buffer const &, std::ostream & os,
56                 OutputParams const &) const;
57         ///
58         bool directWrite() const;
59         ///
60         InsetBase::Code lyxCode()const;
61         ///
62         inline bool canDisplay();
63         // should this inset be handled like a normal charater
64         bool isChar() const { return true; }
65
66         /// is this equivalent to a letter?
67         virtual bool isLetter() const { return candisp; }
68
69         /// all the accent types
70         enum ACCENT_TYPES{
71                 ///
72                 ACUTE, // 0
73                 ///
74                 GRAVE,
75                 ///
76                 MACRON,
77                 ///
78                 TILDE,
79                 ///
80                 UNDERBAR,
81                 ///
82                 CEDILLA, // 5
83                 ///
84                 UNDERDOT,
85                 ///
86                 CIRCLE,
87                 ///
88                 TIE,
89                 ///
90                 BREVE,
91                 ///
92                 CARON, // 10
93                 ///
94                 SPECIAL_CARON,
95                 ///
96                 HUNGARIAN_UMLAUT,
97                 ///
98                 UMLAUT,
99                 ///
100                 DOT,
101                 ///
102                 CIRCUMFLEX, // 15
103                 ///
104                 OGONEK,
105                 ///
106                 DOT_LESS_I,
107                 ///
108                 DOT_LESS_J, // 18
109                 ///
110                 lSLASH,
111                 ///
112                 LSLASH
113         };
114 private:
115         friend std::ostream & operator<<(std::ostream &, ACCENT_TYPES);
116
117         virtual std::auto_ptr<InsetBase> doClone() const;
118
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, lyx::char_type 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