home *** CD-ROM | disk | FTP | other *** search
/ ftp.cs.arizona.edu / ftp.cs.arizona.edu.tar / ftp.cs.arizona.edu / icon / historic / v92.tgz / v92.tar / v92 / src / runtime / rmac.ri < prev    next >
Text File  |  1996-03-22  |  19KB  |  1,048 lines

  1. /*
  2.  * File: rmac.ri - Mac system-specific graphics interface code.
  3.  */
  4.  
  5. #ifdef Graphics
  6.  
  7. #passthru #ifndef __QUICKDRAW__
  8. struct RGBColor {
  9.     unsigned short    red;        /*magnitude of red component*/
  10.     unsigned short    green;        /*magnitude of green component*/
  11.     unsigned short    blue;        /*magnitude of blue component*/
  12. };
  13. typedef struct RGBColor RGBColor, *RGBColorPtr, **RGBColorHdl;
  14. #passthru #endif
  15. #passthru #include <sound.h>
  16.  
  17. /*
  18.  * Global variables specific to Mac
  19.  */
  20. extern PaletteHandle gPal;
  21. extern long gNumColors;
  22.  
  23. /*
  24.  * Prototypes
  25.  */
  26. int    CreateWindow    Params((wbp wb));
  27. int    seticonicstate    Params((wbp w, char *s));
  28. novalue    unsetclip    Params((wbp w));
  29. int    seticonpos    Params((wbp w, char *s));
  30. int        setdisplay    Params((wbp w, char *s));
  31.  
  32. /*
  33.  * allocates a window binding, a context and a state, then calls
  34.  * CreateWindow to draw the window on screen
  35.  */
  36.  
  37. FILE *wopen(name, lp, attr, n, err_index)
  38. char *name;
  39. struct b_list *lp;
  40. dptr attr;
  41. int n, *err_index;
  42.  
  43.    {
  44.    wbp wb;
  45.    wsp ws;
  46.    wcp wc;
  47.    char dispchrs[256];
  48.    char answer[128];
  49.    char *display = NULL;
  50.    int i;
  51.    tended struct b_list *tlp;
  52.    tended struct descrip attrrslt;
  53.  
  54.    tlp = lp;
  55.    
  56.    for(i=0;i<n;i++) 
  57.       {
  58.       if (is:string(attr[i]) &&
  59.       (StrLen(attr[i])>8) &&
  60.       !strncmp("display=",StrLoc(attr[i]),8)) 
  61.          {
  62.          mystrncpy(dispchrs,StrLoc(attr[i])+8,StrLen(attr[i])-8);
  63.          display = dispchrs;
  64.          }
  65.       }
  66.  
  67.    
  68.    /*
  69.     * Allocate a binding, a state and a context
  70.     */
  71.     
  72.    Protect(wb = alc_wbinding(), return NULL);
  73.    Protect(wb->window = alc_winstate(), { free_binding(wb); return NULL; });
  74.    Protect(wb->context = alc_context(wb), { free_binding(wb); return NULL; });
  75.    ws = wb->window;
  76.    ws->listp.dword = D_List;
  77.    BlkLoc(ws->listp) = (union block *)tlp;
  78.    wc = wb->context;
  79.  
  80.    /*
  81.     * Defaults
  82.     */
  83.    ws->height = 100;
  84.    ws->width = 100;
  85.    ws->posy = 60;
  86.    ws->posx = 20;
  87.    ws->visible = kVisible;
  88.    
  89.    /*
  90.     * some window attributes
  91.     */
  92.  
  93.    /*
  94.     * Loop through any remaining arguments.
  95.     */
  96.    for (i = 0; i < n; i++)
  97.       {
  98.       /*
  99.        * write the attribute,
  100.        *  except "display=" attribute, which is done earlier
  101.        */
  102.       if((StrLen(attr[i])<9)||strncmp(StrLoc(attr[i]),"display=",8)) 
  103.          {
  104.          switch (wattrib((wbp) wb, StrLoc(attr[i]), StrLen(attr[i]), &attrrslt, answer)) 
  105.             {
  106.             case Error:
  107.                *err_index = i;
  108.                return NULL;
  109.             case Failed:
  110.                free_binding((wbp)wb);
  111.                return NULL;
  112.             }
  113.          }
  114.       }
  115.       
  116.  
  117.    /* set window color according to context */
  118.  
  119.    if (CreateWindow(wb) != 1) return NULL;
  120.    return (FILE *)wb;
  121.    }
  122.  
  123. /*
  124.  * Creates a window and shows it on screen
  125.  */
  126.  
  127. int CreateWindow(wbp wb)
  128.    {
  129.    Rect winRect;
  130.    QDErr errGWorld;
  131.    STDLOCALS (wb);
  132.  
  133.    
  134.  
  135.    /*
  136.     * create the window
  137.     */
  138.     
  139.    SetRect (&winRect, 
  140.             ws->posx, ws->posy, 
  141.             (ws->posx)+(ws->width), 
  142.             (ws->posy)+(ws->height));
  143.    
  144.    ws->theWindow = NewCWindow (nil,
  145.                               &winRect,
  146.                               "\pUntitled",
  147.                               ws->visible,
  148.                               documentProc,
  149.                               kMoveToFront,
  150.                               kHasGoAway,
  151.                               kNilRefCon);
  152.   
  153.    /*
  154.     *  creating offscreen graphics world
  155.     */
  156.  
  157.    SetRect (&(ws->GWorldRect), 0, 0, kMaxDocSize, kMaxDocSize);
  158.    GetGWorld (&(ws->origPort), &(ws->origDev));
  159.    errGWorld = NewGWorld (&(ws->offScreenGWorld), 0, &(ws->GWorldRect), nil, nil, 0);
  160.    if (errGWorld != noErr)
  161.       printf ("Cannot create offscreen graphics world!\n");
  162.    SetGWorld (ws->offScreenGWorld, nil);
  163.    ws->offScreenPMHandle = GetGWorldPixMap (ws->offScreenGWorld);
  164.    ws->lockOK = LockPixels (ws->offScreenPMHandle);
  165.    EraseRect (&(ws->offScreenGWorld->portRect));
  166.    UnlockPixels (ws->offScreenPMHandle);
  167.    SetGWorld (ws->origPort, ws->origDev);
  168.  
  169.    return 1;
  170. }
  171.  
  172. /*
  173.  * Draw a bilevel image
  174.  */
  175. int blimage(w, x, y, width, height, ch, s, len)
  176. wbp w;
  177. int x, y, width, height, ch;
  178. unsigned char *s;
  179. word len;
  180. {
  181. }
  182.  
  183. /*
  184.  * copy an area
  185.  */
  186. int copyArea(wb1,wb2,x,y,width,height,x2,y2)
  187. wbp wb1, wb2;
  188. int x, y, width, height, x2, y2;
  189. {
  190.    Rect sourceRect, destRect;
  191.  
  192.    SetRect (&sourceRect, x, y, x+width, y+height);
  193.    SetRect (&destRect, x2, y2, x2+width, y2+width);
  194.    
  195.    CopyBits (&(((GrafPtr)(wb1->window->theWindow))->portBits),
  196.              &(((GrafPtr)(wb2->window->theWindow))->portBits),
  197.              &sourceRect, &destRect, srcCopy, nil);
  198.    LockPixels (wb1->window->offScreenGWorld->portPixMap);
  199.    LockPixels (wb2->window->offScreenGWorld->portPixMap);
  200.    CopyBits (&(((GrafPtr)(wb1->window->offScreenGWorld))->portBits),
  201.              &(((GrafPtr)(wb2->window->offScreenGWorld))->portBits),
  202.              &sourceRect, &destRect, srcCopy, nil);
  203.    UnlockPixels (wb1->window->offScreenGWorld->portPixMap);
  204.    UnlockPixels (wb2->window->offScreenGWorld->portPixMap);
  205. }
  206.  
  207. /*
  208.  * clear an area
  209.  */
  210. void clearArea(w,x,y,width,height)
  211. wbp w;
  212. int x, y, width, height;
  213. {
  214. }
  215.  
  216. /*
  217.  * erase an area
  218.  */
  219. void eraseArea(wb, x, y, width, height)
  220. wbp wb;
  221. int x, y, width, height;
  222. {
  223.   Rect r;
  224.   STDLOCALS (wb);
  225.   
  226.   SetPort (ws->theWindow);
  227.   COPYCONTEXT (wc->contextPtr);
  228.   SetRect (&r, x - 1,
  229.                y - 1,
  230.                (width == 0) ? (ws->posx + ws->width) : (x - 1 + width),
  231.                (height == 0) ? (ws->posy + ws->height) : (y - 1 + height) );
  232.   EraseRect (&r);
  233.   
  234. /*   */  
  235.   PREPAREGWORLD (ws);
  236.   COPYCONTEXT (wc->contextPtr);
  237.   EraseRect (&r);
  238.   UnlockPixels (ws->offScreenPMHandle);
  239.   SetGWorld (ws->origPort, ws->origDev);
  240. /*   */
  241. }
  242.  
  243. /*
  244.  * dumpimage -- write an image to a disk file in an X format.
  245.  *
  246.  * Accepts only .xpm and .xbm file names, returning NoCvt for anything else.
  247.  */
  248.  
  249. int dumpimage(w,filename,x,y,width,height)
  250. wbp w;
  251. char *filename;
  252. unsigned int x, y, height, width;
  253. {
  254. }
  255.  
  256. int do_config(w, status)
  257. wbp w;
  258. int status;
  259. {
  260. }
  261.  
  262. novalue free_rgb(w, rgb)
  263. wbp w;
  264. RGBColor *rgb;
  265. {
  266. }
  267.  
  268. novalue freecolor(w, s)
  269. wbp  w;
  270. char s;
  271. {
  272. }
  273.  
  274. novalue geticonic(w, answer)
  275. wbp w;
  276. char *answer;
  277. {
  278. }
  279.  
  280. novalue getpointername(w, answer)
  281. wbp w;
  282. char *answer;
  283. {
  284. }
  285.  
  286. novalue getlinestyle(w, answer)
  287. wbp w;
  288. char *answer;
  289. {
  290. }
  291.  
  292.  
  293. novalue getfg(w, answer)
  294. wbp w;
  295. char *answer;
  296. {
  297. }
  298.  
  299. novalue getbg(w, answer)
  300. wbp w;
  301. char *answer;
  302. {
  303. }
  304.  
  305. /*
  306.  * Set the context's foreground color by color cell.
  307.  */
  308. int isetfg(wb,i)
  309. wbp wb;
  310. int i;
  311. {
  312.    RGBColor c;
  313.    STDLOCALS (wb);
  314.    
  315.    if (-i > gNumColors) return Failed;
  316.    GetEntryColor (gPal, -i-1, &c);
  317.    wc->contextPtr->fgColor = c;
  318.    
  319.    SetPort (ws->theWindow);
  320.    PmForeColor (-i - 1);
  321.  
  322. /*   */  
  323.    GetGWorld (&(ws->origPort), &(ws->origDev));
  324.    SetGWorld (ws->offScreenGWorld, nil);
  325.    ws->lockOK = LockPixels (ws->offScreenPMHandle);
  326.    PmForeColor (-i - 1);
  327.    UnlockPixels (ws->offScreenPMHandle);
  328.    SetGWorld (ws->origPort, ws->origDev);
  329.    return Succeeded;
  330. /*   */
  331. }
  332.  
  333. /*
  334.  * Set the context's background color by color cell.
  335.  */
  336. int isetbg(wb,i)
  337. wbp wb;
  338. int i;
  339. {
  340.    RGBColor c;
  341.    STDLOCALS (wb);
  342.    
  343.    if (-i > gNumColors) return Failed;
  344.    GetEntryColor (gPal, -i-1, &c);
  345.    wc->contextPtr->bgColor = c;
  346.    
  347.    SetPort (ws->theWindow);
  348.    PmBackColor (-i - 1);
  349. }
  350.  
  351. int setfg(wb,s)
  352. wbp wb;
  353. char *s;
  354. {
  355.    long  r, g, b;
  356.    RGBColor c;
  357.    STDLOCALS (wb);
  358.    
  359.    if (parsecolor (NULL, s, &r, &g, &b) == Succeeded) {
  360.       RED (c) = r;
  361.       GREEN (c) = g;
  362.       BLUE (c) = b;
  363.       wc->contextPtr->fgColor = c;
  364.       
  365.       SetPort (ws->theWindow);
  366.       RGBForeColor (&c);
  367.  
  368.       GetGWorld (&(ws->origPort), &(ws->origDev));
  369.       SetGWorld (ws->offScreenGWorld, nil);
  370.       ws->lockOK = LockPixels (ws->offScreenPMHandle);
  371.       RGBForeColor (&c);
  372.       UnlockPixels (ws->offScreenPMHandle);
  373.       SetGWorld (ws->origPort, ws->origDev);
  374.  
  375.       }
  376.    else
  377.       return Failed;
  378.       
  379.    return Succeeded; 
  380. }
  381.  
  382. int setbg(wb,s)
  383. wbp wb;
  384. char *s;
  385. {
  386.    long r, g, b;
  387.    RGBColor c;
  388.    STDLOCALS (wb);
  389.    
  390.    if (parsecolor (NULL, s, &r, &g, &b) == Succeeded) {
  391.       RED (c) = r;
  392.       GREEN (c) = g;
  393.       BLUE (c) = b;
  394.       wc->contextPtr->bgColor = c;
  395.       SetPort (ws->theWindow);
  396.       RGBBackColor (&c);
  397.       }
  398.    else
  399.       return Failed;
  400.       
  401.    return Succeeded; 
  402. }
  403.  
  404. int nativecolor(w, s, r, g, b)
  405. wbp  w;
  406. char *s;
  407. long *r;
  408. long *g;
  409. long *b;
  410. {
  411.    return 0;
  412. }
  413.  
  414. int getvisual(w, answer)
  415. wbp w;
  416. char *answer;
  417. {
  418. }
  419.  
  420. /*
  421.  * Initialize client for producing pixels from a window
  422.  */
  423. int getpixel_init(wb, x, y, width, height)
  424. wbp wb;
  425. int x, y, width, height;
  426. {
  427. }
  428.  
  429. /*
  430.  * Return pixel (x,y) from a window in long value (rv)
  431.  */
  432. int getpixel(wb, x, y, rv, s)
  433. wbp wb;
  434. int x, y;
  435. long *rv;
  436. char *s;
  437. {
  438.    RGBColor c;
  439.    STDLOCALS (wb);
  440.    
  441.    SetPort (ws->theWindow);
  442.    GetCPixel (x, y, &c);
  443.    *rv = ((c.red << 8) + c.green) << 8 + c.blue;
  444.    sprintf (s, "%d,%d,%d", c.red, c.green, c.blue);
  445.    return Succeeded;
  446. }
  447.  
  448. novalue getdrawop(w, answer)
  449. wbp w;
  450. char *answer;
  451. {
  452. }
  453.  
  454.  
  455. /*
  456.  * getimstr(w, x, y, width, height, paltbl, data) -- get image as a string.
  457.  *
  458.  * Stores the specified subimage in data, one pixel per byte, and sets
  459.  * entries in paltbl corresponding to the pixel values that were used.
  460.  */
  461. /*
  462.  * The getimstr() code assumes that a maximum of 256 colors can be onscreen
  463.  * at one time.  If DMAXCOLORS maximum is raised, code must be added for the
  464.  * depth>8 case to reduce the local copy of the image to no more than the
  465.  * 256-color maximum allowed in a GIF file.  This reduction operation is
  466.  * nontrivial; look up "color quantization" in computer graphics literature.
  467.  */
  468. #passthru #if (DMAXCOLORS > 256)
  469. #passthru   Deliberate Syntax error
  470. #passthru #endif                /* DMAXCOLORS */
  471.  
  472. int getimstr(w, x, y, width, height, paltbl, data)
  473. wbp w;
  474. int x, y, width, height;
  475. struct palentry paltbl[DMAXCOLORS];
  476. unsigned char *data;
  477. {
  478. }
  479.  
  480. int geticonpos(w, s)
  481. wbp w;
  482. char *s;
  483. {
  484. }
  485.  
  486. novalue getcanvas(wb, s)
  487. wbp wb;
  488. char *s;
  489. {
  490.    STDLOCALS (wb);
  491.    
  492.    if (ws->theWindow == (WindowPtr) (NULL))
  493.       sprintf (s, "absent");
  494.    else
  495.       switch (ws->visible) {
  496.          case kVisible:
  497.             sprintf (s, "normal");
  498.             break;
  499.          case kInvisible:
  500.             sprintf (s, "hidden");
  501.             break;
  502.          default:
  503.             sprintf (s, "unknown");
  504.          }
  505. }
  506.  
  507. /*
  508.  *  Set the canvas type, either during open (pixmap is null, set a flag)
  509.  *   or change an existing canvas to a different type.
  510.  */
  511. int setcanvas(wb,s)
  512. wbp wb;
  513. char *s;
  514. {
  515.    STDLOCALS(wb);
  516.  
  517.    if (!strcmp(s, "iconic")) {
  518.       return Failed;                    /* not supported */
  519.       }
  520.    else if (!strcmp(s, "normal")) {
  521.            ws->visible = kVisible;
  522.            if (ws->theWindow != (WindowPtr) (NULL)) {
  523.               ShowHide (ws->theWindow, kVisible);
  524.               SelectWindow (ws->theWindow);
  525.               }
  526.            }
  527.    else if (!strcmp(s, "maximal")) {
  528.            return Failed;                    /* not supported */
  529.            }
  530.    else if (!strcmp(s, "hidden")) {
  531.            ws->visible = kInvisible;
  532.            if (ws->theWindow != (WindowPtr) (NULL)) {
  533.               ShowHide (ws->theWindow, kInvisible);
  534.               }
  535.            }
  536.    else return Error;
  537.    return Succeeded;
  538. }
  539.  
  540. /*
  541.  * getpos() - update the window state's notion of its current position
  542.  */
  543. int getpos(w)
  544. wbp w;
  545. {
  546.    if (!w->window->theWindow) return Failed;
  547.    return Succeeded;
  548. }
  549.  
  550. int getdefault(w, prog, opt, answer)
  551. wbp w;
  552. char *prog, *opt, *answer;
  553. {
  554. }
  555.  
  556. novalue getdisplay(wbp w, char *answer)
  557. {
  558.    strcpy(answer, "local");
  559. }
  560.  
  561. int setdisplay(wbp w, char *s)
  562. {
  563.   return Failed;
  564. }
  565.  
  566. int raiseWindow(w)
  567. wbp w;
  568. {
  569. }
  570.  
  571. int lowerWindow(w)
  572. wbp w;
  573. {
  574. }
  575.  
  576. /*
  577.  * rebind() - bind w's context to that of w2.
  578.  */
  579. int rebind(w, w2)
  580. wbp w, w2;
  581. {
  582. }
  583.  
  584. int readimage(w, filename, x, y, status)
  585. wbp w;
  586. char *filename;
  587. int x, y, *status;
  588. {
  589. }
  590.  
  591. int setimage(w, val)
  592. wbp w;
  593. char *val;
  594. {
  595. }
  596.  
  597. /*
  598.  * Set the context's line style by name.
  599.  */
  600. int setlinestyle(w, s)
  601. wbp w;
  602. char *s;
  603. {
  604. }
  605.  
  606. /*
  607.  * Set the context's fill style by name.
  608.  */
  609. int setfillstyle(w, s)
  610. wbp w;
  611. char *s;
  612. {
  613. }
  614.  
  615. int seticonimage(w, dp)
  616. wbp w;
  617. dptr dp;
  618. {
  619. }
  620.  
  621. int seticonicstate(w,s)
  622. wbp w;
  623. char *s;
  624. {
  625. }
  626.  
  627.  
  628. /*
  629.  * Draw a character-per-pixel image
  630.  */
  631. int strimage(w, x, y, width, height, e, s, len)
  632. wbp w;
  633. int x, y, width, height;
  634. struct palentry *e;
  635. unsigned char *s;
  636. word len;
  637. {
  638. }
  639.  
  640. char *get_mutable_name(wb, mute_index)
  641. wbp wb;
  642. int mute_index;
  643. {
  644.    RGBColor c;
  645.    char *tmp = malloc (28);
  646.    STDLOCALS (wb);
  647.       
  648.    if (-mute_index > gNumColors) return NULL;
  649.    GetEntryColor (gPal, -mute_index - 1, &c);
  650.    sprintf(tmp, "%d", mute_index);
  651.    sprintf(tmp + strlen (tmp) + 1, "%d,%d,%d", c.red, c.green, c.blue);
  652.    return tmp;
  653. }
  654.  
  655. int set_mutable(wb, i, s)
  656. wbp wb;
  657. int i;
  658. char *s;
  659. {
  660.    long  r, g, b;
  661.    RGBColor c;
  662.    STDLOCALS (wb);
  663.    
  664.    if (parsecolor (NULL, s, &r, &g, &b) != Succeeded )
  665.       return Failed;
  666.    c.red = r;
  667.    c.green = g;
  668.    c.blue =b;
  669.    AnimateEntry (ws->theWindow, -i - 1, &c);
  670.    ActivatePalette (ws->theWindow);
  671.  
  672. /*  
  673.    ws->lockOK = LockPixels (ws->offScreenPMHandle);
  674.    AnimateEntry ((WindowPtr)(ws->offScreenGWorld), -i-1, &c);
  675.    ActivatePalette ((WindowPtr)(ws->offScreenGWorld));
  676.    UnlockPixels (ws->offScreenPMHandle);
  677.  */ 
  678.    return Succeeded;
  679. }
  680.  
  681. novalue free_mutable(w, mute_index)
  682. wbp w;
  683. int mute_index;
  684. {
  685. }
  686.  
  687. /*
  688.  * Allocate a mutable color
  689.  */
  690. int mutable_color(wb, argv, argc, retval)
  691. wbp wb;
  692. dptr argv;
  693. int argc;
  694. int *retval;
  695. {
  696.    long  r, g, b;
  697.    tended char *str;
  698.    RGBColor c;
  699.    {
  700.    STDLOCALS(wb);
  701.  
  702.    
  703.    gNumColors++;
  704.    if (gNumColors == 1) {
  705.       gPal = NewPalette (gNumColors, nil, pmAnimated, kZeroTolerance);
  706.       }
  707.    else{
  708.       ResizePalette (gPal, gNumColors);
  709.       SetEntryUsage (gPal, gNumColors-1, pmAnimated, kZeroTolerance);
  710.       }
  711.    SetPalette (ws->theWindow, gPal, true);
  712.    
  713. /*   */
  714.    ws->lockOK = LockPixels (ws->offScreenPMHandle);
  715.    SetPalette((WindowPtr)(ws->offScreenGWorld), gPal, true);
  716.    UnlockPixels (ws->offScreenPMHandle);
  717. /*   */
  718.  
  719.    /* set the color */
  720.    
  721.    if (argc > 0) {
  722.       if (argc != 1) 
  723.          return Error;
  724.       else
  725.          if (argv[0].dword == D_Integer) {
  726.             if (IntVal (argv[0]) >= 0) return Failed;  /* must be negative */
  727.             }
  728.          else {
  729.             if (!cnv:C_string(argv[0], str)) {
  730.                ReturnErrVal (103, argv[0], Error);
  731.                }
  732.             if (parsecolor (NULL, str, &r, &g, &b) != Succeeded) {
  733.                gNumColors--;
  734.                return Failed;
  735.                }
  736.             c.red = r;
  737.             c.green = g;
  738.             c.blue = b;
  739.             }
  740.       SetEntryColor (gPal, gNumColors-1, &c);
  741.       ActivatePalette (ws->theWindow);
  742. /*      
  743.       ws->lockOK = LockPixels (ws->offScreenPMHandle);
  744.       ActivatePalette ((WindowPtr)(ws->offScreenGWorld));
  745.       UnlockPixels (ws->offScreenPMHandle);
  746.  */
  747.       }
  748.       
  749.       *retval = -gNumColors;
  750.       return Succeeded;
  751.    }
  752. }
  753.  
  754. int setleading(wb, i)
  755. wbp wb;
  756. int i;
  757. {  
  758.    STDLOCALS(wb);
  759.    
  760.    if (i<0) return Failed;
  761.    wc->font->fInfo.leading = i;
  762.    return Succeeded;
  763. }
  764.  
  765. /*
  766.  * Set the context's line width
  767.  */
  768. int setlinewidth(wb, linewid)
  769. wbp wb;
  770. LONG linewid;
  771. {
  772.    STDLOCALS(wb);
  773.    
  774.    if (linewid < 0) return Failed;
  775.    wc->contextPtr->pnSize.h = linewid;
  776.    wc->contextPtr->pnSize.v = linewid;
  777.    return Succeeded;
  778. }
  779.  
  780. int setwidth(wb, new_width)
  781. wbp wb;
  782. SHORT new_width;
  783. {
  784.    STDLOCALS(wb);
  785.    if (new_width < 0) return Failed;
  786.    ws->width = new_width;
  787.    return Succeeded;
  788. }
  789.  
  790. int setheight(wb, new_height)
  791. wbp wb;
  792. short new_height;
  793. {
  794.    STDLOCALS(wb);
  795.    if (new_height < 0) return Failed;
  796.    ws->height = new_height;
  797.    return Succeeded;
  798. }
  799.  
  800. int query_pointer(wb, pp)
  801. wbp wb;
  802. XPoint *pp;
  803. {
  804.    Point mousePt;
  805.    STDLOCALS (wb);
  806.    
  807.    SetPort (ws->theWindow);
  808.    GetMouse (&mousePt);
  809.    pp->x = mousePt.h;
  810.    pp->y = mousePt.v;
  811.    return Succeeded;
  812. }
  813.  
  814. int query_rootpointer(pp)
  815. XPoint *pp;
  816. {
  817. }
  818.  
  819. void toggle_fgbg(w)
  820. wbp w;
  821. {
  822. }
  823.  
  824. int setwindowlabel(wb, s)
  825. wbp wb;
  826. char *s;
  827. {
  828.    wsp ws = wb->window;
  829.    if (ws->windowlabel != NULL) free(ws->windowlabel);
  830.    ws->windowlabel = salloc(s);
  831.    SetWTitle (ws->theWindow, "\pUntitled");
  832.    return Succeeded;
  833. }
  834.  
  835. int seticonlabel(w, val)
  836. wbp w;
  837. char *val;
  838. {
  839. }
  840.  
  841. /*
  842.  * setdrawop() - set the drawing operation
  843.  */
  844. int setdrawop(w, val)
  845. wbp w;
  846. char *val;
  847. {
  848. }
  849.  
  850. void setclip(wb)
  851. wbp wb;
  852. {
  853.    Rect r;
  854.    STDLOCALS(wb);
  855.    
  856.    SetRect (&r, wc->clipx, wc->clipy, wc->clipx+wc->clipw, wc->clipy+wc->cliph);
  857.    SetPort (ws->theWindow);
  858.    ClipRect (&r);
  859. }
  860.  
  861. void unsetclip(w)
  862. wbp  w;
  863. {
  864. }
  865.  
  866. int    allowresize(w, on)
  867. wbp  w;
  868. int  on;
  869. {
  870.    return 0;
  871. }
  872.  
  873. int    setgamma(w, gamma)
  874. wbp  w;
  875. double  gamma;
  876. {
  877.    return 0;
  878. }
  879.  
  880. /*
  881.  * setpointer() - define a mouse pointer shape
  882.  */
  883. int setpointer(w, val)
  884. wbp w;
  885. char *val;
  886. {
  887. }
  888.  
  889. /*
  890.  * setcursor() - 
  891.  */
  892. int setcursor(w, on)
  893. wbp w;
  894. int on;
  895. {
  896.    if (on==1)
  897.       InitCursor ();
  898.    else {
  899.       InitCursor ();
  900.       HideCursor ();
  901.       }
  902.    return Succeeded;
  903. }
  904.  
  905. int seticonpos(w,s)
  906. wbp w;
  907. char *s;
  908. {
  909. }
  910.  
  911.  
  912. /*
  913.  * Set the window's font by name.
  914.  */
  915. int setfont(wb,s)
  916. wbp wb;
  917. char **s;
  918. {
  919.    short theFontNum;
  920.    STDLOCALS(wb);
  921.    
  922.    GetFNum (CtoPstr (*s), &theFontNum);
  923.    wc->contextPtr->txFont = theFontNum;
  924.    return Succeeded;
  925. }
  926.  
  927. /*
  928.  * sync all the servers ???
  929.  */
  930. novalue wsync(w)
  931. wbp w;
  932. {
  933. }
  934.  
  935. /*
  936.  * put a character out to a window using the current attributes
  937.  */
  938. int wputc(ci,w)
  939. int ci;
  940. wbp w;
  941. {
  942. }
  943.  
  944. int setgeometry(wb, geo)
  945. wbp wb;
  946. char *geo;
  947. {
  948.    int width = 0, height = 0;
  949.    int x = 0, y = 0, status;
  950.    char *tmps;
  951.    STDLOCALS(wb);
  952.  
  953.    if ((status = parsegeometry(geo, &x, &y, &width, &height)) == 0)
  954.       return Error;
  955.    if (status & 1) {
  956.       ws->width = width;
  957.       ws->height = height;
  958.       }
  959.    if (status & 2) {
  960.       ws->posx = x;
  961.       ws->posy = y;
  962.       }
  963.    /* insert assigns here:
  964.     *  ws->posx = ((sign > 0) ? tmp :
  965.     *              DisplayWidth(stddpy,wd->screen) - ws->width - tmp);
  966.     *  ws->posy = ((sign > 0) ? tmp :
  967.     *              DisplayHeight(stddpy,wd->screen) - ws->height - tmp);
  968.     */
  969.    return Succeeded;
  970. }
  971.  
  972. /*
  973.  * wclose - close a window.  If is a real on-screen window,
  974.  * wait for a DestroyNotify event from the server before returning.
  975.  */
  976. int wclose(wb)
  977. wbp wb;
  978. {
  979.    STDLOCALS (wb);
  980.    
  981.    DisposeWindow (ws->theWindow);
  982.    DisposeGWorld (ws->offScreenGWorld);
  983. }
  984.  
  985. /*
  986.  * flush a window
  987.  */
  988. novalue wflush(w)
  989. wbp w;
  990. {
  991. }
  992.  
  993. /*
  994.  * get a single item from w's pending queue
  995.  */
  996. int wgetq(wb,res)
  997. wbp wb;
  998. dptr res;
  999. {
  1000.    wsp ws;
  1001.    if (!wb || !(ws = wb->window) || !(ws->theWindow)) return -1;
  1002.    while (1) {
  1003.       if (!EVQUEEMPTY (ws)) {
  1004.          EVQUEGET (ws, *res);
  1005.          return 1;
  1006.          }
  1007.       GetEvents ();
  1008.       }
  1009.    return -1;
  1010. }
  1011.  
  1012. void warpPointer(w, x, y)
  1013. wbp w;
  1014. int x, y;
  1015. {
  1016.    /* can't change cursor location, Inside Mac, Imaging: 8-4 */
  1017. }
  1018.  
  1019. int walert(w, volume) 
  1020. wbp w;
  1021. long volume;
  1022. {
  1023.    long oldVol;
  1024.    
  1025.    GetDefaultOutputVolume(&oldVol);
  1026.    SetDefaultOutputVolume(volume);
  1027.    SysBeep (30);
  1028.    SetDefaultOutputVolume(oldVol);
  1029. }
  1030.  
  1031. /*
  1032.  * write some text to both the window and the pixmap
  1033.  */
  1034. void xdis(w,s,n)
  1035. register wbp w;
  1036. char *s;
  1037. int n;
  1038. {
  1039. }
  1040.  
  1041. wsp GetActiveWindow(void)
  1042. {
  1043. }
  1044.  
  1045. #else                    /* Graphics */
  1046. static char junk;        /* avoid empty module */
  1047. #endif                    /* Graphics */
  1048.