2002-06-11 04:02:23 +00:00
|
|
|
|
/*
|
|
|
|
|
|
* $XFree86: $
|
|
|
|
|
|
*
|
2002-08-14 00:39:43 +00:00
|
|
|
|
* Copyright <EFBFBD> 2002 Carl D. Worth
|
2002-06-11 04:02:23 +00:00
|
|
|
|
*
|
|
|
|
|
|
* Permission to use, copy, modify, distribute, and sell this software
|
|
|
|
|
|
* and its documentation for any purpose is hereby granted without
|
|
|
|
|
|
* fee, provided that the above copyright notice appear in all copies
|
|
|
|
|
|
* and that both that copyright notice and this permission notice
|
2002-08-14 00:39:43 +00:00
|
|
|
|
* appear in supporting documentation, and that the name of Carl
|
|
|
|
|
|
* D. Worth not be used in advertising or publicity pertaining to
|
|
|
|
|
|
* distribution of the software without specific, written prior
|
|
|
|
|
|
* permission. Carl D. Worth makes no representations about the
|
|
|
|
|
|
* suitability of this software for any purpose. It is provided "as
|
|
|
|
|
|
* is" without express or implied warranty.
|
2002-06-11 04:02:23 +00:00
|
|
|
|
*
|
2002-08-14 00:39:43 +00:00
|
|
|
|
* CARL D. WORTH DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
|
|
|
|
|
|
* SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
|
|
|
|
|
* FITNESS, IN NO EVENT SHALL CARL D. WORTH BE LIABLE FOR ANY SPECIAL,
|
|
|
|
|
|
* INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
|
|
|
|
|
|
* RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
|
|
|
|
|
|
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
|
|
|
|
|
|
* IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
|
|
|
|
*/
|
2002-06-11 04:02:23 +00:00
|
|
|
|
|
|
|
|
|
|
#include "xrint.h"
|
|
|
|
|
|
|
2002-10-16 12:57:00 +00:00
|
|
|
|
#define _XR_CURRENT_GSTATE(xrs) (xrs->stack)
|
|
|
|
|
|
|
2002-06-11 04:02:23 +00:00
|
|
|
|
XrState *
|
2002-06-14 15:13:44 +00:00
|
|
|
|
XrCreate(Display *dpy)
|
2002-06-11 04:02:23 +00:00
|
|
|
|
{
|
2002-10-16 12:57:00 +00:00
|
|
|
|
return _XrStateCreate(dpy);
|
2002-06-11 04:02:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
|
XrDestroy(XrState *xrs)
|
|
|
|
|
|
{
|
2002-10-16 12:57:00 +00:00
|
|
|
|
_XrStateDestroy(xrs);
|
2002-06-11 04:02:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
|
XrSave(XrState *xrs)
|
|
|
|
|
|
{
|
2002-10-16 12:57:00 +00:00
|
|
|
|
XrStatus status;
|
2002-08-15 05:22:59 +00:00
|
|
|
|
|
2002-10-16 12:57:00 +00:00
|
|
|
|
status = _XrStatePush(xrs);
|
|
|
|
|
|
if (status)
|
|
|
|
|
|
xrs->status = status;
|
2002-06-11 04:02:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
|
XrRestore(XrState *xrs)
|
|
|
|
|
|
{
|
2002-09-03 08:42:25 +00:00
|
|
|
|
/* XXX: BUG: Calling XrRestore without a matching XrSave shoud
|
|
|
|
|
|
flag an error. Also, in order to prevent crashes, XrStatePop
|
|
|
|
|
|
should not be called in that case. */
|
2002-10-16 12:57:00 +00:00
|
|
|
|
_XrStatePop(xrs);
|
2002-06-11 04:02:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
2002-06-14 15:13:44 +00:00
|
|
|
|
XrSetDrawable(XrState *xrs, Drawable drawable)
|
|
|
|
|
|
{
|
2002-10-16 12:57:00 +00:00
|
|
|
|
_XrGStateSetDrawable(_XR_CURRENT_GSTATE(xrs), drawable);
|
2002-06-14 15:13:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
|
XrSetVisual(XrState *xrs, Visual *visual)
|
|
|
|
|
|
{
|
2002-10-16 12:57:00 +00:00
|
|
|
|
_XrGStateSetVisual(_XR_CURRENT_GSTATE(xrs), visual);
|
2002-06-14 15:13:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
|
XrSetFormat(XrState *xrs, XrFormat format)
|
2002-06-11 04:02:23 +00:00
|
|
|
|
{
|
2002-10-16 12:57:00 +00:00
|
|
|
|
_XrGStateSetFormat(_XR_CURRENT_GSTATE(xrs), format);
|
2002-06-11 04:02:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2002-07-23 07:22:23 +00:00
|
|
|
|
void
|
|
|
|
|
|
XrSetOperator(XrState *xrs, XrOperator operator)
|
|
|
|
|
|
{
|
2002-10-16 12:57:00 +00:00
|
|
|
|
_XrGStateSetOperator(_XR_CURRENT_GSTATE(xrs), operator);
|
2002-07-23 07:22:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2002-06-11 04:02:23 +00:00
|
|
|
|
void
|
2002-06-14 15:13:44 +00:00
|
|
|
|
XrSetRGBColor(XrState *xrs, double red, double green, double blue)
|
2002-06-11 04:02:23 +00:00
|
|
|
|
{
|
2002-10-16 12:57:00 +00:00
|
|
|
|
_XrGStateSetRGBColor(_XR_CURRENT_GSTATE(xrs), red, green, blue);
|
2002-06-11 04:02:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2002-09-03 08:42:25 +00:00
|
|
|
|
void
|
|
|
|
|
|
XrSetTolerance(XrState *xrs, double tolerance)
|
|
|
|
|
|
{
|
2002-10-16 12:57:00 +00:00
|
|
|
|
_XrGStateSetTolerance(_XR_CURRENT_GSTATE(xrs), tolerance);
|
2002-09-03 08:42:25 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2002-06-11 04:02:23 +00:00
|
|
|
|
void
|
|
|
|
|
|
XrSetAlpha(XrState *xrs, double alpha)
|
|
|
|
|
|
{
|
2002-10-16 12:57:00 +00:00
|
|
|
|
_XrGStateSetAlpha(_XR_CURRENT_GSTATE(xrs), alpha);
|
2002-06-11 04:02:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
|
XrSetLineWidth(XrState *xrs, double width)
|
|
|
|
|
|
{
|
2002-10-16 12:57:00 +00:00
|
|
|
|
_XrGStateSetLineWidth(_XR_CURRENT_GSTATE(xrs), width);
|
2002-07-23 07:22:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
|
XrSetLineCap(XrState *xrs, XrLineCap line_cap)
|
|
|
|
|
|
{
|
2002-10-16 12:57:00 +00:00
|
|
|
|
_XrGStateSetLineCap(_XR_CURRENT_GSTATE(xrs), line_cap);
|
2002-07-23 07:22:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
|
XrSetLineJoin(XrState *xrs, XrLineJoin line_join)
|
|
|
|
|
|
{
|
2002-10-16 12:57:00 +00:00
|
|
|
|
_XrGStateSetLineJoin(_XR_CURRENT_GSTATE(xrs), line_join);
|
2002-07-23 07:22:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2002-08-15 17:19:28 +00:00
|
|
|
|
void
|
|
|
|
|
|
XrSetDash(XrState *xrs, double *dashes, int ndash, double offset)
|
|
|
|
|
|
{
|
2002-10-16 12:57:00 +00:00
|
|
|
|
XrStatus status;
|
|
|
|
|
|
status = _XrGStateSetDash(_XR_CURRENT_GSTATE(xrs), dashes, ndash, offset);
|
|
|
|
|
|
if (status)
|
|
|
|
|
|
xrs->status = status;
|
2002-08-15 17:19:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2002-07-23 07:22:23 +00:00
|
|
|
|
void
|
|
|
|
|
|
XrSetMiterLimit(XrState *xrs, double limit)
|
|
|
|
|
|
{
|
2002-10-16 12:57:00 +00:00
|
|
|
|
_XrGStateSetMiterLimit(_XR_CURRENT_GSTATE(xrs), limit);
|
2002-06-11 04:02:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
|
XrTranslate(XrState *xrs, double tx, double ty)
|
|
|
|
|
|
{
|
2002-10-16 12:57:00 +00:00
|
|
|
|
_XrGStateTranslate(_XR_CURRENT_GSTATE(xrs), tx, ty);
|
2002-06-11 04:02:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
|
XrScale(XrState *xrs, double sx, double sy)
|
|
|
|
|
|
{
|
2002-10-16 12:57:00 +00:00
|
|
|
|
_XrGStateScale(_XR_CURRENT_GSTATE(xrs), sx, sy);
|
2002-06-11 04:02:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
|
XrRotate(XrState *xrs, double angle)
|
|
|
|
|
|
{
|
2002-10-16 12:57:00 +00:00
|
|
|
|
_XrGStateRotate(_XR_CURRENT_GSTATE(xrs), angle);
|
2002-06-11 04:02:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
|
XrNewPath(XrState *xrs)
|
|
|
|
|
|
{
|
2002-10-16 12:57:00 +00:00
|
|
|
|
_XrGStateNewPath(_XR_CURRENT_GSTATE(xrs));
|
2002-06-11 04:02:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
|
XrMoveTo(XrState *xrs, double x, double y)
|
|
|
|
|
|
{
|
2002-10-16 12:57:00 +00:00
|
|
|
|
XrStatus status;
|
2002-08-15 05:22:59 +00:00
|
|
|
|
|
2002-10-16 12:57:00 +00:00
|
|
|
|
status = _XrGStateAddUnaryPathOp(_XR_CURRENT_GSTATE(xrs), XrPathOpMoveTo, x, y);
|
|
|
|
|
|
if (status)
|
|
|
|
|
|
xrs->status = status;
|
2002-06-11 04:02:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
|
XrLineTo(XrState *xrs, double x, double y)
|
|
|
|
|
|
{
|
2002-10-16 12:57:00 +00:00
|
|
|
|
XrStatus status;
|
2002-08-15 05:22:59 +00:00
|
|
|
|
|
2002-10-16 12:57:00 +00:00
|
|
|
|
status = _XrGStateAddUnaryPathOp(_XR_CURRENT_GSTATE(xrs), XrPathOpLineTo, x, y);
|
|
|
|
|
|
if (status)
|
|
|
|
|
|
xrs->status = status;
|
2002-08-15 05:22:59 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
|
XrCurveTo(XrState *xrs,
|
|
|
|
|
|
double x1, double y1,
|
|
|
|
|
|
double x2, double y2,
|
|
|
|
|
|
double x3, double y3)
|
|
|
|
|
|
{
|
2002-10-16 12:57:00 +00:00
|
|
|
|
XrStatus status;
|
2002-08-15 05:22:59 +00:00
|
|
|
|
XPointDouble pt[3];
|
|
|
|
|
|
|
|
|
|
|
|
pt[0].x = x1; pt[0].y = y1;
|
|
|
|
|
|
pt[1].x = x2; pt[1].y = y2;
|
|
|
|
|
|
pt[2].x = x3; pt[2].y = y3;
|
|
|
|
|
|
|
2002-10-16 12:57:00 +00:00
|
|
|
|
status = _XrGStateAddPathOp(_XR_CURRENT_GSTATE(xrs), XrPathOpCurveTo, pt, 3);
|
|
|
|
|
|
if (status)
|
|
|
|
|
|
xrs->status = status;
|
2002-06-11 04:02:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
2002-10-16 12:57:00 +00:00
|
|
|
|
XrRelMoveTo(XrState *xrs, double dx, double dy)
|
2002-06-11 04:02:23 +00:00
|
|
|
|
{
|
2002-10-16 12:57:00 +00:00
|
|
|
|
XrStatus status;
|
2002-08-15 05:22:59 +00:00
|
|
|
|
|
2002-10-16 12:57:00 +00:00
|
|
|
|
status = _XrGStateAddUnaryPathOp(_XR_CURRENT_GSTATE(xrs), XrPathOpRelMoveTo, dx, dy);
|
|
|
|
|
|
if (status)
|
|
|
|
|
|
xrs->status = status;
|
2002-06-11 04:02:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
2002-10-16 12:57:00 +00:00
|
|
|
|
XrRelLineTo(XrState *xrs, double dx, double dy)
|
2002-06-11 04:02:23 +00:00
|
|
|
|
{
|
2002-10-16 12:57:00 +00:00
|
|
|
|
XrStatus status;
|
2002-08-15 05:22:59 +00:00
|
|
|
|
|
2002-10-16 12:57:00 +00:00
|
|
|
|
status = _XrGStateAddUnaryPathOp(_XR_CURRENT_GSTATE(xrs), XrPathOpRelLineTo, dx, dy);
|
|
|
|
|
|
if (status)
|
|
|
|
|
|
xrs->status = status;
|
2002-08-15 05:22:59 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
|
XrRelCurveTo(XrState *xrs,
|
2002-10-16 12:57:00 +00:00
|
|
|
|
double dx1, double dy1,
|
|
|
|
|
|
double dx2, double dy2,
|
|
|
|
|
|
double dx3, double dy3)
|
2002-08-15 05:22:59 +00:00
|
|
|
|
{
|
2002-10-16 12:57:00 +00:00
|
|
|
|
XrStatus status;
|
2002-08-15 05:22:59 +00:00
|
|
|
|
XPointDouble pt[3];
|
|
|
|
|
|
|
2002-10-16 12:57:00 +00:00
|
|
|
|
pt[0].x = dx1; pt[0].y = dy1;
|
|
|
|
|
|
pt[1].x = dx2; pt[1].y = dy2;
|
|
|
|
|
|
pt[2].x = dx3; pt[2].y = dy3;
|
2002-08-15 05:22:59 +00:00
|
|
|
|
|
2002-10-16 12:57:00 +00:00
|
|
|
|
status = _XrGStateAddPathOp(_XR_CURRENT_GSTATE(xrs), XrPathOpRelCurveTo, pt, 3);
|
|
|
|
|
|
if (status)
|
|
|
|
|
|
xrs->status = status;
|
2002-06-11 04:02:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
|
XrClosePath(XrState *xrs)
|
|
|
|
|
|
{
|
2002-10-16 12:57:00 +00:00
|
|
|
|
XrStatus status;
|
2002-08-15 05:22:59 +00:00
|
|
|
|
|
2002-10-16 12:57:00 +00:00
|
|
|
|
status = _XrGStateClosePath(_XR_CURRENT_GSTATE(xrs));
|
|
|
|
|
|
if (status)
|
|
|
|
|
|
xrs->status = status;
|
2002-06-11 04:02:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
|
XrStroke(XrState *xrs)
|
|
|
|
|
|
{
|
2002-10-16 12:57:00 +00:00
|
|
|
|
XrStatus status;
|
2002-08-15 05:22:59 +00:00
|
|
|
|
|
2002-10-16 12:57:00 +00:00
|
|
|
|
if (xrs->status)
|
2002-08-15 05:22:59 +00:00
|
|
|
|
return;
|
|
|
|
|
|
|
2002-10-16 12:57:00 +00:00
|
|
|
|
status = _XrGStateStroke(_XR_CURRENT_GSTATE(xrs));
|
|
|
|
|
|
if (status)
|
|
|
|
|
|
xrs->status = status;
|
2002-06-11 04:02:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
|
XrFill(XrState *xrs)
|
|
|
|
|
|
{
|
2002-10-16 12:57:00 +00:00
|
|
|
|
XrStatus status;
|
2002-08-15 05:22:59 +00:00
|
|
|
|
|
2002-10-16 12:57:00 +00:00
|
|
|
|
if (xrs->status)
|
2002-08-15 05:22:59 +00:00
|
|
|
|
return;
|
|
|
|
|
|
|
2002-10-16 12:57:00 +00:00
|
|
|
|
status = _XrGStateFill(_XR_CURRENT_GSTATE(xrs));
|
|
|
|
|
|
if (status) {
|
|
|
|
|
|
xrs->status = status;
|
2002-08-15 05:22:59 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|