2000-02-10 17:53:36 +00:00
|
|
|
// -*- C++ -*-
|
|
|
|
/* This file is part of
|
|
|
|
* ======================================================
|
2002-03-21 17:27:08 +00:00
|
|
|
*
|
2000-02-10 17:53:36 +00:00
|
|
|
* LyX, The Document Processor
|
2002-03-21 17:27:08 +00:00
|
|
|
*
|
2001-05-30 13:53:44 +00:00
|
|
|
* Copyright 1998-2001 The LyX Team
|
2000-02-10 17:53:36 +00:00
|
|
|
*
|
|
|
|
*======================================================*/
|
|
|
|
|
|
|
|
#ifndef PAINTERBASE_H
|
|
|
|
#define PAINTERBASE_H
|
|
|
|
|
|
|
|
#ifdef __GNUG__
|
|
|
|
#pragma interface
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "LString.h"
|
|
|
|
#include "LColor.h"
|
|
|
|
|
|
|
|
class WorkArea;
|
|
|
|
class LyXFont;
|
2002-02-27 09:59:52 +00:00
|
|
|
namespace grfx {
|
|
|
|
class GImage;
|
|
|
|
}
|
2000-02-10 17:53:36 +00:00
|
|
|
|
|
|
|
/** A painter class to encapsulate all graphics parameters and operations
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
|
|
Every graphics operation in LyX should be made by this class. It will
|
2000-02-10 17:53:36 +00:00
|
|
|
be initialized and managed by the Screen class, and will be passed
|
|
|
|
as a parameter to inset.
|
2002-03-21 17:27:08 +00:00
|
|
|
|
2000-02-10 17:53:36 +00:00
|
|
|
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.
|
2002-03-21 17:27:08 +00:00
|
|
|
|
2000-02-10 17:53:36 +00:00
|
|
|
*/
|
|
|
|
class PainterBase {
|
|
|
|
public:
|
|
|
|
///
|
|
|
|
enum line_width {
|
|
|
|
///
|
|
|
|
line_thin,
|
|
|
|
///
|
|
|
|
line_thick
|
|
|
|
};
|
2002-03-21 17:27:08 +00:00
|
|
|
|
2000-02-10 17:53:36 +00:00
|
|
|
///
|
|
|
|
enum line_style {
|
|
|
|
///
|
|
|
|
line_solid,
|
|
|
|
///
|
|
|
|
line_doubledash,
|
|
|
|
///
|
|
|
|
line_onoffdash
|
|
|
|
};
|
2002-03-21 17:27:08 +00:00
|
|
|
|
2000-02-10 17:53:36 +00:00
|
|
|
///
|
2000-04-08 17:02:02 +00:00
|
|
|
explicit PainterBase(WorkArea & wa) : owner(wa) {}
|
2002-03-21 17:27:08 +00:00
|
|
|
|
2000-02-10 17:53:36 +00:00
|
|
|
///
|
|
|
|
virtual ~PainterBase() {}
|
2002-03-21 17:27:08 +00:00
|
|
|
|
2000-08-07 20:58:24 +00:00
|
|
|
/* Screen geometry */
|
2000-02-10 17:53:36 +00:00
|
|
|
///
|
2000-02-17 19:59:08 +00:00
|
|
|
int paperMargin() const;
|
2000-02-10 17:53:36 +00:00
|
|
|
///
|
2000-02-17 19:59:08 +00:00
|
|
|
int paperWidth() const;
|
2000-06-12 11:27:15 +00:00
|
|
|
///
|
|
|
|
int paperHeight() const;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
2000-02-10 17:53:36 +00:00
|
|
|
/// Draw a line from point to point
|
|
|
|
virtual PainterBase & line(
|
2002-03-21 17:27:08 +00:00
|
|
|
int x1, int y1, int x2, int y2,
|
2000-02-10 17:53:36 +00:00
|
|
|
LColor::color = LColor::foreground,
|
|
|
|
enum line_style = line_solid,
|
|
|
|
enum line_width = line_thin) = 0;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
2000-02-10 17:53:36 +00:00
|
|
|
/** 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;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
2000-02-10 17:53:36 +00:00
|
|
|
/// Here xp and yp are arrays of points
|
|
|
|
virtual PainterBase & fillPolygon(
|
|
|
|
int const * xp, int const * yp,
|
|
|
|
int np,
|
2000-11-15 18:02:45 +00:00
|
|
|
LColor::color = LColor::foreground) = 0;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
2000-02-10 17:53:36 +00:00
|
|
|
/// Draw lines from x1,y1 to x2,y2. They are arrays
|
2002-03-21 17:27:08 +00:00
|
|
|
virtual PainterBase & segments(
|
|
|
|
int const * x1, int const * y1,
|
2000-02-10 17:53:36 +00:00
|
|
|
int const * x2, int const * y2, int ns,
|
|
|
|
LColor::color = LColor::foreground,
|
|
|
|
enum line_style = line_solid,
|
|
|
|
enum line_width = line_thin) = 0;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
|
|
/// Draw a rectangle
|
2000-02-10 17:53:36 +00:00
|
|
|
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;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
2000-02-10 17:53:36 +00:00
|
|
|
/// Draw a circle, d is the diameter, not the radious
|
|
|
|
virtual PainterBase & circle(
|
|
|
|
int x, int y, unsigned int d,
|
|
|
|
LColor::color = LColor::foreground);
|
2002-03-21 17:27:08 +00:00
|
|
|
|
2000-02-10 17:53:36 +00:00
|
|
|
/// Draw an ellipse
|
|
|
|
virtual PainterBase & ellipse(
|
|
|
|
int x, int y,
|
|
|
|
unsigned int w, unsigned int h,
|
|
|
|
LColor::color = LColor::foreground);
|
2002-03-21 17:27:08 +00:00
|
|
|
|
2000-02-10 17:53:36 +00:00
|
|
|
/// Draw an arc
|
|
|
|
virtual PainterBase & arc(
|
|
|
|
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,
|
|
|
|
LColor::color = LColor::foreground) = 0;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
2000-02-10 17:53:36 +00:00
|
|
|
/// Draw a pixel
|
|
|
|
virtual PainterBase & point(
|
|
|
|
int x, int y,
|
|
|
|
LColor::color = LColor::foreground) = 0;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
2000-02-10 17:53:36 +00:00
|
|
|
/// Fill a rectangle
|
|
|
|
virtual PainterBase & fillRectangle(
|
|
|
|
int x, int y, int w, int h,
|
2001-07-24 10:13:19 +00:00
|
|
|
LColor::color) = 0;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
2000-02-10 17:53:36 +00:00
|
|
|
/// A filled rectangle with the shape of a 3D button
|
|
|
|
virtual PainterBase & button(int x, int y, int w, int h);
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
|
|
///
|
|
|
|
virtual PainterBase & buttonFrame(int x, int y, int w, int h);
|
|
|
|
|
|
|
|
|
2000-08-07 20:58:24 +00:00
|
|
|
// For the figure inset
|
2002-02-27 09:59:52 +00:00
|
|
|
virtual PainterBase & image(int x, int y, int w, int h,
|
|
|
|
grfx::GImage const & image) = 0;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
2000-02-10 17:53:36 +00:00
|
|
|
/// Draw a string at position x, y (y is the baseline)
|
|
|
|
virtual PainterBase & text(int x, int y,
|
2000-09-14 17:53:12 +00:00
|
|
|
string const & str, LyXFont const & f) = 0;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
2000-02-10 17:53:36 +00:00
|
|
|
/** Draw a string at position x, y (y is the baseline)
|
|
|
|
This is just for fast drawing */
|
2000-09-27 18:13:30 +00:00
|
|
|
virtual PainterBase & text(int x, int y, char const * str, size_t l,
|
2002-03-13 13:22:54 +00:00
|
|
|
LyXFont const & f) = 0;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
2000-02-10 17:53:36 +00:00
|
|
|
/// Draw a char at position x, y (y is the baseline)
|
|
|
|
virtual PainterBase & text(int x, int y, char c, LyXFont const & f)=0;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
2001-07-30 11:56:00 +00:00
|
|
|
/** Draws a string and encloses it inside a rectangle. */
|
2002-03-21 17:27:08 +00:00
|
|
|
PainterBase & rectText(int x, int baseline,
|
|
|
|
string const & string,
|
2001-07-30 11:56:00 +00:00
|
|
|
LyXFont const & font,
|
|
|
|
LColor::color back,
|
2001-07-24 09:12:20 +00:00
|
|
|
LColor::color frame);
|
2002-03-21 17:27:08 +00:00
|
|
|
|
2001-07-30 11:56:00 +00:00
|
|
|
/** Draw a string and encloses it inside a button frame. */
|
2001-07-24 09:12:20 +00:00
|
|
|
PainterBase & buttonText(int x, int baseline, string const & s,
|
|
|
|
LyXFont const & font);
|
2000-02-18 22:22:42 +00:00
|
|
|
protected:
|
2000-08-07 20:58:24 +00:00
|
|
|
///
|
2000-02-10 17:53:36 +00:00
|
|
|
WorkArea & owner;
|
|
|
|
};
|
|
|
|
|
2002-05-23 09:21:32 +00:00
|
|
|
// VERY temporary
|
|
|
|
#include "xforms/XPainter.h"
|
2002-05-29 16:21:03 +00:00
|
|
|
|
2000-02-10 17:53:36 +00:00
|
|
|
#endif
|