2002-06-19 03:38:44 +00:00
|
|
|
// -*- C++ -*-
|
|
|
|
/**
|
|
|
|
* \file QLPainter.h
|
2002-09-24 13:57:09 +00:00
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
2002-06-19 03:38:44 +00:00
|
|
|
*
|
2002-09-24 13:57:09 +00:00
|
|
|
* \author John Levon
|
|
|
|
*
|
2003-08-23 00:17:00 +00:00
|
|
|
* Full author contact details are available in file CREDITS.
|
2002-06-19 03:38:44 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef QLPAINTER_H
|
|
|
|
#define QLPAINTER_H
|
|
|
|
|
|
|
|
#include "Painter.h"
|
|
|
|
|
2002-09-24 13:57:09 +00:00
|
|
|
#include <boost/scoped_ptr.hpp>
|
|
|
|
|
2002-06-19 03:38:44 +00:00
|
|
|
class LyXFont;
|
|
|
|
class QWorkArea;
|
|
|
|
class QPainter;
|
2002-10-15 15:13:49 +00:00
|
|
|
class QString;
|
2002-06-19 03:38:44 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* QLPainter - a painter implementation for Xlib
|
|
|
|
*/
|
|
|
|
class QLPainter : public Painter {
|
|
|
|
public:
|
|
|
|
QLPainter(QWorkArea &);
|
2002-09-24 13:57:09 +00:00
|
|
|
|
2002-06-19 03:38:44 +00:00
|
|
|
/// begin painting
|
|
|
|
virtual void start();
|
|
|
|
|
|
|
|
/// end painting
|
|
|
|
virtual void end();
|
2002-09-24 13:57:09 +00:00
|
|
|
|
2002-06-19 03:38:44 +00:00
|
|
|
/// return the width of the work area in pixels
|
|
|
|
virtual int paperWidth() const;
|
|
|
|
/// return the height of the work area in pixels
|
|
|
|
virtual int paperHeight() const;
|
|
|
|
|
|
|
|
/// draw a line from point to point
|
|
|
|
virtual Painter & line(
|
2002-09-24 13:57:09 +00:00
|
|
|
int x1, int y1,
|
2002-06-19 03:38:44 +00:00
|
|
|
int x2, int y2,
|
2003-09-18 11:48:11 +00:00
|
|
|
LColor_color,
|
2002-06-19 03:38:44 +00:00
|
|
|
line_style = line_solid,
|
|
|
|
line_width = line_thin);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* lines - draw a set of lines
|
|
|
|
* @param xp array of points' x co-ords
|
|
|
|
* @param yp array of points' y co-ords
|
|
|
|
* @param np size of the points array
|
|
|
|
*/
|
|
|
|
virtual Painter & lines(
|
2002-09-24 13:57:09 +00:00
|
|
|
int const * xp,
|
|
|
|
int const * yp,
|
2002-06-19 03:38:44 +00:00
|
|
|
int np,
|
2003-09-18 11:48:11 +00:00
|
|
|
LColor_color,
|
2002-06-19 03:38:44 +00:00
|
|
|
line_style = line_solid,
|
|
|
|
line_width = line_thin);
|
|
|
|
|
|
|
|
/// draw a rectangle
|
|
|
|
virtual Painter & rectangle(
|
|
|
|
int x, int y,
|
|
|
|
int w, int h,
|
2003-09-18 11:48:11 +00:00
|
|
|
LColor_color,
|
2002-06-19 03:38:44 +00:00
|
|
|
line_style = line_solid,
|
|
|
|
line_width = line_thin);
|
2002-09-24 13:57:09 +00:00
|
|
|
|
2002-06-19 03:38:44 +00:00
|
|
|
/// draw a filled rectangle
|
|
|
|
virtual Painter & fillRectangle(
|
|
|
|
int x, int y,
|
|
|
|
int w, int h,
|
2003-09-18 11:48:11 +00:00
|
|
|
LColor_color);
|
2002-09-24 13:57:09 +00:00
|
|
|
|
2002-06-19 03:38:44 +00:00
|
|
|
/// draw a filled (irregular) polygon
|
|
|
|
virtual Painter & fillPolygon(
|
2002-09-24 13:57:09 +00:00
|
|
|
int const * xp,
|
|
|
|
int const * yp,
|
2002-06-19 03:38:44 +00:00
|
|
|
int np,
|
2003-09-18 11:48:11 +00:00
|
|
|
LColor_color);
|
2002-09-24 13:57:09 +00:00
|
|
|
|
2002-06-19 03:38:44 +00:00
|
|
|
/// draw an arc
|
|
|
|
virtual Painter & arc(
|
|
|
|
int x, int y,
|
|
|
|
unsigned int w, unsigned int h,
|
|
|
|
int a1, int a2,
|
2003-09-18 11:48:11 +00:00
|
|
|
LColor_color);
|
2002-09-24 13:57:09 +00:00
|
|
|
|
2002-06-19 03:38:44 +00:00
|
|
|
/// draw a pixel
|
|
|
|
virtual Painter & point(
|
|
|
|
int x, int y,
|
2003-09-18 11:48:11 +00:00
|
|
|
LColor_color);
|
2002-09-24 13:57:09 +00:00
|
|
|
|
2002-06-19 03:38:44 +00:00
|
|
|
/// draw an image from the image cache
|
|
|
|
virtual Painter & image(int x, int y,
|
|
|
|
int w, int h,
|
2003-07-04 08:23:23 +00:00
|
|
|
lyx::graphics::Image const & image);
|
2002-09-24 13:57:09 +00:00
|
|
|
|
2002-06-19 03:38:44 +00:00
|
|
|
/// draw a string at position x, y (y is the baseline)
|
|
|
|
virtual Painter & text(int x, int y,
|
2003-10-06 15:43:21 +00:00
|
|
|
std::string const & str, LyXFont const & f);
|
2002-06-19 03:38:44 +00:00
|
|
|
|
|
|
|
/** Draw a string at position x, y (y is the baseline)
|
|
|
|
* This is just for fast drawing
|
|
|
|
*/
|
|
|
|
virtual Painter & 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)
|
|
|
|
virtual Painter & text(int x, int y,
|
|
|
|
char c, LyXFont const & f);
|
|
|
|
private:
|
|
|
|
/// draw small caps text
|
|
|
|
void smallCapsText(int x, int y,
|
2002-10-15 15:13:49 +00:00
|
|
|
QString const & str, LyXFont const & f);
|
2002-06-19 03:38:44 +00:00
|
|
|
|
|
|
|
/// set pen parameters
|
2003-09-18 11:48:11 +00:00
|
|
|
QPainter & setPen(LColor_color c,
|
2002-06-19 03:38:44 +00:00
|
|
|
line_style ls = line_solid,
|
|
|
|
line_width lw = line_thin);
|
2002-09-24 13:57:09 +00:00
|
|
|
|
2002-06-19 03:38:44 +00:00
|
|
|
/// our owner who we paint upon
|
|
|
|
QWorkArea & owner_;
|
|
|
|
|
|
|
|
/// our qt painter
|
|
|
|
boost::scoped_ptr<QPainter> qp_;
|
2002-09-24 13:57:09 +00:00
|
|
|
|
2002-06-19 03:38:44 +00:00
|
|
|
/// recursion check
|
|
|
|
int paint_check_;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // QLPAINTER_H
|