/*Windows.c -- Includes all routines that access the stuff in Windows.h*/

extern struct MenuItem *ItemAddress();

#include "Globals.h"
#include "Windows.h"

#define NTSC_ITEM_NUM 4|SHIFTITEM(5)|SHIFTSUB(7)
#define PAL_ITEM_NUM 4|SHIFTITEM(5)|SHIFTSUB(8)

UWORD wbPens[]={0,1,1,2,1,3,1,0,3,~0};

struct TagItem tag[]=
{
   {SA_Pens,NULL},
   {SA_DisplayID,HIRES_KEY},
   {TAG_DONE,NULL}
};

struct IntuiText IT_foo =  /*Used to get the current font width*/
{
   0,0,JAM1,0,0,NULL,"A",NULL
};

void MakeMenus() /*Create the 2.0 style menus*/
{
   FinalMenus=(struct Menu *)CreateMenusA(menu,&menutags[0]);
   GetMenuPointers();
}

void OpenGraphics() /*Open screen, window, etc.*/
{
      /*Setup a tag so the 3D gadgets actually look 3Dish*/
   tag[0].ti_Data=(ULONG)wbPens;

   /*Open screen*/
   NewWindow.Screen=Screen=(struct Screen *)OpenScreenTagList(&NewScreen,tag);
   if(Screen==NULL)
      Leave(50,"Can't open screen!!");

   if(prefs.Exists)    /*Set screen colors to those in prefs*/
      LoadColors(&(Screen->ViewPort));
   else     /*Otherwise, use the defaults and save those in the prefs*/
   {
      SaveColors(&(Screen->ViewPort));
      prefs.Exists=TRUE;
   }

      /*Set window size, taking current font size into account*/
   NewWindow.TopEdge=Screen->BarHeight+1;
   NewWindow.Height=Screen->Height-Screen->BarHeight-1;
   NewWindow.Width=Screen->Width;

   /*Open backdrop window & make requestors open onto it*/
   if((ThisProc->pr_WindowPtr=Window=
	 (struct Window *)OpenWindow(&NewWindow))==NULL)
   {
      CloseScreen(Screen);
      Leave(60,"Can't open Window!");
   }

   /*Get VisualInfo*/
   beveltag[0].ti_Data=(Tag)GetVisualInfo(Screen,TAG_DONE);
   VisInfo=(APTR)beveltag[0].ti_Data;

   /*Install menus*/
   LayoutMenus(FinalMenus,VisInfo,TAG_DONE);
   SetMenuStrip(Window,FinalMenus);

   CopyPrefsToMenus();
   PutScreenTypeInMenu();

   /*Get font width*/

   IT_foo.ITextFont=(struct TextAttr *)Screen->Font;
   FontWidth = IntuiTextLength(&IT_foo);

   /*Setup the console.device*/
   consoleWritePort=(struct Port *)CreatePort("mycon.write",0);
   if(consoleWritePort==NULL)
      Leave(70,"Couldn't open console.device!");

   consoleWriteMsg=(struct IOStdReq *)CreateStdIO(consoleWritePort);
   if(consoleWriteMsg==NULL)
      Leave(80,"Couldn't open console.device!");

   consoleReadPort=(struct Port *)CreatePort("mycon.read",0);
   if(consoleReadPort==NULL)
      Leave(90,"Can't create communications port!");

   consoleReadMsg=(struct IOStdReq *)CreateStdIO(consoleReadPort);
   if(consoleReadMsg==NULL)
      Leave(100,"Can't create standard IO!");

   consoleWriteMsg->io_Data=(struct Window *)Window;  /*Attach console*/
   consoleWriteMsg->io_Length=sizeof(struct Window);  /*device to window...*/
   OpenDevice("console.device",0,consoleWriteMsg,0); /*& open it*/

   consoleReadMsg->io_Device=consoleWriteMsg->io_Device;

   consoleReadMsg->io_Unit=consoleWriteMsg->io_Unit; /*Get the current keymap*/
   consoleReadMsg->io_Command=CD_ASKKEYMAP;
   consoleReadMsg->io_Length=sizeof(struct KeyMap);
   consoleReadMsg->io_Data=&keymap;
   DoIO(consoleReadMsg);
   TitleErrorCancel();
   if(!SetupFileRequestor())
   {
     CloseGraphics();
     Leave(1000,"Couldn't allocate needed file requestor information!");
   }
}

