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