2000-02-10 17:53:36 +00:00
|
|
|
// -*- C++ -*-
|
2002-06-12 15:01:32 +00:00
|
|
|
/**
|
|
|
|
* \file Painter.h
|
2002-09-05 15:14:23 +00:00
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
2002-03-21 17:27:08 +00:00
|
|
|
*
|
2002-06-12 15:01:32 +00:00
|
|
|
* \author unknown
|
2002-11-27 10:30:28 +00:00
|
|
|
* \author John Levon
|
2002-09-05 14:10:50 +00:00
|
|
|
*
|
2003-08-23 00:17:00 +00:00
|
|
|
* Full author contact details are available in file CREDITS.
|
2002-06-12 15:01:32 +00:00
|
|
|
*/
|
2000-02-10 17:53:36 +00:00
|
|
|
|
2002-06-12 15:01:32 +00:00
|
|
|
#ifndef PAINTER_H
|
|
|
|
#define PAINTER_H
|
2000-02-10 17:53:36 +00:00
|
|
|
|
2004-11-16 23:18:46 +00:00
|
|
|
#include "LColor.h"
|
|
|
|
|
2003-10-06 15:43:21 +00:00
|
|
|
#include <string>
|
2000-02-10 17:53:36 +00:00
|
|
|
|
2003-09-15 15:20:22 +00:00
|
|
|
|
2000-02-10 17:53:36 +00:00
|
|
|
class LyXFont;
|
2002-06-12 15:01:32 +00:00
|
|
|
|
2003-07-04 08:23:23 +00:00
|
|
|
namespace lyx {
|
|
|
|
namespace graphics {
|
2002-06-28 11:22:56 +00:00
|
|
|
class Image;
|
2002-02-27 09:59:52 +00:00
|
|
|
}
|
2003-07-04 08:23:23 +00:00
|
|
|
}
|
|
|
|
|
2000-02-10 17:53:36 +00:00
|
|
|
|
2002-06-12 15:01:32 +00:00
|
|
|
/**
|
|
|
|
* Painter - A painter class to encapsulate all graphics parameters and operations
|
|
|
|
*
|
|
|
|
* Every graphics operation in LyX should be made by this class. The
|
|
|
|
* painter is used for drawing on the WorkArea, and is passed around
|
|
|
|
* during draw operations.
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* The intention for a toolkit is that it uses these methods to paint
|
|
|
|
* onto a backing pixmap. Only when expose events arrive via the event
|
|
|
|
* queue (perhaps generated via Screen::expose), does the copy onto
|
|
|
|
* the actual WorkArea widget take place. Paints are wrapped in (possibly
|
|
|
|
* recursive) calls to start() and end() to facilitate the backing pixmap
|
|
|
|
* management.
|
|
|
|
*
|
|
|
|
* Note that the methods return *this for convenience.
|
2000-02-10 17:53:36 +00:00
|
|
|
*/
|
2002-06-12 15:01:32 +00:00
|
|
|
class Painter {
|
2000-02-10 17:53:36 +00:00
|
|
|
public:
|
2002-06-12 15:01:32 +00:00
|
|
|
/// possible line widths
|
2000-02-10 17:53:36 +00:00
|
|
|
enum line_width {
|
2002-06-12 15:01:32 +00:00
|
|
|
line_thin, //< thin line
|
|
|
|
line_thick //< thick line
|
2000-02-10 17:53:36 +00:00
|
|
|
};
|
2002-03-21 17:27:08 +00:00
|
|
|
|
2002-06-12 15:01:32 +00:00
|
|
|
/// possible line styles
|
2000-02-10 17:53:36 +00:00
|
|
|
enum line_style {
|
2002-06-12 15:01:32 +00:00
|
|
|
line_solid, //< solid line
|
|
|
|
line_onoffdash //< dashes with spaces
|
2000-02-10 17:53:36 +00:00
|
|
|
};
|
2002-03-21 17:27:08 +00:00
|
|
|
|
2002-06-12 15:01:32 +00:00
|
|
|
virtual ~Painter() {}
|
|
|
|
|
|
|
|
/// begin painting
|
|
|
|
virtual void start() {}
|
2002-11-27 10:30:28 +00:00
|
|
|
|
2002-06-12 15:01:32 +00:00
|
|
|
/// end painting
|
|
|
|
virtual void end() {}
|
2002-11-27 10:30:28 +00:00
|
|
|
|
2002-06-12 15:01:32 +00:00
|
|
|
/// return the width of the work area in pixels
|
|
|
|
virtual int paperWidth() const = 0;
|
|
|
|
/// return the height of the work area in pixels
|
|
|
|
virtual int paperHeight() const = 0;
|
|
|
|
|
|
|
|
/// draw a line from point to point
|
2004-04-07 20:20:15 +00:00
|
|
|
virtual void line(
|
2002-06-12 15:01:32 +00:00
|
|
|
int x1, int y1,
|
|
|
|
int x2, int y2,
|
2003-09-18 11:48:11 +00:00
|
|
|
LColor_color,
|
2002-06-12 15:01:32 +00:00
|
|
|
line_style = line_solid,
|
|
|
|
line_width = line_thin) = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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-06-12 15:01:32 +00:00
|
|
|
int const * xp,
|
|
|
|
int const * yp,
|
2000-02-10 17:53:36 +00:00
|
|
|
int np,
|
2003-09-18 11:48:11 +00:00
|
|
|
LColor_color,
|
2002-06-12 15:01:32 +00:00
|
|
|
line_style = line_solid,
|
|
|
|
line_width = line_thin) = 0;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
2002-06-12 15:01:32 +00:00
|
|
|
/// draw a rectangle
|
2004-04-07 20:20:15 +00:00
|
|
|
virtual void rectangle(
|
2002-06-12 15:01:32 +00:00
|
|
|
int x, int y,
|
|
|
|
int w, int h,
|
2003-09-18 11:48:11 +00:00
|
|
|
LColor_color,
|
2002-06-12 15:01:32 +00:00
|
|
|
line_style = line_solid,
|
|
|
|
line_width = line_thin) = 0;
|
2002-11-27 10:30:28 +00:00
|
|
|
|
2002-06-12 15:01:32 +00:00
|
|
|
/// draw a filled rectangle
|
2004-04-07 20:20:15 +00:00
|
|
|
virtual void fillRectangle(
|
2000-02-10 17:53:36 +00:00
|
|
|
int x, int y,
|
2002-06-12 15:01:32 +00:00
|
|
|
int w, int h,
|
2003-09-18 11:48:11 +00:00
|
|
|
LColor_color) = 0;
|
2002-11-27 10:30:28 +00:00
|
|
|
|
2002-06-12 15:01:32 +00:00
|
|
|
/// draw a filled (irregular) polygon
|
2004-04-07 20:20:15 +00:00
|
|
|
virtual void fillPolygon(
|
2002-06-12 15:01:32 +00:00
|
|
|
int const * xp,
|
|
|
|
int const * yp,
|
|
|
|
int np,
|
2003-09-18 11:48:11 +00:00
|
|
|
LColor_color) = 0;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
2002-06-12 15:01:32 +00:00
|
|
|
/// draw an arc
|
2004-04-07 20:20:15 +00:00
|
|
|
virtual void arc(
|
2000-02-10 17:53:36 +00:00
|
|
|
int x, int y,
|
2002-03-21 17:27:08 +00:00
|
|
|
unsigned int w, unsigned int h,
|
2000-02-10 17:53:36 +00:00
|
|
|
int a1, int a2,
|
2003-09-18 11:48:11 +00:00
|
|
|
LColor_color) = 0;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
2002-06-12 15:01:32 +00:00
|
|
|
/// draw a pixel
|
2004-04-07 20:20:15 +00:00
|
|
|
virtual void point(
|
2000-02-10 17:53:36 +00:00
|
|
|
int x, int y,
|
2003-09-18 11:48:11 +00:00
|
|
|
LColor_color) = 0;
|
2002-11-27 10:30:28 +00:00
|
|
|
|
2002-06-12 15:01:32 +00:00
|
|
|
/// draw a filled rectangle with the shape of a 3D button
|
2004-04-07 20:20:15 +00:00
|
|
|
virtual void button(int x, int y,
|
2002-06-12 15:01:32 +00:00
|
|
|
int w, int h);
|
|
|
|
|
|
|
|
/// draw an image from the image cache
|
2004-04-07 20:20:15 +00:00
|
|
|
virtual void image(int x, int y,
|
2002-06-12 15:01:32 +00:00
|
|
|
int w, int h,
|
2003-07-04 08:23:23 +00:00
|
|
|
lyx::graphics::Image const & image) = 0;
|
2002-11-27 10:30:28 +00:00
|
|
|
|
2002-06-12 15:01:32 +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) = 0;
|
2002-06-12 15:01:32 +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-12 15:01:32 +00:00
|
|
|
char const * str, size_t l,
|
|
|
|
LyXFont const & f) = 0;
|
|
|
|
|
|
|
|
/// 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-12 15:01:32 +00:00
|
|
|
char c, LyXFont const & f) = 0;
|
|
|
|
|
2002-07-09 16:23:20 +00:00
|
|
|
/**
|
|
|
|
* Draw a string and enclose it inside a rectangle. If
|
|
|
|
* back color is specified, the background is cleared with
|
|
|
|
* the given color. If frame is specified, a thin frame is drawn
|
|
|
|
* around the text with the given color.
|
|
|
|
*/
|
2004-04-07 20:20:15 +00:00
|
|
|
virtual void rectText(int x, int baseline,
|
2003-10-06 15:43:21 +00:00
|
|
|
std::string const & str,
|
2002-06-12 15:01:32 +00:00
|
|
|
LyXFont const & font,
|
2003-09-18 11:48:11 +00:00
|
|
|
LColor_color back,
|
|
|
|
LColor_color frame);
|
2002-06-12 15:01:32 +00:00
|
|
|
|
|
|
|
/// draw a string and enclose it inside a button frame
|
2004-04-07 20:20:15 +00:00
|
|
|
virtual void buttonText(int x,
|
2003-10-06 15:43:21 +00:00
|
|
|
int baseline, std::string const & s,
|
2002-06-12 15:01:32 +00:00
|
|
|
LyXFont const & font);
|
2002-03-21 17:27:08 +00:00
|
|
|
|
2000-02-18 22:22:42 +00:00
|
|
|
protected:
|
2002-06-12 15:01:32 +00:00
|
|
|
/// check the font, and if set, draw an underline
|
2004-04-07 20:20:15 +00:00
|
|
|
virtual void underline(LyXFont const & f,
|
2002-06-12 15:01:32 +00:00
|
|
|
int x, int y, int width);
|
2002-11-27 10:30:28 +00:00
|
|
|
|
2002-06-12 15:01:32 +00:00
|
|
|
/// draw a bevelled button border
|
2004-04-07 20:20:15 +00:00
|
|
|
virtual void buttonFrame(int x, int y, int w, int h);
|
2000-02-10 17:53:36 +00:00
|
|
|
};
|
|
|
|
|
2002-06-12 15:01:32 +00:00
|
|
|
#endif // PAINTER_H
|