home *** CD-ROM | disk | FTP | other *** search
/ Collection of Internet / Collection of Internet.iso / msdos / lynx / source / doslynx / src / turlvie9.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1994-10-25  |  4.4 KB  |  173 lines

  1. //    Copyright (c) 1993, University of Kansas, All Rights Reserved
  2. //
  3. //    Class:        TURLView
  4. //    Include File:    turlview.h
  5. //    Purpose:    Provide the view of a URL
  6. //    Remarks/Portability/Dependencies/Restrictions:
  7. //    Revision History:
  8. //        12-27-93    created
  9. //        02-02-94    Began a major revision to fully handle a
  10. //                multiple document interface with WWW, take
  11. //                over the formatting and drawing of the
  12. //                old gridtext functions of HText, and optimize
  13. //                memory usage, selecting anchors, the usage of
  14. //                HText's new image file.  See gridtext.
  15. //        02-09-94    Split all members into seperate files.
  16. #define Uses_TKeys
  17. #define Uses_MsgBox
  18. #include"turlview.h"
  19. #include<ctype.h>
  20.  
  21. void TURLView::handleEvent(TEvent& TE_event)    {
  22. //    Purpose:    Handles any event messages.
  23. //    Arguments:    TE_event    The event occuring.
  24. //    Return Value:    void
  25. //    Remarks/Portability/Dependencies/Restrictions:
  26. //    Revision History:
  27. //        01-11-94    created
  28.  
  29.     //    Commands through message passing.
  30.     if(TE_event.what & evMessage)    {
  31.         switch(TE_event.message.command)    {
  32.         //    Set the global variable to indicate which view
  33.         //    the user is currently in.  If not, WWW routines
  34.         //    won't know which window to load document into.
  35.         case cmReceivedFocus:
  36.             //    Maybe not.  Creates a bug.  Depend on the
  37.             //    fact that all WWW code is executed during
  38.             //    creation and thereafter has no effect.
  39.             //    TURLV_current = this;
  40.             break;
  41.         case cmNextAnchor:
  42.             //    Select the next anchor.
  43.             AnchorSelectNext();
  44.             clearEvent(TE_event);
  45.             break;
  46.         case cmPreviousAnchor:
  47.             //    Select the previous anchor.
  48.             AnchorSelectPrevious();
  49.             clearEvent(TE_event);
  50.             break;
  51.         case cmSelectAnchor:
  52.             //    Load the anchor.
  53.             LoadChild();
  54.             clearEvent(TE_event);
  55.             break;
  56.         case cmPreviousDocument:
  57.             //    Load the parent.
  58.             LoadParent();
  59.             clearEvent(TE_event);
  60.             break;
  61.         case cmShowDestination:
  62.             //    Show the destiniation of the selected link.
  63.             auto char *cp_childURL = getChild();
  64.             messageBox(cp_childURL, mfInformation | mfOKButton);
  65.             delete(cp_childURL);
  66.             clearEvent(TE_event);
  67.             break;
  68.         case cmSaveDLX:
  69.             save();
  70.             clearEvent(TE_event);
  71.             break;
  72.         case cmPrint:
  73.             print();
  74.             clearEvent(TE_event);
  75.             break;
  76.         case cmSearch:
  77.             search();
  78.             clearEvent(TE_event);
  79.             break;
  80.         case cmSearchAgainDLX:
  81.             search(ca_searchLast);
  82.             clearEvent(TE_event);
  83.             break;
  84.         case cmAddToHotList:
  85.             addToHotList();
  86.             clearEvent(TE_event);
  87.             break;
  88.         }
  89.     }
  90.     //    Commands through the keyboard.
  91.     else if(TE_event.what & evKeyboard)    {
  92.         //    Let's look at the actual character.
  93.         //    Take nothing without scan code.
  94.         //    Map the VI keys.
  95.         if(TE_event.keyDown.charScan.scanCode != 0)    {
  96.             switch(toupper(TE_event.keyDown.charScan.charCode)) {
  97.             case 'H':
  98.             case '4':
  99.                 //    Load the parent.
  100.                 LoadParent();
  101.                 clearEvent(TE_event);
  102.                 break;
  103.             case 'J':
  104.             case '2':
  105.                 //    Select the next anchor.
  106.                 AnchorSelectNext();
  107.                 AnchorInView();
  108.                 clearEvent(TE_event);
  109.                 break;
  110.             case 'K':
  111.             case '8':
  112.                 //    Select the previous anchor.
  113.                 AnchorSelectPrevious();
  114.                 AnchorInView();
  115.                 clearEvent(TE_event);
  116.                 break;
  117.             case 'L':
  118.             case '6':
  119.                 //    Load the anchor.
  120.                 LoadChild();
  121.                 clearEvent(TE_event);
  122.                 break;
  123.             case ' ':
  124.             case '3':
  125.                 //    The space bar should also be page
  126.                 //    down.
  127.                 TE_event.keyDown.keyCode = kbPgDn;
  128.                 //    Don't clear the event, will let base
  129.                 //    class handle.
  130.                 break;
  131.             case '9':
  132.                 TE_event.keyDown.keyCode = kbPgUp;
  133.                 //    Don't clear the event, will let base
  134.                 //    class handle.
  135.                 break;
  136.             case '7':
  137.                 TE_event.keyDown.keyCode = kbHome;
  138.                 break;
  139.             case '1':
  140.                 TE_event.keyDown.keyCode = kbEnd;
  141.                 break;
  142.             }
  143.         }
  144.     }
  145.     //    Commands through the mouse.
  146.     //    Only handle left button clicks.
  147.     else if((TE_event.what & evMouse) != 0 && TE_event.mouse.buttons ==
  148.         mbLeftButton)    {
  149.  
  150.         //    First, convert the mouse coordinates to the local
  151.         //    view.
  152.         TPoint TP_local = makeLocal(TE_event.mouse.where);
  153.  
  154.         //    No matter what, attempt to select an anchor where
  155.         //    the clicks occured, if no anchor, ignore.
  156.         if(AnchorSelectXYView(TP_local.x, TP_local.y) == True)    {
  157.             //    Should redraw to show selection.
  158.             draw();
  159.  
  160.             //    If double clicked, load the anchor.
  161.             if(TE_event.mouse.doubleClick == True)    {
  162.                 LoadChild();
  163.             }
  164.  
  165.             //    Clear the event.
  166.             clearEvent(TE_event);
  167.         }
  168.     }
  169.  
  170.     //    Call the base event handler.
  171.     TScroller::handleEvent(TE_event);
  172. }
  173.