void CloseGraphics()   /*Close the window, screen, etc.*/
{
      /*Close the console*/
   CloseDevice(consoleWriteMsg);
   DeleteStdIO(consoleWriteMsg);
   DeleteStdIO(consoleReadMsg);
   DeletePort(consoleWritePort);
   DeletePort(consoleReadPort);

      /*Free the file requestor structures*/
   FreeFileRequest(MainReq);
   FreeFileRequest(PTDReq);

      /*Return the Intuition resources to the system*/
   ClearMenuStrip(Window);
   FreeMenus(FinalMenus);
   CloseWindow(Window);
   FreeVisualInfo(VisInfo);
   CloseScreen(Screen);
}

   /*Under KS1.3, the menu structures could be accessed fairly easily,*/
   /*since they were part of 'Liner's data directly.  Under 2.0, however,*/
   /*the menu structures don't exist until 'Liner explicitly creates*/
   /*them.  What GenMenuPointers() does is create an array of pointers*/
   /* to the created menu structures, so 'Liner can do stuff like change*/
   /*preferences settings when liner.prefs is loaded.  This was not needed*/
   /*under 1.3 for the reasons given above*/

void GetMenuPointers()
{
   struct Menu *CurMenu;
   struct MenuItem *CurItem,*CurSub;
   UWORD *num;

   CurMenu=(struct Menu *)FinalMenus;

   while(CurMenu != NULL) /*Go through the linked list of Menu structures*/
   {
      CurItem=(struct MenuItem *)CurMenu->FirstItem;
	 /*Go through each Menu's MenuItems (and their SubItems)*/
      while(CurItem != NULL)
      {
	 if(CurItem->SubItem != NULL)
	 {
	    CurSub=(struct MenuItem *)CurItem->SubItem;
	    while(CurSub != NULL)
	    {
		  /*Find where the MenuItem goes in the array*/
	       num=GTMENUITEM_USERDATA(CurSub);

		  /*And put it's pointer there*/
	       if(num != NULL)
		  MenuPtrs[*num]=(struct MenuItem *)CurSub;

		  /*Go on to the next item*/
	       CurSub=(struct MenuItem *)CurSub->NextItem;
	    }
	 }
	 else
	 {
	    /*Same as above*/
	    num=GTMENUITEM_USERDATA(CurItem);
	    if(num != NULL)
	       MenuPtrs[*num]=(struct MenuItem *)CurItem;
	 }

	 CurItem=(struct MenuItem *)CurItem->NextItem;
      }

      CurMenu=(struct Menu *)CurMenu->NextMenu;
   }
}

/*Initialize the 2.0 asl.library filerequestor structures*/
BOOL SetupFileRequestor()
{

   if((MainReq=(struct FileRequester *)AllocFileRequest())==NULL)
      return(FALSE);

   if((PTDReq=(struct FileRequester *)AllocFileRequest())==NULL)
   {
      FreeFileRequest(MainReq);
      return(FALSE);
   }

   /*File requestor used for saves & opens*/
   MainReq->rf_File=(char *)SFileName;
   MainReq->rf_Dir=(char *)SDirName;
   MainReq->rf_Function=NULL;
   MainReq->rf_Window=(struct Window *)Window;
   MainReq->rf_FuncFlags=RFF_DOCOLOR;
   MainReq->rf_Flags2=NULL;
   MainReq->rf_NumArgs=0;

   /*Used for print to disks*/
   PTDReq->rf_File=(char *)PFileName;
   PTDReq->rf_Dir=(char *)PDirName;
   PTDReq->rf_Function=NULL;
   PTDReq->rf_Window=(struct Window *)Window;
   PTDReq->rf_FuncFlags=NULL;
   PTDReq->rf_Flags2=NULL;
   PTDReq->rf_NumArgs=0;

   return(TRUE);
}

