home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-385-Vol-1of3.iso / d / dir_nm20.zip / Dir_NM_2.0 / NM-Menu.c < prev    next >
C/C++ Source or Header  |  1992-07-16  |  20KB  |  712 lines

  1. /*                         ===  NM-Menu.c  ===
  2.  *
  3.  * int  In_Use(Action,Choice)
  4.  * void Renew_Notice()
  5.  * void draw_command_box(text_string,x_start,y_start,width,height)
  6.  * void Show_Menu()
  7.  * void Show_Preface(Y)
  8.  * void Show_Face(Y)
  9.  * void RefreshMenu()
  10.  * void HighlightMenu(mx,my)
  11.  * int  In_Table(mouse_x,mouse_y)
  12.  * int  Get_Row_Id(mouse_x,mouse_y)
  13.  * int  Get_Column_Id(mouse_x,mouse_y)
  14.  * void Hi_light_Table(mx,my)
  15.  * void Get_New_XY(mouse_x,mouse_y,X,Y)
  16.  * void Hi_light_host(mouse_x,mouse_y)
  17.  * int  In_Map(mouse_x,mouse_y)
  18.  * int  In_Text(mouse_x,mouse_y)
  19.  * int  In_Set(mouse_x,mouse_y,W,H)
  20.  * int  In_Value(mouse_x,mouse_y)
  21.  * void Hi_light_Map(mouse_x,mouse_y)
  22.  * void Hi_light_Text(mouse_x,mouse_y)
  23.  * void Hi_light_Set(mouse_x,mouse_y)
  24.  * void Hi_light_Value(mouse_x,mouse_y)
  25.  * void High_Light_Char(X,Y)
  26.  * void Move_Table(mouse_x,mouse_y,dx,dy)
  27.  * int  NewMenuSelection()
  28.  * int  Menu_box(x,y,nboxes,xstart_array,ystart,width,height)
  29.  *
  30.  */
  31.  
  32. #include "NM.h" 
  33.  
  34. #define NBOXES 24
  35. #define OUTLINEWIDTH 2
  36.  
  37. char *title_array[NBOXES]={"Input","List","Output/Bk","Re_Name","Move_To",
  38.                "Delete","Value","Check_Tmp","Switch","Combine",
  39.                " "," ","Load","Tempo_Set"," ","Timbre",
  40.                "Words","Dance","Sounds","Voice","Piano","Print_Out",
  41.                " ","Quit"};
  42.  
  43. int xstart_array[NBOXES]={10,10,10,120,120,120,230,230,230,340,340,340,692,692,
  44.               692,802,802,802,912,912,912,1022,1022,1022},
  45.     ystart_array[NBOXES]={2,32,62,2,32,62,2,32,62,2,32,62,
  46.               2,32,62,2,32,62,2,32,62,2,32,62},
  47.     width=100,height=30,Map_SX=451;
  48.  
  49. int (*fcn_array[24])()={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
  50.  
  51. int lit=-1,IN=-1,now=0,total=0,unite=0,Action=0,Motion=0,Copy=0,
  52.     Delete=0,Move=0,Switch=0,Replace=0,Mix=0;
  53.  
  54. extern GC saveGC;
  55.  
  56. int In_Use(Action,Choice)
  57.   int Action,Choice;
  58. {
  59.   if (Action==Choice) return 1;else return 0;
  60. }
  61.  
  62. void Renew_Notice()
  63. {
  64.   int i,X,Y,W,H;
  65.   char *On_Clr,*Off_Clr;
  66.  
  67.   if (Replace==-1) { Replace=0;tail=content[now];Save_Name(); }
  68.   On_Clr=(char *)malloc(20);*On_Clr='\0';
  69.   sprintf(On_Clr+strlen(On_Clr),"%s","magenta");
  70.   Off_Clr=(char *)malloc(20);*Off_Clr='\0';
  71.   sprintf(Off_Clr+strlen(Off_Clr),"%s","SteelBlue");
  72.  
  73.   for (i=0;i<23;i++)
  74.     {
  75.       X=xstart_array[i]+8*(width/10)+2;Y=ystart_array[i]+height/4+2;
  76.       W=width/10-3;H=height/2-3;
  77.       switch (i)
  78.     {
  79.           case 0:Notice(X,Y,W,H,In_Use(Motion,Input_On),On_Clr,Off_Clr);break;
  80.       case 1:Notice(X,Y,W,H,In_Use(Motion,List_On),On_Clr,Off_Clr);break;
  81.       case 2:Notice(X,Y,W,H,In_Use(Motion,Output_On),On_Clr,Off_Clr);break;
  82.       case 3:Notice(X,Y,W,H,In_Use(Action,Re_Name_On),On_Clr,Off_Clr);break;
  83.       case 4:Notice(X,Y,W,H,In_Use(Action,Move_On),On_Clr,Off_Clr);break;
  84.       case 5:Notice(X,Y,W,H,In_Use(Action,Delete_On),On_Clr,Off_Clr);break;
  85.       case 6:Notice(X,Y,W,H,In_Use(Action,Value_On),On_Clr,Off_Clr);break;
  86.       case 7:Notice(X,Y,W,H,In_Use(Action,Check_Tmp_On),On_Clr,Off_Clr);
  87.         break;
  88.       case 8:Notice(X,Y,W,H,In_Use(Action,Switch_On),On_Clr,Off_Clr);break;
  89.       case 9:Notice(X,Y,W,H,In_Use(Action,Combine_On),On_Clr,Off_Clr);break;
  90.  
  91.       case 12:Notice(X,Y,W,H,In_Use(Motion,Load_On),On_Clr,Off_Clr);break;
  92.       case 13:Notice(X,Y,W,H,In_Use(Motion,Tempo_Set_On),On_Clr,Off_Clr);
  93.         break;
  94.       case 15:Notice(X,Y,W,H,In_Use(Motion,Timbre_On),On_Clr,Off_Clr);break;
  95.       case 16:Notice(X,Y,W,H,In_Use(Motion,Words_On),On_Clr,Off_Clr);break;
  96.       case 17:Notice(X,Y,W,H,In_Use(Motion,Dance_On),On_Clr,Off_Clr);break;
  97.       case 18:Notice(X,Y,W,H,In_Use(Motion,Sounds_On),On_Clr,Off_Clr);break;
  98.       case 19:Notice(X,Y,W,H,In_Use(Motion,Voice_On),On_Clr,Off_Clr);break;
  99.       case 20:Notice(X,Y,W,H,In_Use(Motion,Piano_On),On_Clr,Off_Clr);break;
  100.       case 21:Notice(X,Y,W,H,In_Use(Motion,Print_On),On_Clr,Off_Clr);break;
  101.         break;
  102.     }
  103.     }
  104. }
  105.  
  106. /* Routines for displaying and highlighting command boxes */
  107. void draw_command_box(text_string,x_start,y_start,width,height)
  108.   char *text_string;
  109.   int x_start,y_start,width,height;
  110. {
  111.   XSetLineAttributes(display,gc,2,0,0,0);
  112.   DrawRectangle(x_start,y_start,width,height);
  113.   SetColor("SkyBlue");XSetLineAttributes(display,gc,1,0,0,0);
  114.   DrawRectangle(x_start+8*(width/10),y_start+height/4,width/10,height/2);
  115.   SetColor("PaleGreen");OutTextXY(x_start+7,y_start+20,text_string);
  116. }
  117.  
  118. void Show_Menu()
  119. {
  120.   int n;
  121.  
  122.   Rub(0,0,1139,93,"MediumBlue");Use_Font("7x14");Map_Dx=0;Map_Dy=0;
  123.  
  124.   for (n=0;n<NBOXES;n++)
  125.     {
  126.       Rub(xstart_array[n],ystart_array[n],width,height,"MidNightBlue");
  127.       switch (n)
  128.     {
  129.           case 0:
  130.       case 1:
  131.       case 2:SetColor("LightSkyBlue");break;
  132.           case 3:
  133.       case 4:
  134.       case 5:SetColor("yellow");break;
  135.           case 6:
  136.       case 7:
  137.       case 8:SetColor("turquoise");break;
  138.           case 9:
  139.       case 10:
  140.       case 11:
  141.       case 12:
  142.           case 13:
  143.       case 14:SetColor("HotPink");break;
  144.       case 15:
  145.           case 16:
  146.       case 17:SetColor("turquoise");break;
  147.       case 18:
  148.           case 19:
  149.       case 20:SetColor("yellow");break;
  150.           case 21:
  151.           case 22:
  152.       case 23:SetColor("LightSkyBlue");break;
  153.     }
  154.       draw_command_box(title_array[n],xstart_array[n],ystart_array[n],
  155.                width,height);
  156.     }
  157.   Column_Id=-10;Row_Id=-10;Map_Column_Id=-10;Map_Row_Id=-10;Draw_Map(Map_SX,2);
  158. }
  159.  
  160. void Show_Preface(Y)
  161.   int Y;
  162. {
  163.   int i,j;
  164.  
  165.   Dx_bar=137;Dy_bar=45;X_bar=170;Y_bar=Y+380;W_bar=106;H_bar=26;total=0;
  166.   Rub(0,480,1132,384,"MediumBlue");XSetLineAttributes(display,gc,2,0,0,0);
  167.   SetColor("yellow");Line(0,480,1132,480);Use_Font("7x14");SetColor("white");
  168.   DrawRectangle(X_bar-27,Y_bar-20,32*H_bar+16,12*H_bar-16);SetColor("SkyBlue");
  169.  
  170.   for (i=0;i<6;i++)
  171.     for (j=0;j<6;j++) 
  172.       DrawRectangle(i*Dx_bar+X_bar,j*Dy_bar+Y_bar,W_bar+4,H_bar+4);
  173.  
  174.   for (i=0;i<6;i++)
  175.     for (j=0;j<6;j++) 
  176.       Rub(i*Dx_bar+X_bar+2,j*Dy_bar+Y_bar+2,W_bar,H_bar,"MidNightBlue");
  177.  
  178.   SetColor("gold");
  179.   for (i=0;i<6;i++)
  180.     for (j=0;j<6;j++)
  181.       {
  182.     OutTextXY(i*Dx_bar+X_bar+8,j*Dy_bar+Y_bar+21,Get_Filename(i*6+j,0));
  183.     total+=content[i*6+j];
  184.       }
  185.   SetColor("green");DrawRectangle(8,812,1117,37);Rub(9,813,1115,35,"black");
  186.   SetColor("yellow");Use_Font("12x24");OutTextXY(506,842,"Total = ");
  187.   SetColor("SpringGreen");Out_I_XY(606,842,total);
  188. }
  189.  
  190. void Show_Face(Y)
  191.   int Y;
  192. {
  193.   SetColor("cyan");XSetLineAttributes(display,gc,2,0,0,0);
  194.   DrawRectangle(1,1,1130,860);Line(1,94,1130,94);
  195.   Rub(3,95,1126,385,"MidNightBlue");XSetFunction(display,gc,GXcopy);
  196.   XSetLineAttributes(display,gc,3,0,0,0);Use_Font("12x24");SetColor("white");
  197.   
  198.   DrawRectangle(326,Y,480,290);Rub(339,Y+13,454,264,"RoyalBlue");
  199.   Rub(349,Y+23,434,244,"black");SetColor("magenta");
  200.   DrawRectangle(359,Y+33,414,224);Rub(369,Y+43,394,204,"RoyalBlue");
  201.   SetColor("yellow");OutTextXY(548,Y+143,"2.0");SetColor("white");
  202.   OutTextXY(463,Y+100,"imble        usician");SetColor("gold");
  203.   Use_Font("-bitstream-charter-bold-r-normal--33-240-100-100-p-206-iso8859-1");
  204.   OutTextXY(439,Y+100,"N           M");SetColor("SpringGreen");
  205.   Use_Font("12x24");OutTextXY(510,Y+187,"Ni     Min");SetColor("pink");
  206.   Use_Font("7x14");OutTextXY(470,Y+223,"Developed at I.U. IN. U.S.A.");
  207.   Show_Preface(Y);
  208. }
  209.  
  210. void RefreshMenu()
  211. {
  212.   static XGCValues newValues;
  213.   static unsigned long valuemask;
  214.  
  215. /* NEW TRICK for switching states-> copy the current GC values into a static 
  216.  * dummy, change the attributes,then copy the preexisting GC values back before 
  217.  * exiting.  The manual implies there is no better way...
  218.  */
  219.  
  220.   XClearWindow(display,win);valuemask=GCFunction|GCLineWidth;
  221.   XCopyGC(display,gc,valuemask,saveGC);
  222.   newValues.function=GXxor;newValues.line_width=OUTLINEWIDTH;
  223.   XChangeGC(display,gc,valuemask,&newValues);XSetFunction(display,gc,GXcopy);
  224.  
  225.   IN=-1;lit=-1;In_Menu=1;Del=-1;freq=392.0;Show_Menu();Show_Face(139);
  226.   Action=0;Motion=0;Host=0;Host_X=-1;Host_Y=-1;Tour_On=0;Print_pt=0;
  227. }
  228.  
  229. /* Process the motion events to see if menu box needs highlighting. */
  230.  
  231. void HighlightMenu(mx,my)
  232.   int mx,my;
  233. {
  234.   int cmd;
  235.  
  236.   cmd=Menu_box(mx,my,NBOXES,xstart_array,ystart_array,width,height);
  237.  
  238.  if (cmd>=0)         /* Toggle on */
  239.     {
  240.       if (lit!=cmd)
  241.         {
  242.       if (lit==-1) 
  243.         {
  244.           highlight(xstart_array[cmd]+3,ystart_array[cmd]+3,width-5,
  245.             height-5);
  246.           lit=cmd;
  247.         }
  248.       else 
  249.         {
  250.           highlight(xstart_array[lit]+3,ystart_array[lit]+3,width-5,
  251.             height-5);
  252.           highlight(xstart_array[cmd]+3,ystart_array[cmd]+3,width-5,
  253.             height-5);
  254.           lit=cmd;
  255.         }
  256.     }
  257.     }
  258.   else if (lit>=0)  /* Toggle off */
  259.          {
  260.        highlight(xstart_array[lit]+3,ystart_array[lit]+3,width-5,height-5);
  261.        lit=-1;
  262.      }
  263. }
  264.  
  265. int In_Table(mouse_x,mouse_y)
  266.   int mouse_x,mouse_y;
  267. {
  268.   int Lim_Y;
  269.  
  270.   if (Host==1) Lim_Y=380;else Lim_Y=Table_Height;
  271.   if (5<mouse_x && mouse_x<Table_Width && 97<mouse_y && mouse_y<100+Lim_Y)
  272.     return 1;
  273.   else return 0;
  274. }
  275.  
  276. int Get_Row_Id(mouse_x,mouse_y)
  277.   int mouse_x,mouse_y;
  278. {
  279.   if (In_Table(mouse_x,mouse_y)==1)
  280.     {
  281.       if (97<mouse_y && mouse_y<120) return -2;          /*   In_Name   */
  282.       else if (77+Table_Height<mouse_y) return -3;       /*   Out_Name  */
  283.            else return (mouse_y-121)/20+Row_Pointer;     /*     Atom    */
  284.     }
  285.   else return -1;
  286. }
  287.  
  288. int Get_Column_Id(mouse_x,mouse_y)
  289.   int mouse_x,mouse_y;
  290. {
  291.   int i,X;
  292.  
  293.   if (In_Table(mouse_x,mouse_y)==1)
  294.     {
  295.       if (5<mouse_x && mouse_x<7*Column_Range[0].Delta+5) return 0;
  296.       for (i=Column_Pointer;i<Max_Column;i++)
  297.     {
  298.       X=Head_Len+Column_Range[i].Position+3
  299.         -Column_Range[Column_Pointer].Position;
  300.       if (X<=mouse_x && mouse_x<=X+7*Column_Range[i].Delta) return i;
  301.     }
  302.     }
  303.   else return -1;
  304. }
  305.  
  306. Hi_light_Table(mx,my)
  307.   int mx,my;
  308. {
  309.   int New_Row_Id,New_Column_Id,X,New_X,Y,New_Y,Width,
  310.       New_Width,Height;
  311.  
  312.   if (Row_On==1) 
  313.     { 
  314.       New_Row_Id=Get_Row_Id(mx,my);Height=15;
  315.       if (New_Row_Id!=-1 && Row_Id!=New_Row_Id)
  316.     {
  317.       if (Row_Id!=-10)
  318.         {
  319.           if (Row_Id==-2) highlight(6,99,Table_Width-6,19);
  320.           else if (Row_Id==-3) 
  321.              highlight(6,Row_Range[Table_Row_Num-Row_Pointer].Position
  322.                    +3,Table_Width-6,19);
  323.                else highlight(6,Row_Range[Row_Id-Row_Pointer].Position+3,
  324.                   Table_Width-6,Height);
  325.         }
  326.       Row_Id=New_Row_Id;
  327.       if (Row_Id==-2) highlight(6,99,Table_Width-6,19);
  328.       else if (Row_Id==-3) 
  329.              highlight(6,Row_Range[Table_Row_Num-Row_Pointer].Position+3,
  330.                Table_Width-6,19);
  331.       else highlight(6,Row_Range[Row_Id-Row_Pointer].Position+3,
  332.              Table_Width-6,Height);
  333.     }
  334.       else if (New_Row_Id==-1 && Row_Id!=-10)
  335.          {
  336.            if (Row_Id==-2) highlight(6,99,Table_Width-6,19);
  337.            else if (Row_Id==-3) 
  338.                   highlight(6,Row_Range[Table_Row_Num-Row_Pointer].Position
  339.                 +3,Table_Width-6,19);
  340.            else highlight(6,Row_Range[Row_Id-Row_Pointer].Position+3,
  341.                   Table_Width-6,Height);
  342.            Row_Id=-10;
  343.          }
  344.     }
  345.   else if (Column_On==1)
  346.          {
  347.        New_Column_Id=Get_Column_Id(mx,my);
  348.        if (New_Column_Id!=-1 && Column_Id!=New_Column_Id)
  349.          {
  350.            X=Column_Range[Column_Id].Position+Head_Len+6
  351.          -Column_Range[Column_Pointer].Position;
  352.            Width=7*Column_Range[Column_Id].Delta;
  353.            New_X=Column_Range[New_Column_Id].Position+Head_Len+6
  354.              -Column_Range[Column_Pointer].Position;
  355.            New_Width=7*Column_Range[New_Column_Id].Delta;
  356.            if (Column_Id!=-10) highlight(X,99,Width-5,Table_Height);
  357.            Column_Id=New_Column_Id;X=New_X;Width=New_Width;
  358.            highlight(X,99,Width-5,Table_Height);
  359.          }
  360.        else if (New_Column_Id==-1 && Column_Id!=-10)
  361.               {
  362.             X=Column_Range[Column_Id].Position+Head_Len+6
  363.               -Column_Range[Column_Pointer].Position;
  364.             Width=7*Column_Range[Column_Id].Delta;
  365.             highlight(X,99,Width-5,Table_Height);Column_Id=-10;
  366.           }
  367.      }
  368.        else if (Atom_On==1)
  369.           {
  370.         New_Column_Id=Get_Column_Id(mx,my);
  371.         New_Row_Id=Get_Row_Id(mx,my);
  372.         if (New_Column_Id!=-1 && New_Row_Id!=-1 &&
  373.             (Column_Id!=New_Column_Id || Row_Id!=New_Row_Id))
  374.           {
  375.             X=Column_Range[Column_Id].Position+6;
  376.             if (Row_Id==-2) { Y=99;Height=19; }
  377.             else if (Row_Id==-3)
  378.                    {
  379.                      Y=Row_Range[Table_Row_Num-Row_Pointer].Position+3;
  380.                  Height=19;
  381.                }
  382.                  else 
  383.                { 
  384.                  Y=Row_Range[Row_Id-Row_Pointer].Position+3;
  385.                  Height=15;
  386.                }
  387.             Width=7*Column_Range[Column_Id].Delta;
  388.             if (Column_Id!=-10 && Row_Id!=-10)
  389.               highlight(X,Y,Width-5,Height);
  390.  
  391.             New_X=Column_Range[New_Column_Id].Position+6;
  392.             if (New_Row_Id==-2) { New_Y=99;Height=19; }
  393.             else if (New_Row_Id==-3) 
  394.                    {
  395.                      New_Y=Row_Range[Table_Row_Num-Row_Pointer].Position
  396.                        +3;
  397.                  Height=19;
  398.                }
  399.                  else
  400.                {
  401.                  New_Y=Row_Range[New_Row_Id-Row_Pointer].Position+3;
  402.                  Height=15;
  403.                }
  404.             New_Width=7*Column_Range[New_Column_Id].Delta;
  405.             Column_Id=New_Column_Id;Row_Id=New_Row_Id;
  406.             X=New_X;Y=New_Y;Width=New_Width;
  407.             highlight(X,Y,Width-5,Height);
  408.           }
  409.         else if (New_Column_Id==-1 && Column_Id!=-10 &&
  410.              New_Row_Id==-1 && Row_Id!=-10)
  411.                {
  412.              X=Column_Range[Column_Id].Position+6;
  413.              if (Row_Id==-2) { Y=99;Height=19; }
  414.              else if (Row_Id==-3)
  415.                     { 
  416.                   Y=Row_Range[Table_Row_Num-
  417.                           Row_Pointer].Position+3;
  418.                   Height=19;
  419.                 }
  420.                       else
  421.                 {
  422.                   Y=Row_Range[Row_Id-Row_Pointer].Position+3;
  423.                   Height=15;
  424.                 }
  425.              Width=7*Column_Range[Column_Id].Delta;
  426.              highlight(X,Y,Width-5,Height);Column_Id=-10;Row_Id=-10;
  427.                }
  428.           }
  429. }
  430.  
  431. void Get_New_XY(mouse_x,mouse_y,X,Y)
  432.   int mouse_x,mouse_y,*X,*Y;
  433. {
  434.   int x,y;
  435.  
  436.   for (x=0;x<6;x++)
  437.     for (y=0;y<6;y++)
  438.       if (X_bar+x*Dx_bar<mouse_x && mouse_x<X_bar+x*Dx_bar+W_bar+2 &&
  439.           Y_bar+y*Dy_bar<mouse_y && mouse_y<Y_bar+y*Dy_bar+H_bar+2)
  440.     { *X=x;*Y=y;return; }
  441.   
  442. }
  443.  
  444. void Hi_light_host(mouse_x,mouse_y)
  445.   int mouse_x,mouse_y;
  446. {
  447.   int New_host_x,New_host_y;
  448.  
  449.   New_host_x=-1;New_host_y=-1;
  450.  
  451.   Get_New_XY(mouse_x,mouse_y,&New_host_x,&New_host_y);
  452.  
  453.   if (New_host_x>=0)         /* Toggle on */
  454.     {
  455.       if (Host_X != New_host_x && Host_Y != New_host_y)
  456.         {
  457.       if (Host_X==-1) 
  458.         {
  459.           Host_X=New_host_x;Host_Y=New_host_y;
  460.           highlight(X_bar+Host_X*Dx_bar+3,Y_bar+Host_Y*Dy_bar+3,
  461.             W_bar-1,H_bar-1);
  462.         }
  463.       else 
  464.         {
  465.           highlight(X_bar+Host_X*Dx_bar+3,Y_bar+Host_Y*Dy_bar+3,
  466.             W_bar-1,H_bar-1);
  467.           Host_X=New_host_x;Host_Y=New_host_y;
  468.           highlight(X_bar+Host_X*Dx_bar+3,Y_bar+Host_Y*Dy_bar+3,
  469.             W_bar-1,H_bar-1);
  470.         }
  471.     }
  472.     }
  473.   else if (Host_X>=0)  /* Toggle off */
  474.          {
  475.        highlight(X_bar+Host_X*Dx_bar+3,Y_bar+Host_Y*Dy_bar+3,
  476.              W_bar-1,H_bar-1);
  477.        Host_X=-1;Host_Y=-1;
  478.      }
  479.  
  480. }
  481.  
  482. int In_Map(mouse_x,mouse_y)
  483.   int mouse_x,mouse_y;
  484. {
  485.   if (Map_SX-1<mouse_x && mouse_x<Map_SX+228 && 2<mouse_y && mouse_y<92) 
  486.     return 1;
  487.   else return 0;
  488. }
  489.  
  490. int In_Text(mouse_x,mouse_y)
  491.   int mouse_x,mouse_y;
  492. {
  493.   if (Map_SX-1<mouse_x && mouse_x<Map_SX+228 && Text_SY-1<mouse_y && 
  494.       mouse_y<Text_SY+73) 
  495.     return 1;
  496.   else return 0;
  497. }
  498.  
  499. int In_Set(mouse_x,mouse_y,W,H)
  500.   int mouse_x,mouse_y,W,H;
  501. {
  502.   if (Set_X+2*W-1<mouse_x && mouse_x<Set_X+Set_W && Set_Y+H-1<mouse_y && 
  503.       mouse_y<Set_Y+Set_H) 
  504.     return 1;
  505.   else if (Set_X-1<mouse_x && mouse_x<Set_X+2*W+1 && Set_Y-1<mouse_y && 
  506.        mouse_y<Set_Y+H) 
  507.          return 0;
  508.        else return -1;
  509. }
  510.  
  511. int In_Value(mouse_x,mouse_y)
  512.   int mouse_x,mouse_y;
  513. {
  514.   if (Value_X-1<mouse_x && mouse_x<Value_X+Value_W && Value_Y-1<mouse_y && 
  515.       mouse_y<Value_Y+Value_H) 
  516.     return 1;
  517.   else return -1;
  518. }
  519.  
  520. void Hi_light_Map(mouse_x,mouse_y)
  521.   int mouse_x,mouse_y;
  522. {
  523.   int New_Col_Id,New_Row_Id,X,Y,W,H;
  524.  
  525.   W=16;H=15;
  526.   if (In_Map(mouse_x,mouse_y)==1)
  527.     {
  528.       New_Col_Id=(mouse_x-Map_SX-1)/19;New_Row_Id=(mouse_y-5)/18;
  529.       if (Map_Column_Id!=New_Col_Id || Map_Row_Id!=New_Row_Id)
  530.     {
  531.       if (Map_Column_Id!=-10 && Map_Row_Id!=-10)
  532.         { 
  533.           X=Map_SX+Map_Column_Id*19+2;Y=4+Map_Row_Id*18;highlight(X,Y,W,H); 
  534.         }
  535.       Map_Column_Id=New_Col_Id;Map_Row_Id=New_Row_Id;
  536.       X=Map_SX+Map_Column_Id*19+2;Y=4+Map_Row_Id*18;highlight(X,Y,W,H);
  537.     }
  538.     }
  539.   else if (Map_Column_Id!=-10 || Map_Row_Id!=-10)
  540.          {
  541.            X=Map_SX+Map_Column_Id*19+2;Y=4+Map_Row_Id*18;highlight(X,Y,W,H);
  542.        Map_Column_Id=-10;Map_Row_Id=-10;
  543.      }
  544. }
  545.  
  546. void Hi_light_Text(mouse_x,mouse_y)
  547.   int mouse_x,mouse_y;
  548. {
  549.   int New_Col_Id,New_Row_Id,X,Y,W,H;
  550.  
  551.   W=16;H=15;
  552.   if (In_Text(mouse_x,mouse_y)==1)
  553.     {
  554.       New_Col_Id=(mouse_x-Map_SX-1)/19;New_Row_Id=(mouse_y-Text_SY-1)/18;
  555.       if (Text_Column_Id!=New_Col_Id || Text_Row_Id!=New_Row_Id)
  556.     {
  557.       if (Text_Column_Id!=-10 && Text_Row_Id!=-10)
  558.         { 
  559.           X=Map_SX+Text_Column_Id*19+2;Y=2+Text_SY+Text_Row_Id*18;
  560.           highlight(X,Y,W,H); 
  561.         }
  562.       Text_Column_Id=New_Col_Id;Text_Row_Id=New_Row_Id;
  563.       X=Map_SX+Text_Column_Id*19+2;Y=2+Text_SY+Text_Row_Id*18;
  564.       highlight(X,Y,W,H);
  565.     }
  566.     }
  567.   else if (Text_Column_Id!=-10 || Text_Row_Id!=-10)
  568.          {
  569.            X=Map_SX+Text_Column_Id*19+2;Y=2+Text_SY+Text_Row_Id*18;
  570.        highlight(X,Y,W,H);Text_Column_Id=-10;Text_Row_Id=-10;
  571.      }
  572. }
  573.  
  574. void Hi_light_Set(mouse_x,mouse_y)
  575.   int mouse_x,mouse_y;
  576. {
  577.   int New_Col_Id,New_Row_Id,X,Y,W,H;
  578.  
  579.   W=60;H=40;
  580.  
  581.   if (In_Set(mouse_x,mouse_y,W,H)==1)
  582.     {
  583.       New_Col_Id=(mouse_x-Set_X-2*W-1)/W;New_Row_Id=(mouse_y-Set_Y-H-1)/H;
  584.       if (Set_Column!=New_Col_Id || Set_Row!=New_Row_Id)
  585.     {
  586.       if (Set_Column!=-10 && Set_Row!=-10)
  587.         { 
  588.           X=Set_X+2*W+Set_Column*W+2;Y=2+Set_Y+H+Set_Row*H;
  589.           highlight(X+1,Y+1,W-5,H-6); 
  590.         }
  591.       Set_Column=New_Col_Id;Set_Row=New_Row_Id;
  592.       X=Set_X+2*W+Set_Column*W+2;Y=2+Set_Y+H+Set_Row*H;
  593.       highlight(X+1,Y+1,W-5,H-6);
  594.     }
  595.     }
  596.   else if (Set_Column!=-10 || Set_Row!=-10)
  597.          {
  598.            X=Set_X+2*W+Set_Column*W+2;Y=2+Set_Y+H+Set_Row*H;
  599.        highlight(X+1,Y+1,W-5,H-6);Set_Column=-10;Set_Row=-10;
  600.      }
  601. }
  602.  
  603. void Hi_light_Value(mouse_x,mouse_y)
  604.   int mouse_x,mouse_y;
  605. {
  606.   int New_Col_Id,New_Row_Id,X,Y,W,H;
  607.  
  608.   W=136;H=60;
  609.  
  610.   if (In_Value(mouse_x,mouse_y)==1)
  611.     {
  612.       New_Col_Id=(mouse_x-Value_X-1)/W;New_Row_Id=(mouse_y-Value_Y-1)/H;
  613.       if (Value_Column!=New_Col_Id || Value_Row!=New_Row_Id)
  614.     {
  615.       if (Value_Column!=-10 && Value_Row!=-10)
  616.         { 
  617.           X=Value_X+Value_Column*W+2;Y=2+Value_Y+Value_Row*H;
  618.           highlight(X+Value_H_X,Y+Value_H_Y,Value_H_W,Value_H_H); 
  619.         }
  620.       Value_Column=New_Col_Id;Value_Row=New_Row_Id;
  621.       X=Value_X+Value_Column*W+2;Y=2+Value_Y+Value_Row*H;
  622.       highlight(X+Value_H_X,Y+Value_H_Y,Value_H_W,Value_H_H); 
  623.     }
  624.     }
  625.   else if (Value_Column!=-10 || Value_Row!=-10)
  626.          {
  627.            X=Value_X+Value_Column*W+2;Y=2+Value_Y+Value_Row*H;
  628.        highlight(X+Value_H_X,Y+Value_H_Y,Value_H_W,Value_H_H); 
  629.        Value_Column=-10;Value_Row=-10;
  630.      }
  631. }
  632.  
  633. void High_Light_Char(X,Y)
  634.   int X,Y;
  635. {
  636.   highlight(X*7+47,Y*Dist+149,7,11);
  637. }
  638.  
  639. void Move_Table(mouse_x,mouse_y,dx,dy)
  640.   int mouse_x,mouse_y,dx,dy;
  641. {
  642.   if (dx>0)
  643.     {
  644.       if (Column_Pointer>1)
  645.     { if (Column_Pointer-dx>0) Column_Pointer-=dx;else Column_Pointer=1; }
  646.     }
  647.   else
  648.     {
  649.       if (Column_Pointer-dx<Table_Column_Num) Column_Pointer-=dx;
  650.       else Column_Pointer=Table_Column_Num-2;
  651.     }
  652.   if (dy>0)
  653.     {
  654.       if (Row_Pointer>0)
  655.     { if (Row_Pointer-dy>0) Row_Pointer-=dy;else Row_Pointer=0; }
  656.     }
  657.   else
  658.     {
  659.       if (Row_Pointer-dy<Table_Row_Num) Row_Pointer-=dy;
  660.       else Row_Pointer=Table_Row_Num-2;
  661.     }
  662.   Update_Table(mouse_x,mouse_y);
  663. }
  664.  
  665. int NewMenuSelection()
  666. {
  667.   if (lit>=0)
  668.     {
  669.       if (IN>=0)
  670.     {
  671.       if (IN!=lit)     /* both lit but different */
  672.         {
  673.           if (fcn_array[lit]) { (*fcn_array[lit])(lit);IN=-1; } else IN=lit;
  674.         }
  675.     }
  676.       else
  677.     {
  678.       if (fcn_array[lit]) (*fcn_array[lit])(lit);  /* Just call function */
  679.       else IN=lit;
  680.     }
  681.       return(1);
  682.     }
  683.   else return(0);
  684. }
  685.  
  686.  
  687. /* Return MINUS ONE if not in a command box, box number = otherwise. */
  688.  
  689. int Menu_box(x,y,nboxes,xstart_array,ystart_array,width,height)
  690.   int x,y,nboxes,*xstart_array,*ystart_array,width,height;
  691. {
  692.   int n,xstart,ystart;
  693.  
  694.   for (n=0;n<nboxes;n++)
  695.     {
  696.       xstart=xstart_array[n];ystart=ystart_array[n];
  697.       if ((xstart<=x)&&(x<xstart+width)&&(ystart<=y)&&(y<ystart+height))
  698.     return(n);
  699.     }
  700.   n=-1;return(n);        /* Return -1 if no hit */
  701. }
  702.  
  703.  
  704. /* Miscellaneous useful calls
  705.  *
  706.  XSetLineAttributes(display,gc,3,0,0,0);
  707.  * Args of XSetLineAttributes
  708.  *   =  (dis,gc,line_width,line_style,cap_style,join_style)
  709.  *   See  /usr/include/X11/X.h for LineSolid,CapNotLast,JoinMiter, etc.
  710.  */
  711.  
  712.