/*
 * Copyright (c) 1992, The Geometry Center
 *                     University of Minnesota 
 *                     1300 South Second Street
 *                     Minneapolis, MN  55454
 *
 * email address: software@geom.umn.edu
 *
 * This software is copyrighted as noted above.  It may be freely copied,
 * modified, and redistributed, provided that the copyright notice is
 * preserved on all copies.
 *
 * There is no warranty or other guarantee of fitness for this software,
 * it is provided solely "as is".  Bug reports or fixes may be sent
 * to the authors, who may or may not act on them as they desire.
 *
 * You may not include this software in a program or other software product
 * without supplying the source, or without informing the end-user that the
 * source is available for no extra charge.
 *
 * If you modify this software, you should include a notice giving the
 * name of the person performing the modification, the date of modification,
 * and the reason for such modification.
 *
 *     The National Science and Technology Research Center for
 *      Computation and Visualization of Geometric Structures
 */

#import <dpsclient/wraps.h>
#include <dpsclient/dpsfriends.h>
#include <string.h>

void clrscrn(void)
{
  PSclippath();
  PSsetgray(.667);
  PSfill();
}

void clrscrn2(void)
{
  PSclippath();
  PSsetgray(1);
  PSfill();
}

void drawIL(float x1,float y1,float x2,float y2)
{
  PSnewinstance();
  
  PSnewpath();
  PSsetgray(0.0);
  PSmoveto(x1,y1);
  PSlineto(x2,y2);
  PSstroke();
}

void drawL(float x1,float y1,float x2,float y2,float c)
{
  PSnewpath();
  
  PSsetgray(c);
  PSmoveto(x1,y1);
  PSlineto(x2,y2);
  PSstroke();
}

void drawR(float x,float y,float w,float h,float c)
{
  PSnewpath();
  
  PSsetgray(c);
  PSmoveto(x,y);
  PSlineto(x+w,y);
  PSlineto(x+w,y+h);
  PSlineto(x,y+h);
  PSlineto(x,y);
  PSstroke();
}

void drawIR(float x,float y,float w,float h)
{
  PSnewinstance();
  
  PSnewpath();
  PSsetgray(0.0);
  PSmoveto(x,y);
  PSlineto(x+w,y);
  PSlineto(x+w,y+h);
  PSlineto(x,y+h);
  PSlineto(x,y);
  PSstroke();
}

void fillP(float x1,float y1,float x2,float y2,float x3,float y3,float c)
{
  PSnewpath();
  
  PSsetgray(c);
  PSmoveto(x1,y1);
  PSlineto(x2,y2);
  PSlineto(x3,y3);
  PSlineto(x1,y1);
  PSclosepath();
  PSfill();
}

void fillR(float x,float y,float w,float h,float c)
{
  PSnewpath();
  
  PSsetgray(c);
  PSmoveto(x,y);
  PSlineto(x+w,y);
  PSlineto(x+w,y+h);
  PSlineto(x,y+h);
  PSlineto(x,y);
  PSclosepath();
  PSfill();
}

void mysetfont()
{
  typedef struct {
    unsigned char tokenType;
    unsigned char topLevelCount;
    unsigned short nBytes;

    DPSBinObjGeneric obj0;
    } _dpsQ;
  static _dpsQ _dpsF = {
    DPS_DEF_TOKENTYPE, 1, 12,
    {DPS_EXEC|DPS_NAME, 0, DPSSYSNAME, 149},	/* setfont */
    }; /* _dpsQ */
  register DPSContext _dpsCurCtxt = DPSPrivCurrentContext();
  DPSBinObjSeqWrite(_dpsCurCtxt,(char *) &_dpsF,12);
}

float getwidth(char *s)
{
  float x,y;
  PSstringwidth(s, &x, &y);
  return x;
}
