]> git.lyx.org Git - lyx.git/blobdiff - src/Painter.C
Improved support for docbook export in inset text.
[lyx.git] / src / Painter.C
index 8b0e3e679c7cc7002247c4d923da8f5e466665df..7726af8365595f21c12e09335825bd8eef640cde 100644 (file)
@@ -1,10 +1,9 @@
-// -*- C++ -*-
 /* This file is part of
  * ======================================================
  * 
  *           LyX, The Document Processor
  *      
- *         Copyright 1998-2000 The LyX Team
+ *         Copyright 1998-2001 The LyX Team
  *
  *======================================================*/
 
 
 #include <cmath>
 
-#include FORMS_H_LOCATION
 #include "Painter.h"
 #include "LString.h"
 #include "debug.h"
 #include "lyxfont.h"
+#include "frontends/GUIRunTime.h"
 #include "support/LAssert.h"
 #include "support/lstrings.h"
 #include "WorkArea.h"
@@ -32,6 +31,9 @@
 #include "ColorHandler.h"
 #include "lyxrc.h"
 #include "encoding.h"
+#include "language.h"
+
+#include "frontends/support/LyXImage.h"
 
 using std::endl;
 using std::max;
@@ -39,7 +41,7 @@ using std::max;
 Painter::Painter(WorkArea & wa)
        : PainterBase(wa)
 {
-       display = fl_display;
+       display = GUIRunTime::x11Display();
 }
 
 
@@ -53,7 +55,7 @@ PainterBase & Painter::point(int x, int y, LColor::color c)
                if (!Lgb_bug_find_hack)
                        lyxerr << "point not called from "
                                "workarea::workhandler\n";
-               lyxerr.debug() << "Painter drawable: "
+               lyxerr[Debug::INFO] << "Painter drawable: "
                               << owner.getPixmap() << endl;
        }
        
@@ -72,7 +74,7 @@ PainterBase & Painter::line(int x1, int y1, int x2, int y2,
                if (!Lgb_bug_find_hack)
                        lyxerr << "line not called from "
                                "workarea::workhandler\n";
-               lyxerr.debug() << "Painter drawable: "
+               lyxerr[Debug::INFO] << "Painter drawable: "
                               << owner.getPixmap() << endl;
        }
        
@@ -92,7 +94,7 @@ PainterBase & Painter::lines(int const * xp, int const * yp, int np,
                if (!Lgb_bug_find_hack)
                        lyxerr << "lines not called from "
                                "workarea::workhandler\n";
-               lyxerr.debug() << "Painter drawable: "
+               lyxerr[Debug::INFO] << "Painter drawable: "
                               << owner.getPixmap() << endl;
        }
        
@@ -235,7 +237,6 @@ PainterBase & Painter::segments(int const * x1, int const * y1,
        return *this;
 }
 
-
 PainterBase & Painter::pixmap(int x, int y, int w, int h, Pixmap bitmap)
 {
        if (lyxerr.debugging(Debug::GUI)) {
@@ -244,7 +245,7 @@ PainterBase & Painter::pixmap(int x, int y, int w, int h, Pixmap bitmap)
                                "workarea::workhandler\n";
                lyxerr << "Painter drawable: " << owner.getPixmap() << endl;
        }
-       
+
        XGCValues val;
        val.function = GXcopy;
        GC gc = XCreateGC(display, owner.getPixmap(),
@@ -255,10 +256,17 @@ PainterBase & Painter::pixmap(int x, int y, int w, int h, Pixmap bitmap)
        return *this;
 }
 
+PainterBase & Painter::image(int x, int y, int w, int h, LyXImage const * image)
+{
+       Pixmap bitmap = image->getPixmap();
+
+       return pixmap(x, y, w, h, bitmap);
+}
+
 
 PainterBase & Painter::text(int x, int y, string const & s, LyXFont const & f)
 {
-       return text(x, y, s.c_str(), s.length(), f);
+       return text(x, y, s.data(), s.length(), f);
 }
 
 
@@ -275,13 +283,11 @@ PainterBase & Painter::text(int x, int y, char const * s, size_t ls,
        if (lyxrc.font_norm_type == LyXRC::ISO_10646_1) {
                XChar2b * xs = new XChar2b[ls];
                Encoding const * encoding = f.language()->encoding();
-               LyXFont const * font = &f; 
-               if (f.family() == LyXFont::SYMBOL_FAMILY) {
+               LyXFont font(f);
+               if (f.isSymbolFont()) {
 #ifdef USE_UNICODE_FOR_SYMBOLS
-                       LyXFont font2 = f;
-                       font2.setFamily(LyXFont::ROMAN_FAMILY);
-                       font2.setShape(LyXFont::UP_SHAPE);
-                       font = &font2;
+                       font.setFamily(LyXFont::ROMAN_FAMILY);
+                       font.setShape(LyXFont::UP_SHAPE);
 #endif
                        encoding = encodings.symbol_encoding();
                }
@@ -290,7 +296,7 @@ PainterBase & Painter::text(int x, int y, char const * s, size_t ls,
                        xs[i].byte1 = c >> 8;
                        xs[i].byte2 = c & 0xff;
                }
-               text(x , y, xs, ls, *font);
+               text(x , y, xs, ls, font);
                delete[] xs;
                return *this;
        }
@@ -310,7 +316,7 @@ PainterBase & Painter::text(int x, int y, char const * s, size_t ls,
                smallfont.decSize().decSize().setShape(LyXFont::UP_SHAPE);
                char c;
                int tmpx = x;
-               for(size_t i = 0; i < ls; ++i) {
+               for (size_t i = 0; i < ls; ++i) {
                        c = s[i];
                        if (islower(static_cast<unsigned char>(c))) {
                                c = toupper(c);
@@ -326,8 +332,11 @@ PainterBase & Painter::text(int x, int y, char const * s, size_t ls,
                        }
                }
        }
-       if (f.underbar() == LyXFont::ON && f.latex() != LyXFont::ON)
+
+       if (f.underbar() == LyXFont::ON) {
                underline(f, x, y, lyxfont::width(s, ls, f));
+       }
+       
        return *this;
 }
 
@@ -348,9 +357,9 @@ PainterBase & Painter::text(int x, int y, XChar2b const * s, int ls,
        } else {
                LyXFont smallfont(f);
                smallfont.decSize().decSize().setShape(LyXFont::UP_SHAPE);
-               static XChar2b c = {0, 0};
+               static XChar2b c;
                int tmpx = x;
-               for(int i = 0; i < ls; ++i) {
+               for (int i = 0; i < ls; ++i) {
                        if (s[i].byte1 == 0 && islower(s[i].byte2)) {
                                c.byte2 = toupper(s[i].byte2);
                                lyxfont::XSetFont(display, gc, smallfont);
@@ -365,8 +374,11 @@ PainterBase & Painter::text(int x, int y, XChar2b const * s, int ls,
                        }
                }
        }
-       if (f.underbar() == LyXFont::ON && f.latex() != LyXFont::ON)
+       
+       if (f.underbar() == LyXFont::ON) {
                underline(f, x, y, lyxfont::width(s, ls, f));
+       }
+       
        return *this;
 }