home *** CD-ROM | disk | FTP | other *** search
/ Fish 'n' More 2 / fishmore-publicdomainlibraryvol.ii1991xetec.iso / dirs / rramdisk_451.lzh / 'Liner / Source / Windows.c < prev    next >
C/C++ Source or Header  |  1991-02-06  |  20KB  |  721 lines

  1. /*Windows.c -- Includes all routines that access the stuff in Windows.h*/
  2.  
  3. extern struct MenuItem *ItemAddress();
  4.  
  5. #include "Globals.h"
  6. #include "Windows.h"
  7.  
  8. #define NTSC_ITEM_NUM 4|SHIFTITEM(5)|SHIFTSUB(7)
  9. #define PAL_ITEM_NUM 4|SHIFTITEM(5)|SHIFTSUB(8)
  10.  
  11. UWORD wbPens[]={0,1,1,2,1,3,1,0,3,~0};
  12.  
  13. struct TagItem tag[]=
  14. {
  15.    {SA_Pens,NULL},
  16.    {SA_DisplayID,HIRES_KEY},
  17.    {TAG_DONE,NULL}
  18. };
  19.  
  20. struct IntuiText IT_foo =  /*Used to get the current font width*/
  21. {
  22.    0,0,JAM1,0,0,NULL,"A",NULL
  23. };
  24.  
  25. void MakeMenus() /*Create the 2.0 style menus*/
  26. {
  27.    FinalMenus=(struct Menu *)CreateMenusA(menu,&menutags[0]);
  28.    GetMenuPointers();
  29. }
  30.  
  31. void OpenGraphics() /*Open screen, window, etc.*/
  32. {
  33.       /*Setup a tag so the 3D gadgets actually look 3Dish*/
  34.    tag[0].ti_Data=(ULONG)wbPens;
  35.  
  36.    /*Open screen*/
  37.    NewWindow.Screen=Screen=(struct Screen *)OpenScreenTagList(&NewScreen,tag);
  38.    if(Screen==NULL)
  39.       Leave(50,"Can't open screen!!");
  40.  
  41.    if(prefs.Exists)    /*Set screen colors to those in prefs*/
  42.       LoadColors(&(Screen->ViewPort));
  43.    else     /*Otherwise, use the defaults and save those in the prefs*/
  44.    {
  45.       SaveColors(&(Screen->ViewPort));
  46.       prefs.Exists=TRUE;
  47.    }
  48.  
  49.       /*Set window size, taking current font size into account*/
  50.    NewWindow.TopEdge=Screen->BarHeight+1;
  51.    NewWindow.Height=Screen->Height-Screen->BarHeight-1;
  52.    NewWindow.Width=Screen->Width;
  53.  
  54.    /*Open backdrop window & make requestors open onto it*/
  55.    if((ThisProc->pr_WindowPtr=Window=
  56.      (struct Window *)OpenWindow(&NewWindow))==NULL)
  57.    {
  58.       CloseScreen(Screen);
  59.       Leave(60,"Can't open Window!");
  60.    }
  61.  
  62.    /*Get VisualInfo*/
  63.    beveltag[0].ti_Data=(Tag)GetVisualInfo(Screen,TAG_DONE);
  64.    VisInfo=(APTR)beveltag[0].ti_Data;
  65.  
  66.    /*Install menus*/
  67.    LayoutMenus(FinalMenus,VisInfo,TAG_DONE);
  68.    SetMenuStrip(Window,FinalMenus);
  69.  
  70.    CopyPrefsToMenus();
  71.    PutScreenTypeInMenu();
  72.  
  73.    /*Get font width*/
  74.  
  75.    IT_foo.ITextFont=(struct TextAttr *)Screen->Font;
  76.    FontWidth = IntuiTextLength(&IT_foo);
  77.  
  78.    /*Setup the console.device*/
  79.    consoleWritePort=(struct Port *)CreatePort("mycon.write",0);
  80.    if(consoleWritePort==NULL)
  81.       Leave(70,"Couldn't open console.device!");
  82.  
  83.    consoleWriteMsg=(struct IOStdReq *)CreateStdIO(consoleWritePort);
  84.    if(consoleWriteMsg==NULL)
  85.       Leave(80,"Couldn't open console.device!");
  86.  
  87.    consoleReadPort=(struct Port *)CreatePort("mycon.read",0);
  88.    if(consoleReadPort==NULL)
  89.       Leave(90,"Can't create communications port!");
  90.  
  91.    consoleReadMsg=(struct IOStdReq *)CreateStdIO(consoleReadPort);
  92.    if(consoleReadMsg==NULL)
  93.       Leave(100,"Can't create standard IO!");
  94.  
  95.    consoleWriteMsg->io_Data=(struct Window *)Window;  /*Attach console*/
  96.    consoleWriteMsg->io_Length=sizeof(struct Window);  /*device to window...*/
  97.    OpenDevice("console.device",0,consoleWriteMsg,0); /*& open it*/
  98.  
  99.    consoleReadMsg->io_Device=consoleWriteMsg->io_Device;
  100.  
  101.    consoleReadMsg->io_Unit=consoleWriteMsg->io_Unit; /*Get the current keymap*/
  102.    consoleReadMsg->io_Command=CD_ASKKEYMAP;
  103.    consoleReadMsg->io_Length=sizeof(struct KeyMap);
  104.    consoleReadMsg->io_Data=&keymap;
  105.    DoIO(consoleReadMsg);
  106.    TitleErrorCancel();
  107.    if(!SetupFileRequestor())
  108.    {
  109.      CloseGraphics();
  110.      Leave(1000,"Couldn't allocate needed file requestor information!");
  111.    }
  112. }
  113.  
  114. void CloseGraphics()   /*Close the window, screen, etc.*/
  115. {
  116.       /*Close the console*/
  117.    CloseDevice(consoleWriteMsg);
  118.    DeleteStdIO(consoleWriteMsg);
  119.    DeleteStdIO(consoleReadMsg);
  120.    DeletePort(consoleWritePort);
  121.    DeletePort(consoleReadPort);
  122.  
  123.       /*Free the file requestor structures*/
  124.    FreeFileRequest(MainReq);
  125.    FreeFileRequest(PTDReq);
  126.  
  127.       /*Return the Intuition resources to the system*/
  128.    ClearMenuStrip(Window);
  129.    FreeMenus(FinalMenus);
  130.    CloseWindow(Window);
  131.    FreeVisualInfo(VisInfo);
  132.    CloseScreen(Screen);
  133. }
  134.  
  135.    /*Under KS1.3, the menu structures could be accessed fairly easily,*/
  136.    /*since they were part of 'Liner's data directly.  Under 2.0, however,*/
  137.    /*the menu structures don't exist until 'Liner explicitly creates*/
  138.    /*them.  What GenMenuPointers() does is create an array of pointers*/
  139.    /* to the created menu structures, so 'Liner can do stuff like change*/
  140.    /*preferences settings when liner.prefs is loaded.  This was not needed*/
  141.    /*under 1.3 for the reasons given above*/
  142.  
  143. void GetMenuPointers()
  144. {
  145.    struct Menu *CurMenu;
  146.    struct MenuItem *CurItem,*CurSub;
  147.    UWORD *num;
  148.  
  149.    CurMenu=(struct Menu *)FinalMenus;
  150.  
  151.    while(CurMenu != NULL) /*Go through the linked list of Menu structures*/
  152.    {
  153.       CurItem=(struct MenuItem *)CurMenu->FirstItem;
  154.      /*Go through each Menu's MenuItems (and their SubItems)*/
  155.       while(CurItem != NULL)
  156.       {
  157.      if(CurItem->SubItem != NULL)
  158.      {
  159.         CurSub=(struct MenuItem *)CurItem->SubItem;
  160.         while(CurSub != NULL)
  161.         {
  162.           /*Find where the MenuItem goes in the array*/
  163.            num=GTMENUITEM_USERDATA(CurSub);
  164.  
  165.           /*And put it's pointer there*/
  166.            if(num != NULL)
  167.           MenuPtrs[*num]=(struct MenuItem *)CurSub;
  168.  
  169.           /*Go on to the next item*/
  170.            CurSub=(struct MenuItem *)CurSub->NextItem;
  171.         }
  172.      }
  173.      else
  174.      {
  175.         /*Same as above*/
  176.         num=GTMENUITEM_USERDATA(CurItem);
  177.         if(num != NULL)
  178.            MenuPtrs[*num]=(struct MenuItem *)CurItem;
  179.      }
  180.  
  181.      CurItem=(struct MenuItem *)CurItem->NextItem;
  182.       }
  183.  
  184.       CurMenu=(struct Menu *)CurMenu->NextMenu;
  185.    }
  186. }
  187.  
  188. /*Initialize the 2.0 asl.library filerequestor structures*/
  189. BOOL SetupFileRequestor()
  190. {
  191.  
  192.    if((MainReq=(struct FileRequester *)AllocFileRequest())==NULL)
  193.       return(FALSE);
  194.  
  195.    if((PTDReq=(struct FileRequester *)AllocFileRequest())==NULL)
  196.    {
  197.       FreeFileRequest(MainReq);
  198.       return(FALSE);
  199.    }
  200.  
  201.    /*File requestor used for saves & opens*/
  202.    MainReq->rf_File=(char *)SFileName;
  203.    MainReq->rf_Dir=(char *)SDirName;
  204.    MainReq->rf_Function=NULL;
  205.    MainReq->rf_Window=(struct Window *)Window;
  206.    MainReq->rf_FuncFlags=RFF_DOCOLOR;
  207.    MainReq->rf_Flags2=NULL;
  208.    MainReq->rf_NumArgs=0;
  209.  
  210.    /*Used for print to disks*/
  211.    PTDReq->rf_File=(char *)PFileName;
  212.    PTDReq->rf_Dir=(char *)PDirName;
  213.    PTDReq->rf_Function=NULL;
  214.    PTDReq->rf_Window=(struct Window *)Window;
  215.    PTDReq->rf_FuncFlags=NULL;
  216.    PTDReq->rf_Flags2=NULL;
  217.    PTDReq->rf_NumArgs=0;
  218.  
  219.    return(TRUE);
  220. }
  221.  
  222. /*This is in liner.c and not menu.c because it needs to manipulate the*/
  223. /*'Liner NewScreen and NewWindow information, which it can't do from*/
  224. /*menu.c*/
  225.  
  226. void ChangeDisplay()
  227. {
  228.    UBYTE X,Y;
  229.    BOOL stat2,stat3,stat4;
  230.  
  231.  
  232.    X=CurX;
  233.    Y=CurY;
  234.  
  235.    stat2=ChangeScreenSize();
  236.    stat3=DoubleSpacing();
  237.    stat4=HandleStartingLevel();
  238.  
  239.    if( stat2 )
  240.    {
  241.       if( stat3 || stat4 )
  242.      CheckModified();
  243.  
  244.       CloseGraphics();
  245.       MakeMenus();
  246.       OpenGraphics();
  247.  
  248.       SetRowsInScreen();
  249.       PrintItemList(FirstScrnItem,1);
  250.  
  251.       if(Y > DispRows)/*if the old laced Y is > the current possible rows*/
  252.       {
  253.      Y=DispRows;    /*Y now = the last screen item*/
  254.      CurrentItem=(struct LineItem *)ScrnBtm;
  255.       }
  256.       if(X > MaxX(CurrentItem))  /*Out of bounds*/
  257.      X=MaxX(CurrentItem);
  258.       else if(X < MinX(CurrentItem))
  259.      X=MinX(CurrentItem);
  260.  
  261.       PlotCursor(X,Y);     /*Restore cursor position*/
  262.    }
  263.    else
  264.       if( stat4 )
  265.       {
  266.      SetRowsInScreen();
  267.      PrintItemList(FirstScrnItem,1);
  268.  
  269.      if(Y > DispRows)  /*if the old laced Y is > the current possible rows*/
  270.      {
  271.         Y=DispRows;    /*Y now = the last screen item*/
  272.         CurrentItem=(struct LineItem *)ScrnBtm;
  273.      }
  274.      if(X > MaxX(CurrentItem))  /*Out of bounds*/
  275.         X=MaxX(CurrentItem);
  276.      else if(X < MinX(CurrentItem))
  277.         X=MinX(CurrentItem);
  278.  
  279.      PlotCursor(X,Y);     /*Restore cursor position*/
  280.       }
  281. }
  282.  
  283. void PutScreenTypeInMenu()
  284. {
  285.    UBYTE c;
  286.    for(c=28;c<=31;c++)
  287.       MenuPtrs[c]->Flags &= ~CHECKED;
  288.    for(c=36;c<=40;c++)
  289.       MenuPtrs[c]->Flags &= ~CHECKED;
  290.  
  291.      /*Switch on the NTSC and PAL menu items*/
  292.    OnMenu(Window,NTSC_ITEM_NUM);
  293.    OnMenu(Window,PAL_ITEM_NUM);
  294.  
  295.    switch(prefs.ScreenType & MONITOR_ID_MASK) /*Check monitor type*/
  296.    {
  297.       case NTSC_MONITOR_ID:
  298.      MenuPtrs[38]->Flags |= CHECKED;
  299.      break;
  300.       case PAL_MONITOR_ID:
  301.      MenuPtrs[39]->Flags |= CHECKED;
  302.      break;
  303.       case VGA_MONITOR_ID:
  304.       case A2024_MONITOR_ID:
  305.      OffMenu(Window,NTSC_ITEM_NUM); /*turn off NTSC and PAL*/
  306.      OffMenu(Window,PAL_ITEM_NUM);
  307.       case DEFAULT_MONITOR_ID:
  308.      MenuPtrs[40]->Flags |= CHECKED;
  309.      break;
  310.    }
  311.  
  312.    switch(prefs.ScreenType)   /*Check for A2024 modes*/
  313.    {
  314.       case A2024TENHERTZ_KEY:
  315.      MenuPtrs[36]->Flags |= CHECKED;
  316.      return;
  317.       case A2024FIFTEENHERTZ_KEY:
  318.      MenuPtrs[37]->Flags |= CHECKED;
  319.      return;
  320.    }
  321.  
  322.    switch(prefs.ScreenType & ~MONITOR_ID_MASK) /*Check for other modes*/
  323.    {
  324.       case HIRES_KEY:
  325.      MenuPtrs[28]->Flags|=CHECKED;
  326.      break;
  327.       case HIRESLACE_KEY:
  328.      MenuPtrs[29]->Flags|=CHECKED;
  329.      break;
  330.       case VGAPRODUCT_KEY & ~MONITOR_ID_MASK:
  331.      MenuPtrs[30]->Flags|=CHECKED;
  332.      break;
  333.       case VGAPRODUCTLACE_KEY & ~MONITOR_ID_MASK:
  334.      MenuPtrs[31]->Flags|=CHECKED;
  335.    }
  336.  
  337. }
  338.  
  339. BOOL ChangeScreenSize()   /*Determine which display mode to use*/
  340. {
  341.    ULONG temp;
  342.  
  343.    temp=tag[1].ti_Data;
  344.  
  345.    if(MenuPtrs[28]->Flags & CHECKED) /*Check each menu item*/
  346.       tag[1].ti_Data=HIRES_KEY;      /*The one that is checked determines*/
  347.  
  348.    if(MenuPtrs[29]->Flags & CHECKED) /*What mode is used*/
  349.       tag[1].ti_Data=HIRESLACE_KEY;
  350.  
  351.    if(MenuPtrs[30]->Flags & CHECKED)
  352.       tag[1].ti_Data=VGAPRODUCT_KEY;
  353.  
  354.    if(MenuPtrs[31]->Flags & CHECKED)
  355.       tag[1].ti_Data=VGAPRODUCTLACE_KEY;
  356.  
  357.    if(MenuPtrs[38]->Flags & CHECKED)
  358.       tag[1].ti_Data |= NTSC_MONITOR_ID;
  359.  
  360.    if(MenuPtrs[39]->Flags & CHECKED)
  361.       tag[1].ti_Data |= PAL_MONITOR_ID;
  362.  
  363.    if(MenuPtrs[36]->Flags & CHECKED)
  364.       tag[1].ti_Data=A2024TENHERTZ_KEY;
  365.    if(MenuPtrs[37]->Flags & CHECKED)
  366.       tag[1].ti_Data=A2024FIFTEENHERTZ_KEY;
  367.  
  368.    prefs.ScreenType=tag[1].ti_Data;
  369.  
  370.    PutScreenTypeInMenu();
  371.  
  372.    if(temp != tag[1].ti_Data)
  373.       return(TRUE);  /*The display mode was changed*/
  374.    else
  375.       return(FALSE); /*Or it wasn't*/
  376. }
  377.  
  378. BOOL HandleStartingLevel() /*Change the starting level*/
  379. {
  380.    BYTE c;
  381.  
  382.    for(c=0;c<6 && (MenuPtrs[21+c]->Flags & CHECKED) != CHECKED;c++);
  383.    if(c==6)
  384.    {
  385.       c=0;
  386.       MenuPtrs[21]->Flags |= CHECKED;
  387.    }
  388.  
  389.    if(c!=StartingLevel)
  390.    {
  391.       StartingLevel=c;
  392.       CheckModified();
  393.       return(TRUE);
  394.    }
  395.  
  396.    return(FALSE);
  397. }
  398.  
  399. BOOL DoubleSpacing() /*Toggle between single & double spacing*/
  400. {
  401.  
  402.    if(prefs.DS==(( MenuPtrs[20]->Flags & CHECKED)==CHECKED))
  403.       return(FALSE);
  404.    prefs.DS=!prefs.DS;
  405.  
  406.    CheckModified();
  407.    return(TRUE);
  408. }
  409.  
  410. void ModifyMenus(Flag)/*Modify Double Spacing and Starting Level menus for the*/
  411. char Flag;          /*ReadItemList function*/
  412. {
  413.    if(Flag>=32)   /*If double spaced...*/
  414.    {
  415.       prefs.DS=TRUE;
  416.       MenuPtrs[20]->Flags |= CHECKED;
  417.       Flag-=32;  /*Removed double spacing flag*/
  418.    }
  419.    else
  420.    {
  421.       prefs.DS=FALSE;
  422.       MenuPtrs[20]->Flags &= (~CHECKED);
  423.    }
  424.  
  425.    MenuPtrs[21+StartingLevel]->Flags &= ~CHECKED;
  426.    StartingLevel=(Flag <= 5) ? Flag : 5;
  427.    MenuPtrs[21+StartingLevel]->Flags |= CHECKED;
  428. }
  429.  
  430. void GetLinerPrefs(filename)
  431. char *filename;
  432. {
  433.    BPTR fp;
  434.  
  435.    if((fp=(BPTR)Open(filename,MODE_OLDFILE))==NULL)
  436.       return;          /*If no preferences file could be found*/
  437.               /*use the defaults*/
  438.  
  439.    Read(fp,&prefs,sizeof(struct LinerPrefs));  /*Read in the preferences*/
  440.    Close(fp);        /*Close the file*/
  441. }
  442.  
  443. void InterpretPrefs()   /*Install the preferences*/
  444. {
  445.    StartingLevel = 0;
  446.    MenuPtrs[21+StartingLevel]->Flags|=CHECKED;
  447.    ModifyMenus(prefs.Level+((prefs.DS) ? 32 : 0)); /*Double spacing and*/
  448.                            /*starting level*/
  449.  
  450.    prefs.Name[0][12]=NULL; /*Make sure none of the name >12 characters*/
  451.    prefs.Name[1][12]=NULL;
  452.    prefs.Name[2][12]=NULL;
  453.    prefs.Name[3][12]=NULL;
  454.  
  455.    tag[1].ti_Data=prefs.ScreenType;
  456.  
  457.    strcpy(SDirName,prefs.DefaultDir); /*Get the default disk directories*/
  458.    strcpy(PDirName,prefs.DefPrintDir);
  459.  
  460.    OpenGraphics();      /*And open the screen, window, etc...*/
  461.    SetRowsInScreen();
  462. }
  463.  
  464. PutPrefs(filename,AREXX)      /*Save the preferences to disk*/
  465. char *filename;
  466. BYTE AREXX;
  467. {
  468.    UBYTE c;
  469.    struct IntuiText *it;
  470.  
  471.    BPTR fp;
  472.  
  473.    if((fp=(BPTR)Open(filename,MODE_NEWFILE))==NULL)
  474.    {
  475.       if(!AREXX)
  476.      TitleError("Couldn't save the preferences!");
  477.       return(FALSE);
  478.    }
  479.  
  480.    for(c=0;c<4;c++)   /*Copy ARexx macro name info into the menus*/
  481.    {
  482.       it=(struct IntuiText *)MenuPtrs[15+c]->ItemFill;
  483.       strcpy(prefs.Name[c],it->IText);
  484.    }
  485.  
  486.    strcpy(prefs.DefaultDir,SDirName);
  487.    strcpy(prefs.DefPrintDir,PDirName);
  488.  
  489.    prefs.Level=StartingLevel;
  490.  
  491.  
  492.    Write(fp,&prefs,sizeof(struct LinerPrefs));
  493.    Close(fp);  /*Done*/
  494.    CreatePrefsIcon();   /*Make the icon for liner.prefs*/
  495.    return(TRUE);
  496. }
  497.  
  498. #define MAXAREXXMENUNAMELENGTH 12
  499.  
  500. void CopyPrefsToMenus()
  501. {
  502.    UBYTE c;
  503.    struct IntuiText *it;
  504.  
  505.    ClearMenuStrip(Window);
  506.    for(c=0;c<4;c++)   /*Copy ARexx macro name info into the menus*/
  507.    {
  508.       it=(struct IntuiText *)MenuPtrs[15+c]->ItemFill;
  509.       strncpy(it->IText,prefs.Name[c],MAXAREXXMENUNAMELENGTH);
  510.    }
  511.  
  512.    if(prefs.Icons)
  513.       MenuPtrs[19]->Flags |= CHECKED;
  514.    else
  515.       MenuPtrs[19]->Flags &= ~CHECKED;
  516.  
  517.       /*Make sure the menus are properly formatted*/
  518.    LayoutMenus(FinalMenus,VisInfo,TAG_DONE);
  519.  
  520.       /*Activate 'em*/
  521.    SetMenuStrip(Window,FinalMenus);
  522. }
  523.  
  524. struct MenuItem *GetFirstItemAddress(code) /*Get a MenuItem associated*/
  525. USHORT code;   /*with the menu's number*/
  526. {
  527.    return(ItemAddress(FinalMenus,code));
  528. }
  529.  
  530. void SaveColors(vp)  /*Save the screen's colors to prefs*/
  531. struct ViewPort *vp;
  532. {
  533.    ULONG c,rgb;
  534.  
  535.    for(c=0; c < 4 ; c++)   /*Get screen colors*/
  536.    {
  537.       rgb=GetRGB4(vp->ColorMap,c);
  538.  
  539.       prefs.Color[c][0]=(rgb >> 8) & 0xF;
  540.       prefs.Color[c][1]=(rgb >> 4) & 0xF;
  541.       prefs.Color[c][2]= rgb & 0xF;
  542.  
  543.    }
  544. }
  545.  
  546. void LoadColors(vp)  /*Change the screen colors to those in prefs*/
  547. struct ViewPort *vp;
  548. {
  549.    ULONG c;
  550.  
  551.    for(c=0; c < 4; c++)
  552.       SetRGB4(vp,c,prefs.Color[c][0],prefs.Color[c][1],prefs.Color[c][2]);
  553. }
  554.  
  555. void SetRowsInScreen() /*Determine the # of text rows in a screen*/
  556. {
  557.         /*Divide the height of the window by the current font's*/
  558.    RowsInScreen=(Window->Height)/Screen->Font->ta_YSize-1; /*height*/
  559. }
  560.  
  561. void ModifyIconMenu()   /*Modify the icon menu*/
  562. {
  563.    if(prefs.Icons)
  564.       MenuPtrs[19]->Flags |= CHECKED;
  565.    else
  566.       MenuPtrs[19]->Flags &= ~CHECKED;
  567. }
  568.  
  569. HandleAbout()  /*Displays the 'About' window*/
  570. {     /*It's here because it needs to access Windows.h*/
  571.    struct Window *AboutWdw;
  572.    struct Gadget junk;
  573.  
  574.    NewAboutWindow.Screen=Screen;    /*Pointer to window's screen*/
  575.  
  576.      /*Position the window*/
  577.    NewAboutWindow.TopEdge=(Screen->Height-NewAboutWindow.Height)/2;
  578.    NewAboutWindow.LeftEdge=(Screen->Width-NewAboutWindow.Width)/2;
  579.  
  580.    MakeButtonGadgets(&junk,&Continue,VisInfo,&Topaz,1,0);
  581.    if(junk.NextGadget == NULL)
  582.       return(FALSE);
  583.  
  584.    NewAboutWindow.FirstGadget=(struct Gadget *)junk.NextGadget;
  585.  
  586.    if((AboutWdw=(struct Window *)OpenWindow(&NewAboutWindow))==NULL)
  587.       return(FALSE);
  588.  
  589.    SetWindowTitles(AboutWdw,NULL,"For your information...");
  590.    SetAPen(AboutWdw->RPort,1);
  591.    PrintIText(AboutWdw->RPort,&IntuiTextList2,0,6);
  592.  
  593.       /*Draw a box around the text*/
  594.    DrawBevelBoxA(AboutWdw->RPort,9,7,464,41,&beveltag[0]);
  595.  
  596.      /*Wait for the user to press the Continue... gadget*/
  597.    Wait(1<<AboutWdw->UserPort->mp_SigBit);
  598.  
  599.    FreeGadgets(junk.NextGadget);
  600.    CloseWindow(AboutWdw);     /*Close the window*/
  601. }
  602.  
  603.    /*Reset the menus to their original (startup) state*/
  604. void ClearMenus()
  605. {
  606.    FreeMenus(FinalMenus);
  607.    MakeMenus();
  608.    ModifyMenus(0);
  609. }
  610.  
  611. NewAll() /*Get rid of all the Items*/
  612. {
  613.    char Buffer[10];
  614.  
  615.    FreeListMem(FirstItem,LastItem);
  616.  
  617.    prefs.DS=FALSE;
  618.    SetRowsInScreen();
  619.  
  620.    ModifyMenus(0); /*Set menus (Double Spacing & Starting Level) to defaults*/
  621.    StartingLevel=0;
  622.    MenuPtrs[21]->Flags|=CHECKED;
  623.  
  624.       /*Setup a fresh outline*/
  625.    FirstItem=LastItem=FirstScrnItem=ScrnBtm=CurrentItem=
  626.      (struct LineItem *)InsertItem(NULL,NULL);
  627.    if(FirstItem==NULL)
  628.    {
  629.       CloseGraphics();
  630.       CloseLibrary(GadToolsBase);
  631.       CloseLibrary(AslBase);
  632.       CloseLibrary(IconBase);
  633.       CloseLibrary(DosBase);
  634.       Leave(1000,"Out of memory!");
  635.    }
  636.  
  637.    CurrentItem->Level=1;
  638.    Buffer[0]=0x0c;
  639.    WriteConsole(Buffer,1);
  640.  
  641.    Buffer[0]=CSI;
  642.    Buffer[1]='0';
  643.    Buffer[2]=0x6d;
  644.  
  645.    WriteConsole(Buffer,3); /*Cancel any highlighting*/
  646.    InvsMode=NOINV;
  647.    PrintItemList(CurrentItem,1);
  648.    PlotCursor(MinX(CurrentItem),CurY);
  649.    Modified=FALSE;
  650.    TitleErrorCancel();
  651.    MenuPtrs[20]->Flags &= ~CHECKED;
  652.  
  653.    FileName[0]=NULL;     /*Remove default filenames*/
  654.    SFileName[0]=NULL;
  655.    PDName[0]=NULL;
  656.    PFileName[0]=NULL;
  657.    TitleErrorCancel();
  658.  
  659.    return(TRUE);
  660. }
  661.  
  662. void HandleIcons()
  663. {
  664.    prefs.Icons = ((MenuPtrs[19]->Flags & CHECKED)==CHECKED);
  665. }
  666.  
  667. BOOL HandleEvent(object)
  668. APTR object;
  669. {
  670.   struct MenuItem *mi;
  671.   UWORD *num;
  672.  
  673.   mi=(struct MenuItem *)object;
  674.   num=GTMENUITEM_USERDATA(mi);
  675.  
  676.   if (object == (APTR)MenuPtrs[0]) { HandleNew(); return(FALSE); }
  677.   if (object == (APTR)MenuPtrs[1]) { HandleOpen(); return(FALSE); }
  678.   if (object == (APTR)MenuPtrs[2]) { Save(FALSE); return(FALSE); }
  679.   if (object == (APTR)MenuPtrs[3]) { HandleSaveAs(); return(FALSE); }
  680.   if (object == (APTR)MenuPtrs[4]) { HandlePrintPrinter(); return(FALSE); }
  681.   if (object == (APTR)MenuPtrs[5]) { HandlePrintDisk(FALSE,""); return(FALSE); }
  682.   if (object == (APTR)MenuPtrs[6]) { HandleAbout(); return(FALSE); }
  683.   if (object == (APTR)MenuPtrs[7]) { HandleQuit(); return(FALSE); }
  684.   if (object == (APTR)MenuPtrs[8]) { HandleCut(); return(FALSE); }
  685.   if (object == (APTR)MenuPtrs[9]) { HandleCopy(); return(FALSE); }
  686.   if (object == (APTR)MenuPtrs[10]) { HandlePaste(); return(FALSE); }
  687.   if (object == (APTR)MenuPtrs[11]) { HandleErase(); return(FALSE); }
  688.   if (object == (APTR)MenuPtrs[12]) { DoSearch(FALSE,FALSE); return(FALSE); }
  689.   if (object == (APTR)MenuPtrs[13]) { DoSearch(TRUE,FALSE); return(FALSE); }
  690.   if (object == (APTR)MenuPtrs[15]) { EngageMacro(prefs.Macro[0]); return(FALSE); }
  691.   if (object == (APTR)MenuPtrs[16]) { EngageMacro(prefs.Macro[1]); return(FALSE); }
  692.   if (object == (APTR)MenuPtrs[17]) { EngageMacro(prefs.Macro[2]); return(FALSE); }
  693.   if (object == (APTR)MenuPtrs[18]) { EngageMacro(prefs.Macro[3]); return(FALSE); }
  694.   if (object == (APTR)MenuPtrs[19]) { HandleIcons(); return(FALSE); }
  695.   if (object == (APTR)MenuPtrs[20]) { ChangeDisplay(); return(TRUE); }
  696.   if (object == (APTR)MenuPtrs[21]) { ChangeDisplay(); return(TRUE); }
  697.   if (object == (APTR)MenuPtrs[22]) { ChangeDisplay(); return(TRUE); }
  698.   if (object == (APTR)MenuPtrs[23]) { ChangeDisplay(); return(TRUE); }
  699.   if (object == (APTR)MenuPtrs[24]) { ChangeDisplay(); return(TRUE); }
  700.   if (object == (APTR)MenuPtrs[25]) { ChangeDisplay(); return(TRUE); }
  701.   if (object == (APTR)MenuPtrs[26]) { ChangeDisplay(); return(TRUE); }
  702.   if (object == (APTR)MenuPtrs[28]) { ChangeDisplay(); return(TRUE); }
  703.   if (object == (APTR)MenuPtrs[29]) { ChangeDisplay(); return(TRUE); }
  704.   if (object == (APTR)MenuPtrs[30]) { ChangeDisplay(); return(TRUE); }
  705.   if (object == (APTR)MenuPtrs[31]) { ChangeDisplay(); return(TRUE); }
  706.   if (object == (APTR)MenuPtrs[27]) { HandlePalette(); return(TRUE); }
  707.   if (object == (APTR)MenuPtrs[32]) { GetMacroInfo(); return(FALSE); }
  708.   if (object == (APTR)MenuPtrs[33]) { HandleReloadPrefs(); return(TRUE); }
  709.   if (object == (APTR)MenuPtrs[34]) { PutPrefs("liner:liner.prefs",FALSE);return(FALSE);}
  710.   if (object == (APTR)MenuPtrs[14]) { ReplaceAll(TRUE); return(FALSE); }
  711.   if (object == (APTR)MenuPtrs[35]) { ReplaceAll(FALSE); return(FALSE); }
  712.   if (object == (APTR)MenuPtrs[36]) { ChangeDisplay(); return(TRUE); }
  713.   if (object == (APTR)MenuPtrs[37]) { ChangeDisplay(); return(TRUE); }
  714.   if (object == (APTR)MenuPtrs[38]) { ChangeDisplay(); return(TRUE); }
  715.   if (object == (APTR)MenuPtrs[39]) { ChangeDisplay(); return(TRUE); }
  716.   if (object == (APTR)MenuPtrs[40]) { ChangeDisplay(); return(TRUE); }
  717.  
  718. }
  719.  
  720. /*~~~End of Windows.c*/
  721.