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
|
2004-04-07 20:20:15 +00:00
|
|
|
virtual void 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
|
|
|
|
*/
|
2004-04-07 20:20:15 +00:00
|
|
|
virtual void 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
|
2004-04-07 20:20:15 +00:00
|
|
|
virtual void rectangle(
|
2002-06-19 03:38:44 +00:00
|
|
|
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
|
2004-04-07 20:20:15 +00:00
|
|
|
virtual void fillRectangle(
|
2002-06-19 03:38:44 +00:00
|
|
|
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
|
2004-04-07 20:20:15 +00:00
|
|
|
virtual void 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
|
2004-04-07 20:20:15 +00:00
|
|
|
virtual void arc(
|
2002-06-19 03:38:44 +00:00
|
|
|
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
|
2004-04-07 20:20:15 +00:00
|
|
|
virtual void point(
|
2002-06-19 03:38:44 +00:00
|
|
|
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
|
2004-04-07 20:20:15 +00:00
|
|
|
virtual void image(int x, int y,
|
2002-06-19 03:38:44 +00:00
|
|
|
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)
|
2004-04-07 20:20:15 +00:00
|
|
|
virtual void 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
|
|
|
|
*/
|
2004-04-07 20:20:15 +00:00
|
|
|
virtual void text(int x, int y,
|
2002-06-19 03:38:44 +00:00
|
|
|
char const * str, size_t l,
|
|
|
|
LyXFont const & f);
|
|
|
|
|
|
|
|
/// draw a char at position x, y (y is the baseline)
|
2004-04-07 20:20:15 +00:00
|
|
|
virtual void text(int x, int y,
|
2002-06-19 03:38:44 +00:00
|
|
|
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
|