home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 13 / AACD13.ISO / AACD / Resources / System / BoingBag1 / Contributions / Workbench / RexxArpLib3p6 / src / whfunctions.c < prev    next >
C/C++ Source or Header  |  1998-06-21  |  27KB  |  1,683 lines

  1. /**    Whfunctions.c
  2.   *
  3.   *    Implement the Window access and control functions for rexxarplib.library.
  4.   *
  5.   *   AUTHOR/DATE:  W.G.J. Langeveld, November 1987.
  6.   *   ============
  7.   *
  8.   *    CURRENT VERSION:
  9.   *
  10.   *    This version has been converted to SAS C 6.5 format. It has been modified
  11.   *    for modern definition sequences for ANSI compilation. This no longer works
  12.   *    with OS versions prior to 2.04.
  13.   *
  14.   *   AUTHOR/DATE:  Joanne Dow, jdow@bix.com, June 1998.
  15.   *   ============
  16.   *
  17.   **/
  18. #include <functions.h>
  19. #include "ralprotos.h"
  20. #include <exec/types.h>
  21. #include <exec/exec.h>
  22. #include <libraries/dos.h>
  23. #include <libraries/dosextens.h>
  24. #include <intuition/intuition.h>
  25. #include <graphics/gfxbase.h>
  26. #include <graphics/rastport.h>
  27. #include <graphics/gfxmacros.h>
  28. #include <graphics/text.h>
  29. #include <libraries/MyARP.h>
  30. #include <proto/rexxsyslib.h>
  31. #include <stdio.h>
  32. #include <stdlib.h>
  33. #include <string.h>
  34. #include <ctype.h>
  35. #include "rexxarplib.h"
  36. #include <simpmenu.h>
  37. #include <simpreq.h>
  38. #include "areapolydraw.h"
  39.  
  40. static struct TextFont *GetFont(struct TextAttr *, int);
  41.  
  42. /**
  43.  *
  44.  *   whf_draw
  45.  *
  46. **/
  47. char *whf_draw( struct HostParams *hp, int n, char *args[] )
  48. {
  49.     struct RastPort *rp;
  50.     
  51.     hp->Result = 41L;
  52.     
  53.     if (hp->Window == NULL)
  54.         return(NULL);
  55.     rp = hp->Window->RPort;
  56.     
  57.     if (hp->Result = checkargs(n, args))
  58.         return(NULL);
  59.     
  60.     Draw(rp, atol(args[0]), atol(args[1]));
  61.     
  62.     return(NULL);
  63. }
  64.  
  65.  
  66. /**
  67.  *
  68.  *   whf_move
  69.  *
  70. **/
  71. char *whf_move( struct HostParams *hp, int n, char *args[] )
  72. {
  73.     struct RastPort *rp;
  74.     
  75.     hp->Result = 41L;
  76.     
  77.     if (hp->Window == NULL)
  78.         return(NULL);
  79.     rp = hp->Window->RPort;
  80.     
  81.     if (hp->Result = checkargs(n, args))
  82.         return(NULL);
  83.     
  84.     Move(rp, atol(args[0]), atol(args[1]));
  85.     
  86.     return(NULL);
  87. }
  88.  
  89.  
  90. /**
  91.  *
  92.  *   whf_text
  93.  *
  94. **/
  95. char *whf_text( struct HostParams *hp, int n, char *args[] )
  96. {
  97.     struct RastPort *rp;
  98.     int temp;
  99.     
  100.     hp->Result = 41L;
  101.     
  102.     if (hp->Window == NULL)
  103.         return(NULL);
  104.     rp = hp->Window->RPort;
  105.     
  106.     if (hp->Result = checkargs(n, args))
  107.         return(NULL);
  108.     
  109.     temp = strlen(args[0]);
  110.     Text(rp, args[0], (long) temp);
  111.     
  112.     return(NULL);
  113. }
  114.  
  115.  
  116. /**
  117.  *
  118.  *   whf_writepixel
  119.  *
  120. **/
  121. char *whf_writepixel( struct HostParams *hp, int n, char *args[] )
  122. {
  123.     struct RastPort *rp;
  124.     
  125.     hp->Result = 41L;
  126.     
  127.     if (hp->Window == NULL)
  128.         return(NULL);
  129.     rp = hp->Window->RPort;
  130.     
  131.     if (hp->Result = checkargs(n, args))
  132.         return(NULL);
  133.     
  134.     WritePixel(rp, atol(args[0]), atol(args[1]));
  135.     
  136.     return(NULL);
  137. }
  138.  
  139.  
  140. /**
  141.  *
  142.  *   whf_drawellipse
  143.  *
  144. **/
  145. char *whf_drawellipse( struct HostParams *hp, int n, char *args[] )
  146. {
  147.     struct RastPort *rp;
  148.     long a, b;
  149.     
  150.     hp->Result = 41L;
  151.     
  152.     if (hp->Window == NULL)
  153.         return(NULL);
  154.     rp = hp->Window->RPort;
  155.     
  156.     if (hp->Result = checkargs(n, args))
  157.         return(NULL);
  158.     
  159.     a = atol(args[2]);
  160.     a = (a > 0L) ? a : -a;
  161.     b = atol(args[3]);
  162.     b = (b > 0L) ? b : -b;
  163.     DrawEllipse(rp, atol(args[0]), atol(args[1]), a, b);
  164.     
  165.     return(NULL);
  166. }
  167.  
  168.  
  169. /**
  170.  *
  171.  *   whf_drawcircle
  172.  *
  173. **/
  174. char *whf_drawcircle( struct HostParams *hp, int n, char *args[] )
  175. {
  176.     struct RastPort *rp;
  177.     long a;
  178.     
  179.     hp->Result = 41L;
  180.     
  181.     if (hp->Window == NULL)
  182.         return(NULL);
  183.     rp = hp->Window->RPort;
  184.     
  185.     if (hp->Result = checkargs(n, args))
  186.         return(NULL);
  187.     
  188.     a = atol(args[2]);
  189.     a = (a > 0L) ? a : -a;
  190.     DrawCircle(rp, atol(args[0]), atol(args[1]), a);
  191.     
  192.     return(NULL);
  193. }
  194.  
  195.  
  196. /**
  197.  *
  198.  *   whf_flood
  199.  *
  200. **/
  201. char *whf_flood( struct HostParams *hp, int n, char *args[] )
  202. {
  203.     struct RastPort *rp;
  204.     
  205.     hp->Result = 41L;
  206.     
  207.     if (hp->Window == NULL)
  208.         return(NULL);
  209.     rp = hp->Window->RPort;
  210.     
  211.     if (hp->Result = checkargs(n, args))
  212.         return(NULL);
  213.     
  214.     if (AllocTmpRas(rp, hp->Window->Width + 32, hp->Window->Height + 2)) 
  215.     {
  216.         Flood(rp, atol(args[0]), atol(args[1]), atol(args[2]));
  217.         FreeTmpRas(rp);
  218.     }
  219.     
  220.     return(NULL);
  221. }
  222.  
  223.  
  224. /**
  225.  *
  226.  *   whf_rectfill
  227.  *
  228. **/
  229. char *whf_rectfill( struct HostParams *hp, int n, char *args[] )
  230. {
  231.     struct RastPort *rp;
  232.     long x1, y1, x2, y2;
  233.     
  234.     hp->Result = 41L;
  235.     
  236.     if (hp->Window == NULL)
  237.         return(NULL);
  238.     rp = hp->Window->RPort;
  239.     
  240.     if (hp->Result = checkargs(n, args))
  241.         return(NULL);
  242.     
  243.     hp->Result = 12L;
  244.     
  245.     x1 = atol(args[0]);
  246.     y1 = atol(args[1]);
  247.     x2 = atol(args[2]);
  248.     y2 = atol(args[3]);
  249.     
  250.     if (x1 > x2)
  251.         return(NULL);
  252.     if (y1 > y2)
  253.         return(NULL);
  254.     
  255.     RectFill(rp, x1, y1, x2, y2);
  256.     
  257.     hp->Result = 0L;
  258.     
  259.     return(NULL);
  260. }
  261.  
  262.  
  263. /**
  264.  *
  265.  *   whf_setrgb4
  266.  *
  267. **/
  268. char *whf_setrgb4( struct HostParams *hp, int n, char *args[] )
  269. {
  270.     struct ViewPort *vp;
  271.     
  272.     hp->Result = 41L;
  273.     
  274.     if (hp->Window == NULL)
  275.         return(NULL);
  276.     vp = ViewPortAddress(hp->Window);
  277.     
  278.     if (hp->Result = checkargs(n, args))
  279.         return(NULL);
  280.     
  281.     SetRGB4(vp, atol(args[0]), atol(args[1]), atol(args[2]), atol(args[3]));
  282.     
  283.     return(NULL);
  284. }
  285.  
  286.  
  287. /**
  288.  *
  289.  *   whf_setapen
  290.  *
  291. **/
  292. char *whf_setapen( struct HostParams *hp, int n, char *args[] )
  293. {
  294.     struct RastPort *rp;
  295.     
  296.     hp->Result = 41L;
  297.     
  298.     if (hp->Window == NULL)
  299.         return(NULL);
  300.     rp = hp->Window->RPort;
  301.     
  302.     if (hp->Result = checkargs(n, args))
  303.         return(NULL);
  304.     
  305.     SetAPen(rp, atol(args[0]));
  306.     
  307.     return(NULL);
  308. }
  309.  
  310.  
  311. /**
  312.  *
  313.  *   whf_setbpen
  314.  *
  315. **/
  316. char *whf_setbpen( struct HostParams *hp, int n, char *args[] )
  317. {
  318.     struct RastPort *rp;
  319.     
  320.     hp->Result = 41L;
  321.     
  322.     if (hp->Window == NULL)
  323.         return(NULL);
  324.     rp = hp->Window->RPort;
  325.     
  326.     if (hp->Result = checkargs(n, args))
  327.         return(NULL);
  328.     
  329.     SetBPen(rp, atol(args[0]));
  330.     
  331.     return(NULL);
  332. }
  333.  
  334.  
  335. /**
  336.  *
  337.  *   whf_setopen
  338.  *
  339. **/
  340. char *whf_setopen( struct HostParams *hp, int n, char *args[] )
  341. {
  342.     struct RastPort *rp;
  343.     
  344.     hp->Result = 41L;
  345.     
  346.     if (hp->Window == NULL)
  347.         return(NULL);
  348.     rp = hp->Window->RPort;
  349.     
  350.     if (hp->Result = checkargs(n, args))
  351.         return(NULL);
  352.     
  353.     SetOPen(rp, atol(args[0]));
  354.     
  355.     return(NULL);
  356. }
  357.  
  358.  
  359. /**
  360.  *
  361.  *   whf_setdrmd
  362.  *
  363. **/
  364. char *whf_setdrmd( struct HostParams *hp, int n, char *args[] )
  365. {
  366.     struct RastPort *rp;
  367.     long Md = 0L;
  368.     
  369.     hp->Result = 41L;
  370.     
  371.     if (hp->Window == NULL)
  372.         return(NULL);
  373.     rp = hp->Window->RPort;
  374.     
  375.     if (hp->Result = checkargs(n, args))
  376.         return(NULL);
  377.     
  378.     if (strstr(args[0], "JAM1"))
  379.         Md |= JAM1;
  380.     if (strstr(args[0], "JAM2"))
  381.         Md |= JAM2;
  382.     if (strstr(args[0], "COMPLEMENT"))
  383.         Md |= COMPLEMENT;
  384.     if (strstr(args[0], "INVERSVID"))
  385.         Md |= INVERSVID;
  386.     
  387.     SetDrMd(rp, Md);
  388.     
  389.     return(NULL);
  390. }
  391.  
  392.  
  393. /**
  394.  *
  395.  *   whf_setdrpt
  396.  *
  397. **/
  398. char *whf_setdrpt( struct HostParams *hp, int n, char *args[] )
  399. {
  400.     struct RastPort *rp;
  401.     
  402.     hp->Result = 41L;
  403.     
  404.     if (hp->Window == NULL)
  405.         return(NULL);
  406.     rp = hp->Window->RPort;
  407.     
  408.     if (hp->Result = checkargs(n, args))
  409.         return(NULL);
  410.     
  411.     SetDrPt(rp, atol(args[0]));
  412.     
  413.     return(NULL);
  414. }
  415.  
  416.  
  417. /**
  418.  *
  419.  *   whf_areamove
  420.  *
  421. **/
  422. char *whf_areamove( struct HostParams *hp, int n, char *args[] )
  423. {
  424.     struct vtx *v;
  425.     
  426.     hp->Result = 41L;
  427.     
  428.     if (hp->Window == NULL)
  429.         return(NULL);
  430.     if (hp->Result = checkargs(n, args))
  431.         return(NULL);
  432.     
  433.     v = AddVertex(hp->Vertex);
  434.     if (v) 
  435.     {
  436.         v->type = AREAMOVE;
  437.         v->x = atoi(args[0]);
  438.         v->y = atol(args[1]);
  439.     }
  440.     else
  441.     {
  442.         KillVertex(hp->Vertex);
  443.         hp->Vertex = AddVertex(NULL);
  444.         hp->Result = 12L;
  445.     }
  446.     
  447.     return(NULL);
  448. }
  449.  
  450.  
  451. /**
  452.  *
  453.  *   whf_areadraw
  454.  *
  455. **/
  456. char *whf_areadraw( struct HostParams *hp, int n, char *args[] )
  457. {
  458.     struct vtx *v;
  459.     
  460.     hp->Result = 41L;
  461.     
  462.     if (hp->Window == NULL)
  463.         return(NULL);
  464.     if (hp->Result = checkargs(n, args))
  465.         return(NULL);
  466.     
  467.     v = AddVertex(hp->Vertex);
  468.     if (v) 
  469.     {
  470.         v->type = AREADRAW;
  471.         v->x = atoi(args[0]);
  472.         v->y = atol(args[1]);
  473.     }
  474.     else
  475.     {
  476.         KillVertex(hp->Vertex);
  477.         hp->Vertex = AddVertex(NULL);
  478.         hp->Result = 12L;
  479.     }
  480.     
  481.     return(NULL);
  482. }
  483.  
  484.  
  485. /**
  486.  *
  487.  *   whf_areaend
  488.  *
  489. **/
  490. char *whf_areaend( struct HostParams *hp, int n, char *args[] )
  491. {
  492.     struct RastPort *rp;
  493.     int pen;
  494.     
  495.     hp->Result = 41L;
  496.     
  497.     if (hp->Window == NULL)
  498.         return(NULL);
  499.     rp = hp->Window->RPort;
  500.     
  501.     if (hp->Result = checkargs(n, args))
  502.         return(NULL);
  503.     
  504.     if (n == 1)
  505.         pen = atoi(args[0]);
  506.     else
  507.         pen = rp->FgPen;
  508.     
  509.     if ((pen & 1024) == 0) 
  510.     {
  511.         if (AreaPolyDraw(hp->Window, hp->Vertex, pen, 0, 0) == 0)
  512.             hp->Result = 12L;
  513.     }
  514.     
  515.     KillVertex(hp->Vertex);
  516.     hp->Vertex = AddVertex(NULL);
  517.     
  518.     return(NULL);
  519. }
  520.  
  521.  
  522. /**
  523.  *
  524.  *   whf_areaellipse
  525.  *
  526. **/
  527. char *whf_areaellipse( struct HostParams *hp, int n, char *args[] )
  528. {
  529.     struct vtx *v;
  530.     int a, b;
  531.     
  532.     hp->Result = 41L;
  533.     
  534.     if (hp->Window == NULL)
  535.         return(NULL);
  536.     if (hp->Result = checkargs(n, args))
  537.         return(NULL);
  538.     
  539.     v = AddVertex(hp->Vertex);
  540.     if (v) 
  541.     {
  542.         v->type = AREAELLIPSE;
  543.         v->x = atoi(args[0]);
  544.         v->y = atol(args[1]);
  545.         a = atoi(args[2]);
  546.         a = (a > 0L) ? a : -a;
  547.         b = atoi(args[3]);
  548.         b = (b > 0L) ? b : -b;
  549.         v->a = a;
  550.         v->b = b;
  551.     }
  552.     else
  553.     {
  554.         KillVertex(hp->Vertex);
  555.         hp->Vertex = AddVertex(NULL);
  556.         hp->Result = 12L;
  557.     }
  558.     
  559.     return(NULL);
  560. }
  561.  
  562.  
  563. /**
  564.  *
  565.  *   whf_areacircle
  566.  *
  567. **/
  568. char *whf_areacircle( struct HostParams *hp, int n, char *args[] )
  569. {
  570.     struct vtx *v;
  571.     long a;
  572.     
  573.     hp->Result = 41L;
  574.     
  575.     if (hp->Window == NULL)
  576.         return(NULL);
  577.     if (hp->Result = checkargs(n, args))
  578.         return(NULL);
  579.     
  580.     v = AddVertex(hp->Vertex);
  581.     if (v) 
  582.     {
  583.         v->type = AREACIRCLE;
  584.         v->x = atoi(args[0]);
  585.         v->y = atol(args[1]);
  586.         a = atoi(args[2]);
  587.         a = (a > 0L) ? a : -a;
  588.         v->a = a;
  589.         v->b = a;
  590.     }
  591.     else
  592.     {
  593.         KillVertex(hp->Vertex);
  594.         hp->Vertex = AddVertex(NULL);
  595.         hp->Result = 12L;
  596.     }
  597.     
  598.     return(NULL);
  599. }
  600.  
  601.  
  602. /**
  603.  *
  604.  *   whf_addgadget
  605.  *
  606. **/
  607. char *whf_addgadget( struct HostParams *hp, int n, char *args[] )
  608. {
  609.     char *ps = NULL;
  610.     int x = 0, y = 0, i = 0, strwidth = 0, numgad = 0;
  611.     ULONG ec;
  612.     struct Gadget *g = NULL;
  613.     /*
  614.      *   Check the arguments
  615.      */
  616.     hp->Result = 41L;
  617.     if (hp->Window == NULL)
  618.         return(NULL);
  619.     
  620.     hp->Result = 17L;
  621.     if ((n < 5) || (n > 7))
  622.         return(NULL);
  623.     /*
  624.      *   Top, left edge of gadget
  625.      */
  626.     if (args[0])
  627.         x = atoi(args[0]);
  628.     if (args[1])
  629.         y = atoi(args[1]);
  630.     /*
  631.      *   Gadget text or default string
  632.      */
  633.     hp->Result = 3L;
  634.     if (args[3])
  635.         strwidth = strlen(args[3]);
  636.     
  637.     ps = mymalloc(strwidth + 1);
  638.     if (ps == NULL)
  639.         return(NULL);
  640.     ps[0] = '\0';
  641.     
  642.     if (args[3])
  643.         strcpy(ps, args[3]);
  644.     /*
  645.      *   Add the gadget
  646.      */
  647.     if (n == 5) 
  648.     {
  649.         for (i = 0; ps[i] != '\0'; i++)
  650.             if (ps[i] == '\\') ps[i] = '\n';
  651.  
  652.         g = MakeSBoolGad( ps,
  653.                           hp->ReqPens->reqp_BoxPen,
  654.                           hp->ReqPens->reqp_ShadowPen,
  655.                           hp->ReqPens->reqp_OkayPen,
  656.                           x,
  657.                           y,
  658.                           2,
  659.                           1,
  660.                           0x71,
  661.                           &ec);
  662.  
  663.         g->Activation |= GADGIMMEDIATE;
  664.  
  665.     }
  666.     else
  667.     {
  668.         if (args[3])
  669.             strwidth = strlen(args[3]) * 8;
  670.         if (args[5])
  671.             strwidth = atoi(args[5]);
  672.         if (strwidth < 8)
  673.             strwidth = 8;
  674.         if ((n == 7) && args[6]) 
  675.         {
  676.             if (strstr(args[6], "RIDGEBORDER"))
  677.                 strwidth = -strwidth;
  678.             if (strstr(args[6], "NUMERIC"))
  679.                 numgad = 1;
  680.         }
  681.  
  682.         g = MakeSStrGad( ps,
  683.                          hp->ReqPens->reqp_BoxPen,
  684.                          hp->ReqPens->reqp_ShadowPen,
  685.                          x,
  686.                          y + 1,
  687.                          strwidth,
  688.                          0x72,
  689.                          &ec);
  690.         
  691.         if (g && numgad)
  692.             g->Activation |= LONGINT;
  693.     }
  694.     if (g == NULL)
  695.         goto cleanup;
  696.  
  697.     /*
  698.      *   Store the message text
  699.      */
  700.     g->UserData = MakeGUData(args[2], args[4]);
  701.     /*
  702.      *   Refresh the gadget
  703.      */
  704.     AddGadget(hp->Window, g, -1L);
  705.     RefreshGadgets(g, hp->Window, NULL);
  706.     
  707.     hp->Result = 0L;
  708.     
  709.     cleanup:
  710.     if (ps)
  711.         myfree(ps);
  712.     
  713.     return(NULL);
  714. }
  715.  
  716. APTR MakeGUData(char *s, char *t)
  717. {
  718.     struct GUData *result = NULL;
  719.     
  720.     if (s == NULL || t == NULL)
  721.         return(NULL);
  722.     result = (struct GUData *) mymalloc(sizeof(struct GUData));
  723.     if (result) 
  724.     {
  725.         result->GadgetID = mymalloc(strlen(s) + 1);
  726.         if (result->GadgetID)
  727.             strcpy(result->GadgetID, s);
  728.         result->MsgText  = mymalloc(strlen(t) + 1);
  729.         if (result->MsgText)
  730.             strcpy(result->MsgText,  t);
  731.     }
  732.     return((APTR) result);
  733. }
  734.  
  735. APTR FreeGUData( struct GUData *g )
  736. {
  737.     if (g) 
  738.     {
  739.         if (g->GadgetID)
  740.             myfree(g->GadgetID);
  741.         if (g->MsgText)
  742.             myfree(g->MsgText);
  743.         myfree(g);
  744.     }
  745.     return(NULL);
  746. }
  747.  
  748. /**
  749.  *
  750.  *   whf_removegadget
  751.  *
  752. **/
  753. char *whf_removegadget( struct HostParams *hp, int n, char *args[] )
  754. {
  755.     struct Gadget *gadget = NULL;
  756.     
  757.     hp->Result = 41L;
  758.     
  759.     if (hp->Window == NULL)
  760.         return(NULL);
  761.     
  762.     if (hp->Result = checkargs(n, args))
  763.         return(NULL);
  764.     
  765.     hp->Result = 12L;
  766.     
  767.     gadget = hp->Window->FirstGadget;
  768.     while (gadget) 
  769.     {
  770.         if ((gadget->GadgetID & 0xF0) == 0x70) 
  771.         {
  772.             if (gadget->UserData) 
  773.             {
  774.                 if (strcmpu( ((struct GUData *) gadget->UserData)->GadgetID,
  775.                 args[0]) == 0) 
  776.                 {
  777.                     RemoveGadget(hp->Window, gadget);
  778.                     gadget->UserData = FreeGUData(gadget->UserData);
  779.                     FreeSimpGad(gadget);
  780.                     hp->Result = 0L;
  781.                     break;
  782.                 }
  783.             }
  784.         }
  785.         gadget = gadget->NextGadget;
  786.     }
  787.     
  788.     return(NULL);
  789. }
  790.  
  791.  
  792. /**
  793.  *
  794.  *   whf_refreshgadget
  795.  *
  796. **/
  797. char *whf_refreshgadgets( struct HostParams *hp, int n, char *args[] )
  798. {
  799.     hp->Result = 41L;
  800.     
  801.     if (hp->Window == NULL)
  802.         return(NULL);
  803.     
  804.     if (hp->Result = checkargs(n, args))
  805.         return(NULL);
  806.     
  807.     if (hp->Window->FirstGadget)
  808.         RefreshGadgets(hp->Window->FirstGadget, hp->Window, NULL);
  809.     
  810.     return(NULL);
  811. }
  812.  
  813.  
  814. /**
  815.  *
  816.  *   whf_windowtext
  817.  *
  818. **/
  819. char *whf_windowtext( struct HostParams *hp, int n, char *args[] )
  820. {
  821.     struct SimpleRequester s;
  822.     char *sr_prompts[SR_MAXPROMPTS];
  823.     char *ps;
  824.  
  825.     hp->Result = 41L;
  826.  
  827.     if (hp->Window == NULL)
  828.         return(NULL);
  829.  
  830.     if (hp->Result = checkargs(n, args))
  831.         return(NULL);
  832.  
  833.     setmem(sr_prompts, SR_MAXPROMPTS << 2, 0);
  834.     setmem(&s, sizeof(struct SimpleRequester), 0);
  835.     
  836.     hp->Result = 3L;
  837.     ps = mymalloc(strlen(args[0]) + 1);
  838.     if (!ps)
  839.         return(NULL);
  840.  
  841.     DecodeAutoText(args[0], sr_prompts, ps);
  842.     s.sr_Prompt  = sr_prompts;
  843.     s.sr_PenList = hp->ReqPens;
  844.     UpdateMsgWindow(hp->Window, &s);
  845.  
  846.     myfree(ps);
  847.     
  848.     hp->Result = 0L;
  849.     
  850.     return(NULL);
  851. }
  852.  
  853.  
  854. /**
  855.  *
  856.  *   whf_backfill
  857.  *
  858. **/
  859. char *whf_backfill( struct HostParams *hp, int n, char *args[] )
  860. {
  861.     register long pen;
  862.     hp->Result = 41L;
  863.     
  864.     if (hp->Window == NULL)
  865.         return(NULL);
  866.     
  867.     if (hp->Result = checkargs(n, args))
  868.         return(NULL);
  869.     
  870.     pen = hp->Window->RPort->FgPen;
  871.     BlankSReqWin(hp->Window, (LONG) hp->ReqPens->reqp_BackPen);
  872.     SetAPen(hp->Window->RPort, pen);
  873.     
  874.     return(NULL);
  875. }
  876.  
  877. /**
  878.  *
  879.  *   whf_modifyhost
  880.  *
  881. **/
  882. char *whf_modifyhost( struct HostParams *hp, int n, char *args[] )
  883. {
  884.     int i;
  885.     
  886.     hp->Result = 41L;
  887.     
  888.     if (hp->Window == NULL)
  889.         return(NULL);
  890.     
  891.     if (hp->Result = checkargs(n, args))
  892.         return(NULL);
  893.     
  894.     for (i = 0; i < MAXCLASSES; i++) 
  895.     {
  896.         if (strcmp(args[0], ch_classtext(i)) == 0) 
  897.         {
  898.             if (hp->ClassText[i])
  899.                 myfree(hp->ClassText[i]);
  900.             hp->ClassText[i] = mymalloc(strlen(args[1]) + 1);
  901.             if (hp->ClassText[i] == NULL) 
  902.             {
  903.                 hp->Result = 3L;
  904.             }
  905.             else
  906.             {
  907.                 strcpy(hp->ClassText[i], args[1]);
  908.             }
  909.             return(NULL);
  910.         }
  911.     }
  912.     
  913.     hp->Result = 12L;
  914.     
  915.     return(NULL);
  916. }
  917.  
  918. /**
  919.  *
  920.  *   whf_setnotify
  921.  *
  922. **/
  923. char *whf_setnotify( struct HostParams *hp, int n, char *args[] )
  924. {
  925.     int i;
  926.     
  927.     hp->Result = 41L;
  928.     
  929.     if (hp->Window == NULL)
  930.         return(NULL);
  931.     
  932.     if (hp->Result = checkargs(n, args))
  933.         return(NULL);
  934.     
  935.     for (i = 0; i < MAXCLASSES; i++) 
  936.     {
  937.         if (strcmp(args[0], ch_classtext(i)) == 0) 
  938.         {
  939.             if (hp->NotifyPortName[i])
  940.                 myfree(hp->NotifyPortName[i]);
  941.             hp->NotifyPortName[i] = mymalloc(strlen(args[1]) + 1);
  942.             if (hp->NotifyPortName[i] == NULL) 
  943.             {
  944.                 hp->Result = 3L;
  945.             }
  946.             else
  947.             {
  948.                 strcpy(hp->NotifyPortName[i], args[1]);
  949.             }
  950.             return(NULL);
  951.         }
  952.     }
  953.     
  954.     hp->Result = 12L;
  955.     
  956.     return(NULL);
  957. }
  958.  
  959. /**
  960.  *
  961.  *   whf_windowtoback
  962.  *
  963. **/
  964. char *whf_windowtoback( struct HostParams *hp, int n, char *args[] )
  965. {
  966.     hp->Result = 41L;
  967.     
  968.     if (hp->Window == NULL)
  969.         return(NULL);
  970.     
  971.     if (hp->Result = checkargs(n, args))
  972.         return(NULL);
  973.     
  974.     WindowToBack(hp->Window);
  975.     
  976.     return(NULL);
  977. }
  978.  
  979. /**
  980.  *
  981.  *   whf_windowtofront
  982.  *
  983. **/
  984. char *whf_windowtofront( struct HostParams *hp, int n, char *args[] )
  985. {
  986.     hp->Result = 41L;
  987.     
  988.     if (hp->Window == NULL)
  989.         return(NULL);
  990.     
  991.     if (hp->Result = checkargs(n, args))
  992.         return(NULL);
  993.     
  994.     WindowToFront(hp->Window);
  995.     
  996.     return(NULL);
  997. }
  998.  
  999. /**
  1000.  *
  1001.  *   whf_activatewindow
  1002.  *
  1003. **/
  1004. char *whf_activatewindow( struct HostParams *hp, int n, char *args[] )
  1005. {
  1006.     hp->Result = 41L;
  1007.     
  1008.     if (hp->Window == NULL)
  1009.         return(NULL);
  1010.     
  1011.     if (hp->Result = checkargs(n, args))
  1012.         return(NULL);
  1013.     
  1014.     ActivateWindow(hp->Window);
  1015.     
  1016.     return(NULL);
  1017. }
  1018.  
  1019. /**
  1020.  *
  1021.  *   whf_setfont
  1022.  *
  1023. **/
  1024. char *whf_setfont( struct HostParams *hp, int n, char *args[] )
  1025. {
  1026.     struct RastPort *rp;
  1027.     struct TextAttr attr;
  1028.     int xsize = 0;
  1029.     struct TextFont *font;
  1030.     
  1031.     hp->Result = 41L;
  1032.     
  1033.     if (DiskfontBase == NULL)
  1034.         return(NULL);
  1035.     if (hp->Window == NULL)
  1036.         return(NULL);
  1037.     rp = hp->Window->RPort;
  1038.     
  1039.     if (hp->Result = checkargs(n, args))
  1040.         return(NULL);
  1041.     
  1042.     attr.ta_Name  = (STRPTR) args[0];
  1043.     attr.ta_YSize = atoi(args[1]);
  1044.     attr.ta_Style = 0;
  1045.     attr.ta_Flags = 0;
  1046.     
  1047.     if ((n >= 3) && args[2])
  1048.         attr.ta_Style = atoi(args[2]);
  1049.     if ((n >= 4) && args[3])
  1050.         attr.ta_Flags = atoi(args[3]);
  1051.     if ((n >= 5) && args[4])
  1052.         xsize         = atoi(args[4]);
  1053.     
  1054.     if (font = GetFont(&attr, xsize)) 
  1055.     {
  1056.         if (hp->Font)
  1057.             CloseFont(hp->Font);
  1058.         SetFont(rp, font);
  1059.         if (font->tf_Style != attr.ta_Style) 
  1060.         {
  1061.             SetSoftStyle(rp, (ULONG) font->tf_Style ^ (ULONG) attr.ta_Style, 0xFF);
  1062.         }
  1063.         hp->Font = font;
  1064.     }
  1065.     else
  1066.     {
  1067.         hp->Result = 12L;
  1068.     }
  1069.     
  1070.     return(NULL);
  1071. }
  1072.  
  1073. /**
  1074.  *
  1075.  *   Get a specific font
  1076.  *
  1077. **/
  1078. static struct TextFont *GetFont( struct TextAttr *attr, int xsize )
  1079. {
  1080.     struct TextFont *font = NULL;
  1081.     
  1082.     font = (struct TextFont *) OpenFont(attr);
  1083.     if (font) 
  1084.     {
  1085.         if ((font->tf_YSize != attr->ta_YSize) ||
  1086.         (xsize && (font->tf_XSize != xsize))    ) 
  1087.         {
  1088.             CloseFont(font);
  1089.             font = NULL;
  1090.         }
  1091.     }
  1092.     if (!font)
  1093.         font = (struct TextFont *) OpenDiskFont(attr);
  1094.     if (font) 
  1095.     {
  1096.         if ((font->tf_YSize != attr->ta_YSize) ||
  1097.         (xsize && (font->tf_XSize != xsize))    ) 
  1098.         {
  1099.             CloseFont(font);
  1100.             font = NULL;
  1101.         }
  1102.     }
  1103.     return(font);
  1104. }
  1105.  
  1106. /**
  1107.  *
  1108.  *   whf_activategadget
  1109.  *
  1110. **/
  1111. char *whf_activategadget( struct HostParams *hp, int n, char *args[] )
  1112. {
  1113.     struct Gadget *gadget;
  1114.     
  1115.     hp->Result = 41L;
  1116.     
  1117.     if (hp->Window == NULL)
  1118.         return(NULL);
  1119.     
  1120.     if (hp->Result = checkargs(n, args))
  1121.         return(NULL);
  1122.     
  1123.     hp->Result = 12L;
  1124.     
  1125.     gadget = hp->Window->FirstGadget;
  1126.     while (gadget) 
  1127.     {
  1128.         if (gadget->GadgetID == 0x72) 
  1129.         {
  1130.             if (gadget->UserData) 
  1131.             {
  1132.                 if (strcmpu( ((struct GUData *) gadget->UserData)->GadgetID,
  1133.                 args[0]) == 0) 
  1134.                 {
  1135.                     ActivateGadget(gadget, hp->Window, NULL);
  1136.                     hp->Result = 0L;
  1137.                     break;
  1138.                 }
  1139.             }
  1140.         }
  1141.         gadget = gadget->NextGadget;
  1142.     }
  1143.     
  1144.     return(NULL);
  1145. }
  1146.  
  1147. /**
  1148.  *
  1149.  *   whf_setgadget
  1150.  *
  1151. **/
  1152. char *whf_setgadget( struct HostParams *hp, int n, char *args[] )
  1153. {
  1154.     struct Gadget *gadget;
  1155.     int setit;
  1156.     
  1157.     hp->Result = 41L;
  1158.     
  1159.     if (hp->Window == NULL)
  1160.         return(NULL);
  1161.     
  1162.     if (hp->Result = checkargs(n, args))
  1163.         return(NULL);
  1164.     
  1165.     hp->Result = 17L;
  1166.     
  1167.     if      (strcmpu(args[1], "ON")  == 0)
  1168.         setit = 1;
  1169.     else
  1170.     if (strcmpu(args[1], "OFF") == 0)
  1171.         setit = 0;
  1172.     else
  1173.         return(NULL);
  1174.     
  1175.     hp->Result = 12L;
  1176.     
  1177.     gadget = hp->Window->FirstGadget;
  1178.     while (gadget) 
  1179.     {
  1180.         if (gadget->GadgetID == 0x71) 
  1181.         {
  1182.             if (gadget->UserData) 
  1183.             {
  1184.                 if (strcmpu( ((struct GUData *) gadget->UserData)->GadgetID,
  1185.                 args[0]) == 0) 
  1186.                 {
  1187.                     if (setit) 
  1188.                     {
  1189.                         GadMXSet(hp->Window, gadget);
  1190.                     }
  1191.                     else
  1192.                     {
  1193.                         GadMXClr(hp->Window, gadget);
  1194.                     }
  1195.                     hp->Result = 0L;
  1196.                     break;
  1197.                 }
  1198.             }
  1199.         }
  1200.         gadget = gadget->NextGadget;
  1201.     }
  1202.     
  1203.     return(NULL);
  1204. }
  1205.  
  1206. /**
  1207.  *
  1208.  *   whf_readgadget
  1209.  *
  1210. **/
  1211. char *whf_readgadget( struct HostParams *hp, int n, char *args[] )
  1212. {
  1213.     struct Gadget *gadget;
  1214.     char *sg = NULL;
  1215.     int num = -1, na = 0;
  1216.     
  1217.     hp->Result = 41L;
  1218.     
  1219.     if (hp->Window == NULL)
  1220.         return(NULL);
  1221.     
  1222.     if (hp->Result = checkargs(n, args))
  1223.         return(NULL);
  1224.     
  1225.     hp->Result = 12L;
  1226.     
  1227.     gadget = hp->Window->FirstGadget;
  1228.     while (gadget) 
  1229.     {
  1230.         if (gadget->GadgetID == 0x72) 
  1231.         {
  1232.             if (gadget->UserData) 
  1233.             {
  1234.                 if (strcmpu( ((struct GUData *) gadget->UserData)->GadgetID,
  1235.                 args[0]) == 0) 
  1236.                 {
  1237.                     sg = NULL;
  1238.                     
  1239.                     if ((gadget->GadgetID & 0x0F) == 0x02)
  1240.                         sg = (char *)
  1241.                     ((struct StringInfo*) (gadget->SpecialInfo))->Buffer;
  1242.                     
  1243.                     na = ch_makestr(hp, ((struct GUData *) gadget->UserData)->MsgText,
  1244.                     GADGETUP, 0, 0,
  1245.                     ((struct GUData *) gadget->UserData)->GadgetID,
  1246.                     sg);
  1247.                     
  1248.                     num = ch_classtoindex(GADGETUP);
  1249.                     
  1250.                     if (na) 
  1251.                     {
  1252.                         if (SendPortMsg(hp->NotifyPortName[num], na, hp->MsgPtr,
  1253.                             hp->MasterPort) == 0) hp->MsgCount++;
  1254.                     }
  1255.                     
  1256.                     hp->Result = 0L;
  1257.                     break;
  1258.                 }
  1259.             }
  1260.         }
  1261.         gadget = gadget->NextGadget;
  1262.     }
  1263.     
  1264.     return(NULL);
  1265. }
  1266.  
  1267. /**
  1268.  *
  1269.  *   whf_readhost
  1270.  *
  1271. **/
  1272. char *whf_readhost( struct HostParams *hp, int n, char *args[] )
  1273. {
  1274.     int na = 0;
  1275.     
  1276.     hp->Result = 41L;
  1277.     
  1278.     if (hp->Window == NULL)
  1279.         return(NULL);
  1280.     
  1281.     if (hp->Result = checkargs(n, args))
  1282.         return(NULL);
  1283.     
  1284.     hp->Result = 12L;
  1285.     
  1286.     na = ch_makestr(hp, args[1], 0, 0, 0, NULL, NULL);
  1287.     
  1288.     if (na) 
  1289.     {
  1290.         if (SendPortMsg(args[0], na, hp->MsgPtr, hp->MasterPort) == 0) 
  1291.         {
  1292.             hp->MsgCount++;
  1293.         }
  1294.     }
  1295.     
  1296.     hp->Result = 0L;
  1297.     
  1298.     return(NULL);
  1299. }
  1300.  
  1301.  
  1302. /**
  1303.  *
  1304.  *   whf_addmenu
  1305.  *
  1306. **/
  1307. char *whf_addmenu( struct HostParams *hp, int n, char *args[] )
  1308. {
  1309.     struct Menu *menu = NULL, *temp;
  1310.     
  1311.     hp->Result = 41L;
  1312.     
  1313.     if (hp->Window == NULL)
  1314.         return(NULL);
  1315.     
  1316.     if (hp->Result = checkargs(n, args))
  1317.         return(NULL);
  1318.     
  1319.     menu = hp->Window->MenuStrip;
  1320.     if (menu)
  1321.         ClearMenuStrip(hp->Window);
  1322.     
  1323.     hp->Result = 12L;
  1324.     temp = SMenu(menu, args[0]);
  1325.     
  1326.     if (temp == NULL) 
  1327.     {
  1328.         if (menu)
  1329.             freesmenu(menu);
  1330.         return(NULL);
  1331.     }
  1332.     
  1333.     hp->Result = 0L;
  1334.     if (menu == NULL)
  1335.         menu = temp;
  1336.     
  1337.     SetMenuStrip(hp->Window, menu);
  1338.     
  1339.     return(NULL);
  1340. }
  1341.  
  1342. /**
  1343.  *
  1344.  *   whf_remmenu
  1345.  *
  1346. **/
  1347. char *whf_remmenu( struct HostParams *hp, int n, char *args[] )
  1348. {
  1349.     struct Menu *menu = NULL;
  1350.     
  1351.     hp->Result = 41L;
  1352.     
  1353.     if (hp->Window == NULL)
  1354.         return(NULL);
  1355.     
  1356.     if (hp->Result = checkargs(n, args))
  1357.         return(NULL);
  1358.     
  1359.     menu = hp->Window->MenuStrip;
  1360.     if (menu) 
  1361.     {
  1362.         ClearMenuStrip(hp->Window);
  1363.         freesmenu(menu);
  1364.     }
  1365.     
  1366.     return(NULL);
  1367. }
  1368.  
  1369. freesmenu( struct Menu *menu )
  1370. {
  1371.     struct Menu *tempm;
  1372.     struct MenuItem *tempi, *temps;
  1373.     struct XMenuItem *tempxi, *tempxs;
  1374.     
  1375.     if (tempm = menu) 
  1376.     {
  1377.         while (tempm) 
  1378.         {
  1379.             if (tempi = tempm->FirstItem) 
  1380.             {
  1381.                 while (tempi) 
  1382.                 {
  1383.                     if (temps = tempi->SubItem) 
  1384.                     {
  1385.                         while (temps) 
  1386.                         {
  1387.                             tempxs = (struct XMenuItem *) temps;
  1388.                             if (tempxs->UserData)
  1389.                                 myfree(tempxs->UserData);
  1390.                             temps = temps->NextItem;
  1391.                         }
  1392.                     }
  1393.                     tempxi = (struct XMenuItem *) tempi;
  1394.                     if (tempxi->UserData)
  1395.                         myfree(tempxi->UserData);
  1396.                     tempi = tempi->NextItem;
  1397.                 }
  1398.             }
  1399.             tempm = tempm->NextMenu;
  1400.         }
  1401.     }
  1402.     FreeSMenu(menu);
  1403.     return;
  1404. }
  1405.  
  1406. /**
  1407.  *
  1408.  *   whf_additem
  1409.  *
  1410. **/
  1411. char *whf_additem( struct HostParams *hp, int n, char *args[] )
  1412. {
  1413.     struct Menu *menu = NULL;
  1414.     struct XMenuItem *temp;
  1415.     
  1416.     hp->Result = 41L;
  1417.     
  1418.     if (hp->Window == NULL)
  1419.         return(NULL);
  1420.     
  1421.     hp->Result = 17L;
  1422.     if (args[0] == NULL)
  1423.         return(NULL);
  1424.     if (args[1] == NULL)
  1425.         return(NULL);
  1426.     
  1427.     hp->Result = 12L;
  1428.     if ((menu = hp->Window->MenuStrip) == NULL)
  1429.         return(NULL);
  1430.     
  1431.     ClearMenuStrip(hp->Window);
  1432.     
  1433.     if (n == 5 && (strncmpu(args[4], "SAME", 4) == 0)) 
  1434.     {
  1435.         temp = (struct XMenuItem *) SItemB(menu, args[0],
  1436.         args[2] ? args[2][0] : 0,
  1437.         args[3] ? atol(args[3]) : 0L);
  1438.     }
  1439.     else
  1440.     {
  1441.         temp = (struct XMenuItem *) SItem(menu, args[0],
  1442.         args[2] ? args[2][0] : 0,
  1443.         args[3] ? atol(args[3]) : 0L);
  1444.     }
  1445.     
  1446.     if (temp) 
  1447.     {
  1448.         hp->Result = 0L;
  1449.         temp->UserData = mymalloc(strlen(args[1]) + 1);
  1450.         if (temp->UserData)
  1451.             strcpy(temp->UserData, args[1]);
  1452.     }
  1453.     
  1454.     AdjustItems(menu);
  1455.     
  1456.     SetMenuStrip(hp->Window, menu);
  1457.     
  1458.     return(NULL);
  1459. }
  1460.  
  1461. /**
  1462.  *
  1463.  *   whf_addsubitem
  1464.  *
  1465. **/
  1466. char *whf_addsubitem( struct HostParams *hp, int n, char *args[] )
  1467. {
  1468.     struct Menu *menu = NULL;
  1469.     struct XMenuItem *temp;
  1470.     
  1471.     hp->Result = 41L;
  1472.     
  1473.     if (hp->Window == NULL)
  1474.         return(NULL);
  1475.     
  1476.     hp->Result = 17L;
  1477.     if (args[0] == NULL)
  1478.         return(NULL);
  1479.     if (args[1] == NULL)
  1480.         return(NULL);
  1481.     
  1482.     hp->Result = 12L;
  1483.     if ((menu = hp->Window->MenuStrip) == NULL)
  1484.         return(NULL);
  1485.     
  1486.     hp->Result = 0L;
  1487.     ClearMenuStrip(hp->Window);
  1488.     
  1489.     if (n <= 4) 
  1490.     {
  1491.         temp = (struct XMenuItem *) SSItem(menu, args[0],
  1492.         args[2] ? args[2][0] : 0,
  1493.         args[3] ? atol(args[3]) : 0L);
  1494.     }
  1495.     else
  1496.     {
  1497.         temp = (struct XMenuItem *) SSItemB(menu, args[0],
  1498.         args[2] ? args[2][0] : 0,
  1499.         args[3] ? atol(args[3]) : 0L);
  1500.     }
  1501.     
  1502.     if (temp) 
  1503.     {
  1504.         hp->Result = 0L;
  1505.         temp->UserData = mymalloc(strlen(args[1]) + 1);
  1506.         if (temp->UserData)
  1507.             strcpy(temp->UserData, args[1]);
  1508.     }
  1509.     
  1510.     AdjustItems(menu);
  1511.     
  1512.     SetMenuStrip(hp->Window, menu);
  1513.     
  1514.     return(NULL);
  1515. }
  1516.  
  1517. /**
  1518.  *
  1519.  *   whf_setreqcolor
  1520.  *
  1521. **/
  1522. char *whf_setreqcolor( struct HostParams *hp, int n, char *args[] )
  1523. {
  1524.     hp->Result = 41L;
  1525.     
  1526.     if (hp->Result = checkargs(n, args))
  1527.         return(NULL);
  1528.     
  1529.     if      (strncmpu(args[0], "BLO", 3) == 0) 
  1530.     {
  1531.         hp->ReqPens->reqp_BlockPen  = atoi(args[1]);
  1532.     }
  1533.     else
  1534.     if (strncmpu(args[0], "DET", 3) == 0) 
  1535.     {
  1536.         hp->ReqPens->reqp_DetailPen = atoi(args[1]);
  1537.     }
  1538.     else
  1539.     if (strncmpu(args[0], "BAC", 3) == 0) 
  1540.     {
  1541.         hp->ReqPens->reqp_BackPen   = atoi(args[1]);
  1542.     }
  1543.     else
  1544.     if (strncmpu(args[0], "PRO", 3) == 0) 
  1545.     {
  1546.         hp->ReqPens->reqp_PromptPen = atoi(args[1]);
  1547.     }
  1548.     else
  1549.     if (strncmpu(args[0], "BOX", 3) == 0) 
  1550.     {
  1551.         hp->ReqPens->reqp_BoxPen    = atoi(args[1]);
  1552.     }
  1553.     else
  1554.     if (strncmpu(args[0], "SHA", 3) == 0) 
  1555.     {
  1556.         hp->ReqPens->reqp_ShadowPen = atoi(args[1]);
  1557.     }
  1558.     else
  1559.     if (strncmpu(args[0], "OKA", 3) == 0) 
  1560.     {
  1561.         hp->ReqPens->reqp_OkayPen   = atoi(args[1]);
  1562.     }
  1563.     else
  1564.     if (strncmpu(args[0], "GTE", 3) == 0) 
  1565.     {
  1566.         hp->ReqPens->reqp_OkayPen   = atoi(args[1]);
  1567.     }
  1568.     else
  1569.     if (strncmpu(args[0], "CAN", 3) == 0) 
  1570.     {
  1571.         hp->ReqPens->reqp_CancelPen = atoi(args[1]);
  1572.     }
  1573.     
  1574.     return(NULL);
  1575. }
  1576.  
  1577.  
  1578. /**
  1579.  *
  1580.  *   whf_setitem
  1581.  *
  1582. **/
  1583. char *whf_setitem( struct HostParams *hp, int n, char *args[] )
  1584. {
  1585.     struct Menu *menu = NULL;
  1586.     struct MenuItem *item = NULL;
  1587.     USHORT menunum = 0;
  1588.     
  1589.     hp->Result = 41L;
  1590.     
  1591.     if (hp->Window == NULL)
  1592.         return(NULL);
  1593.     
  1594.     hp->Result = 17L;
  1595.     if (args[3] == NULL)
  1596.         return(NULL);
  1597.     
  1598.     hp->Result = 12L;
  1599.     if ((menu = hp->Window->MenuStrip) == NULL)
  1600.         return(NULL);
  1601.     
  1602.     menunum  = ((args[2] ? atoi(args[2]) : -1) & 0x1F) << 11;
  1603.     menunum |= ((args[1] ? atoi(args[1]) : -1) & 0x3F) << 5 ;
  1604.     menunum |= ((args[0] ? atoi(args[0]) : -1) & 0x1F)      ;
  1605.     
  1606.     item = ItemAddress(menu, (ULONG) menunum);
  1607.     
  1608.     ClearMenuStrip(hp->Window);
  1609.     
  1610.     if (item) 
  1611.     {
  1612.         if (item->Flags & CHECKIT) 
  1613.         {
  1614.             if (strncmpu(args[3], "ON", 2) == 0)
  1615.                 item->Flags |= CHECKED;
  1616.             else
  1617.                 item->Flags &= ~CHECKED;
  1618.         }
  1619.         hp->Result = 0L;
  1620.     }
  1621.     
  1622.     SetMenuStrip(hp->Window, menu);
  1623.     
  1624.     return(NULL);
  1625. }
  1626.  
  1627. /**
  1628.  *
  1629.  *   whf_drawiff
  1630.  *
  1631. **/
  1632. char *whf_drawiff( struct HostParams *hp, int n, char *args[] )
  1633. {
  1634.     struct RastPort *rp;
  1635.     int x = 0, y = 0, w = 0, h = 0;
  1636.     struct Screen *screen = NULL;
  1637.     
  1638.     hp->Result = 41L;
  1639.     
  1640.     if (hp->Window == NULL)
  1641.         return(NULL);
  1642.     rp = hp->Window->RPort;
  1643.     
  1644.     if (hp->Result = checkargs(1, args))
  1645.         return(NULL);
  1646.     
  1647.     if (args[1])
  1648.         x = atoi(args[1]);
  1649.     else
  1650.         x = hp->Window->BorderLeft;
  1651.     
  1652.     if (args[2])
  1653.         y = atoi(args[2]);
  1654.     else
  1655.         y = hp->Window->BorderTop;
  1656.     
  1657.     if (args[3])
  1658.         w = atoi(args[3]);
  1659.     else
  1660.         w = hp->Window->Width - hp->Window->BorderRight - x;
  1661.     
  1662.     if (args[4])
  1663.         h = atoi(args[4]);
  1664.     else
  1665.         h = hp->Window->Height - hp->Window->BorderBottom - y;
  1666.     
  1667.     screen = hp->Window->WScreen;
  1668.     if ((screen->Flags & SCREENTYPE) == WBENCHSCREEN)
  1669.         screen = NULL;
  1670.     if (args[5]) 
  1671.     {
  1672.         if ((args[5][0] | ' ') == 'n')
  1673.             screen = NULL;
  1674.     }
  1675.     
  1676.     hp->Result = 12L;
  1677.     if (DrawIFF(args[0], rp, x, y, w, h, screen) == 0)
  1678.         hp->Result = 0L;
  1679.     
  1680.     return(NULL);
  1681. }
  1682.  
  1683.