/*
 * $RCSfile: ClockWraps.psw,v $
 *
 * (c) Copyright 1992-1994 Adobe Systems Incorporated.
 * All rights reserved.
 * 
 * Permission to use, copy, modify, distribute, and sublicense this software
 * and its documentation for any purpose and without fee is hereby granted,
 * provided that the above copyright notices appear in all copies and that
 * both those copyright notices and this permission notice appear in
 * supporting documentation and that the name of Adobe Systems Incorporated
 * not be used in advertising or publicity pertaining to distribution of the
 * software without specific, written prior permission.  No trademark license
 * to use the Adobe trademarks is hereby granted.  If the Adobe trademark
 * "Display PostScript"(tm) is used to describe this software, its
 * functionality or for any other purpose, such use shall be limited to a
 * statement that this software works in conjunction with the Display
 * PostScript system.  Proper trademark attribution to reflect Adobe's
 * ownership of the trademark shall be given whenever any such reference to
 * the Display PostScript system is made.
 * 
 * ADOBE MAKES NO REPRESENTATIONS ABOUT THE SUITABILITY OF THE SOFTWARE FOR
 * ANY PURPOSE.  IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
 * ADOBE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
 * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 * NON- INFRINGEMENT OF THIRD PARTY RIGHTS.  IN NO EVENT SHALL ADOBE BE LIABLE
 * TO YOU OR ANY OTHER PARTY FOR ANY SPECIAL, INDIRECT, OR CONSEQUENTIAL
 * DAMAGES OR ANY DAMAGES WHATSOEVER WHETHER IN AN ACTION OF CONTRACT,
 * NEGLIGENCE, STRICT LIABILITY OR ANY OTHER ACTION ARISING OUT OF OR IN
 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.  ADOBE WILL NOT
 * PROVIDE ANY TRAINING OR OTHER SUPPORT FOR THE SOFTWARE.
 * 
 * Adobe, PostScript, and Display PostScript are trademarks of Adobe Systems
 * Incorporated which may be registered in certain jurisdictions
 * 
 * Author:  Adobe Systems Incorporated
 */

/***************************************************************
**
** FUNCTION:    PSWErasePage
**
** DESCRIPTION: Erases the page.
**
** PARAMETERS:  BGColor     background color
**              X, Y        X, Y coordinates of origin
**              W, H        width and height of page
**
** RETURN:      None
**
***************************************************************/
defineps PSWErasePage (float BGColor, X, Y, W, H)
    BGColor setgray X Y W H rectfill
endps

/***************************************************************
**
** FUNCTION:    PSWDrawCircle
**
** DESCRIPTION: Creates a circular path around origin and fills or strokes it
**
** PARAMETERS:  Radius	    radius of circle
**		Color       gray scale color value (0 to 1)
**		Fill	    whether to fill or stroke
**
** RETURN:      None
**
***************************************************************/
defineps PSWDrawCircle (float Radius, Color; boolean Fill)
    newpath
    0 0 Radius 0 360 arc
    Color setgray Fill {fill} {stroke} ifelse
endps

/***************************************************************
**
** FUNCTION:    PSWSetUpath
**
** DESCRIPTION: Places a two entry array defining the userpath
**              on the DPS stack.  The entry is the float array
**              of coordinate points, the second is the character
**              array of DPS operators.
**
** PARAMETERS:  Pts         Array of coordinate points
**              Tot_Pts     Number of coordinate points
**              Ops         Array of DPS operators
**              Tot_Ops     Number of DPS operators
**
** RETURN:      None
**
***************************************************************/
defineps PSWSetUpath (float Pts[Tot_Pts]; int Tot_Pts;
                    char Ops[Tot_Ops]; int Tot_Ops)
    [Pts (Ops)]
endps

