home *** CD-ROM | disk | FTP | other *** search
/ Collection of Internet / Collection of Internet.iso / msdos / lynx / source / doslynx / src / turlvi13.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1994-10-25  |  2.4 KB  |  85 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. //        02-24-94    Revised to work with a rendered image file.
  17. #include"turlview.h"
  18.  
  19. void TURLView::AnchorInView()    {
  20. //    Purpose:    Move the view coordinates so that the selected anchor
  21. //            is viewable.
  22. //    Arguments:    void
  23. //    Return Value:    void
  24. //    Remarks/Portability/Dependencies/Restrictions:
  25. //        Will redraw screen if necessary
  26. //    Revision History:
  27. //        01-30-94    created
  28.  
  29.     //    Only continue if there are valid anchors in the document.
  30.     if(TAp_selected == NULL)    {
  31.         return;
  32.     }
  33.  
  34.     //    Only if the anchor is off the y screen do we do the below.
  35.     if(TAp_selected->getEnd() <= (signed long int)(TNSCp_lines->
  36.         at(delta.y)) || TAp_selected->getBegin() >= (signed long int)
  37.         (TNSCp_lines->at((delta.y + size.y < limit.y) ?
  38.         delta.y + size.y : limit.y - 1)))    {
  39.  
  40.         //    Find the line containing the anchor.
  41.         for(unsigned short int usi_find = 0U; usi_find < TNSCp_lines
  42.             ->getCount(); usi_find++)    {
  43.  
  44.             //    Break if anchor is before the line.
  45.             if(TAp_selected->getBegin() < (signed long int)(
  46.                 TNSCp_lines->at(usi_find)))    {
  47.                 //    Back up a line.
  48.                 if(usi_find != 0U)    {
  49.                     usi_find--;
  50.                 }
  51.                 break;
  52.             }
  53.         }
  54.         //    If no line was found, set to line 1.
  55.         if(usi_find == TNSCp_lines->getCount())    {
  56.             usi_find = 0U;
  57.         }
  58.  
  59. #ifdef TODO
  60. #error X value may also be off screen.
  61. #endif // TODO
  62.  
  63.         //    If this is near the last line of the file, should
  64.         //    show a full last screen.
  65.         if(usi_find + size.y >= limit.y)    {
  66.             usi_find = limit.y - size.y > 0 ? limit.y - size.y :
  67.                 0;
  68.         }
  69.  
  70.         //    If this is near the start of the file, show a complete
  71.         //    first page.
  72.         if(usi_find < size.y)    {
  73.             usi_find = 0U;
  74.         }
  75.  
  76.         //    Set where we should draw the screen only if line not
  77.         //    on screen.
  78.         scrollTo(delta.x, usi_find);
  79.     }
  80.     else    {
  81.         //    Draw the view so that the selected anchor is viewable.
  82.         drawView();
  83.     }
  84. }
  85.