]> git.lyx.org Git - lyx.git/blob - src/insets/insetlatexaccent.C
Added clean CutAndPaste handling with it's own class. Various updates for
[lyx.git] / src / insets / insetlatexaccent.C
1 /* This file is part of
2  * ====================================================== 
3  * 
4  *           LyX, The Document Processor
5  *       
6  *          Copyright 1995 Matthias Ettrich
7  *          Copyright 1995-2000 The LyX Team.
8  *
9  * ====================================================== */
10
11 #include <config.h>
12
13 #ifdef __GNUG__
14 #pragma implementation
15 #endif
16
17 #include "insetlatexaccent.h"
18 #include "debug.h"
19 #include "lyxrc.h"
20 #include "support/lstrings.h"
21 #include "Painter.h"
22 #include "font.h"
23
24 using std::ostream;
25 using std::endl;
26
27 /* LatexAccent. Proper handling of accented characters */
28 /* This part is done by Ivan Schreter, schreter@ccsun.tuke.sk */
29 /* Later modified by Lars G. Bjønnes, larsbj@lyx.org */
30
31 InsetLatexAccent::InsetLatexAccent()
32 {
33         candisp = false;
34 }
35
36
37 InsetLatexAccent::InsetLatexAccent(string const & string)
38         : contents(string)
39 {
40         checkContents();
41 }
42
43
44 void InsetLatexAccent::checkContents()
45         // check, if we know the modifier and can display it ok on screen
46 {
47         candisp = false;
48
49         if (contents.empty() || contents.length() < 2) return;
50
51         // REMOVE IN 0.13
52         // Dirty Hack for backward compability. remove in 0.13 (Lgb)
53         contents = frontStrip(strip(contents));
54         if (!contains(contents, "{") && !contains(contents, "}")) {
55                 if (contents.length() == 2) {
56                         string tmp;
57                         tmp += contents[0];
58                         tmp += contents[1];
59                         tmp += "{}";
60                         contents = tmp;
61                 } else if (contents.length() == 3) {
62                         string tmp;
63                         tmp += contents[0];
64                         tmp += contents[1];
65                         tmp += '{';
66                         tmp += contents[2];
67                         tmp += '}';
68                         contents = tmp;
69                 } else if (contents.length() == 4 && contents[2] == ' ') {
70                         string tmp;
71                         tmp += contents[0];
72                         tmp += contents[1];
73                         tmp += '{';
74                         tmp += contents[3];
75                         tmp += '}';
76                         contents = tmp;
77                 } else if  (contents.length() == 4 && contents[2] == '\\'
78                             && (contents[3] == 'i' || contents[3] == 'j')) {
79                         string tmp;
80                         tmp += contents[0];
81                         tmp += contents[1];
82                         tmp += '{';
83                         tmp += contents[2];
84                         tmp += contents[3];
85                         tmp += '}';
86                         contents = tmp;
87                 }
88         }
89         if (contents[0] != '\\') return; // demand that first char is a '\\'
90
91         lyxerr[Debug::KEY] << "Decode: " << contents << endl;
92
93         remdot = false; plusasc = false; plusdesc = false;
94
95         switch (contents[1]) { // second char should be one of these
96         case '\'':  // acute
97                 modtype = ACUTE;    // acute
98                 plusasc = true;    // at the top of character
99                 break;
100         case '`':   // grave
101                 modtype = GRAVE;    // grave
102                 plusasc = true;    // at the top
103                 break;
104         case '=':   // macron
105                 modtype = MACRON;    // macron
106                 plusasc = true;    // at the top
107                 break;
108         case '~':   // tilde
109                 modtype = TILDE;    // tilde
110                 plusasc = true;    // at the top
111                 break;
112         case 'b':   // underbar
113                 modtype = UNDERBAR;    // underbar
114                 plusdesc = true;   // at the bottom
115                 break;
116         case 'c':   // cedilla
117                 modtype = CEDILLA;    // cedilla
118                 plusdesc = true;   // at the bottom
119                 break;
120         case 'd':   // underdot
121                 modtype = UNDERDOT;    // underdot
122                 plusdesc = true;   // at the bottom
123                 break;
124         case 'r':   // circle
125                 modtype = CIRCLE;    // circle
126                 plusasc = true;    // at the top
127                 break;
128         case 't':   // tie
129                 modtype = TIE;    // tie
130                 plusasc = true;    // at the top
131                 break;
132         case 'u':   // breve
133                 modtype = BREVE;    // breve
134                 plusasc = true;    // at the top
135                 break;
136         case 'v':   // caron
137                 modtype = CARON;   // caron
138                 plusasc = true;    // at the top
139                 break;
140         case 'q':   // special caron
141                 modtype = SPECIAL_CARON;   // special caron
142                 plusasc = true;    // at the top
143                 break;
144         case 'H':   // hungarian umlaut
145                 modtype = HUNGARIAN_UMLAUT;   // hungarian umlaut
146                 plusasc = true;    // at the top
147                 break;
148         case '"':   // umlaut
149                 modtype = UMLAUT;   // umlaut
150                 plusasc = true;    // at the top
151                 break;
152         case '.':   // dot
153                 modtype = DOT;   // dot
154                 plusasc = true;    // at the top
155                 break;
156         case '^':   // circumflex
157                 modtype = CIRCUMFLEX;   // circumflex
158                 plusasc = true;    // at the top
159                 break;
160         case 'k':   // ogonek
161                 modtype = OGONEK;  // ogonek
162                 plusdesc = true;
163                 break;
164         case 'i': // dot-less-i
165                 modtype = DOT_LESS_I;  // dot-less-i
166                 plusasc = true; // at the top (not really needed)
167                 remdot = true;
168                 break;
169         case 'j': // dot-less-j
170                 modtype = DOT_LESS_J; // dot-less-j
171                 plusasc = true; // at the top (not really needed)
172                 remdot = true;
173                 break;
174         case 'l': // lslash
175                 modtype = lSLASH;
176                 plusasc = true; // at the top (not really needed)
177                 break;
178         case 'L': // lslash
179                 modtype = LSLASH;
180                 plusasc = true; // at the top (not really needed)
181                 break;
182         default:
183                 printf ("Default\n");
184                 // unknow accent (or something else)
185                 return;
186         }
187
188         // we demand that third char is a '{' (Lgb)
189         if (contents[2] != '{') return;
190
191         // special clause for \i{}, \j{} \l{} and \L{}
192         if ((modtype == DOT_LESS_I || modtype == DOT_LESS_J
193              || modtype == lSLASH || modtype == LSLASH)
194             && contents[3] == '}' ) {
195                 switch (modtype) {
196                 case DOT_LESS_I: ic = 'i'; break;
197                 case DOT_LESS_J: ic = 'j'; break;
198                 case lSLASH:     ic = 'l'; break;
199                 case LSLASH:     ic = 'L'; break;
200                 default:
201                         // if this happens something is really wrong
202                         lyxerr << "InsetLaTexAccent: weird error." << endl;
203                         break;
204                 }
205                 //ic = (modtype == DOT_LESS_J ? 'j' : 'i');
206                 lyxerr[Debug::KEY] << "Contents: [" << contents << "]"
207                                    << ", ic: " << ic 
208                                    << ", top: " << plusasc 
209                                    << ", bot: " << plusdesc 
210                                    << ", dot: " << remdot 
211                                    << ", mod: " << modtype << endl;
212                 // Special case for space
213         } else if (contents[3] == '}') {
214                 ic = ' ';
215         } else {
216                 int i = 3;
217                 
218                 // now get the char
219                 ic = contents[3]; // i will always be 3 here
220
221                 // ic should now be a alfa-char or '\\'
222                 if (ic == '\\') {
223                         ic = contents[++i]; // will only allow \<foo>{\i} and \<foo>{\j}
224                         if (ic == 'i' || ic == 'j')
225                                 remdot = true;
226                         else
227                                 return;
228                 } else if ( (ic == 'i'|| ic == 'j') && contents[4] == '}') {
229                         // Do a rewrite: \<foo>{i} --> \<foo>{\i}
230                         string temp = contents;
231                         temp.erase(3, string::npos);
232                         temp += '\\';
233                         temp += char(ic);
234                         for(string::size_type j = 4;
235                             j < contents.length(); ++j)
236                                 temp+= contents[j];
237                         contents= temp;
238                         ++i;
239                         remdot = true;
240                 }    
241
242                 // demand a '}' at the end
243                 if (contents[++i] != '}' && contents[++i]) return;
244                                            
245                 // fine, the char is properly decoded now (hopefully)
246                 lyxerr[Debug::KEY] << "Contents: [" << contents << "]"
247                                    << ", ic: " << ic
248                                    << ", top: " << plusasc 
249                                    << ", bot: " << plusdesc 
250                                    << ", dot: " << remdot
251                                    << ", mod: " << modtype << endl;
252         }
253         candisp = true;
254 }
255
256
257 int InsetLatexAccent::ascent(Painter &, LyXFont const & font) const
258 {
259         // This function is a bit too simplistix and is just a
260         // "try to make a fit for all accents" approach, to
261         // make it better we need to know what kind of accent is
262         // used and add to max based on that.
263         int max;
264         if (candisp) {
265                 if (ic == ' ')
266                         max = lyxfont::ascent('a', font);
267                 else
268                         max = lyxfont::ascent(ic, font);
269                 if (plusasc) 
270                         max += (lyxfont::maxAscent(font) + 3) / 3;
271         } else
272                 max = lyxfont::maxAscent(font) + 4;
273         return max;
274 }
275
276
277 int InsetLatexAccent::descent(Painter &, LyXFont const & font) const
278 {
279         int max;
280         if (candisp) {
281                 if (ic == ' ') 
282                         max = lyxfont::descent('a', font);
283                 else
284                         max = lyxfont::descent(ic, font);
285                 if (plusdesc)
286                         max += 3;
287         } else
288                 max = lyxfont::maxDescent(font) + 4;
289         return max;
290 }
291
292
293 int InsetLatexAccent::width(Painter &, LyXFont const & font) const
294 {
295         if (candisp)
296                 return lyxfont::width(ic, font);
297         else
298                 return lyxfont::width(contents, font) + 4;
299 }
300
301
302 int InsetLatexAccent::Lbearing(LyXFont const & font) const
303 {
304         return lyxfont::lbearing(ic, font);
305 }
306
307
308 int InsetLatexAccent::Rbearing(LyXFont const & font) const
309 {
310         return lyxfont::rbearing(ic, font);
311 }
312
313
314 bool InsetLatexAccent::DisplayISO8859_9(Painter & pain, LyXFont const & font,
315                                         int baseline, 
316                                         float & x) const
317 {
318         unsigned char tmpic = ic;
319         
320         switch (modtype) {
321         case CEDILLA:
322         {
323                 if (ic == 'c') tmpic = 0xe7;
324                 if (ic == 'C') tmpic = 0xc7;
325                 if (ic == 's') tmpic = 0xfe;
326                 if (ic == 'S') tmpic = 0xde;
327                 break;
328         }
329         case BREVE:
330         {       if (ic == 'g') tmpic = 0xf0;
331         if (ic == 'G') tmpic = 0xd0;
332         break;
333         }
334         case UMLAUT:
335         {
336                 if (ic == 'o') tmpic = 0xf6;
337                 if (ic == 'O') tmpic = 0xd6;
338                 if (ic == 'u') tmpic = 0xfc;
339                 if (ic == 'U') tmpic = 0xdc;
340                 break;
341         }
342         case DOT:        if (ic == 'I') tmpic = 0xdd; break;
343         case DOT_LESS_I: tmpic = 0xfd; break;
344         default:         return false;
345         }
346         if (tmpic != ic) {
347                 char ch = char(tmpic);
348                 pain.text(x, baseline, ch, font);
349                 x += width(pain, font);
350                 return true;
351         }
352         else
353                 return false;
354 }
355
356
357 void InsetLatexAccent::draw(Painter & pain, LyXFont const & font,
358                             int baseline, float & x) const
359 {
360         if (lyxrc.font_norm == "iso8859-9")
361                 if (DisplayISO8859_9(pain, font, baseline, x))  
362                         return;
363         
364         /* draw it! */ 
365         // All the manually drawn accents in this function could use an
366         // overhaul. Different ways of drawing (what metrics to use)
367         // should also be considered.
368         
369         if (candisp) {
370                 int asc = ascent(pain, font);
371                 int desc = descent(pain, font);
372                 int wid = width(pain, font);
373                 float x2 = x + (Rbearing(font) - Lbearing(font)) / 2.0;
374                 float hg;
375                 int y;
376                 if (plusasc) {
377                         // mark at the top
378                         hg = lyxfont::maxDescent(font);
379                         y = baseline - asc;
380
381                         if (font.shape() == LyXFont::ITALIC_SHAPE)
382                                 x2 += (4.0 * hg) / 5.0; // italic
383                 } else {
384                         // at the bottom
385                         hg = desc;
386                         y = baseline;
387                 }
388
389                 float hg35 = float(hg * 3.0) / 5.0;
390
391                 // display with proper accent mark
392                 // first the letter
393                 pain.text(int(x), baseline, ic, font);
394
395                 if (remdot) {
396                         int tmpvar = baseline - lyxfont::ascent('i', font);
397                         float tmpx = 0;
398                         if (font.shape() == LyXFont::ITALIC_SHAPE)
399                                 tmpx += (8.0 * hg) / 10.0; // italic
400                         lyxerr[Debug::KEY] << "Removing dot." << endl;
401                         // remove the dot first
402                         pain.fillRectangle(int(x + tmpx), tmpvar, wid,
403                                            lyxfont::ascent('i', font) -
404                                            lyxfont::ascent('x', font) - 1,
405                                            LColor::background);
406                         // the five lines below is a simple hack to
407                         // make the display of accent 'i' and 'j'
408                         // better. It makes the accent be written
409                         // closer to the top of the dot-less 'i' or 'j'.
410                         char tmpic = ic; // store the ic when we
411                         ic = 'x';        // calculates the ascent of
412                         asc = ascent(pain, font); // the dot-less version (here: 'x')
413                         ic = tmpic;      // set the orig ic back
414                         y = baseline - asc; // update to new y coord.
415                 }
416                 // now the rest - draw within (x, y, x+wid, y+hg)
417                 switch (modtype) {
418                 case ACUTE:     // acute 0xB4
419                 {
420 #if 0
421                         pain.line(int(x2), int(y + hg),
422                                   int(x2 + hg35), y + hg35);
423 #else
424                         pain.text(x2 - (lyxfont::rbearing(0xB4, font) - lyxfont::lbearing(0xB4, font)) / 2,
425                                   baseline - lyxfont::ascent(ic, font) - lyxfont::descent(0xB4, font) - (lyxfont::ascent(0xB4, font) + lyxfont::descent(0xB4, font)) / 2,
426                                   char(0xB4), font);
427 #endif
428                         break;
429                 }
430                 case GRAVE:     // grave 0x60
431                 {
432 #if 0
433                         pain.line(int(x2), int(y + hg),
434                                   int(x2 - hg35), y + hg35);
435 #else
436                         pain.text(x2 - (lyxfont::rbearing(0x60, font) - lyxfont::lbearing(0x60, font)) / 2,
437                                   baseline - lyxfont::ascent(ic, font) - lyxfont::descent(0x60, font) - (lyxfont::ascent(0x60, font) + lyxfont::descent(0x60, font)) / 2.0,
438                                   char(0x60), font);
439 #endif
440                         break;
441                 }
442                 case MACRON:     // macron
443                 {
444 #if 0
445                         pain.line(int(x2 - wid * 0.4),
446                                   int(y + hg),
447                                   int(x2 + wid * 0.4),
448                                   int(y + hg));
449 #else
450                         pain.text(x2 - (lyxfont::rbearing(0xAF, font) - lyxfont::lbearing(0xAF, font)) / 2,
451                                   baseline - lyxfont::ascent(ic, font) - lyxfont::descent(0xAF, font) - (lyxfont::ascent(0xAF, font) + lyxfont::descent(0xAF, font)),
452                                   char(0xAF), font);
453 #endif
454                         break;
455                 }
456                 case TILDE:     // tilde
457                 {
458 #if 0
459                         if (hg35 > 2.0) hg35 -= 1.0;
460                         x2 += (hg35 / 2.0);
461                         int xp[4], yp[4];
462                         
463                         xp[0] = int(x2 - 2.0 * hg35);
464                         yp[0] = int(y + hg);
465                         
466                         xp[1] = int(x2 - hg35);
467                         yp[1] = int(y + hg35);
468                         
469                         xp[2] = int(x2);
470                         yp[2] = int(y + hg);
471                         
472                         xp[3] = int(x2 + hg35);
473                         yp[3] = int(y + hg35);
474                         
475                         pain.lines(xp, yp, 4);
476 #else
477                         pain.text(x2 - (lyxfont::rbearing('~', font) - lyxfont::lbearing('~', font)) / 2,
478                                   baseline - lyxfont::ascent(ic, font) - lyxfont::descent('~', font) - (lyxfont::ascent('~', font) + lyxfont::descent('~', font)) / 2,
479                                   '~', font);
480 #endif
481                         break;
482                 }
483                 case UNDERBAR:     // underbar 0x5F
484                 {
485 #if 0
486                         pain.line(int(x2 - wid * 0.4),
487                                   y + hg / 2.0,
488                                   int(x2 + wid * 0.4),
489                                   y + hg / 2.0);
490 #else
491                         pain.text(x2 - (lyxfont::rbearing(0x5F, font) - lyxfont::lbearing(0x5F, font)) / 2, baseline,
492                                   char(0x5F), font);
493 #endif
494                         break;
495                 }
496                 case CEDILLA:     // cedilla
497                 {
498 #if 0
499                         int xp[4], yp[4];
500                         
501                         xp[0] = int(x2);
502                         yp[0] = y;
503                         
504                         xp[1] = int(x2);
505                         yp[1] = y + int(hg / 3.0);
506                         
507                         xp[2] = int(x2 + (hg / 3.0));
508                         yp[2] = y + int(hg / 2.0);
509                         
510                         xp[3] = int(x2 - (hg / 4.0));
511                         yp[3] = y + int(hg);
512
513                         pain.lines(xp, yp, 4);
514 #else
515                         pain.text(x2 - (lyxfont::rbearing(0xB8, font) - lyxfont::lbearing(0xB8, font)) / 2, baseline,
516                                   char(0xB8), font);
517                         
518 #endif
519                         break;
520                 }
521                 case UNDERDOT:     // underdot
522                 {
523 #if 0
524                         pain.arc(int(x2), y + hg35,
525                                      3, 3, 0, 360 * 64);
526 #else
527                         pain.text(x2 - (lyxfont::rbearing('.', font) - lyxfont::lbearing('.', font)) / 2.0,
528                                   baseline + 3.0 / 2.0 * (lyxfont::ascent('.', font) + lyxfont::descent('.', font)),
529                                   '.', font);
530 #endif
531                         break;
532                 }
533
534                 case DOT:    // dot
535                 {
536 #if 0
537                         pain.arc(int(x2), y + hg * 0.5,
538                                      (hg + 3.0)/5.0,
539                                      (hg + 3.0)/5.0,
540                                      0, 360 * 64);
541 #else
542                         pain.text(x2 - (lyxfont::rbearing('.', font) - lyxfont::lbearing('.', font)) / 2.0,
543                                   baseline - lyxfont::ascent(ic, font) - lyxfont::descent('.', font) - (lyxfont::ascent('.', font) + lyxfont::descent('.', font)) / 2,
544                                   '.', font);
545 #endif
546                         break;
547                 }
548
549                 case CIRCLE:     // circle
550                 {
551 #if 0
552                         pain.arc(int(x2 - (hg / 2.0)),
553                                  y + (hg / 2.0), hg, hg , 0,
554                                  360 * 64);
555 #else
556                         LyXFont tmpf(font);
557                         tmpf.decSize().decSize();
558                         pain.text(x2 - (lyxfont::rbearing(0xB0, tmpf) - lyxfont::lbearing(0xB0, tmpf)) / 2.0,
559                                   baseline - lyxfont::ascent(ic, font) - lyxfont::descent(0xB0, tmpf) - (lyxfont::ascent(0xB0, tmpf) + lyxfont::descent(0xB0, tmpf)) / 3.0,
560                                   char(0xB0), tmpf);
561 #endif
562                         break;
563                 }
564                 case TIE:     // tie
565                 {
566                         pain.arc(int(x2 + hg35), y + hg / 2.0,
567                                  2 * hg, hg, 0, 360 * 32);
568                         break;
569                 }
570                 case BREVE:     // breve
571                 {
572                         pain.arc(int(x2 - (hg / 2.0)), y,
573                                  hg, hg, 0, -360*32);
574                         break;
575                 }
576                 case CARON:    // caron
577                 {
578                         int xp[3], yp[3];
579                         
580                         xp[0] = int(x2 - hg35); yp[0] = int(y + hg35);
581                         xp[1] = int(x2);        yp[1] = int(y + hg);
582                         xp[2] = int(x2 + hg35); yp[2] = int(y + hg35);
583                         pain.lines(xp, yp, 3);
584                         break;
585                 }
586                 case SPECIAL_CARON:    // special caron
587                 {
588                         switch (ic) {
589                         case 'L': wid = int(4.0 * wid / 5.0); break;
590                         case 't': y -= int(hg35 / 2.0); break;
591                         }
592                         int xp[3], yp[3];
593                         xp[0] = int(x + wid);
594                         yp[0] = int(y + hg35 + hg);
595                         
596                         xp[1] = int(x + wid + (hg35 / 2.0));
597                         yp[1] = int(y + hg + (hg35 / 2.0));
598                         
599                         xp[2] = int(x + wid + (hg35 / 2.0));
600                         yp[2] = y + int(hg);
601
602                         pain.lines(xp, yp, 3);
603                         break;
604                 }
605                 case HUNGARIAN_UMLAUT:    // hung. umlaut
606                 {
607 #if 0
608                         int xs1[2], xs2[2], ys1[2], ys2[2];
609                         
610                         xs1[0] = int(x2 - (hg / 2.0));
611                         ys1[0] = int(y + hg);
612                         
613                         xs2[0] = int(x2 + hg35 - (hg / 2.0));
614                         ys2[0] = int(y + hg35);
615                         
616                         xs1[1] = int(x2 + (hg / 2.0));
617                         ys1[1] = int(y + hg);
618                         
619                         xs2[1] = int(x2 + hg35 + (hg / 2.0));
620                         ys2[1] = int(y + hg35);
621
622                         pain.segments(xs1, ys1, xs2, ys2, 2);
623 #else
624                         pain.text(x2 - (lyxfont::rbearing('´', font) - lyxfont::lbearing('´', font)),
625                                   baseline - lyxfont::ascent(ic, font) - lyxfont::descent('´', font) - (lyxfont::ascent('´', font) + lyxfont::descent('´', font)) / 2,
626                                   '´', font);
627                         pain.text(x2,
628                                   baseline - lyxfont::ascent(ic, font) - lyxfont::descent('´', font) - (lyxfont::ascent('´', font) + lyxfont::descent('´', font)) / 2,
629                                   '´', font);
630 #endif
631                         break;
632                 }
633                 case UMLAUT:    // umlaut
634                 {
635 #if 0
636                         float rad = hg / 2.0;
637                         if (rad <= 1.0) {
638                                 pain.point(int(x2 - 4.0 * hg / 7.0),
639                                            y + hg35);
640                                 pain.point(int(x2 + 4.0 * hg / 7.0),
641                                            y + hg35);
642                         } else {
643                                 rad += .5; // this ensures that f.ex. 1.5 will
644                                 // not be rounded down to .5 and then
645                                 // converted to int = 0
646                                 pain.arc(int(x2 - 2.0 * hg / 4.0),
647                                              y + hg35,
648                                              rad, rad,
649                                              0, 360 * 64);
650                                 pain.arc(int(x2 + 2.0 * hg / 4.0),
651                                             y + hg35,
652                                             rad, rad, 0, 360*64);
653                         }
654 #else
655                         pain.text(x2 - (lyxfont::rbearing('¨', font) - lyxfont::lbearing('¨', font)) / 2,
656                                   baseline - lyxfont::ascent(ic, font) - lyxfont::descent('¨', font) - ( lyxfont::ascent('¨', font) + lyxfont::descent('¨', font)) / 2,
657                                   '¨', font);
658 #endif
659                         break;
660                 }
661                 case CIRCUMFLEX:    // circumflex
662                 {
663 #if 0
664                         int xp[3], yp[3];
665                         
666                         xp[0] = int(x2 - hg35); yp[0] = y + int(hg);
667                         xp[1] = int(x2);        yp[1] = int(y + hg35);
668                         xp[2] = int(x2 + hg35); yp[2] = y + int(hg);
669                         pain.lines(xp, yp, 3);
670 #else
671                         LyXFont tmpf(font);
672                         tmpf.decSize().decSize().decSize();
673                         pain.text(x2 - (lyxfont::rbearing(0x5E, tmpf) - lyxfont::lbearing(0x5E, tmpf)) / 2,
674                                   baseline - lyxfont::ascent(ic, font) - lyxfont::descent(0x5E, tmpf) - (lyxfont::ascent(0x5E, tmpf) + lyxfont::descent(0x5E, tmpf)) / 3.0,
675                                   char(0x5E), tmpf);
676 #endif
677                         break;
678                 }
679                 case OGONEK:    // ogonek
680                 {
681                         // this does probably not look like an ogonek, so
682                         // it should certainly be refined
683                         int xp[4], yp[4];
684                         
685                         xp[0] = int(x2);
686                         yp[0] = y;
687                         
688                         xp[1] = int(x2);
689                         yp[1] = y + int(hg35);
690                         
691                         xp[2] = int(x2 - hg35);
692                         yp[2] = y + int(hg / 2.0);
693                         
694                         xp[3] = int(x2 + hg / 4.0);
695                         yp[3] = y + int(hg);
696
697                         pain.lines(xp, yp, 4);
698                         break;
699                 }
700                 case lSLASH:
701                 case LSLASH:
702                 {
703                         int xp[2], yp[2];
704                         
705                         xp[0] = int(x);
706                         yp[0] = y + int(3.0 * hg);
707                         
708                         xp[1] = int(x + float(wid) * 0.75);
709                         yp[1] = y + int(hg);
710                         
711                         pain.lines(xp, yp, 2);
712                         break;
713                 }
714                 case DOT_LESS_I: // dotless-i
715                 case DOT_LESS_J: // dotless-j
716                 {
717                         // nothing to do for these
718                         break;
719                 }
720                 }
721         } else {
722                 pain.fillRectangle(int(x + 1),
723                                    baseline - ascent(pain, font) + 1,
724                                    width(pain, font) - 2,
725                                    ascent(pain, font)
726                                    + descent(pain, font) - 2);
727                 pain.rectangle(int(x + 1), baseline - ascent(pain, font) + 1,
728                                width(pain, font) - 2,
729                                ascent(pain, font) + descent(pain, font) - 2);
730                 pain.text(int(x + 2), baseline, contents, font);
731         }
732         x +=  width(pain, font);
733 }
734
735
736 void InsetLatexAccent::Write(ostream & os) const
737 {
738         os << "\\i " << contents << "\n";
739 }
740
741
742 void InsetLatexAccent::Read(LyXLex & lex)
743 {
744         lex.EatLine();
745         contents = lex.GetString();
746         checkContents();
747 }
748
749
750 int InsetLatexAccent::Latex(ostream & os,
751                             signed char /*fragile*/, bool/*fs*/) const
752 {
753         os << contents;
754         return 0;
755 }
756
757
758 int InsetLatexAccent::Linuxdoc(ostream & os) const
759 {
760         os << contents;
761         return 0;
762 }
763
764
765 int InsetLatexAccent::DocBook(ostream & os) const
766 {
767         os << contents;
768         return 0;
769 }
770
771
772 bool InsetLatexAccent::Deletable() const
773 {
774         return true;
775 }
776
777
778 bool InsetLatexAccent::DirectWrite() const
779 {
780         return true;
781 }
782
783
784 Inset * InsetLatexAccent::Clone() const
785 {
786         return new InsetLatexAccent(contents);
787 }
788
789
790 Inset::Code InsetLatexAccent::LyxCode() const
791 {
792         return Inset::ACCENT_CODE;
793 }
794
795
796 ostream & operator<<(ostream & o, InsetLatexAccent::ACCENT_TYPES at)
797 {
798         return o << int(at);
799 }