home *** CD-ROM | disk | FTP | other *** search
/ Nebula / nebula.bin / SourceCode / MiniExamples / AskMe / Clock.c < prev    next >
C/C++ Source or Header  |  1993-01-19  |  3KB  |  93 lines

  1. /* Clock.c generated from Clock.psw
  2.    by unix pswrap V1.009  Wed Apr 19 17:50:24 PDT 1989
  3.  */
  4.  
  5. #include <dpsclient/dpsfriends.h>
  6. #include <string.h>
  7.  
  8. #line 1 "Clock.psw"
  9. /*
  10.  * Clock.psw, Postscript code for drawing the digital clock.
  11.  * You may freely copy, distribute and reuse the code in this example.  
  12.  * NeXT disclaims any warranty of any kind, expressed or implied, as to its 
  13.  * fitness for any particular use.
  14.  */
  15.  
  16.  
  17.  
  18.  
  19. /* centerShow centers the width of a string at the specific x y location 
  20.  * using specified gray
  21.  */ 
  22. #line 23 "Clock.c"
  23. void PSWcenterShow(float x, float y, const char *str, float gray)
  24. {
  25.   typedef struct {
  26.     unsigned char tokenType;
  27.     unsigned char sizeFlag;
  28.     unsigned short topLevelCount;
  29.     unsigned long nBytes;
  30.  
  31.     DPSBinObjReal obj0;
  32.     DPSBinObjGeneric obj1;
  33.     DPSBinObjReal obj2;
  34.     DPSBinObjGeneric obj3;
  35.     DPSBinObjGeneric obj4;
  36.     DPSBinObjGeneric obj5;
  37.     DPSBinObjGeneric obj6;
  38.     DPSBinObjGeneric obj7;
  39.     DPSBinObjGeneric obj8;
  40.     DPSBinObjReal obj9;
  41.     DPSBinObjGeneric obj10;
  42.     DPSBinObjGeneric obj11;
  43.     DPSBinObjGeneric obj12;
  44.     DPSBinObjGeneric obj13;
  45.     } _dpsQ;
  46.   static const _dpsQ _dpsStat = {
  47.     DPS_DEF_TOKENTYPE, 0, 14, 120,
  48.     {DPS_LITERAL|DPS_REAL, 0, 0, 0},    /* param: gray */
  49.     {DPS_EXEC|DPS_NAME, 0, DPSSYSNAME, 150},    /* setgray */
  50.     {DPS_LITERAL|DPS_REAL, 0, 0, 0},    /* param: x */
  51.     {DPS_LITERAL|DPS_STRING, 0, 0, 112},    /* param str */
  52.     {DPS_EXEC|DPS_NAME, 0, DPSSYSNAME, 166},    /* stringwidth */
  53.     {DPS_EXEC|DPS_NAME, 0, DPSSYSNAME, 117},    /* pop */
  54.     {DPS_LITERAL|DPS_INT, 0, 0, 2},
  55.     {DPS_EXEC|DPS_NAME, 0, DPSSYSNAME, 54},    /* div */
  56.     {DPS_EXEC|DPS_NAME, 0, DPSSYSNAME, 169},    /* sub */
  57.     {DPS_LITERAL|DPS_REAL, 0, 0, 0},    /* param: y */
  58.     {DPS_EXEC|DPS_NAME, 0, DPSSYSNAME, 107},    /* moveto */
  59.     {DPS_LITERAL|DPS_STRING, 0, 0, 112},    /* param str */
  60.     {DPS_EXEC|DPS_NAME, 0, DPSSYSNAME, 160},    /* show */
  61.     {DPS_EXEC|DPS_NAME, 0, DPSSYSNAME, 167},    /* stroke */
  62.     }; /* _dpsQ */
  63.   _dpsQ _dpsF;    /* local copy  */
  64.   register DPSContext _dpsCurCtxt = DPSPrivCurrentContext();
  65.   char pad[3];
  66.   register DPSBinObjRec *_dpsP = (DPSBinObjRec *)&_dpsF.obj0;
  67.   register int _dps_offset = 112;
  68.   _dpsF = _dpsStat;    /* assign automatic variable */
  69.  
  70.   _dpsP[2].val.realVal = x;
  71.   _dpsP[9].val.realVal = y;
  72.   _dpsP[3].length =
  73.   _dpsP[11].length = strlen(str);
  74.   _dpsP[0].val.realVal = gray;
  75.   _dpsP[11].val.stringVal = _dps_offset;
  76.   _dps_offset += (_dpsP[11].length + 3) & ~3;
  77.   _dpsP[3].val.stringVal = _dps_offset;
  78.   _dps_offset += (_dpsP[3].length + 3) & ~3;
  79.  
  80.   _dpsF.nBytes = _dps_offset+8;
  81.   DPSBinObjSeqWrite(_dpsCurCtxt,(char *) &_dpsF,120);
  82.   DPSWriteStringChars(_dpsCurCtxt, (char *)str, _dpsP[11].length);
  83.   DPSWriteStringChars(_dpsCurCtxt, (char *)pad, ~(_dpsP[11].length + 3) & 3);
  84.   DPSWriteStringChars(_dpsCurCtxt, (char *)str, _dpsP[3].length);
  85.   DPSWriteStringChars(_dpsCurCtxt, (char *)pad, ~(_dpsP[3].length + 3) & 3);
  86.   if (0) *pad = 0;    /* quiets compiler warnings */
  87. }
  88. #line 19 "Clock.psw"
  89.  
  90.  
  91.  
  92.  
  93.