/*This is in liner.c and not menu.c because it needs to manipulate the*/
/*'Liner NewScreen and NewWindow information, which it can't do from*/
/*menu.c*/

void ChangeDisplay()
{
   UBYTE X,Y;
   BOOL stat2,stat3,stat4;


   X=CurX;
   Y=CurY;

   stat2=ChangeScreenSize();
   stat3=DoubleSpacing();
   stat4=HandleStartingLevel();

   if( stat2 )
   {
      if( stat3 || stat4 )
	 CheckModified();

      CloseGraphics();
      MakeMenus();
      OpenGraphics();

      SetRowsInScreen();
      PrintItemList(FirstScrnItem,1);

      if(Y > DispRows)/*if the old laced Y is > the current possible rows*/
      {
	 Y=DispRows;	/*Y now = the last screen item*/
	 CurrentItem=(struct LineItem *)ScrnBtm;
      }
      if(X > MaxX(CurrentItem))  /*Out of bounds*/
	 X=MaxX(CurrentItem);
      else if(X < MinX(CurrentItem))
	 X=MinX(CurrentItem);

      PlotCursor(X,Y);     /*Restore cursor position*/
   }
   else
      if( stat4 )
      {
	 SetRowsInScreen();
	 PrintItemList(FirstScrnItem,1);

	 if(Y > DispRows)  /*if the old laced Y is > the current possible rows*/
	 {
	    Y=DispRows;    /*Y now = the last screen item*/
	    CurrentItem=(struct LineItem *)ScrnBtm;
	 }
	 if(X > MaxX(CurrentItem))  /*Out of bounds*/
	    X=MaxX(CurrentItem);
	 else if(X < MinX(CurrentItem))
	    X=MinX(CurrentItem);

	 PlotCursor(X,Y);     /*Restore cursor position*/
      }
}

void PutScreenTypeInMenu()
{
   UBYTE c;
   for(c=28;c<=31;c++)
      MenuPtrs[c]->Flags &= ~CHECKED;
   for(c=36;c<=40;c++)
      MenuPtrs[c]->Flags &= ~CHECKED;

	 /*Switch on the NTSC and PAL menu items*/
   OnMenu(Window,NTSC_ITEM_NUM);
   OnMenu(Window,PAL_ITEM_NUM);

   switch(prefs.ScreenType & MONITOR_ID_MASK) /*Check monitor type*/
   {
      case NTSC_MONITOR_ID:
	 MenuPtrs[38]->Flags |= CHECKED;
	 break;
      case PAL_MONITOR_ID:
	 MenuPtrs[39]->Flags |= CHECKED;
	 break;
      case VGA_MONITOR_ID:
      case A2024_MONITOR_ID:
	 OffMenu(Window,NTSC_ITEM_NUM); /*turn off NTSC and PAL*/
	 OffMenu(Window,PAL_ITEM_NUM);
      case DEFAULT_MONITOR_ID:
	 MenuPtrs[40]->Flags |= CHECKED;
	 break;
   }

   switch(prefs.ScreenType)   /*Check for A2024 modes*/
   {
      case A2024TENHERTZ_KEY:
	 MenuPtrs[36]->Flags |= CHECKED;
	 return;
      case A2024FIFTEENHERTZ_KEY:
	 MenuPtrs[37]->Flags |= CHECKED;
	 return;
   }

   switch(prefs.ScreenType & ~MONITOR_ID_MASK) /*Check for other modes*/
   {
      case HIRES_KEY:
	 MenuPtrs[28]->Flags|=CHECKED;
	 break;
      case HIRESLACE_KEY:
	 MenuPtrs[29]->Flags|=CHECKED;
	 break;
      case VGAPRODUCT_KEY & ~MONITOR_ID_MASK:
	 MenuPtrs[30]->Flags|=CHECKED;
	 break;
      case VGAPRODUCTLACE_KEY & ~MONITOR_ID_MASK:
	 MenuPtrs[31]->Flags|=CHECKED;
   }

}

