]> git.lyx.org Git - lyx.git/commitdiff
OK I'll try guii1 again ...
authorJohn Levon <levon@movementarian.org>
Thu, 23 May 2002 09:21:32 +0000 (09:21 +0000)
committerJohn Levon <levon@movementarian.org>
Thu, 23 May 2002 09:21:32 +0000 (09:21 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@4186 a592a061-630c-0410-9148-cb99ea01b6c8

56 files changed:
src/ChangeLog
src/ColorHandler.h
src/Makefile.am
src/Painter.C [deleted file]
src/Painter.h [deleted file]
src/PainterBase.C [deleted file]
src/PainterBase.h [deleted file]
src/WorkArea.h
src/frontends/ChangeLog
src/frontends/Makefile.am
src/frontends/Painter.C [new file with mode: 0644]
src/frontends/Painter.h [new file with mode: 0644]
src/frontends/xforms/ChangeLog
src/frontends/xforms/Makefile.am
src/frontends/xforms/XPainter.C [new file with mode: 0644]
src/frontends/xforms/XPainter.h [new file with mode: 0644]
src/insets/ChangeLog
src/insets/inset.C
src/insets/insetbutton.C
src/insets/insetcaption.C
src/insets/insetcollapsable.C
src/insets/insetcommand.C
src/insets/inseterror.C
src/insets/insetgraphics.C
src/insets/insetgraphicsParams.C
src/insets/insetlatexaccent.C
src/insets/insetquotes.C
src/insets/insetspecialchar.C
src/insets/insettabular.C
src/insets/insettext.C
src/mathed/ChangeLog
src/mathed/formula.C
src/mathed/formulabase.C
src/mathed/formulamacro.C
src/mathed/math_binaryopinset.C
src/mathed/math_casesinset.C
src/mathed/math_charinset.C
src/mathed/math_cursor.C
src/mathed/math_fracinset.C
src/mathed/math_funcinset.C
src/mathed/math_gridinset.C
src/mathed/math_hullinset.C
src/mathed/math_macro.C
src/mathed/math_macrotemplate.C
src/mathed/math_rootinset.C
src/mathed/math_spaceinset.C
src/mathed/math_sqrtinset.C
src/mathed/math_stringinset.C
src/mathed/math_support.C
src/mathed/math_unknowninset.C
src/mathed/math_xdata.C
src/mathed/math_xyarrowinset.C
src/screen.C
src/tabular.C
src/text.C
src/text2.C

index cbdbb7e7defdb9fd5132f50ca17b7716e81c2c8d..72ccf19648ae02c3dfd766991390aa3c9b10f6af 100644 (file)
@@ -1,3 +1,17 @@
+2002-05-23  John Levon  <moz@compsoc.man.ac.uk>
+
+       * src/Makefile.am:
+       * src/PainterBase.C:
+       * src/PainterBase.h:
+       * src/Painter.C:
+       * src/Painter.h:
+       * src/WorkArea.C:
+       * src/WorkArea.h:
+       * src/screen.C:
+       * src/tabular.C:
+       * src/text.C:
+       * src/text2.C: move Painter to frontends/
 2002-05-22  Lars Gullik Bjønnes  <larsbj@birdstep.com>
 
        * buffer.C: comment out some some code that depend upon lyx_format
index db2d913d0372ec39755e77a29f93a24a0f45e906..af85ad88b6a6ef1fa48e77ba5b7e9a686f6eff1f 100644 (file)
@@ -15,7 +15,7 @@
 #pragma interface
 #endif
 
-#include "PainterBase.h"
+#include "frontends/Painter.h"
 
 #include <boost/scoped_ptr.hpp>
 
index d5940914254f7a9291ea50cc83eb06ea63681f11..97f4f7efe68a506a28965dcfb89ba85fd15b3f26 100644 (file)
@@ -30,7 +30,9 @@ EXTRA_DIST = config.h.in stamp-h.in cheaders ext_l10n.h version.C.in \
        Variables.C \
        Variables.h \
        counters.C \
-       counters.h
+       counters.h \
+       tracer.C \
+       tracer.h
 
 INCLUDES = $(SIGC_CFLAGS) $(BOOST_INCLUDES) $(PSPELL_INCLUDES)
 
@@ -78,10 +80,6 @@ lyx_SOURCES = \
        LyXView.h \
        MenuBackend.C \
        MenuBackend.h \
-       Painter.C \
-       Painter.h \
-       PainterBase.C \
-       PainterBase.h \
        ParagraphParameters.C \
        ParagraphParameters.h \
        ParameterStruct.h \
@@ -211,8 +209,6 @@ lyx_SOURCES = \
        texrow.h \
        text.C \
        text2.C \
-       tracer.C \
-       tracer.h \
        trans.C \
        trans.h \
        trans_decl.h \
@@ -222,8 +218,6 @@ lyx_SOURCES = \
        undo.h \
        undo_funcs.C \
        undo_funcs.h \
-       undostack.C \
-       undostack.h \
        vc-backend.C \
        vc-backend.h \
        version.C \
diff --git a/src/Painter.C b/src/Painter.C
deleted file mode 100644 (file)
index be7215e..0000000
+++ /dev/null
@@ -1,303 +0,0 @@
-/* This file is part of
- * ======================================================
- *
- *           LyX, The Document Processor
- *
- *         Copyright 1998-2001 The LyX Team
- *
- *======================================================*/
-
-#include <config.h>
-
-#ifdef __GNUG__
-#pragma implementation
-#endif
-
-#include "Painter.h"
-#include "LString.h"
-#include "debug.h"
-#include "lyxfont.h"
-#include "WorkArea.h"
-#include "font.h"
-#include "ColorHandler.h"
-#include "lyxrc.h"
-#include "encoding.h"
-#include "language.h"
-
-#include "frontends/GUIRunTime.h"
-#include "graphics/GraphicsImage.h"
-
-#include "support/LAssert.h"
-#include "support/lstrings.h"
-
-#include <boost/scoped_array.hpp>
-
-#include <cmath>
-
-
-using std::endl;
-using std::max;
-
-namespace {
-
-inline
-Display * display()
-{
-       return GUIRunTime::x11Display();
-}
-
-}
-
-
-Painter::Painter(WorkArea & wa)
-       : PainterBase(wa)
-{}
-
-
-// Basic drawing routines
-
-PainterBase & Painter::point(int x, int y, LColor::color c)
-{
-       XDrawPoint(display(), owner.getPixmap(),
-                  lyxColorHandler->getGCForeground(c), x, y);
-       return *this;
-}
-
-
-PainterBase & Painter::line(int x1, int y1, int x2, int y2,
-                           LColor::color col,
-                           enum line_style ls,
-                           enum line_width lw)
-{
-       XDrawLine(display(), owner.getPixmap(),
-                 lyxColorHandler->getGCLinepars(ls, lw, col),
-                 x1, y1, x2, y2);
-       return *this;
-}
-
-
-PainterBase & Painter::lines(int const * xp, int const * yp, int np,
-                            LColor::color col,
-                            enum line_style ls,
-                            enum line_width lw)
-{
-       boost::scoped_array<XPoint> points(new XPoint[np]);
-
-       for (int i = 0; i < np; ++i) {
-               points[i].x = xp[i];
-               points[i].y = yp[i];
-       }
-
-       XDrawLines(display(), owner.getPixmap(),
-                  lyxColorHandler->getGCLinepars(ls, lw, col),
-                  points.get(), np, CoordModeOrigin);
-
-       return *this;
-}
-
-
-PainterBase & Painter::rectangle(int x, int y, int w, int h,
-                                LColor::color col,
-                                enum line_style ls,
-                                enum line_width lw)
-{
-       XDrawRectangle(display(), owner.getPixmap(),
-                      lyxColorHandler->getGCLinepars(ls, lw, col),
-                      x, y, w, h);
-       return *this;
-}
-
-
-PainterBase & Painter::fillRectangle(int x, int y, int w, int h,
-                                    LColor::color col)
-{
-       XFillRectangle(display(), owner.getPixmap(),
-                      lyxColorHandler->getGCForeground(col), x, y, w, h);
-       return *this;
-}
-
-
-PainterBase & Painter::fillPolygon(int const * xp, int const * yp, int np,
-                                  LColor::color col)
-{
-       boost::scoped_array<XPoint> points(new XPoint[np]);
-
-       for (int i = 0; i < np; ++i) {
-               points[i].x = xp[i];
-               points[i].y = yp[i];
-       }
-
-       XFillPolygon(display(), owner.getPixmap(),
-                    lyxColorHandler->getGCForeground(col), points.get(), np,
-                    Nonconvex, CoordModeOrigin);
-
-       return *this;
-}
-
-
-PainterBase & Painter::arc(int x, int y,
-                          unsigned int w, unsigned int h,
-                          int a1, int a2, LColor::color col)
-{
-       XDrawArc(display(), owner.getPixmap(),
-                lyxColorHandler->getGCForeground(col),
-                x, y, w, h, a1, a2);
-       return *this;
-}
-
-
-/// Draw lines from x1,y1 to x2,y2. They are arrays
-PainterBase & Painter::segments(int const * x1, int const * y1,
-                               int const * x2, int const * y2, int ns,
-                               LColor::color col,
-                               enum line_style ls, enum line_width lw)
-{
-       boost::scoped_array<XSegment> s(new XSegment[ns]);
-
-       for (int i = 0; i < ns; ++i) {
-               s[i].x1 = x1[i];
-               s[i].y1 = y1[i];
-               s[i].x2 = x2[i];
-               s[i].y2 = y2[i];
-       }
-       XDrawSegments(display(), owner.getPixmap(),
-                     lyxColorHandler->getGCLinepars(ls, lw, col),
-                     s.get(), ns);
-
-       return *this;
-}
-
-
-PainterBase & Painter::image(int x, int y, int w, int h,
-                            grfx::GImage const & image)
-{
-       XGCValues val;
-       val.function = GXcopy;
-       GC gc = XCreateGC(display(), owner.getPixmap(),
-                         GCFunction, &val);
-       XCopyArea(display(), image.getPixmap(), owner.getPixmap(), gc,
-                 0, 0, w, h, x, y);
-       XFreeGC(display(), gc);
-       return *this;
-}
-
-
-PainterBase & Painter::text(int x, int y, string const & s, LyXFont const & f)
-{
-       return text(x, y, s.data(), s.length(), f);
-}
-
-
-PainterBase & Painter::text(int x, int y, char c, LyXFont const & f)
-{
-       char s[2] = { c, '\0' };
-       return text(x, y, s, 1, f);
-}
-
-
-PainterBase & Painter::text(int x, int y, char const * s, size_t ls,
-                           LyXFont const & f)
-{
-       if (lyxrc.font_norm_type == LyXRC::ISO_10646_1) {
-               boost::scoped_array<XChar2b> xs(new XChar2b[ls]);
-               Encoding const * encoding = f.language()->encoding();
-               LyXFont font(f);
-               if (f.isSymbolFont()) {
-#ifdef USE_UNICODE_FOR_SYMBOLS
-                       font.setFamily(LyXFont::ROMAN_FAMILY);
-                       font.setShape(LyXFont::UP_SHAPE);
-#endif
-                       encoding = encodings.symbol_encoding();
-               }
-               for (size_t i = 0; i < ls; ++i) {
-                       Uchar c = encoding->ucs(s[i]);
-                       xs[i].byte1 = c >> 8;
-                       xs[i].byte2 = c & 0xff;
-               }
-               text(x , y, xs.get(), ls, font);
-               return *this;
-       }
-
-       GC gc = lyxColorHandler->getGCForeground(f.realColor());
-       if (f.realShape() != LyXFont::SMALLCAPS_SHAPE) {
-               lyxfont::XSetFont(display(), gc, f);
-               XDrawString(display(), owner.getPixmap(), gc, x, y, s, ls);
-       } else {
-               LyXFont smallfont(f);
-               smallfont.decSize().decSize().setShape(LyXFont::UP_SHAPE);
-               int tmpx = x;
-               for (size_t i = 0; i < ls; ++i) {
-                       char const c = uppercase(s[i]);
-                       if (c != s[i]) {
-                               lyxfont::XSetFont(display(), gc, smallfont);
-                               XDrawString(display(), owner.getPixmap(), gc,
-                                           tmpx, y, &c, 1);
-                               tmpx += lyxfont::XTextWidth(smallfont, &c, 1);
-                       } else {
-                               lyxfont::XSetFont(display(), gc, f);
-                               XDrawString(display(), owner.getPixmap(), gc,
-                                           tmpx, y, &c, 1);
-                               tmpx += lyxfont::XTextWidth(f, &c, 1);
-                       }
-               }
-       }
-
-       if (f.underbar() == LyXFont::ON) {
-               underline(f, x, y, lyxfont::width(s, ls, f));
-       }
-
-       return *this;
-}
-
-
-PainterBase & Painter::text(int x, int y, XChar2b const * s, int ls,
-                           LyXFont const & f)
-{
-       GC gc = lyxColorHandler->getGCForeground(f.realColor());
-       if (f.realShape() != LyXFont::SMALLCAPS_SHAPE) {
-               lyxfont::XSetFont(display(), gc, f);
-               XDrawString16(display(), owner.getPixmap(), gc, x, y, s, ls);
-       } else {
-               LyXFont smallfont(f);
-               smallfont.decSize().decSize().setShape(LyXFont::UP_SHAPE);
-               static XChar2b c;
-               int tmpx = x;
-               for (int i = 0; i < ls; ++i) {
-                       if (s[i].byte1)
-                               c = s[i];
-                       else {
-                               c.byte1 = s[i].byte1;
-                               c.byte2 = uppercase(s[i].byte2);
-                       }
-                       if (c.byte2 != s[i].byte2) {
-                               lyxfont::XSetFont(display(), gc, smallfont);
-                               XDrawString16(display(), owner.getPixmap(), gc,
-                                             tmpx, y, &c, 1);
-                               tmpx += lyxfont::XTextWidth16(smallfont, &c, 1);
-                       } else {
-                               lyxfont::XSetFont(display(), gc, f);
-                               XDrawString16(display(), owner.getPixmap(), gc,
-                                             tmpx, y, &c, 1);
-                               tmpx += lyxfont::XTextWidth16(f, &c, 1);
-                       }
-               }
-       }
-
-       if (f.underbar() == LyXFont::ON) {
-               underline(f, x, y, lyxfont::width(s, ls, f));
-       }
-
-       return *this;
-}
-
-
-void Painter::underline(LyXFont const & f, int x, int y, int width)
-{
-       int const below = max(lyxfont::maxDescent(f) / 2, 2);
-       int const height = max((lyxfont::maxDescent(f) / 4) - 1, 1);
-       if (height < 2)
-               line(x, y + below, x + width, y + below, f.color());
-       else
-               fillRectangle(x, y + below, width, below + height,
-                             f.color());
-}
diff --git a/src/Painter.h b/src/Painter.h
deleted file mode 100644 (file)
index c5524fc..0000000
+++ /dev/null
@@ -1,101 +0,0 @@
-// -*- C++ -*-
-/* This file is part of
- * ======================================================
- *
- *           LyX, The Document Processor
- *
- *         Copyright 1995-2001 The LyX Team
- *
- * ======================================================*/
-
-#ifndef PAINTER_H
-#define PAINTER_H
-
-#ifdef __GNUG__
-#pragma interface
-#endif
-
-#include "LString.h"
-
-// This is only included to provide stuff for the non-public sections
-#include <X11/Xlib.h>
-
-#include "PainterBase.h"
-
-class LyXFont;
-class WorkArea;
-
-/** An inplementation for the X Window System. Xlib.
-    Classes similar to this one can be made for gtk+, Qt, etc.
-*/
-class Painter : public PainterBase {
-public:
-       /// Constructor
-       explicit Painter(WorkArea &);
-
-       /// Draw a line from point to point
-       PainterBase & line(int x1, int y1, int x2, int y2,
-                          LColor::color = LColor::foreground,
-                          enum line_style = line_solid,
-                          enum line_width = line_thin);
-
-       /// Here xp and yp are arrays of points
-       PainterBase & lines(int const * xp, int const * yp, int np,
-                           LColor::color = LColor::foreground,
-                           enum line_style = line_solid,
-                           enum line_width = line_thin);
-
-       /// Here xp and yp are arrays of points
-       PainterBase & fillPolygon(int const * xp, int const * yp, int np,
-                                 LColor::color = LColor::foreground);
-
-       /// Draw lines from x1,y1 to x2,y2. They are arrays
-       PainterBase & segments(int const * x1, int const * y1,
-                              int const * x2, int const * y2, int ns,
-                              LColor::color = LColor::foreground,
-                              enum line_style = line_solid,
-                              enum line_width = line_thin);
-
-       /// Draw a rectangle
-       PainterBase & rectangle(int x, int y, int w, int h,
-                               LColor::color = LColor::foreground,
-                               enum line_style = line_solid,
-                               enum line_width = line_thin);
-
-       /// Draw an arc
-       PainterBase & arc(int x, int y, unsigned int w, unsigned int h,
-                         int a1, int a2,
-                         LColor::color = LColor::foreground);
-
-       /// Draw a pixel
-       PainterBase & point(int x, int y, LColor::color = LColor::foreground);
-
-       /// Fill a rectangle
-       PainterBase & fillRectangle(int x, int y, int w, int h,
-                                   LColor::color);
-
-       /// For the graphics inset.
-       PainterBase & image(int x, int y, int w, int h,
-                           grfx::GImage const & image);
-
-       /// Draw a string at position x, y (y is the baseline)
-       PainterBase & text(int x, int y,
-                          string const & str, LyXFont const & f);
-
-       /** Draw a string at position x, y (y is the baseline)
-           This is just for fast drawing */
-       PainterBase & text(int x, int y, char const * str, size_t l,
-                          LyXFont const & f);
-
-       /// Draw a char at position x, y (y is the baseline)
-       PainterBase & text(int x, int y, char c, LyXFont const & f);
-
-       /// Draw a wide string at position x, y
-       PainterBase & text(int x, int y, XChar2b const * str, int l,
-                          LyXFont const & f);
-private:
-       /// Check the font, and if set, draw an underline
-       void underline(LyXFont const & f, int x, int y, int width);
-};
-
-#endif
diff --git a/src/PainterBase.C b/src/PainterBase.C
deleted file mode 100644 (file)
index 892815d..0000000
+++ /dev/null
@@ -1,121 +0,0 @@
-/* This file is part of
- * ======================================================
- *
- *           LyX, The Document Processor
- *
- *         Copyright 1998-2001 The LyX Team
- *
- *======================================================*/
-
-#include <config.h>
-
-#ifdef __GNUG__
-#pragma implementation
-#endif
-
-#include "PainterBase.h"
-#include "lyxfont.h"
-#include "WorkArea.h"
-#include "font.h"
-
-
-int PainterBase::paperMargin() const
-{
-       return 20;
-}
-
-
-int PainterBase::paperWidth() const
-{
-       return owner.workWidth();
-}
-
-
-int PainterBase::paperHeight() const
-{
-       return owner.height();
-}
-
-
-PainterBase & PainterBase::circle(int x, int y, unsigned int d,
-                                 LColor::color col)
-{
-       return ellipse(x, y, d, d, col);
-}
-
-
-PainterBase & PainterBase::ellipse(int x, int y,
-                                  unsigned int w, unsigned int h,
-                                  LColor::color col)
-{
-       return arc(x, y, w, h, 0, 0, col);
-}
-
-
-PainterBase & PainterBase::button(int x, int y, int w, int h)
-{
-       fillRectangle(x, y, w, h, LColor::buttonbg);
-       buttonFrame(x, y, w, h);
-       return * this;
-}
-
-
-PainterBase & PainterBase::buttonFrame(int x, int y, int w, int h)
-{
-       //  Width of a side of the button
-       int d = 2;
-
-       fillRectangle(x, y, w, d, LColor::top);
-       fillRectangle(x, (y+h-d), w, d, LColor::bottom);
-
-       // Now a couple of trapezoids
-       int x1[4], y1[4];
-
-       x1[0] = x + d;   y1[0] = y + d;
-       x1[1] = x + d;   y1[1] = (y + h - d);
-       x1[2] = x;     y1[2] = y + h;
-       x1[3] = x;     y1[3] = y;
-       fillPolygon(x1, y1, 4, LColor::left);
-
-       x1[0] = (x + w - d); y1[0] = y + d;
-       x1[1] = (x + w - d); y1[1] = (y + h - d);
-       x1[2] = x + w; y1[2] = (y + h - d);
-       x1[3] = x + w; y1[3] = y;
-       fillPolygon(x1, y1, 4, LColor::right);
-
-       return *this;
-}
-
-
-PainterBase & PainterBase::rectText(int x, int baseline,
-                                   string const & str,
-                                   LyXFont const & font,
-                                   LColor::color back,
-                                   LColor::color frame)
-{
-       int width;
-       int ascent;
-       int descent;
-
-       lyxfont::rectText(str, font, width, ascent, descent);
-       rectangle(x, baseline - ascent, width, ascent + descent, frame);
-       fillRectangle(x + 1, baseline - ascent + 1, width - 1,
-                     ascent + descent - 1, back);
-       text(x + 3, baseline, str, font);
-       return *this;
-}
-
-
-PainterBase & PainterBase::buttonText(int x, int baseline,
-                                     string const & str,
-                                     LyXFont const & font)
-{
-       int width;
-       int ascent;
-       int descent;
-
-       lyxfont::buttonText(str, font, width, ascent, descent);
-       button(x, baseline - ascent, width, descent + ascent);
-       text(x + 4, baseline, str, font);
-       return *this;
-}
diff --git a/src/PainterBase.h b/src/PainterBase.h
deleted file mode 100644 (file)
index e5a8676..0000000
+++ /dev/null
@@ -1,175 +0,0 @@
-// -*- C++ -*-
-/* This file is part of
- * ======================================================
- *
- *           LyX, The Document Processor
- *
- *         Copyright 1998-2001 The LyX Team
- *
- *======================================================*/
-
-#ifndef PAINTERBASE_H
-#define PAINTERBASE_H
-
-#ifdef __GNUG__
-#pragma interface
-#endif
-
-#include "LString.h"
-#include "LColor.h"
-
-class WorkArea;
-class LyXFont;
-namespace grfx {
-       class GImage;
-}
-
-/** A painter class to encapsulate all graphics parameters and operations
-
-    Every graphics operation in LyX should be made by this class. It will
-    be initialized and managed by the Screen class, and will be passed
-    as a parameter to inset.
-
-    It hides low level windows system parameters so insets and other
-    clients don't have to worry about them and we can control graphics and
-    GUI toolkit dependent drawing functions inside this single class.
-
- */
-class PainterBase {
-public:
-       ///
-       enum line_width {
-               ///
-               line_thin,
-               ///
-               line_thick
-       };
-
-       ///
-       enum line_style {
-               ///
-               line_solid,
-               ///
-               line_doubledash,
-               ///
-               line_onoffdash
-       };
-
-       ///
-       explicit PainterBase(WorkArea & wa) : owner(wa) {}
-
-       ///
-       virtual ~PainterBase() {}
-
-       /* Screen geometry */
-       ///
-       int paperMargin() const;
-       ///
-       int paperWidth() const;
-       ///
-       int paperHeight() const;
-
-       /// Draw a line from point to point
-       virtual PainterBase & line(
-               int x1, int y1, int x2, int y2,
-               LColor::color = LColor::foreground,
-               enum line_style = line_solid,
-               enum line_width = line_thin) = 0;
-
-       /** Draw the lines between the lines in xp and yp.
-           xp and yp are arrays of points, and np is the
-           number of them. */
-       virtual PainterBase & lines(
-               int const * xp, int const * yp, int np,
-               LColor::color = LColor::foreground,
-               enum line_style = line_solid,
-               enum line_width = line_thin) = 0;
-
-       /// Here xp and yp are arrays of points
-       virtual PainterBase & fillPolygon(
-               int const * xp, int const * yp,
-               int np,
-               LColor::color = LColor::foreground) = 0;
-
-       /// Draw lines from x1,y1 to x2,y2. They are arrays
-       virtual PainterBase & segments(
-               int const * x1, int const * y1,
-               int const * x2, int const * y2, int ns,
-               LColor::color = LColor::foreground,
-               enum line_style = line_solid,
-               enum line_width = line_thin) = 0;
-
-       /// Draw a rectangle
-       virtual PainterBase & rectangle(
-               int x, int y, int w, int h,
-               LColor::color = LColor::foreground,
-               enum line_style = line_solid,
-               enum line_width = line_thin) = 0;
-
-       /// Draw a circle, d is the diameter, not the radious
-       virtual PainterBase & circle(
-               int x, int y, unsigned int d,
-               LColor::color = LColor::foreground);
-
-       /// Draw an ellipse
-       virtual PainterBase & ellipse(
-               int x, int y,
-               unsigned int w, unsigned int h,
-               LColor::color = LColor::foreground);
-
-       /// Draw an arc
-       virtual PainterBase & arc(
-               int x, int y,
-               unsigned int w, unsigned int h,
-               int a1, int a2,
-               LColor::color = LColor::foreground) = 0;
-
-       /// Draw a pixel
-       virtual PainterBase & point(
-               int x, int y,
-               LColor::color = LColor::foreground) = 0;
-
-       /// Fill a rectangle
-       virtual PainterBase & fillRectangle(
-               int x, int y, int w, int h,
-               LColor::color) = 0;
-
-       /// A filled rectangle with the shape of a 3D button
-       virtual PainterBase & button(int x, int y, int w, int h);
-
-       ///
-       virtual PainterBase & buttonFrame(int x, int y, int w, int h);
-
-
-       // For the figure inset
-       virtual PainterBase & image(int x, int y, int w, int h,
-                                   grfx::GImage const & image) = 0;
-
-       /// Draw a string at position x, y (y is the baseline)
-       virtual PainterBase & text(int x, int y,
-                                  string const & str, LyXFont const & f) = 0;
-
-       /** Draw a string at position x, y (y is the baseline)
-           This is just for fast drawing */
-       virtual PainterBase & text(int x, int y, char const * str, size_t l,
-                                  LyXFont const & f) = 0;
-
-       /// Draw a char at position x, y (y is the baseline)
-       virtual PainterBase & text(int x, int y, char c, LyXFont const & f)=0;
-
-       /** Draws a string and encloses it inside a rectangle. */
-       PainterBase & rectText(int x, int baseline,
-                              string const & string,
-                              LyXFont const & font,
-                              LColor::color back,
-                              LColor::color frame);
-
-       /** Draw a string and encloses it inside a button frame. */
-       PainterBase & buttonText(int x, int baseline, string const & s,
-                                LyXFont const & font);
-protected:
-       ///
-       WorkArea & owner;
-};
-
-#endif
index 715f1f56e59b68a26958d310aa1f4dfd3a313acd..90fc8f690e9d6019a124020535efa8c04ca8e1a6 100644 (file)
@@ -21,7 +21,7 @@
 #include <sigc++/signal_system.h>
 
 #include FORMS_H_LOCATION
-#include "Painter.h"
+#include "frontends/Painter.h"
 
 ///
 class WorkArea {
index fe2eb681ff28037fd251e4607128bc3b39097263..69d9685f2823f07c64aca19bd0602461c76e981a 100644 (file)
@@ -1,3 +1,9 @@
+2002-05-23  John Levon  <moz@compsoc.man.ac.uk>
+
+       * Makefile.am:
+       * Painter.h:
+       * Painter.C: add PainterBase here
 2002-05-22  Lars Gullik Bjønnes  <larsbj@birdstep.com>
 
        * Dialogs.h: use more specific smart_ptr header
index f456db8dc0e5284b5c2757d3a7269cb190841532..f4f4bbbf7f210be994545b4dfac2d76f25969e0c 100644 (file)
@@ -26,6 +26,8 @@ libfrontends_la_SOURCES = \
        Liason.h \
        Menubar.C \
        Menubar.h \
+       Painter.C \
+       Painter.h \
        Timeout.C \
        Timeout.h \
        Toolbar.C \
diff --git a/src/frontends/Painter.C b/src/frontends/Painter.C
new file mode 100644 (file)
index 0000000..e79505e
--- /dev/null
@@ -0,0 +1,121 @@
+/* This file is part of
+ * ======================================================
+ *
+ *           LyX, The Document Processor
+ *
+ *         Copyright 1998-2001 The LyX Team
+ *
+ *======================================================*/
+
+#include <config.h>
+
+#ifdef __GNUG__
+#pragma implementation
+#endif
+
+#include "Painter.h"
+#include "lyxfont.h"
+#include "WorkArea.h"
+#include "font.h"
+
+
+int PainterBase::paperMargin() const
+{
+       return 20;
+}
+
+
+int PainterBase::paperWidth() const
+{
+       return owner.workWidth();
+}
+
+
+int PainterBase::paperHeight() const
+{
+       return owner.height();
+}
+
+
+PainterBase & PainterBase::circle(int x, int y, unsigned int d,
+                                 LColor::color col)
+{
+       return ellipse(x, y, d, d, col);
+}
+
+
+PainterBase & PainterBase::ellipse(int x, int y,
+                                  unsigned int w, unsigned int h,
+                                  LColor::color col)
+{
+       return arc(x, y, w, h, 0, 0, col);
+}
+
+
+PainterBase & PainterBase::button(int x, int y, int w, int h)
+{
+       fillRectangle(x, y, w, h, LColor::buttonbg);
+       buttonFrame(x, y, w, h);
+       return * this;
+}
+
+
+PainterBase & PainterBase::buttonFrame(int x, int y, int w, int h)
+{
+       //  Width of a side of the button
+       int d = 2;
+
+       fillRectangle(x, y, w, d, LColor::top);
+       fillRectangle(x, (y+h-d), w, d, LColor::bottom);
+
+       // Now a couple of trapezoids
+       int x1[4], y1[4];
+
+       x1[0] = x + d;   y1[0] = y + d;
+       x1[1] = x + d;   y1[1] = (y + h - d);
+       x1[2] = x;     y1[2] = y + h;
+       x1[3] = x;     y1[3] = y;
+       fillPolygon(x1, y1, 4, LColor::left);
+
+       x1[0] = (x + w - d); y1[0] = y + d;
+       x1[1] = (x + w - d); y1[1] = (y + h - d);
+       x1[2] = x + w; y1[2] = (y + h - d);
+       x1[3] = x + w; y1[3] = y;
+       fillPolygon(x1, y1, 4, LColor::right);
+
+       return *this;
+}
+
+
+PainterBase & PainterBase::rectText(int x, int baseline,
+                                   string const & str,
+                                   LyXFont const & font,
+                                   LColor::color back,
+                                   LColor::color frame)
+{
+       int width;
+       int ascent;
+       int descent;
+
+       lyxfont::rectText(str, font, width, ascent, descent);
+       rectangle(x, baseline - ascent, width, ascent + descent, frame);
+       fillRectangle(x + 1, baseline - ascent + 1, width - 1,
+                     ascent + descent - 1, back);
+       text(x + 3, baseline, str, font);
+       return *this;
+}
+
+
+PainterBase & PainterBase::buttonText(int x, int baseline,
+                                     string const & str,
+                                     LyXFont const & font)
+{
+       int width;
+       int ascent;
+       int descent;
+
+       lyxfont::buttonText(str, font, width, ascent, descent);
+       button(x, baseline - ascent, width, descent + ascent);
+       text(x + 4, baseline, str, font);
+       return *this;
+}
diff --git a/src/frontends/Painter.h b/src/frontends/Painter.h
new file mode 100644 (file)
index 0000000..1578c22
--- /dev/null
@@ -0,0 +1,178 @@
+// -*- C++ -*-
+/* This file is part of
+ * ======================================================
+ *
+ *           LyX, The Document Processor
+ *
+ *         Copyright 1998-2001 The LyX Team
+ *
+ *======================================================*/
+
+#ifndef PAINTERBASE_H
+#define PAINTERBASE_H
+
+#ifdef __GNUG__
+#pragma interface
+#endif
+
+#include "LString.h"
+#include "LColor.h"
+
+class WorkArea;
+class LyXFont;
+namespace grfx {
+       class GImage;
+}
+
+/** A painter class to encapsulate all graphics parameters and operations
+
+    Every graphics operation in LyX should be made by this class. It will
+    be initialized and managed by the Screen class, and will be passed
+    as a parameter to inset.
+
+    It hides low level windows system parameters so insets and other
+    clients don't have to worry about them and we can control graphics and
+    GUI toolkit dependent drawing functions inside this single class.
+
+ */
+class PainterBase {
+public:
+       ///
+       enum line_width {
+               ///
+               line_thin,
+               ///
+               line_thick
+       };
+
+       ///
+       enum line_style {
+               ///
+               line_solid,
+               ///
+               line_doubledash,
+               ///
+               line_onoffdash
+       };
+
+       ///
+       explicit PainterBase(WorkArea & wa) : owner(wa) {}
+
+       ///
+       virtual ~PainterBase() {}
+
+       /* Screen geometry */
+       ///
+       int paperMargin() const;
+       ///
+       int paperWidth() const;
+       ///
+       int paperHeight() const;
+
+       /// Draw a line from point to point
+       virtual PainterBase & line(
+               int x1, int y1, int x2, int y2,
+               LColor::color = LColor::foreground,
+               enum line_style = line_solid,
+               enum line_width = line_thin) = 0;
+
+       /** Draw the lines between the lines in xp and yp.
+           xp and yp are arrays of points, and np is the
+           number of them. */
+       virtual PainterBase & lines(
+               int const * xp, int const * yp, int np,
+               LColor::color = LColor::foreground,
+               enum line_style = line_solid,
+               enum line_width = line_thin) = 0;
+
+       /// Here xp and yp are arrays of points
+       virtual PainterBase & fillPolygon(
+               int const * xp, int const * yp,
+               int np,
+               LColor::color = LColor::foreground) = 0;
+
+       /// Draw lines from x1,y1 to x2,y2. They are arrays
+       virtual PainterBase & segments(
+               int const * x1, int const * y1,
+               int const * x2, int const * y2, int ns,
+               LColor::color = LColor::foreground,
+               enum line_style = line_solid,
+               enum line_width = line_thin) = 0;
+
+       /// Draw a rectangle
+       virtual PainterBase & rectangle(
+               int x, int y, int w, int h,
+               LColor::color = LColor::foreground,
+               enum line_style = line_solid,
+               enum line_width = line_thin) = 0;
+
+       /// Draw a circle, d is the diameter, not the radious
+       virtual PainterBase & circle(
+               int x, int y, unsigned int d,
+               LColor::color = LColor::foreground);
+
+       /// Draw an ellipse
+       virtual PainterBase & ellipse(
+               int x, int y,
+               unsigned int w, unsigned int h,
+               LColor::color = LColor::foreground);
+
+       /// Draw an arc
+       virtual PainterBase & arc(
+               int x, int y,
+               unsigned int w, unsigned int h,
+               int a1, int a2,
+               LColor::color = LColor::foreground) = 0;
+
+       /// Draw a pixel
+       virtual PainterBase & point(
+               int x, int y,
+               LColor::color = LColor::foreground) = 0;
+
+       /// Fill a rectangle
+       virtual PainterBase & fillRectangle(
+               int x, int y, int w, int h,
+               LColor::color) = 0;
+
+       /// A filled rectangle with the shape of a 3D button
+       virtual PainterBase & button(int x, int y, int w, int h);
+
+       ///
+       virtual PainterBase & buttonFrame(int x, int y, int w, int h);
+
+
+       // For the figure inset
+       virtual PainterBase & image(int x, int y, int w, int h,
+                                   grfx::GImage const & image) = 0;
+
+       /// Draw a string at position x, y (y is the baseline)
+       virtual PainterBase & text(int x, int y,
+                                  string const & str, LyXFont const & f) = 0;
+
+       /** Draw a string at position x, y (y is the baseline)
+           This is just for fast drawing */
+       virtual PainterBase & text(int x, int y, char const * str, size_t l,
+                                  LyXFont const & f) = 0;
+
+       /// Draw a char at position x, y (y is the baseline)
+       virtual PainterBase & text(int x, int y, char c, LyXFont const & f)=0;
+
+       /** Draws a string and encloses it inside a rectangle. */
+       PainterBase & rectText(int x, int baseline,
+                              string const & string,
+                              LyXFont const & font,
+                              LColor::color back,
+                              LColor::color frame);
+
+       /** Draw a string and encloses it inside a button frame. */
+       PainterBase & buttonText(int x, int baseline, string const & s,
+                                LyXFont const & font);
+protected:
+       ///
+       WorkArea & owner;
+};
+
+// VERY temporary
+#include "xforms/XPainter.h"
+#endif
index a69ad09b2c59c58d1e1a2a0e4f3ef5c30c7e65c9..f198ce1c72100139e0affd5b9c1b538ecbd662be 100644 (file)
@@ -1,3 +1,9 @@
+2002-05-23  John Levon  <moz@compsoc.man.ac.uk>
+
+       * Makefile.am:
+       * XPainter.h:
+       * XPainter.C: move Painter here
 2002-05-22  Lars Gullik Bjønnes  <larsbj@birdstep.com>
 
        * Menubar_pimpl.C: add scoped_ptr.hpp
index 09ed9db497838abeaaced9d880eff3e2385ef279..a774fa5098374cc7002be035f34e844a3336bd8a 100644 (file)
@@ -208,6 +208,8 @@ libxforms_la_SOURCES = \
        Toolbar_pimpl.h \
        Tooltips.C \
        Tooltips.h \
+       XPainter.h \
+       XPainter.C \
        xforms_helpers.C \
        xforms_helpers.h \
        xforms_resize.C \
diff --git a/src/frontends/xforms/XPainter.C b/src/frontends/xforms/XPainter.C
new file mode 100644 (file)
index 0000000..08eaf77
--- /dev/null
@@ -0,0 +1,303 @@
+/* This file is part of
+ * ======================================================
+ *
+ *           LyX, The Document Processor
+ *
+ *         Copyright 1998-2001 The LyX Team
+ *
+ *======================================================*/
+
+#include <config.h>
+
+#ifdef __GNUG__
+#pragma implementation
+#endif
+
+#include "frontends/Painter.h"
+#include "LString.h"
+#include "debug.h"
+#include "lyxfont.h"
+#include "WorkArea.h"
+#include "font.h"
+#include "ColorHandler.h"
+#include "lyxrc.h"
+#include "encoding.h"
+#include "language.h"
+
+#include "frontends/GUIRunTime.h"
+#include "graphics/GraphicsImage.h"
+
+#include "support/LAssert.h"
+#include "support/lstrings.h"
+
+#include <boost/scoped_array.hpp>
+
+#include <cmath>
+
+
+using std::endl;
+using std::max;
+
+namespace {
+
+inline
+Display * display()
+{
+       return GUIRunTime::x11Display();
+}
+
+}
+
+
+Painter::Painter(WorkArea & wa)
+       : PainterBase(wa)
+{}
+
+
+// Basic drawing routines
+
+PainterBase & Painter::point(int x, int y, LColor::color c)
+{
+       XDrawPoint(display(), owner.getPixmap(),
+                  lyxColorHandler->getGCForeground(c), x, y);
+       return *this;
+}
+
+
+PainterBase & Painter::line(int x1, int y1, int x2, int y2,
+                           LColor::color col,
+                           enum line_style ls,
+                           enum line_width lw)
+{
+       XDrawLine(display(), owner.getPixmap(),
+                 lyxColorHandler->getGCLinepars(ls, lw, col),
+                 x1, y1, x2, y2);
+       return *this;
+}
+
+
+PainterBase & Painter::lines(int const * xp, int const * yp, int np,
+                            LColor::color col,
+                            enum line_style ls,
+                            enum line_width lw)
+{
+       boost::scoped_array<XPoint> points(new XPoint[np]);
+
+       for (int i = 0; i < np; ++i) {
+               points[i].x = xp[i];
+               points[i].y = yp[i];
+       }
+
+       XDrawLines(display(), owner.getPixmap(),
+                  lyxColorHandler->getGCLinepars(ls, lw, col),
+                  points.get(), np, CoordModeOrigin);
+
+       return *this;
+}
+
+
+PainterBase & Painter::rectangle(int x, int y, int w, int h,
+                                LColor::color col,
+                                enum line_style ls,
+                                enum line_width lw)
+{
+       XDrawRectangle(display(), owner.getPixmap(),
+                      lyxColorHandler->getGCLinepars(ls, lw, col),
+                      x, y, w, h);
+       return *this;
+}
+
+
+PainterBase & Painter::fillRectangle(int x, int y, int w, int h,
+                                    LColor::color col)
+{
+       XFillRectangle(display(), owner.getPixmap(),
+                      lyxColorHandler->getGCForeground(col), x, y, w, h);
+       return *this;
+}
+
+
+PainterBase & Painter::fillPolygon(int const * xp, int const * yp, int np,
+                                  LColor::color col)
+{
+       boost::scoped_array<XPoint> points(new XPoint[np]);
+
+       for (int i = 0; i < np; ++i) {
+               points[i].x = xp[i];
+               points[i].y = yp[i];
+       }
+
+       XFillPolygon(display(), owner.getPixmap(),
+                    lyxColorHandler->getGCForeground(col), points.get(), np,
+                    Nonconvex, CoordModeOrigin);
+
+       return *this;
+}
+
+
+PainterBase & Painter::arc(int x, int y,
+                          unsigned int w, unsigned int h,
+                          int a1, int a2, LColor::color col)
+{
+       XDrawArc(display(), owner.getPixmap(),
+                lyxColorHandler->getGCForeground(col),
+                x, y, w, h, a1, a2);
+       return *this;
+}
+
+
+/// Draw lines from x1,y1 to x2,y2. They are arrays
+PainterBase & Painter::segments(int const * x1, int const * y1,
+                               int const * x2, int const * y2, int ns,
+                               LColor::color col,
+                               enum line_style ls, enum line_width lw)
+{
+       boost::scoped_array<XSegment> s(new XSegment[ns]);
+
+       for (int i = 0; i < ns; ++i) {
+               s[i].x1 = x1[i];
+               s[i].y1 = y1[i];
+               s[i].x2 = x2[i];
+               s[i].y2 = y2[i];
+       }
+       XDrawSegments(display(), owner.getPixmap(),
+                     lyxColorHandler->getGCLinepars(ls, lw, col),
+                     s.get(), ns);
+
+       return *this;
+}
+
+
+PainterBase & Painter::image(int x, int y, int w, int h,
+                            grfx::GImage const & image)
+{
+       XGCValues val;
+       val.function = GXcopy;
+       GC gc = XCreateGC(display(), owner.getPixmap(),
+                         GCFunction, &val);
+       XCopyArea(display(), image.getPixmap(), owner.getPixmap(), gc,
+                 0, 0, w, h, x, y);
+       XFreeGC(display(), gc);
+       return *this;
+}
+
+
+PainterBase & Painter::text(int x, int y, string const & s, LyXFont const & f)
+{
+       return text(x, y, s.data(), s.length(), f);
+}
+
+
+PainterBase & Painter::text(int x, int y, char c, LyXFont const & f)
+{
+       char s[2] = { c, '\0' };
+       return text(x, y, s, 1, f);
+}
+
+
+PainterBase & Painter::text(int x, int y, char const * s, size_t ls,
+                           LyXFont const & f)
+{
+       if (lyxrc.font_norm_type == LyXRC::ISO_10646_1) {
+               boost::scoped_array<XChar2b> xs(new XChar2b[ls]);
+               Encoding const * encoding = f.language()->encoding();
+               LyXFont font(f);
+               if (f.isSymbolFont()) {
+#ifdef USE_UNICODE_FOR_SYMBOLS
+                       font.setFamily(LyXFont::ROMAN_FAMILY);
+                       font.setShape(LyXFont::UP_SHAPE);
+#endif
+                       encoding = encodings.symbol_encoding();
+               }
+               for (size_t i = 0; i < ls; ++i) {
+                       Uchar c = encoding->ucs(s[i]);
+                       xs[i].byte1 = c >> 8;
+                       xs[i].byte2 = c & 0xff;
+               }
+               text(x , y, xs.get(), ls, font);
+               return *this;
+       }
+
+       GC gc = lyxColorHandler->getGCForeground(f.realColor());
+       if (f.realShape() != LyXFont::SMALLCAPS_SHAPE) {
+               lyxfont::XSetFont(display(), gc, f);
+               XDrawString(display(), owner.getPixmap(), gc, x, y, s, ls);
+       } else {
+               LyXFont smallfont(f);
+               smallfont.decSize().decSize().setShape(LyXFont::UP_SHAPE);
+               int tmpx = x;
+               for (size_t i = 0; i < ls; ++i) {
+                       char const c = uppercase(s[i]);
+                       if (c != s[i]) {
+                               lyxfont::XSetFont(display(), gc, smallfont);
+                               XDrawString(display(), owner.getPixmap(), gc,
+                                           tmpx, y, &c, 1);
+                               tmpx += lyxfont::XTextWidth(smallfont, &c, 1);
+                       } else {
+                               lyxfont::XSetFont(display(), gc, f);
+                               XDrawString(display(), owner.getPixmap(), gc,
+                                           tmpx, y, &c, 1);
+                               tmpx += lyxfont::XTextWidth(f, &c, 1);
+                       }
+               }
+       }
+
+       if (f.underbar() == LyXFont::ON) {
+               underline(f, x, y, lyxfont::width(s, ls, f));
+       }
+
+       return *this;
+}
+
+
+PainterBase & Painter::text(int x, int y, XChar2b const * s, int ls,
+                           LyXFont const & f)
+{
+       GC gc = lyxColorHandler->getGCForeground(f.realColor());
+       if (f.realShape() != LyXFont::SMALLCAPS_SHAPE) {
+               lyxfont::XSetFont(display(), gc, f);
+               XDrawString16(display(), owner.getPixmap(), gc, x, y, s, ls);
+       } else {
+               LyXFont smallfont(f);
+               smallfont.decSize().decSize().setShape(LyXFont::UP_SHAPE);
+               static XChar2b c;
+               int tmpx = x;
+               for (int i = 0; i < ls; ++i) {
+                       if (s[i].byte1)
+                               c = s[i];
+                       else {
+                               c.byte1 = s[i].byte1;
+                               c.byte2 = uppercase(s[i].byte2);
+                       }
+                       if (c.byte2 != s[i].byte2) {
+                               lyxfont::XSetFont(display(), gc, smallfont);
+                               XDrawString16(display(), owner.getPixmap(), gc,
+                                             tmpx, y, &c, 1);
+                               tmpx += lyxfont::XTextWidth16(smallfont, &c, 1);
+                       } else {
+                               lyxfont::XSetFont(display(), gc, f);
+                               XDrawString16(display(), owner.getPixmap(), gc,
+                                             tmpx, y, &c, 1);
+                               tmpx += lyxfont::XTextWidth16(f, &c, 1);
+                       }
+               }
+       }
+
+       if (f.underbar() == LyXFont::ON) {
+               underline(f, x, y, lyxfont::width(s, ls, f));
+       }
+
+       return *this;
+}
+
+
+void Painter::underline(LyXFont const & f, int x, int y, int width)
+{
+       int const below = max(lyxfont::maxDescent(f) / 2, 2);
+       int const height = max((lyxfont::maxDescent(f) / 4) - 1, 1);
+       if (height < 2)
+               line(x, y + below, x + width, y + below, f.color());
+       else
+               fillRectangle(x, y + below, width, below + height,
+                             f.color());
+}
diff --git a/src/frontends/xforms/XPainter.h b/src/frontends/xforms/XPainter.h
new file mode 100644 (file)
index 0000000..c4b1d8f
--- /dev/null
@@ -0,0 +1,101 @@
+// -*- C++ -*-
+/* This file is part of
+ * ======================================================
+ *
+ *           LyX, The Document Processor
+ *
+ *         Copyright 1995-2001 The LyX Team
+ *
+ * ======================================================*/
+
+#ifndef PAINTER_H
+#define PAINTER_H
+
+#ifdef __GNUG__
+#pragma interface
+#endif
+
+#include "LString.h"
+
+// This is only included to provide stuff for the non-public sections
+#include <X11/Xlib.h>
+
+#include "frontends/Painter.h"
+
+class LyXFont;
+class WorkArea;
+
+/** An inplementation for the X Window System. Xlib.
+    Classes similar to this one can be made for gtk+, Qt, etc.
+*/
+class Painter : public PainterBase {
+public:
+       /// Constructor
+       explicit Painter(WorkArea &);
+
+       /// Draw a line from point to point
+       PainterBase & line(int x1, int y1, int x2, int y2,
+                          LColor::color = LColor::foreground,
+                          enum line_style = line_solid,
+                          enum line_width = line_thin);
+
+       /// Here xp and yp are arrays of points
+       PainterBase & lines(int const * xp, int const * yp, int np,
+                           LColor::color = LColor::foreground,
+                           enum line_style = line_solid,
+                           enum line_width = line_thin);
+
+       /// Here xp and yp are arrays of points
+       PainterBase & fillPolygon(int const * xp, int const * yp, int np,
+                                 LColor::color = LColor::foreground);
+
+       /// Draw lines from x1,y1 to x2,y2. They are arrays
+       PainterBase & segments(int const * x1, int const * y1,
+                              int const * x2, int const * y2, int ns,
+                              LColor::color = LColor::foreground,
+                              enum line_style = line_solid,
+                              enum line_width = line_thin);
+
+       /// Draw a rectangle
+       PainterBase & rectangle(int x, int y, int w, int h,
+                               LColor::color = LColor::foreground,
+                               enum line_style = line_solid,
+                               enum line_width = line_thin);
+
+       /// Draw an arc
+       PainterBase & arc(int x, int y, unsigned int w, unsigned int h,
+                         int a1, int a2,
+                         LColor::color = LColor::foreground);
+
+       /// Draw a pixel
+       PainterBase & point(int x, int y, LColor::color = LColor::foreground);
+
+       /// Fill a rectangle
+       PainterBase & fillRectangle(int x, int y, int w, int h,
+                                   LColor::color);
+
+       /// For the graphics inset.
+       PainterBase & image(int x, int y, int w, int h,
+                           grfx::GImage const & image);
+
+       /// Draw a string at position x, y (y is the baseline)
+       PainterBase & text(int x, int y,
+                          string const & str, LyXFont const & f);
+
+       /** Draw a string at position x, y (y is the baseline)
+           This is just for fast drawing */
+       PainterBase & text(int x, int y, char const * str, size_t l,
+                          LyXFont const & f);
+
+       /// Draw a char at position x, y (y is the baseline)
+       PainterBase & text(int x, int y, char c, LyXFont const & f);
+
+       /// Draw a wide string at position x, y
+       PainterBase & text(int x, int y, XChar2b const * str, int l,
+                          LyXFont const & f);
+private:
+       /// Check the font, and if set, draw an underline
+       void underline(LyXFont const & f, int x, int y, int width);
+};
+
+#endif
index 4030580d04e3aa631dd77a2e9898567aaa05ba73..e4ea1516f9b98695f666a65b2137c677c41137c7 100644 (file)
@@ -1,3 +1,19 @@
+2002-05-23  John Levon  <moz@compsoc.man.ac.uk>
+
+       * inset.C:
+       * insetbutton.C:
+       * insetcaption.C:
+       * insetcollapsable.C:
+       * insetcommand.C:
+       * inseterror.C:
+       * insetgraphics.C:
+       * insetgraphicsParams.C:
+       * insetlatexaccent.C:
+       * insetquotes.C:
+       * insetspecialchar.C:
+       * insettabular.C:
+       * insettext.C: move Painter to frontends/
 2002-05-22  Lars Gullik Bjønnes  <larsbj@birdstep.com>
 
        * insettabular.h: use more specific smart_ptr header.
index c6ba6bf51eaf4439e836a44e48a22da90e2fa501..cfc35e603b2629c051b659d5ac46db80a44895c8 100644 (file)
@@ -18,7 +18,7 @@
 #include "debug.h"
 #include "BufferView.h"
 #include "support/lstrings.h"
-#include "Painter.h"
+#include "frontends/Painter.h"
 #include "commandtags.h"
 #include "support/lstrings.h"
 #include "gettext.h"
index 52cdd300255fa5bd5f7ccb191b1958398337fd13..704890110e61a92352973960d2e2d1efb7862e2a 100644 (file)
@@ -17,7 +17,7 @@
 #include "insetbutton.h"
 #include "debug.h"
 #include "BufferView.h"
-#include "Painter.h"
+#include "frontends/Painter.h"
 #include "support/LAssert.h"
 #include "lyxfont.h"
 #include "font.h"
index 1414e2d438de57ba91e6e87124a644a21b5331c3..de9f0e4f658a47c6bae0e96b8df17f1580bbffd5 100644 (file)
@@ -15,7 +15,7 @@
 #endif
 
 #include "insetcaption.h"
-#include "Painter.h"
+#include "frontends/Painter.h"
 #include "font.h"
 #include "BufferView.h"
 #include "FloatList.h"
index df7d33887a57a94ebcac5dc9874bccf64a29af5e..b7e8c5df972cb297671c87639f92e7d68ce88eea 100644 (file)
@@ -18,7 +18,7 @@
 #include "gettext.h"
 #include "lyxfont.h"
 #include "BufferView.h"
-#include "Painter.h"
+#include "frontends/Painter.h"
 #include "debug.h"
 #include "lyxtext.h"
 #include "font.h"
index 8c64fd76e5dd211c4f859bc9e4bc4506b0147fa4..6fe86786abfe314bcace60e5c8a1b4fe4d4ab05e 100644 (file)
@@ -16,7 +16,7 @@
 
 #include "insetcommand.h"
 #include "debug.h"
-#include "Painter.h"
+#include "frontends/Painter.h"
 #include "lyxlex.h"
 
 using std::ostream;
index c16d3515861adc08c6c37e68e40f13df450aae16..23924528ac61d01653edf140f871dd9f7c2d9c6d 100644 (file)
@@ -20,7 +20,7 @@
 #include "gettext.h"
 #include "inseterror.h"
 #include "LyXView.h"
-#include "Painter.h"
+#include "frontends/Painter.h"
 #include "frontends/Dialogs.h"
 
 using std::ostream;
index b913292146450f1aff4e1a95995bdb4d926f0016..3ba1248838753c6be70bdeebf3cccc7b85c8caab 100644 (file)
@@ -86,7 +86,7 @@ TODO Before initial production release:
 #include "buffer.h"
 #include "BufferView.h"
 #include "converter.h"
-#include "Painter.h"
+#include "frontends/Painter.h"
 #include "lyxrc.h"
 #include "font.h"    // For the lyxfont class.
 #include "debug.h"
index e402934d0e679918515200bb6dda5ab741a0bc18..7268faab523546ee51b3fd9e2456907f953d6317 100644 (file)
@@ -215,7 +215,7 @@ void InsetGraphicsParams::Write(ostream & os) const
 }
 
 
-bool InsetGraphicsParams::Read(LyXLex & lex, string const& token)
+bool InsetGraphicsParams::Read(LyXLex & lex, string const & token)
 {
        if (token == "filename") {
                lex.next();
index 6413256e00f12c5ec94a25c9ae7bfbd9f06ed54f..0fbcd32cc59d59ccc89f69a662ca3ed7d976bd1b 100644 (file)
@@ -19,7 +19,7 @@
 #include "lyxrc.h"
 #include "support/lstrings.h"
 #include "BufferView.h"
-#include "Painter.h"
+#include "frontends/Painter.h"
 #include "font.h"
 #include "language.h"
 
index 4b7e678edf9268b8b2df05eaebc6b8f76d918f95..f4ca0a9870686f6ec6917451725c502057d2c034 100644 (file)
@@ -20,7 +20,7 @@
 #include "support/lstrings.h"
 #include "BufferView.h"
 #include "LaTeXFeatures.h"
-#include "Painter.h"
+#include "frontends/Painter.h"
 #include "buffer.h"
 #include "debug.h"
 #include "font.h"
index b75d573b3700ced7100e567015602675370dd7d5..c89f168a5ee617043a5918653e9d93cd2a859572 100644 (file)
@@ -17,7 +17,7 @@
 #include "debug.h"
 #include "LaTeXFeatures.h"
 #include "BufferView.h"
-#include "Painter.h"
+#include "frontends/Painter.h"
 #include "font.h"
 #include "lyxlex.h"
 #include "lyxfont.h"
index d7c59e82bf5ee72093e0234ab0f982a1443d606a..6c65dca7fffb4ee159b8204f8a8c6abcd95ec443 100644 (file)
@@ -22,7 +22,7 @@
 #include "lyxfunc.h"
 #include "debug.h"
 #include "LaTeXFeatures.h"
-#include "Painter.h"
+#include "frontends/Painter.h"
 #include "font.h"
 #include "lyxtext.h"
 #include "LyXView.h"
index a433a3f35ca85a425420783f9a22254771beb653..23741c9ebebcc1baef6bca0431aedb5c6a6ef59a 100644 (file)
@@ -25,7 +25,7 @@
 #include "BufferView.h"
 #include "lyxtextclasslist.h"
 #include "LaTeXFeatures.h"
-#include "Painter.h"
+#include "frontends/Painter.h"
 #include "lyxtext.h"
 #include "lyxcursor.h"
 #include "CutAndPaste.h"
@@ -2505,7 +2505,7 @@ void InsetText::clearInset(BufferView * bv, int baseline, bool & cleared) const
        if ((top_x + drawTextXOffset + w) > pain.paperWidth())
                w = pain.paperWidth();
 //     w -= TEXT_TO_INSET_OFFSET;
-       pain.fillRectangle(top_x, ty, w+1, h+1, backgroundColor());
+       pain.fillRectangle(top_x + 1, ty + 1, w - 1, h - 1, backgroundColor());
        cleared = true;
        need_update = FULL;
        frame_is_visible = false;
index 20320422db454c33b1f648b13003ae43f4c43e8c..6b84e4adaf3bbc4ccbbba15d6b0ec55af2926c4d 100644 (file)
@@ -1,3 +1,27 @@
+2002-05-23  John Levon  <moz@compsoc.man.ac.uk>
+
+       * formula.C:
+       * formulabase.C:
+       * formulamacro.C:
+       * math_binaryopinset.C:
+       * math_casesinset.C:
+       * math_charinset.C:
+       * math_cursor.C:
+       * math_fracinset.C:
+       * math_funcinset.C:
+       * math_gridinset.C:
+       * math_hullinset.C:
+       * math_macro.C:
+       * math_macrotemplate.C:
+       * math_rootinset.C:
+       * math_spaceinset.C:
+       * math_sqrtinset.C:
+       * math_stringinset.C:
+       * math_support.C:
+       * math_unknowninset.C:
+       * math_xdata.C:
+       * math_xyarrowinset.C: move Painter to frontends/
 2002-05-22  Lars Gullik Bjønnes  <larsbj@birdstep.com>
 
        * math_exintinset.C: use more specific smart_ptr header.
index c145aa8fb5db8f6d0f259c1bb3c2af9707b4245c..415b0e0f42832e40c7e24c5ad55a734a671530b5 100644 (file)
@@ -36,7 +36,7 @@
 #include "support/systemcall.h"
 #include "support/filetools.h" // LibFileSearch
 #include "LyXView.h"
-#include "Painter.h"
+#include "frontends/Painter.h"
 #include "lyxrc.h"
 #include "math_hullinset.h"
 #include "math_support.h"
index 4478ee47acd1cad364d16e8bfc4f4f4dd6938a12..865faf702638c4f4e98cec7e0a729e5280aa2c91 100644 (file)
@@ -34,7 +34,7 @@
 #include "math_support.h"
 #include "support/lstrings.h"
 #include "LyXView.h"
-#include "Painter.h"
+#include "frontends/Painter.h"
 #include "font.h"
 #include "Lsstream.h"
 #include "math_arrayinset.h"
index 5c1d85181e9bc6f468757347b532aeba0287a0be..51cfcdf4bd19053d6ee0691b1a4fbb91bbe592ff 100644 (file)
@@ -27,7 +27,7 @@
 #include "math_mathmlstream.h"
 #include "BufferView.h"
 #include "gettext.h"
-#include "Painter.h"
+#include "frontends/Painter.h"
 #include "font.h"
 #include "support/lyxlib.h"
 #include "support/LOstream.h"
index b20a12fbca22bd6f9b882d0f4b15da4fc82e2e1d..9a447379adbf633dd2d7ff3df1cdc17ea4b73f19 100644 (file)
@@ -5,7 +5,7 @@
 #endif
 
 #include "math_binaryopinset.h"
-#include "Painter.h"
+#include "frontends/Painter.h"
 #include "support/LOstream.h"
 #include "math_support.h"
 #include "math_mathmlstream.h"
index cf3b21ff54fb7216b1ab435cfa43b3e4a57f0b4c..01acf7681206bf6daed6fc2139b8b947608f3f3b 100644 (file)
@@ -8,7 +8,7 @@
 #include "math_parser.h"
 #include "math_mathmlstream.h"
 #include "math_support.h"
-#include "Painter.h"
+#include "frontends/Painter.h"
 
 
 MathCasesInset::MathCasesInset(row_type n)
index 71a3609ccf4538710cfd28dca3a927b831ead7d6..85cdcc6bb9a058584ed559ae04f74aef7de442f8 100644 (file)
@@ -6,7 +6,7 @@
 
 #include "math_charinset.h"
 #include "LColor.h"
-#include "Painter.h"
+#include "frontends/Painter.h"
 #include "support/LOstream.h"
 #include "font.h"
 #include "debug.h"
index 209bcb8a97ce2f9fbe2e790f7144289432f325d1..36834e7612654ec9826a7aa0dd2ef95018f9a7f7 100644 (file)
@@ -26,7 +26,7 @@
 #include "support/LAssert.h"
 #include "debug.h"
 #include "LColor.h"
-#include "Painter.h"
+#include "frontends/Painter.h"
 #include "math_cursor.h"
 #include "formulabase.h"
 #include "math_arrayinset.h"
index 69f935689e62322fe7a992e045e7d08a1ead0bb1..cc7efc8890a7c2b410639b4d9e4b083724723013 100644 (file)
@@ -4,7 +4,7 @@
 
 #include "math_fracinset.h"
 #include "math_support.h"
-#include "Painter.h"
+#include "frontends/Painter.h"
 #include "math_mathmlstream.h"
 #include "textpainter.h"
 
index 6f24b2f475aa71d1f854af46be3ea6951d19ca5e..ce617c6aef7e48063364da7d4590ead83d6bc686 100644 (file)
@@ -6,7 +6,7 @@
 
 #include "math_funcinset.h"
 #include "font.h"
-#include "Painter.h"
+#include "frontends/Painter.h"
 #include "math_support.h"
 #include "math_mathmlstream.h"
 #include "math_streamstr.h"
index b6663b93782abd0884c9d075a3508a3b8c7c4f59..0b7a7ea3c6091955bb19a9c225182c1c683fb6d8 100644 (file)
@@ -6,7 +6,7 @@
 #include "math_mathmlstream.h"
 #include "math_streamstr.h"
 #include "lyxfont.h"
-#include "Painter.h"
+#include "frontends/Painter.h"
 #include "debug.h"
 
 
index 8e52adb9e0b86949f9e2d57e963cf49a760a706a..75bc87bf5b6e6ad39ff3f5548b60f48a0059bd99 100644 (file)
@@ -9,7 +9,7 @@
 #include "math_streamstr.h"
 #include "math_support.h"
 #include "debug.h"
-#include "Painter.h"
+#include "frontends/Painter.h"
 #include "textpainter.h"
 #include "Lsstream.h"
 #include "LaTeXFeatures.h"
index ef3bf5da1bc26561d174f0cdb8062d196b894adc..d80be9f55e53651c520b59a9198b4eb29863decd 100644 (file)
@@ -28,7 +28,7 @@
 #include "support/lstrings.h"
 #include "support/LAssert.h"
 #include "debug.h"
-#include "Painter.h"
+#include "frontends/Painter.h"
 #include "LaTeXFeatures.h"
 
 
index 6ba92c30d343bf7229e6c821868e7c642a7c60c9..7d518782d0ab8c32029740f034ddc11ab7b3d47c 100644 (file)
@@ -4,7 +4,7 @@
 
 #include "math_macrotemplate.h"
 #include "math_mathmlstream.h"
-#include "Painter.h"
+#include "frontends/Painter.h"
 #include "debug.h"
 
 
index 2a7185895da503e2a191bdedf227d855455f4927..98b8423f9491cc6ff0e0e7b7c20ffb6a31214238 100644 (file)
@@ -17,7 +17,7 @@
 
 #include "math_rootinset.h"
 #include "math_mathmlstream.h"
-#include "Painter.h"
+#include "frontends/Painter.h"
 
 
 using std::max;
index d6da0ed575c69629d4031c392c592743864bc987..5fb436730007c321d96122a51e8754cc1ec4d470 100644 (file)
@@ -5,7 +5,7 @@
 #include "math_spaceinset.h"
 #include "math_support.h"
 #include "LColor.h"
-#include "Painter.h"
+#include "frontends/Painter.h"
 #include "math_mathmlstream.h"
 
 
index 3470a41d06241ae3110f1d8d3e3b411cd21a0203..3b6a330cbde0b2e3b91dfcdb4650f987020bcb0b 100644 (file)
@@ -5,7 +5,7 @@
 #include "math_sqrtinset.h"
 #include "math_mathmlstream.h"
 #include "LColor.h"
-#include "Painter.h"
+#include "frontends/Painter.h"
 #include "textpainter.h"
 
 
index 7ad73aa37eb89a0e83bcbb048b229cea2093195b..988ac652080b6e53ee8ca6b5318dc7b0c660d921 100644 (file)
@@ -8,7 +8,7 @@
 #include "math_mathmlstream.h"
 #include "math_streamstr.h"
 #include "LColor.h"
-#include "Painter.h"
+#include "frontends/Painter.h"
 #include "math_support.h"
 #include "math_parser.h"
 #include "LaTeXFeatures.h"
index d6c2d425d31b46ad496877d3d9cbff1155df9d0a..940d3f0dfb1dd2f2a65c3fca20baf98bac902669 100644 (file)
@@ -10,7 +10,7 @@
 #include "math_defs.h"
 #include "math_inset.h"
 #include "math_parser.h"
-#include "Painter.h"
+#include "frontends/Painter.h"
 #include "debug.h"
 #include "commandtags.h"
 
index 3c8b54319a384220452ab2cda5384150c5d64be2..4a3088a189dff22e03f085335e2eae6d0b31f496 100644 (file)
@@ -6,7 +6,7 @@
 
 #include "math_unknowninset.h"
 #include "font.h"
-#include "Painter.h"
+#include "frontends/Painter.h"
 #include "math_support.h"
 #include "math_mathmlstream.h"
 #include "math_streamstr.h"
index 292d82d7b1861cb4a868bd3d9dad6c71cdb603c2..ed5baeebeba610963e60fd2ab122f453319aabfa 100644 (file)
@@ -6,7 +6,7 @@
 
 #include "math_scriptinset.h"
 #include "math_support.h"
-#include "Painter.h"
+#include "frontends/Painter.h"
 #include "textpainter.h"
 #include "debug.h"
 
index 5f3489f3e3631cca333df6a07ce361334277baa3..f2d62fb84ad04258e1cb271739cf9726bebcd016 100644 (file)
@@ -9,7 +9,7 @@
 #include "math_mathmlstream.h"
 #include "math_streamstr.h"
 #include "math_support.h"
-#include "Painter.h"
+#include "frontends/Painter.h"
 #include "debug.h"
 
 
index 55581953cef441872f3851fe4b4c5f4965af8a35..26ab6e797399b96393ebd02307705d11fdea69c7 100644 (file)
@@ -19,7 +19,7 @@
 #include "lyxscreen.h"
 #include "lyxtext.h"
 #include "lyxrow.h"
-#include "Painter.h"
+#include "frontends/Painter.h"
 #include "WorkArea.h"
 #include "buffer.h"
 #include "BufferView.h"
index fbeae9e5c5f0574431440865a0c8e4544886cea9..3ba8ca8bf0065b1d65d2b4a170205a7f25a52d80 100644 (file)
@@ -25,7 +25,7 @@
 #include "layout.h"
 #include "buffer.h"
 #include "BufferView.h"
-#include "Painter.h"
+#include "frontends/Painter.h"
 #include "LaTeXFeatures.h"
 #include "insets/insettabular.h"
 #include "insets/insettext.h"
index aad37b35057987bc9e0564451a032d2495e671a4..469e0e929f5b4fd95582ac1845bdc0513448c447 100644 (file)
@@ -20,7 +20,7 @@
 #include "debug.h"
 #include "lyxrc.h"
 #include "LyXView.h"
-#include "Painter.h"
+#include "frontends/Painter.h"
 #include "tracer.h"
 #include "font.h"
 #include "encoding.h"
index ba98a27f323d1b7cbc6b86424ee1a4bee7a37fda..f45841a81069ef4824495af06f2fa5de714027ad 100644 (file)
@@ -26,7 +26,7 @@
 #include "BufferView.h"
 #include "LyXView.h"
 #include "CutAndPaste.h"
-#include "Painter.h"
+#include "frontends/Painter.h"
 #include "font.h"
 #include "debug.h"
 #include "lyxrc.h"
@@ -739,11 +739,10 @@ void LyXText::setFont(BufferView * bview, LyXFont const & font, bool toggleall)
        freezeUndo();
        cursor = selection.start;
        while (cursor.par() != selection.end.par() ||
-              (cursor.pos() < selection.end.pos()))
+              cursor.pos() < selection.end.pos()) 
        {
                if (cursor.pos() < cursor.par()->size()) {
-                       // an open footnote should behave
-                       // like a closed one
+                       // an open footnote should behave like a closed one
                        setCharFont(bview, cursor.par(), cursor.pos(),
                                    font, toggleall);
                        cursor.pos(cursor.pos() + 1);
@@ -2662,9 +2661,6 @@ LyXText::text_status LyXText::status() const
 
 void LyXText::status(BufferView * bview, LyXText::text_status st) const
 {
-       // well as much as I know && binds more then || so the above and the
-       // below are identical (this for your known use of parentesis!)
-       // Now some explanation:
        // We should only go up with refreshing code so this means that if
        // we have a MORE refresh we should never set it to LITTLE if we still
        // didn't handle it (and then it will be UNCHANGED. Now as long as