ws changes and some cruft removal, slight cleanup

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@3742 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Lars Gullik Bjønnes 2002-03-13 13:22:54 +00:00
parent ad6d9e444b
commit dd0277f83d
5 changed files with 99 additions and 102 deletions

View File

@ -1,3 +1,13 @@
2002-03-13 Lars Gullik Bjønnes <larsbj@birdstep.com>
* Painter.C (display): anon helper function, adjust code for this
change.
(pixmap): remove function.
* Painter.h: remove private display variable.
* PainterBase.[Ch]: remove dummy[123] cruft, ws changes
2002-03-13 Angus Leeming <a.leeming@ic.ac.uk>
* WorkArea.[Ch]: remove figinset_canvas cruft.

View File

@ -34,21 +34,31 @@
#include <cmath>
using std::endl;
using std::max;
namespace {
inline
Display * display()
{
return GUIRunTime::x11Display();
}
}
Painter::Painter(WorkArea & wa)
: PainterBase(wa)
{
display = GUIRunTime::x11Display();
}
{}
// Basic drawing routines
PainterBase & Painter::point(int x, int y, LColor::color c)
{
XDrawPoint(display, owner.getPixmap(),
XDrawPoint(display(), owner.getPixmap(),
lyxColorHandler->getGCForeground(c), x, y);
return *this;
}
@ -59,7 +69,7 @@ PainterBase & Painter::line(int x1, int y1, int x2, int y2,
enum line_style ls,
enum line_width lw)
{
XDrawLine(display, owner.getPixmap(),
XDrawLine(display(), owner.getPixmap(),
lyxColorHandler->getGCLinepars(ls, lw, col),
x1, y1, x2, y2);
return *this;
@ -78,7 +88,7 @@ PainterBase & Painter::lines(int const * xp, int const * yp, int np,
points[i].y = yp[i];
}
XDrawLines(display, owner.getPixmap(),
XDrawLines(display(), owner.getPixmap(),
lyxColorHandler->getGCLinepars(ls, lw, col),
points.get(), np, CoordModeOrigin);
@ -91,7 +101,7 @@ PainterBase & Painter::rectangle(int x, int y, int w, int h,
enum line_style ls,
enum line_width lw)
{
XDrawRectangle(display, owner.getPixmap(),
XDrawRectangle(display(), owner.getPixmap(),
lyxColorHandler->getGCLinepars(ls, lw, col),
x, y, w, h);
return *this;
@ -101,7 +111,7 @@ PainterBase & Painter::rectangle(int x, int y, int w, int h,
PainterBase & Painter::fillRectangle(int x, int y, int w, int h,
LColor::color col)
{
XFillRectangle(display, owner.getPixmap(),
XFillRectangle(display(), owner.getPixmap(),
lyxColorHandler->getGCForeground(col), x, y, w, h);
return *this;
}
@ -117,7 +127,7 @@ PainterBase & Painter::fillPolygon(int const * xp, int const * yp, int np,
points[i].y = yp[i];
}
XFillPolygon(display, owner.getPixmap(),
XFillPolygon(display(), owner.getPixmap(),
lyxColorHandler->getGCForeground(col), points.get(), np,
Nonconvex, CoordModeOrigin);
@ -129,7 +139,7 @@ PainterBase & Painter::arc(int x, int y,
unsigned int w, unsigned int h,
int a1, int a2, LColor::color col)
{
XDrawArc(display, owner.getPixmap(),
XDrawArc(display(), owner.getPixmap(),
lyxColorHandler->getGCForeground(col),
x, y, w, h, a1, a2);
return *this;
@ -150,7 +160,7 @@ PainterBase & Painter::segments(int const * x1, int const * y1,
s[i].x2 = x2[i];
s[i].y2 = y2[i];
}
XDrawSegments(display, owner.getPixmap(),
XDrawSegments(display(), owner.getPixmap(),
lyxColorHandler->getGCLinepars(ls, lw, col),
s.get(), ns);
@ -158,23 +168,17 @@ PainterBase & Painter::segments(int const * x1, int const * y1,
}
PainterBase & Painter::pixmap(int x, int y, int w, int h, Pixmap bitmap)
{
XGCValues val;
val.function = GXcopy;
GC gc = XCreateGC(display, owner.getPixmap(),
GCFunction, &val);
XCopyArea(display, bitmap, owner.getPixmap(), gc,
0, 0, w, h, x, y);
XFreeGC(display, gc);
return *this;
}
PainterBase & Painter::image(int x, int y, int w, int h,
grfx::GImage const & image)
{
return pixmap(x, y, w, h, image.getPixmap());
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;
}
@ -216,8 +220,8 @@ PainterBase & Painter::text(int x, int y, char const * s, size_t ls,
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);
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);
@ -225,13 +229,13 @@ PainterBase & Painter::text(int x, int y, char const * s, size_t ls,
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,
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,
lyxfont::XSetFont(display(), gc, f);
XDrawString(display(), owner.getPixmap(), gc,
tmpx, y, &c, 1);
tmpx += lyxfont::XTextWidth(f, &c, 1);
}
@ -251,8 +255,8 @@ PainterBase & Painter::text(int x, int y, XChar2b const * s, int ls,
{
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);
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);
@ -266,13 +270,13 @@ PainterBase & Painter::text(int x, int y, XChar2b const * s, int ls,
c.byte2 = uppercase(s[i].byte2);
}
if (c.byte2 != s[i].byte2) {
lyxfont::XSetFont(display, gc, smallfont);
XDrawString16(display, owner.getPixmap(), gc,
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,
lyxfont::XSetFont(display(), gc, f);
XDrawString16(display(), owner.getPixmap(), gc,
tmpx, y, &c, 1);
tmpx += lyxfont::XTextWidth16(f, &c, 1);
}

View File

@ -26,7 +26,6 @@ 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 {
@ -79,9 +78,6 @@ public:
PainterBase & image(int x, int y, int w, int h,
grfx::GImage const & image);
/// For the figinset
PainterBase & pixmap(int x, int y, int w, int h, Pixmap bitmap);
/// Draw a string at position x, y (y is the baseline)
PainterBase & text(int x, int y,
string const & str, LyXFont const & f);
@ -100,9 +96,6 @@ public:
private:
/// Check the font, and if set, draw an underline
void underline(LyXFont const & f, int x, int y, int width);
///
Display * display;
};
#endif

View File

@ -18,9 +18,6 @@
#include "WorkArea.h"
#include "font.h"
int PainterBase::dummy1 = 0;
int PainterBase::dummy2 = 0;
int PainterBase::dummy3 = 0;
int PainterBase::paperMargin() const
{
@ -74,16 +71,16 @@ PainterBase & PainterBase::buttonFrame(int x, int y, int w, int h)
// 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[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;
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;

View File

@ -36,13 +36,6 @@ namespace grfx {
*/
class PainterBase {
protected:
///
static int dummy1;
///
static int dummy2;
///
static int dummy3;
public:
///
enum line_width {