BOOL ChangeScreenSize()   /*Determine which display mode to use*/
{
   ULONG temp;

   temp=tag[1].ti_Data;

   if(MenuPtrs[28]->Flags & CHECKED) /*Check each menu item*/
      tag[1].ti_Data=HIRES_KEY;      /*The one that is checked determines*/

   if(MenuPtrs[29]->Flags & CHECKED) /*What mode is used*/
      tag[1].ti_Data=HIRESLACE_KEY;

   if(MenuPtrs[30]->Flags & CHECKED)
      tag[1].ti_Data=VGAPRODUCT_KEY;

   if(MenuPtrs[31]->Flags & CHECKED)
      tag[1].ti_Data=VGAPRODUCTLACE_KEY;

   if(MenuPtrs[38]->Flags & CHECKED)
      tag[1].ti_Data |= NTSC_MONITOR_ID;

   if(MenuPtrs[39]->Flags & CHECKED)
      tag[1].ti_Data |= PAL_MONITOR_ID;

   if(MenuPtrs[36]->Flags & CHECKED)
      tag[1].ti_Data=A2024TENHERTZ_KEY;
   if(MenuPtrs[37]->Flags & CHECKED)
      tag[1].ti_Data=A2024FIFTEENHERTZ_KEY;

   prefs.ScreenType=tag[1].ti_Data;

   PutScreenTypeInMenu();

   if(temp != tag[1].ti_Data)
      return(TRUE);  /*The display mode was changed*/
   else
      return(FALSE); /*Or it wasn't*/
}

BOOL HandleStartingLevel() /*Change the starting level*/
{
   BYTE c;

   for(c=0;c<6 && (MenuPtrs[21+c]->Flags & CHECKED) != CHECKED;c++);
   if(c==6)
   {
      c=0;
      MenuPtrs[21]->Flags |= CHECKED;
   }

   if(c!=StartingLevel)
   {
      StartingLevel=c;
      CheckModified();
      return(TRUE);
   }

   return(FALSE);
}

BOOL DoubleSpacing() /*Toggle between single & double spacing*/
{

   if(prefs.DS==(( MenuPtrs[20]->Flags & CHECKED)==CHECKED))
      return(FALSE);
   prefs.DS=!prefs.DS;

   CheckModified();
   return(TRUE);
}

void ModifyMenus(Flag)/*Modify Double Spacing and Starting Level menus for the*/
char Flag;	      /*ReadItemList function*/
{
   if(Flag>=32)   /*If double spaced...*/
   {
      prefs.DS=TRUE;
      MenuPtrs[20]->Flags |= CHECKED;
      Flag-=32;  /*Removed double spacing flag*/
   }
   else
   {
      prefs.DS=FALSE;
      MenuPtrs[20]->Flags &= (~CHECKED);
   }

   MenuPtrs[21+StartingLevel]->Flags &= ~CHECKED;
   StartingLevel=(Flag <= 5) ? Flag : 5;
   MenuPtrs[21+StartingLevel]->Flags |= CHECKED;
}

void GetLinerPrefs(filename)
char *filename;
{
   BPTR fp;

   if((fp=(BPTR)Open(filename,MODE_OLDFILE))==NULL)
      return;		  /*If no preferences file could be found*/
			  /*use the defaults*/

   Read(fp,&prefs,sizeof(struct LinerPrefs));  /*Read in the preferences*/
   Close(fp);        /*Close the file*/
}

