]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/gtk/GPainter.C
Change glob() API to accept a dir parameter.
[lyx.git] / src / frontends / gtk / GPainter.C
index e57e388691f36f4a372f74d17bbfeb92f26f660f..7b87fc1cc4804b94ee84cf5bdf0c4b35a7463b18 100644 (file)
@@ -9,7 +9,11 @@
  */
 
 #include <config.h>
-#include <gtkmm.h>
+
+// Too hard to make concept checks work with this file
+#ifdef _GLIBCPP_CONCEPT_CHECKS
+#undef _GLIBCPP_CONCEPT_CHECKS
+#endif
 
 #include "GPainter.h"
 #include "debug.h"
 
 #include "support/lstrings.h"
 
-#include <boost/scoped_array.hpp>
+#include <gtkmm.h>
+#include <gdk/gdkx.h>
 
 #include <X11/Xft/Xft.h>
 
+#include <boost/scoped_array.hpp>
+
 #include <cmath>
 
 using std::string;
 
+namespace font_metrics {
+
+int width(wchar_t const * s, size_t n, LyXFont const & f);
+
+} // namespace font_metrics
+
+
+namespace lyx {
+namespace frontend {
 
 GPainter::GPainter(GWorkArea & xwa)
        : Painter(), owner_(xwa)
@@ -62,8 +78,7 @@ void GPainter::setForeground(Glib::RefPtr<Gdk::GC> gc, LColor_color clr)
 void GPainter::setLineParam(Glib::RefPtr<Gdk::GC> gc,
                            line_style ls, line_width lw)
 {
-       int width;
-       Gdk::LineStyle style;
+       int width = 0;
        switch (lw) {
        case Painter::line_thin:
                width = 0;
@@ -73,6 +88,7 @@ void GPainter::setLineParam(Glib::RefPtr<Gdk::GC> gc,
                break;
        }
 
+       Gdk::LineStyle style = Gdk::LINE_SOLID;
        switch (ls) {
        case Painter::line_solid:
                style = Gdk::LINE_SOLID;
@@ -86,15 +102,14 @@ void GPainter::setLineParam(Glib::RefPtr<Gdk::GC> gc,
 }
 
 
-Painter & GPainter::point(int x, int y, LColor_color c)
+void GPainter::point(int x, int y, LColor_color c)
 {
        setForeground(owner_.getGC(), c);
        owner_.getPixmap()->draw_point(owner_.getGC(), x, y);
-       return *this;
 }
 
 
-Painter & GPainter::line(int x1, int y1,
+void GPainter::line(int x1, int y1,
        int x2, int y2,
        LColor_color col,
        line_style ls,
@@ -103,12 +118,10 @@ Painter & GPainter::line(int x1, int y1,
        setForeground(owner_.getGC(), col);
        setLineParam(owner_.getGC(), ls, lw);
        owner_.getPixmap()->draw_line(owner_.getGC(), x1, y1, x2, y2);
-       return *this;
 }
 
 
-Painter & GPainter::lines(int const * xp, int const * yp,
-       int np,
+void GPainter::lines(int const * xp, int const * yp, int np,
        LColor_color col,
        line_style ls,
        line_width lw)
@@ -122,12 +135,10 @@ Painter & GPainter::lines(int const * xp, int const * yp,
                points[i].set_y(yp[i]);
        }
        owner_.getPixmap()->draw_lines(owner_.getGC(), points);
-       return *this;
 }
 
 
-Painter & GPainter::rectangle(int x, int y,
-       int w, int h,
+void GPainter::rectangle(int x, int y, int w, int h,
        LColor_color col,
        line_style ls,
        line_width lw)
@@ -135,21 +146,18 @@ Painter & GPainter::rectangle(int x, int y,
        setForeground(owner_.getGC(), col);
        setLineParam(owner_.getGC(), ls, lw);
        owner_.getPixmap()->draw_rectangle(owner_.getGC(), false, x, y, w, h);
-       return *this;
 }
 
 
-Painter & GPainter::fillRectangle(int x, int y,
-       int w, int h,
+void GPainter::fillRectangle(int x, int y, int w, int h,
        LColor_color col)
 {
        setForeground(owner_.getGC(), col);
        owner_.getPixmap()->draw_rectangle(owner_.getGC(), true, x, y, w, h);
-       return *this;
 }
 
 
-Painter & GPainter::fillPolygon(int const * xp, int const * yp,
+void GPainter::fillPolygon(int const * xp, int const * yp,
        int np, LColor_color col)
 {
        setForeground(owner_.getGC(), col);
@@ -160,50 +168,43 @@ Painter & GPainter::fillPolygon(int const * xp, int const * yp,
                points[i].set_y(yp[i]);
        }
        owner_.getPixmap()->draw_polygon(owner_.getGC(), true, points);
-       return *this;
 }
 
 
-Painter & GPainter::arc(int x, int y,
-       unsigned int w, unsigned int h,
+void GPainter::arc(int x, int y, unsigned int w, unsigned int h,
        int a1, int a2, LColor_color col)
 {
        setForeground(owner_.getGC(), col);
        owner_.getPixmap()->draw_arc(owner_.getGC(),
                                     false, x, y, w, h, a1, a2);
-       return *this;
 }
 
 
-Painter & GPainter::image(int x, int y,
-       int w, int h,
-       lyx::graphics::Image const & i)
+void GPainter::image(int x, int y, int w, int h,
+       graphics::Image const & i)
 {
-       lyx::graphics::xformsImage const & image =
-               static_cast<lyx::graphics::xformsImage const &>(i);
+       graphics::xformsImage const & image =
+               static_cast<graphics::xformsImage const &>(i);
        Pixmap pixmap = GDK_PIXMAP_XID(owner_.getPixmap()->gobj());
        GC gc = GDK_GC_XGC(owner_.getGC()->gobj());
        XCopyArea(owner_.getDisplay(), image.getPixmap(), pixmap,
                  gc, 0, 0, w, h, x, y);
-       return *this;
 }
 
 
-Painter & GPainter::text(int x, int y,
-       std::string const & s, LyXFont const & f)
+void GPainter::text(int x, int y, std::string const & s, LyXFont const & f)
 {
        size_t size = s.length() + 1;
-       wchar_t * wcs = (wchar_t *) alloca(size * sizeof(wchar_t));
-       size = mbstowcs(wcs, s.c_str(), size);
-       return text(x, y, wcs, size, f);
+       boost::scoped_array<wchar_t> wcs(new wchar_t[size]);
+       size = mbstowcs(wcs.get(), s.c_str(), size);
+       return text(x, y, wcs.get(), size, f);
 }
 
 
-Painter & GPainter::text(int x, int y,
-       char c, LyXFont const & f)
+void GPainter::text(int x, int y, char c, LyXFont const & f)
 {
        char s[2] = { c, '\0' };
-       return text(x, y, s, 1, f);
+       text(x, y, s, 1, f);
 }
 
 
@@ -214,16 +215,7 @@ inline XftFont * getXftFont(LyXFont const & f)
 }
 
 
-namespace font_metrics
-{
-
-int width(wchar_t const *s, size_t n, LyXFont const & f);
-
-}
-
-
-Painter & GPainter::text(int x, int y, wchar_t const * s, int ls,
-                      LyXFont const & f)
+void GPainter::text(int x, int y, wchar_t const * s, int ls, LyXFont const & f)
 {
        XftFont * font = getXftFont(f);
        XftColor * xftClr = owner_.getColorHandler().
@@ -239,9 +231,9 @@ Painter & GPainter::text(int x, int y, wchar_t const * s, int ls,
                XftFont * fontS = getXftFont(smallfont);
                wchar_t c;
                int tmpx = x;
-               for(int i = 0; i < ls; ++i) {
+               for (int i = 0; i < ls; ++i) {
                        c = lyx::support::uppercase(s[i]);
-                       if(c != s[i]) {
+                       if (c != s[i]) {
                                XftDrawString32(draw, xftClr, fontS, tmpx, y,
                                                wcsToXftChar32StrFast(&c), 1);
                                tmpx += font_metrics::width(c, smallfont);
@@ -254,13 +246,10 @@ Painter & GPainter::text(int x, int y, wchar_t const * s, int ls,
        }
        if (f.underbar() == LyXFont::ON)
                underline(f, x, y, font_metrics::width(s, ls, f));
-       return *this;
 }
 
 
-Painter & GPainter::text(int x, int y,
-       char const * s, size_t ls,
-       LyXFont const & f)
+void GPainter::text(int x, int y, char const * s, size_t ls, LyXFont const & f)
 {
        boost::scoped_array<wchar_t> wcs(new wchar_t[ls + 1]);
        size_t len;
@@ -271,5 +260,8 @@ Painter & GPainter::text(int x, int y,
                std::copy(us, us + ls, wcs.get());
        } else
                len = mbstowcs(wcs.get(), s, ls + 1);
-       return text(x, y, wcs.get(), len, f);
+       text(x, y, wcs.get(), len, f);
 }
+
+} // namespace frontend
+} // namespace lyx