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