void InterpretPrefs()   /*Install the preferences*/
{
   StartingLevel = 0;
   MenuPtrs[21+StartingLevel]->Flags|=CHECKED;
   ModifyMenus(prefs.Level+((prefs.DS) ? 32 : 0)); /*Double spacing and*/
						   /*starting level*/

   prefs.Name[0][12]=NULL; /*Make sure none of the name >12 characters*/
   prefs.Name[1][12]=NULL;
   prefs.Name[2][12]=NULL;
   prefs.Name[3][12]=NULL;

   tag[1].ti_Data=prefs.ScreenType;

   strcpy(SDirName,prefs.DefaultDir); /*Get the default disk directories*/
   strcpy(PDirName,prefs.DefPrintDir);

   OpenGraphics();      /*And open the screen, window, etc...*/
   SetRowsInScreen();
}

PutPrefs(filename,AREXX)      /*Save the preferences to disk*/
char *filename;
BYTE AREXX;
{
   UBYTE c;
   struct IntuiText *it;

   BPTR fp;

   if((fp=(BPTR)Open(filename,MODE_NEWFILE))==NULL)
   {
      if(!AREXX)
	 TitleError("Couldn't save the preferences!");
      return(FALSE);
   }

   for(c=0;c<4;c++)   /*Copy ARexx macro name info into the menus*/
   {
      it=(struct IntuiText *)MenuPtrs[15+c]->ItemFill;
      strcpy(prefs.Name[c],it->IText);
   }

   strcpy(prefs.DefaultDir,SDirName);
   strcpy(prefs.DefPrintDir,PDirName);

   prefs.Level=StartingLevel;


   Write(fp,&prefs,sizeof(struct LinerPrefs));
   Close(fp);  /*Done*/
   CreatePrefsIcon();   /*Make the icon for liner.prefs*/
   return(TRUE);
}

#define MAXAREXXMENUNAMELENGTH 12

void CopyPrefsToMenus()
{
   UBYTE c;
   struct IntuiText *it;

   ClearMenuStrip(Window);
   for(c=0;c<4;c++)   /*Copy ARexx macro name info into the menus*/
   {
      it=(struct IntuiText *)MenuPtrs[15+c]->ItemFill;
      strncpy(it->IText,prefs.Name[c],MAXAREXXMENUNAMELENGTH);
   }

   if(prefs.Icons)
      MenuPtrs[19]->Flags |= CHECKED;
   else
      MenuPtrs[19]->Flags &= ~CHECKED;

      /*Make sure the menus are properly formatted*/
   LayoutMenus(FinalMenus,VisInfo,TAG_DONE);

      /*Activate 'em*/
   SetMenuStrip(Window,FinalMenus);
}

struct MenuItem *GetFirstItemAddress(code) /*Get a MenuItem associated*/
USHORT code;   /*with the menu's number*/
{
   return(ItemAddress(FinalMenus,code));
}

void SaveColors(vp)  /*Save the screen's colors to prefs*/
struct ViewPort *vp;
{
   ULONG c,rgb;

   for(c=0; c < 4 ; c++)   /*Get screen colors*/
   {
      rgb=GetRGB4(vp->ColorMap,c);

      prefs.Color[c][0]=(rgb >> 8) & 0xF;
      prefs.Color[c][1]=(rgb >> 4) & 0xF;
      prefs.Color[c][2]= rgb & 0xF;

   }
}

void LoadColors(vp)  /*Change the screen colors to those in prefs*/
struct ViewPort *vp;
{
   ULONG c;

   for(c=0; c < 4; c++)
      SetRGB4(vp,c,prefs.Color[c][0],prefs.Color[c][1],prefs.Color[c][2]);
}

void SetRowsInScreen() /*Determine the # of text rows in a screen*/
{
		/*Divide the height of the window by the current font's*/
   RowsInScreen=(Window->Height)/Screen->Font->ta_YSize-1; /*height*/
}

void ModifyIconMenu()   /*Modify the icon menu*/
{
   if(prefs.Icons)
      MenuPtrs[19]->Flags |= CHECKED;
   else
      MenuPtrs[19]->Flags &= ~CHECKED;
}