/***************************************************************
**
** FUNCTION:    PSWSetGraphicsParams
**
** DESCRIPTION: Places the entries defining the gstate on the
**              DPS stack.
**
** PARAMETERS:  X, Y        Coordinate point for origin
**              Gray        Drawing color
**              LineWidth   Stroke line width
**
** RETURN:      None
**
***************************************************************/
defineps PSWSetGraphicsParams (float X, Y, Gray, Linewidth)
    X Y translate Gray setgray Linewidth setlinewidth
endps

/***************************************************************
**
** FUNCTION:    PSWPushDrawingParams
**
** DESCRIPTION: Saves gstate and places the entries defining the
**		new gstate on the stack
**
** PARAMETERS:  X, Y        Coordinate point for origin
**              Gray        Drawing color
**              LineWidth   Stroke line width
**		Angle	    rotation
**
** RETURN:      None
**
***************************************************************/
defineps PSWPushDrawingParams(float X, Y, Gray, Linewidth, Angle)
    gsave
    X Y translate Gray setgray Linewidth setlinewidth Angle rotate
endps

/***************************************************************
**
** FUNCTION:    PSWInstallGstate
**
** DESCRIPTION: Installs the gstate as the current graphics
**              state and rotates the context by the specified
**              angle.
**
** PARAMETERS:  GState      User object identifier of gstate
**              Angle       Angle of rotation
**
** RETURN:      None
**
***************************************************************/
defineps PSWInstallGstate(userobject GState;  float Angle)
    GState setgstate
    Angle rotate
endps

/***************************************************************
**
** FUNCTION:    PSWUpathStrokeFill
**
** DESCRIPTION: Strokes the userpath specified by the user
**              object identifier and then fills the userpath
**              with a lighter gray color.
**
** PARAMETERS:  UPath       User object identifier of userpath
**
** RETURN:      None
**
***************************************************************/
defineps PSWUpathStrokeFill(userobject UPath)
    UPath dup ustroke
    currentgray 0.2 add setgray
    ufill
endps

/***************************************************************
**
** FUNCTION:    PSWUpathFill
**
** DESCRIPTION: Fills the userpath specified by the user object
**              identifier.
**
** PARAMETERS:  UPath       User object identifier of userpath
**
** RETURN:      None
**
***************************************************************/
defineps PSWUpathFill(userobject UPath)
    UPath ufill
endps

/***************************************************************
**
** FUNCTION:    PSWSetDrawable   
**
** DESCRIPTION: Set the X Window System drawable ID in the DPS
**              context.
**
** PARAMETERS:  Ctxt        DPS context
**              Drawable    X System drawable ID
**              XOffset	    new X offset
**		YOffset	    new Y offset
**
** RETURN:      None
**
***************************************************************/
defineps PSWSetDrawable(int Drawable, XOffset, YOffset)
     matrix currentmatrix
     currentXgcdrawable pop pop pop
     Drawable XOffset YOffset setXgcdrawable
     setmatrix
endps

/***************************************************************
**
** FUNCTION:    PSWGetTransform
**
** DESCRIPTION: Gets the current transform matrices and offset
**              coordinates.
**
** PARAMETERS:  None
**
** RETURN:      Ctm         array containing current transform matrix
**              Invctm      array containing inverted matrix
**              XOffset     X offset value
**              YOffset     Y offset value
**
***************************************************************/
defineps PSWGetTransform(| float Ctm[6], Invctm[6]; int *XOffset, *YOffset)
   matrix currentmatrix dup Ctm
   matrix invertmatrix Invctm
   currentXoffset YOffset XOffset
endps

/***************************************************************
**
** FUNCTION:    PSWSetOffset
**
** DESCRIPTION: Sets the x and y offset, maintaining current matrix
**
** PARAMETERS:  X	    X offset value
**		Y	    Y offset value
**
** RETURN:	None
**
***************************************************************/
defineps PSWSetOffset(int x, y)
    matrix currentmatrix
    x y setXoffset
    setmatrix
endps
