From: John Levon Date: Thu, 23 May 2002 09:21:32 +0000 (+0000) Subject: OK I'll try guii1 again ... X-Git-Tag: 1.6.10~19228 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=06f9f0ea08ddcf13e99ea02cff21471aa2020c9e;p=features.git OK I'll try guii1 again ... git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@4186 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/ChangeLog b/src/ChangeLog index cbdbb7e7de..72ccf19648 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,17 @@ +2002-05-23 John Levon + + * 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 * buffer.C: comment out some some code that depend upon lyx_format diff --git a/src/ColorHandler.h b/src/ColorHandler.h index db2d913d03..af85ad88b6 100644 --- a/src/ColorHandler.h +++ b/src/ColorHandler.h @@ -15,7 +15,7 @@ #pragma interface #endif -#include "PainterBase.h" +#include "frontends/Painter.h" #include diff --git a/src/Makefile.am b/src/Makefile.am index d594091425..97f4f7efe6 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -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 index be7215ea5c..0000000000 --- a/src/Painter.C +++ /dev/null @@ -1,303 +0,0 @@ -/* This file is part of - * ====================================================== - * - * LyX, The Document Processor - * - * Copyright 1998-2001 The LyX Team - * - *======================================================*/ - -#include - -#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 - -#include - - -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 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 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 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 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 index c5524fc1a6..0000000000 --- a/src/Painter.h +++ /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 - -#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 index 892815d713..0000000000 --- a/src/PainterBase.C +++ /dev/null @@ -1,121 +0,0 @@ -/* This file is part of - * ====================================================== - * - * LyX, The Document Processor - * - * Copyright 1998-2001 The LyX Team - * - *======================================================*/ - -#include - -#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 index e5a8676bd8..0000000000 --- a/src/PainterBase.h +++ /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 diff --git a/src/WorkArea.h b/src/WorkArea.h index 715f1f56e5..90fc8f690e 100644 --- a/src/WorkArea.h +++ b/src/WorkArea.h @@ -21,7 +21,7 @@ #include #include FORMS_H_LOCATION -#include "Painter.h" +#include "frontends/Painter.h" /// class WorkArea { diff --git a/src/frontends/ChangeLog b/src/frontends/ChangeLog index fe2eb681ff..69d9685f28 100644 --- a/src/frontends/ChangeLog +++ b/src/frontends/ChangeLog @@ -1,3 +1,9 @@ +2002-05-23 John Levon + + * Makefile.am: + * Painter.h: + * Painter.C: add PainterBase here + 2002-05-22 Lars Gullik Bjønnes * Dialogs.h: use more specific smart_ptr header diff --git a/src/frontends/Makefile.am b/src/frontends/Makefile.am index f456db8dc0..f4f4bbbf7f 100644 --- a/src/frontends/Makefile.am +++ b/src/frontends/Makefile.am @@ -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 index 0000000000..e79505e8c9 --- /dev/null +++ b/src/frontends/Painter.C @@ -0,0 +1,121 @@ +/* This file is part of + * ====================================================== + * + * LyX, The Document Processor + * + * Copyright 1998-2001 The LyX Team + * + *======================================================*/ + +#include + +#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 index 0000000000..1578c224e5 --- /dev/null +++ b/src/frontends/Painter.h @@ -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 diff --git a/src/frontends/xforms/ChangeLog b/src/frontends/xforms/ChangeLog index a69ad09b2c..f198ce1c72 100644 --- a/src/frontends/xforms/ChangeLog +++ b/src/frontends/xforms/ChangeLog @@ -1,3 +1,9 @@ +2002-05-23 John Levon + + * Makefile.am: + * XPainter.h: + * XPainter.C: move Painter here + 2002-05-22 Lars Gullik Bjønnes * Menubar_pimpl.C: add scoped_ptr.hpp diff --git a/src/frontends/xforms/Makefile.am b/src/frontends/xforms/Makefile.am index 09ed9db497..a774fa5098 100644 --- a/src/frontends/xforms/Makefile.am +++ b/src/frontends/xforms/Makefile.am @@ -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 index 0000000000..08eaf776de --- /dev/null +++ b/src/frontends/xforms/XPainter.C @@ -0,0 +1,303 @@ +/* This file is part of + * ====================================================== + * + * LyX, The Document Processor + * + * Copyright 1998-2001 The LyX Team + * + *======================================================*/ + +#include + +#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 + +#include + + +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 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 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 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 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 index 0000000000..c4b1d8f81e --- /dev/null +++ b/src/frontends/xforms/XPainter.h @@ -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 + +#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 diff --git a/src/insets/ChangeLog b/src/insets/ChangeLog index 4030580d04..e4ea1516f9 100644 --- a/src/insets/ChangeLog +++ b/src/insets/ChangeLog @@ -1,3 +1,19 @@ +2002-05-23 John Levon + + * 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 * insettabular.h: use more specific smart_ptr header. diff --git a/src/insets/inset.C b/src/insets/inset.C index c6ba6bf51e..cfc35e603b 100644 --- a/src/insets/inset.C +++ b/src/insets/inset.C @@ -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" diff --git a/src/insets/insetbutton.C b/src/insets/insetbutton.C index 52cdd30025..704890110e 100644 --- a/src/insets/insetbutton.C +++ b/src/insets/insetbutton.C @@ -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" diff --git a/src/insets/insetcaption.C b/src/insets/insetcaption.C index 1414e2d438..de9f0e4f65 100644 --- a/src/insets/insetcaption.C +++ b/src/insets/insetcaption.C @@ -15,7 +15,7 @@ #endif #include "insetcaption.h" -#include "Painter.h" +#include "frontends/Painter.h" #include "font.h" #include "BufferView.h" #include "FloatList.h" diff --git a/src/insets/insetcollapsable.C b/src/insets/insetcollapsable.C index df7d33887a..b7e8c5df97 100644 --- a/src/insets/insetcollapsable.C +++ b/src/insets/insetcollapsable.C @@ -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" diff --git a/src/insets/insetcommand.C b/src/insets/insetcommand.C index 8c64fd76e5..6fe86786ab 100644 --- a/src/insets/insetcommand.C +++ b/src/insets/insetcommand.C @@ -16,7 +16,7 @@ #include "insetcommand.h" #include "debug.h" -#include "Painter.h" +#include "frontends/Painter.h" #include "lyxlex.h" using std::ostream; diff --git a/src/insets/inseterror.C b/src/insets/inseterror.C index c16d351586..23924528ac 100644 --- a/src/insets/inseterror.C +++ b/src/insets/inseterror.C @@ -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; diff --git a/src/insets/insetgraphics.C b/src/insets/insetgraphics.C index b913292146..3ba1248838 100644 --- a/src/insets/insetgraphics.C +++ b/src/insets/insetgraphics.C @@ -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" diff --git a/src/insets/insetgraphicsParams.C b/src/insets/insetgraphicsParams.C index e402934d0e..7268faab52 100644 --- a/src/insets/insetgraphicsParams.C +++ b/src/insets/insetgraphicsParams.C @@ -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(); diff --git a/src/insets/insetlatexaccent.C b/src/insets/insetlatexaccent.C index 6413256e00..0fbcd32cc5 100644 --- a/src/insets/insetlatexaccent.C +++ b/src/insets/insetlatexaccent.C @@ -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" diff --git a/src/insets/insetquotes.C b/src/insets/insetquotes.C index 4b7e678edf..f4ca0a9870 100644 --- a/src/insets/insetquotes.C +++ b/src/insets/insetquotes.C @@ -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" diff --git a/src/insets/insetspecialchar.C b/src/insets/insetspecialchar.C index b75d573b37..c89f168a5e 100644 --- a/src/insets/insetspecialchar.C +++ b/src/insets/insetspecialchar.C @@ -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" diff --git a/src/insets/insettabular.C b/src/insets/insettabular.C index d7c59e82bf..6c65dca7ff 100644 --- a/src/insets/insettabular.C +++ b/src/insets/insettabular.C @@ -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" diff --git a/src/insets/insettext.C b/src/insets/insettext.C index a433a3f35c..23741c9ebe 100644 --- a/src/insets/insettext.C +++ b/src/insets/insettext.C @@ -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; diff --git a/src/mathed/ChangeLog b/src/mathed/ChangeLog index 20320422db..6b84e4adaf 100644 --- a/src/mathed/ChangeLog +++ b/src/mathed/ChangeLog @@ -1,3 +1,27 @@ +2002-05-23 John Levon + + * 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 * math_exintinset.C: use more specific smart_ptr header. diff --git a/src/mathed/formula.C b/src/mathed/formula.C index c145aa8fb5..415b0e0f42 100644 --- a/src/mathed/formula.C +++ b/src/mathed/formula.C @@ -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" diff --git a/src/mathed/formulabase.C b/src/mathed/formulabase.C index 4478ee47ac..865faf7026 100644 --- a/src/mathed/formulabase.C +++ b/src/mathed/formulabase.C @@ -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" diff --git a/src/mathed/formulamacro.C b/src/mathed/formulamacro.C index 5c1d85181e..51cfcdf4bd 100644 --- a/src/mathed/formulamacro.C +++ b/src/mathed/formulamacro.C @@ -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" diff --git a/src/mathed/math_binaryopinset.C b/src/mathed/math_binaryopinset.C index b20a12fbca..9a447379ad 100644 --- a/src/mathed/math_binaryopinset.C +++ b/src/mathed/math_binaryopinset.C @@ -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" diff --git a/src/mathed/math_casesinset.C b/src/mathed/math_casesinset.C index cf3b21ff54..01acf76812 100644 --- a/src/mathed/math_casesinset.C +++ b/src/mathed/math_casesinset.C @@ -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) diff --git a/src/mathed/math_charinset.C b/src/mathed/math_charinset.C index 71a3609ccf..85cdcc6bb9 100644 --- a/src/mathed/math_charinset.C +++ b/src/mathed/math_charinset.C @@ -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" diff --git a/src/mathed/math_cursor.C b/src/mathed/math_cursor.C index 209bcb8a97..36834e7612 100644 --- a/src/mathed/math_cursor.C +++ b/src/mathed/math_cursor.C @@ -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" diff --git a/src/mathed/math_fracinset.C b/src/mathed/math_fracinset.C index 69f935689e..cc7efc8890 100644 --- a/src/mathed/math_fracinset.C +++ b/src/mathed/math_fracinset.C @@ -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" diff --git a/src/mathed/math_funcinset.C b/src/mathed/math_funcinset.C index 6f24b2f475..ce617c6aef 100644 --- a/src/mathed/math_funcinset.C +++ b/src/mathed/math_funcinset.C @@ -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" diff --git a/src/mathed/math_gridinset.C b/src/mathed/math_gridinset.C index b6663b9378..0b7a7ea3c6 100644 --- a/src/mathed/math_gridinset.C +++ b/src/mathed/math_gridinset.C @@ -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" diff --git a/src/mathed/math_hullinset.C b/src/mathed/math_hullinset.C index 8e52adb9e0..75bc87bf5b 100644 --- a/src/mathed/math_hullinset.C +++ b/src/mathed/math_hullinset.C @@ -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" diff --git a/src/mathed/math_macro.C b/src/mathed/math_macro.C index ef3bf5da1b..d80be9f55e 100644 --- a/src/mathed/math_macro.C +++ b/src/mathed/math_macro.C @@ -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" diff --git a/src/mathed/math_macrotemplate.C b/src/mathed/math_macrotemplate.C index 6ba92c30d3..7d518782d0 100644 --- a/src/mathed/math_macrotemplate.C +++ b/src/mathed/math_macrotemplate.C @@ -4,7 +4,7 @@ #include "math_macrotemplate.h" #include "math_mathmlstream.h" -#include "Painter.h" +#include "frontends/Painter.h" #include "debug.h" diff --git a/src/mathed/math_rootinset.C b/src/mathed/math_rootinset.C index 2a7185895d..98b8423f94 100644 --- a/src/mathed/math_rootinset.C +++ b/src/mathed/math_rootinset.C @@ -17,7 +17,7 @@ #include "math_rootinset.h" #include "math_mathmlstream.h" -#include "Painter.h" +#include "frontends/Painter.h" using std::max; diff --git a/src/mathed/math_spaceinset.C b/src/mathed/math_spaceinset.C index d6da0ed575..5fb4367300 100644 --- a/src/mathed/math_spaceinset.C +++ b/src/mathed/math_spaceinset.C @@ -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" diff --git a/src/mathed/math_sqrtinset.C b/src/mathed/math_sqrtinset.C index 3470a41d06..3b6a330cbd 100644 --- a/src/mathed/math_sqrtinset.C +++ b/src/mathed/math_sqrtinset.C @@ -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" diff --git a/src/mathed/math_stringinset.C b/src/mathed/math_stringinset.C index 7ad73aa37e..988ac65208 100644 --- a/src/mathed/math_stringinset.C +++ b/src/mathed/math_stringinset.C @@ -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" diff --git a/src/mathed/math_support.C b/src/mathed/math_support.C index d6c2d425d3..940d3f0dfb 100644 --- a/src/mathed/math_support.C +++ b/src/mathed/math_support.C @@ -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" diff --git a/src/mathed/math_unknowninset.C b/src/mathed/math_unknowninset.C index 3c8b54319a..4a3088a189 100644 --- a/src/mathed/math_unknowninset.C +++ b/src/mathed/math_unknowninset.C @@ -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" diff --git a/src/mathed/math_xdata.C b/src/mathed/math_xdata.C index 292d82d7b1..ed5baeebeb 100644 --- a/src/mathed/math_xdata.C +++ b/src/mathed/math_xdata.C @@ -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" diff --git a/src/mathed/math_xyarrowinset.C b/src/mathed/math_xyarrowinset.C index 5f3489f3e3..f2d62fb84a 100644 --- a/src/mathed/math_xyarrowinset.C +++ b/src/mathed/math_xyarrowinset.C @@ -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" diff --git a/src/screen.C b/src/screen.C index 55581953ce..26ab6e7973 100644 --- a/src/screen.C +++ b/src/screen.C @@ -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" diff --git a/src/tabular.C b/src/tabular.C index fbeae9e5c5..3ba8ca8bf0 100644 --- a/src/tabular.C +++ b/src/tabular.C @@ -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" diff --git a/src/text.C b/src/text.C index aad37b3505..469e0e929f 100644 --- a/src/text.C +++ b/src/text.C @@ -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" diff --git a/src/text2.C b/src/text2.C index ba98a27f32..f45841a810 100644 --- a/src/text2.C +++ b/src/text2.C @@ -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