HandleAbout()  /*Displays the 'About' window*/
{     /*It's here because it needs to access Windows.h*/
   struct Window *AboutWdw;
   struct Gadget junk;

   NewAboutWindow.Screen=Screen;    /*Pointer to window's screen*/

	 /*Position the window*/
   NewAboutWindow.TopEdge=(Screen->Height-NewAboutWindow.Height)/2;
   NewAboutWindow.LeftEdge=(Screen->Width-NewAboutWindow.Width)/2;

   MakeButtonGadgets(&junk,&Continue,VisInfo,&Topaz,1,0);
   if(junk.NextGadget == NULL)
      return(FALSE);

   NewAboutWindow.FirstGadget=(struct Gadget *)junk.NextGadget;

   if((AboutWdw=(struct Window *)OpenWindow(&NewAboutWindow))==NULL)
      return(FALSE);

   SetWindowTitles(AboutWdw,NULL,"For your information...");
   SetAPen(AboutWdw->RPort,1);
   PrintIText(AboutWdw->RPort,&IntuiTextList2,0,6);

      /*Draw a box around the text*/
   DrawBevelBoxA(AboutWdw->RPort,9,7,464,41,&beveltag[0]);

	 /*Wait for the user to press the Continue... gadget*/
   Wait(1<<AboutWdw->UserPort->mp_SigBit);

   FreeGadgets(junk.NextGadget);
   CloseWindow(AboutWdw);     /*Close the window*/
}

   /*Reset the menus to their original (startup) state*/
void ClearMenus()
{
   FreeMenus(FinalMenus);
   MakeMenus();
   ModifyMenus(0);
}

NewAll() /*Get rid of all the Items*/
{
   char Buffer[10];

   FreeListMem(FirstItem,LastItem);

   prefs.DS=FALSE;
   SetRowsInScreen();

   ModifyMenus(0); /*Set menus (Double Spacing & Starting Level) to defaults*/
   StartingLevel=0;
   MenuPtrs[21]->Flags|=CHECKED;

      /*Setup a fresh outline*/
   FirstItem=LastItem=FirstScrnItem=ScrnBtm=CurrentItem=
	 (struct LineItem *)InsertItem(NULL,NULL);
   if(FirstItem==NULL)
   {
      CloseGraphics();
      CloseLibrary(GadToolsBase);
      CloseLibrary(AslBase);
      CloseLibrary(IconBase);
      CloseLibrary(DosBase);
      Leave(1000,"Out of memory!");
   }

   CurrentItem->Level=1;
   Buffer[0]=0x0c;
   WriteConsole(Buffer,1);

   Buffer[0]=CSI;
   Buffer[1]='0';
   Buffer[2]=0x6d;

   WriteConsole(Buffer,3); /*Cancel any highlighting*/
   InvsMode=NOINV;
   PrintItemList(CurrentItem,1);
   PlotCursor(MinX(CurrentItem),CurY);
   Modified=FALSE;
   TitleErrorCancel();
   MenuPtrs[20]->Flags &= ~CHECKED;

   FileName[0]=NULL;	 /*Remove default filenames*/
   SFileName[0]=NULL;
   PDName[0]=NULL;
   PFileName[0]=NULL;
   TitleErrorCancel();

   return(TRUE);
}

void HandleIcons()
{
   prefs.Icons = ((MenuPtrs[19]->Flags & CHECKED)==CHECKED);
}

