2009-12-24 03:02:05 +01:00
|
|
|
/***************************************************************************
|
|
|
|
|
|
|
|
gb.paint.h
|
|
|
|
|
|
|
|
(c) 2000-2009 Benoît Minisini <gambas@users.sourceforge.net>
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2, or (at your option)
|
|
|
|
any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
|
|
|
|
***************************************************************************/
|
|
|
|
|
|
|
|
#ifndef __GB_PAINT_H
|
|
|
|
#define __GB_PAINT_H
|
|
|
|
|
|
|
|
#include "gb_common.h"
|
|
|
|
#include "gambas.h"
|
|
|
|
#include "gb.draw.h"
|
|
|
|
|
|
|
|
enum {
|
|
|
|
GB_PAINT_EXTEND_PAD,
|
|
|
|
GB_PAINT_EXTEND_REPEAT,
|
|
|
|
GB_PAINT_EXTEND_REFLECT
|
|
|
|
};
|
|
|
|
|
|
|
|
enum {
|
|
|
|
GB_PAINT_FILL_RULE_WINDING,
|
|
|
|
GB_PAINT_FILL_RULE_EVEN_ODD
|
|
|
|
};
|
|
|
|
|
|
|
|
enum {
|
|
|
|
GB_PAINT_LINE_CAP_BUTT,
|
|
|
|
GB_PAINT_LINE_CAP_ROUND,
|
|
|
|
GB_PAINT_LINE_CAP_SQUARE
|
|
|
|
};
|
|
|
|
|
|
|
|
enum {
|
|
|
|
GB_PAINT_LINE_JOIN_MITER,
|
|
|
|
GB_PAINT_LINE_JOIN_ROUND,
|
|
|
|
GB_PAINT_LINE_JOIN_BEVEL
|
|
|
|
};
|
|
|
|
|
|
|
|
enum {
|
|
|
|
GB_PAINT_OPERATOR_CLEAR,
|
|
|
|
GB_PAINT_OPERATOR_SOURCE,
|
|
|
|
GB_PAINT_OPERATOR_OVER,
|
|
|
|
GB_PAINT_OPERATOR_IN,
|
|
|
|
GB_PAINT_OPERATOR_OUT,
|
|
|
|
GB_PAINT_OPERATOR_ATOP,
|
|
|
|
GB_PAINT_OPERATOR_DEST,
|
|
|
|
GB_PAINT_OPERATOR_DEST_OVER,
|
|
|
|
GB_PAINT_OPERATOR_DEST_IN,
|
2009-12-24 16:09:08 +01:00
|
|
|
GB_PAINT_OPERATOR_DEST_OUT,
|
2009-12-24 03:02:05 +01:00
|
|
|
GB_PAINT_OPERATOR_DEST_ATOP,
|
|
|
|
GB_PAINT_OPERATOR_XOR,
|
|
|
|
GB_PAINT_OPERATOR_ADD,
|
|
|
|
GB_PAINT_OPERATOR_SATURATE
|
|
|
|
};
|
|
|
|
|
2009-12-24 16:09:08 +01:00
|
|
|
struct GB_PAINT_DESC;
|
|
|
|
|
2009-12-24 03:02:05 +01:00
|
|
|
typedef
|
|
|
|
struct {
|
2009-12-27 16:51:27 +01:00
|
|
|
float x1, y1, x2, y2;
|
2009-12-24 03:02:05 +01:00
|
|
|
}
|
|
|
|
GB_EXTENTS;
|
|
|
|
|
|
|
|
typedef
|
|
|
|
void *GB_BRUSH;
|
|
|
|
|
|
|
|
typedef
|
|
|
|
void *GB_TRANSFORM;
|
|
|
|
|
|
|
|
typedef
|
|
|
|
struct {
|
|
|
|
GB_BASE ob;
|
|
|
|
GB_EXTENTS ext;
|
|
|
|
}
|
|
|
|
PAINT_EXTENTS;
|
|
|
|
|
|
|
|
typedef
|
|
|
|
struct {
|
|
|
|
GB_BASE ob;
|
2009-12-24 16:09:08 +01:00
|
|
|
struct GB_PAINT_DESC *desc; // drawing driver
|
2009-12-28 02:19:27 +01:00
|
|
|
GB_TRANSFORM transform;
|
2009-12-24 03:02:05 +01:00
|
|
|
}
|
|
|
|
PAINT_MATRIX;
|
|
|
|
|
|
|
|
typedef
|
|
|
|
struct {
|
|
|
|
GB_BASE ob;
|
2009-12-24 16:09:08 +01:00
|
|
|
struct GB_PAINT_DESC *desc; // drawing driver
|
2009-12-28 02:19:27 +01:00
|
|
|
GB_BRUSH brush; // brush
|
2009-12-24 03:02:05 +01:00
|
|
|
}
|
|
|
|
PAINT_BRUSH;
|
|
|
|
|
|
|
|
typedef
|
|
|
|
struct GB_PAINT {
|
2009-12-24 16:09:08 +01:00
|
|
|
struct GB_PAINT_DESC *desc; // drawing driver
|
|
|
|
struct GB_PAINT *previous; // previous drawing context
|
2009-12-24 03:02:05 +01:00
|
|
|
void *device; // drawing object
|
2010-01-01 22:32:45 +01:00
|
|
|
double width; // device width in device coordinates
|
|
|
|
double height; // device height in device coordinates
|
2009-12-28 02:19:27 +01:00
|
|
|
int resolutionX; // device horizontal resolution in DPI
|
|
|
|
int resolutionY; // device vertical resolution in DPI
|
|
|
|
PAINT_BRUSH *brush; // current brush
|
|
|
|
void *extra; // driver-specific state
|
2009-12-24 03:02:05 +01:00
|
|
|
}
|
|
|
|
GB_PAINT;
|
|
|
|
|
|
|
|
typedef
|
|
|
|
struct GB_PAINT_DESC {
|
|
|
|
// Size of the GB_PAINT structure extra data
|
|
|
|
int size;
|
|
|
|
// Begins and terminates the drawing
|
|
|
|
int (*Begin)(GB_PAINT *d);
|
|
|
|
void (*End)(GB_PAINT *d);
|
|
|
|
|
|
|
|
void (*Save)(GB_PAINT *d);
|
|
|
|
void (*Restore)(GB_PAINT *d);
|
|
|
|
|
2009-12-28 02:19:27 +01:00
|
|
|
void (*Font)(GB_PAINT *d, int set, GB_FONT *font);
|
2009-12-24 03:02:05 +01:00
|
|
|
|
2009-12-28 02:19:27 +01:00
|
|
|
void (*Clip)(GB_PAINT *d, int preserve);
|
2009-12-24 03:02:05 +01:00
|
|
|
void (*ResetClip)(GB_PAINT *d);
|
|
|
|
void (*ClipExtents)(GB_PAINT *d, GB_EXTENTS *ext);
|
|
|
|
|
2009-12-28 02:19:27 +01:00
|
|
|
void (*Fill)(GB_PAINT *d, int preserve);
|
|
|
|
void (*Stroke)(GB_PAINT *d, int preserve);
|
2009-12-24 03:02:05 +01:00
|
|
|
|
|
|
|
void (*PathExtents)(GB_PAINT *d, GB_EXTENTS *ext);
|
2009-12-28 02:19:27 +01:00
|
|
|
int (*PathContains)(GB_PAINT *d, float x, float y);
|
2009-12-24 03:02:05 +01:00
|
|
|
|
2009-12-28 02:19:27 +01:00
|
|
|
void (*Dash)(GB_PAINT *d, int set, float **dash, int *count);
|
|
|
|
void (*DashOffset)(GB_PAINT *d, int set, float *offset);
|
2009-12-24 03:02:05 +01:00
|
|
|
|
2009-12-28 02:19:27 +01:00
|
|
|
void (*FillRule)(GB_PAINT *d, int set, int *value);
|
|
|
|
void (*LineCap)(GB_PAINT *d, int set, int *value);
|
|
|
|
void (*LineJoin)(GB_PAINT *d, int set, int *value);
|
|
|
|
void (*LineWidth)(GB_PAINT *d, int set, float *value);
|
|
|
|
void (*MiterLimit)(GB_PAINT *d, int set, float *value);
|
2009-12-24 03:02:05 +01:00
|
|
|
|
2009-12-28 02:19:27 +01:00
|
|
|
void (*Operator)(GB_PAINT *d, int set, int *value);
|
2009-12-24 03:02:05 +01:00
|
|
|
|
|
|
|
void (*NewPath)(GB_PAINT *d);
|
|
|
|
void (*ClosePath)(GB_PAINT *d);
|
|
|
|
|
2009-12-28 02:19:27 +01:00
|
|
|
void (*Arc)(GB_PAINT *d, float xc, float yc, float radius, float angle, float length);
|
2009-12-27 16:51:27 +01:00
|
|
|
void (*Rectangle)(GB_PAINT *d, float x, float y, float width, float height);
|
|
|
|
void (*GetCurrentPoint)(GB_PAINT *d, float *x, float *y);
|
|
|
|
void (*MoveTo)(GB_PAINT *d, float x, float y);
|
|
|
|
void (*LineTo)(GB_PAINT *d, float x, float y);
|
|
|
|
void (*CurveTo)(GB_PAINT *d, float x1, float y1, float x2, float y2, float x3, float y3);
|
2009-12-24 03:02:05 +01:00
|
|
|
|
2009-12-29 19:08:06 +01:00
|
|
|
void (*Text)(GB_PAINT *d, const char *text, int len, float w, float h, int align);
|
2009-12-29 22:42:40 +01:00
|
|
|
//void (*RichText)(GB_PAINT *d, const char *text, int len, float w, float h, int align);
|
2009-12-30 00:18:43 +01:00
|
|
|
//void (*TextExtents)(GB_PAINT *d, const char *text, int len, GB_EXTENTS *ext);
|
2009-12-24 03:02:05 +01:00
|
|
|
|
2009-12-28 02:19:27 +01:00
|
|
|
void (*Matrix)(GB_PAINT *d, int set, GB_TRANSFORM matrix);
|
2009-12-24 16:09:08 +01:00
|
|
|
|
2009-12-29 02:21:39 +01:00
|
|
|
void (*SetBrush)(GB_PAINT *d, GB_BRUSH brush);
|
2009-12-24 16:09:08 +01:00
|
|
|
|
|
|
|
struct {
|
|
|
|
void (*Free)(GB_BRUSH brush);
|
|
|
|
void (*Color)(GB_BRUSH *brush, GB_COLOR color);
|
2009-12-28 02:19:27 +01:00
|
|
|
void (*Image)(GB_BRUSH *brush, GB_IMAGE image);
|
|
|
|
void (*LinearGradient)(GB_BRUSH *brush, float x0, float y0, float x1, float y1, int nstop, double *positions, GB_COLOR *colors, int extend);
|
2009-12-30 00:18:43 +01:00
|
|
|
void (*RadialGradient)(GB_BRUSH *brush, float cx, float cy, float r, float fx, float fy, int nstop, double *positions, GB_COLOR *colors, int extend);
|
2009-12-28 02:19:27 +01:00
|
|
|
void (*Matrix)(GB_BRUSH brush, int set, GB_TRANSFORM matrix);
|
2009-12-24 16:09:08 +01:00
|
|
|
}
|
|
|
|
Brush;
|
|
|
|
|
|
|
|
struct {
|
2009-12-28 02:19:27 +01:00
|
|
|
void (*Create)(GB_TRANSFORM *matrix);
|
|
|
|
void (*Delete)(GB_TRANSFORM *matrix);
|
2009-12-27 16:51:27 +01:00
|
|
|
void (*Init)(GB_TRANSFORM matrix, float xx, float yx, float xy, float yy, float x0, float y0);
|
|
|
|
void (*Translate)(GB_TRANSFORM matrix, float tx, float ty);
|
|
|
|
void (*Scale)(GB_TRANSFORM matrix, float sx, float sy);
|
|
|
|
void (*Rotate)(GB_TRANSFORM matrix, float angle);
|
2009-12-28 02:19:27 +01:00
|
|
|
int (*Invert)(GB_TRANSFORM matrix);
|
2009-12-24 16:09:08 +01:00
|
|
|
void (*Multiply)(GB_TRANSFORM matrix, GB_TRANSFORM matrix2);
|
|
|
|
}
|
|
|
|
Transform;
|
2009-12-24 03:02:05 +01:00
|
|
|
}
|
|
|
|
GB_PAINT_DESC;
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|