BOOL HandleEvent(object)
APTR object;
{
  struct MenuItem *mi;
  UWORD *num;

  mi=(struct MenuItem *)object;
  num=GTMENUITEM_USERDATA(mi);

  if (object == (APTR)MenuPtrs[0]) { HandleNew(); return(FALSE); }
  if (object == (APTR)MenuPtrs[1]) { HandleOpen(); return(FALSE); }
  if (object == (APTR)MenuPtrs[2]) { Save(FALSE); return(FALSE); }
  if (object == (APTR)MenuPtrs[3]) { HandleSaveAs(); return(FALSE); }
  if (object == (APTR)MenuPtrs[4]) { HandlePrintPrinter(); return(FALSE); }
  if (object == (APTR)MenuPtrs[5]) { HandlePrintDisk(FALSE,""); return(FALSE); }
  if (object == (APTR)MenuPtrs[6]) { HandleAbout(); return(FALSE); }
  if (object == (APTR)MenuPtrs[7]) { HandleQuit(); return(FALSE); }
  if (object == (APTR)MenuPtrs[8]) { HandleCut(); return(FALSE); }
  if (object == (APTR)MenuPtrs[9]) { HandleCopy(); return(FALSE); }
  if (object == (APTR)MenuPtrs[10]) { HandlePaste(); return(FALSE); }
  if (object == (APTR)MenuPtrs[11]) { HandleErase(); return(FALSE); }
  if (object == (APTR)MenuPtrs[12]) { DoSearch(FALSE,FALSE); return(FALSE); }
  if (object == (APTR)MenuPtrs[13]) { DoSearch(TRUE,FALSE); return(FALSE); }
  if (object == (APTR)MenuPtrs[15]) { EngageMacro(prefs.Macro[0]); return(FALSE); }
  if (object == (APTR)MenuPtrs[16]) { EngageMacro(prefs.Macro[1]); return(FALSE); }
  if (object == (APTR)MenuPtrs[17]) { EngageMacro(prefs.Macro[2]); return(FALSE); }
  if (object == (APTR)MenuPtrs[18]) { EngageMacro(prefs.Macro[3]); return(FALSE); }
  if (object == (APTR)MenuPtrs[19]) { HandleIcons(); return(FALSE); }
  if (object == (APTR)MenuPtrs[20]) { ChangeDisplay(); return(TRUE); }
  if (object == (APTR)MenuPtrs[21]) { ChangeDisplay(); return(TRUE); }
  if (object == (APTR)MenuPtrs[22]) { ChangeDisplay(); return(TRUE); }
  if (object == (APTR)MenuPtrs[23]) { ChangeDisplay(); return(TRUE); }
  if (object == (APTR)MenuPtrs[24]) { ChangeDisplay(); return(TRUE); }
  if (object == (APTR)MenuPtrs[25]) { ChangeDisplay(); return(TRUE); }
  if (object == (APTR)MenuPtrs[26]) { ChangeDisplay(); return(TRUE); }
  if (object == (APTR)MenuPtrs[28]) { ChangeDisplay(); return(TRUE); }
  if (object == (APTR)MenuPtrs[29]) { ChangeDisplay(); return(TRUE); }
  if (object == (APTR)MenuPtrs[30]) { ChangeDisplay(); return(TRUE); }
  if (object == (APTR)MenuPtrs[31]) { ChangeDisplay(); return(TRUE); }
  if (object == (APTR)MenuPtrs[27]) { HandlePalette(); return(TRUE); }
  if (object == (APTR)MenuPtrs[32]) { GetMacroInfo(); return(FALSE); }
  if (object == (APTR)MenuPtrs[33]) { HandleReloadPrefs(); return(TRUE); }
  if (object == (APTR)MenuPtrs[34]) { PutPrefs("liner:liner.prefs",FALSE);return(FALSE);}
  if (object == (APTR)MenuPtrs[14]) { ReplaceAll(TRUE); return(FALSE); }
  if (object == (APTR)MenuPtrs[35]) { ReplaceAll(FALSE); return(FALSE); }
  if (object == (APTR)MenuPtrs[36]) { ChangeDisplay(); return(TRUE); }
  if (object == (APTR)MenuPtrs[37]) { ChangeDisplay(); return(TRUE); }
  if (object == (APTR)MenuPtrs[38]) { ChangeDisplay(); return(TRUE); }
  if (object == (APTR)MenuPtrs[39]) { ChangeDisplay(); return(TRUE); }
  if (object == (APTR)MenuPtrs[40]) { ChangeDisplay(); return(TRUE); }

}

/*~~~End of Windows.c*/
