home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 240.lha / PickPacket_v1.0 / Sources / stview.c < prev    next >
C/C++ Source or Header  |  1989-05-04  |  4KB  |  149 lines

  1. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\
  2. * |_o_o|\\ Copyright (c) 1989 The Software Distillery.                    *
  3. * |. o.| ||          All Rights Reserved                                  *
  4. * | .  | ||          Written by John Toebes and Doug Walker               *
  5. * | o  | ||          The Software Distillery                              *
  6. * |  . |//           235 Trillingham Lane                                 *
  7. * ======             Cary, NC 27513                                       *
  8. *                    BBS:(919)-471-6436                                   *
  9. \* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
  10. #include "pickpack.h"
  11. #include "struct.h"
  12. #include "viewgen.h"
  13.  
  14. static struct IntuiText IText =
  15. {
  16.     1,0,JAM2,   /* front and back text pens, drawmode and fill byte */
  17.     0,0,       /* XY origin relative to container TopLeft */
  18.     &TOPAZ80,   /* font pointer or NULL for default */
  19.     NULL,       /* pointer to text */
  20.     NULL        /* next IntuiText structure */
  21. };
  22.  
  23. void stviewnew(nw, it, stnode)
  24. struct NewWindow **nw;
  25. struct IntuiText **it;
  26. struct STNODE *stnode;
  27. {
  28.    *nw = &NewWindowStructure1;
  29.    stnode->d.bdata->Gadget1 = Gadget1;
  30.    stnode->d.bdata->Gadget3 = Gadget2;
  31.    stnode->d.bdata->Gadget3 = Gadget3;
  32.    stnode->d.bdata->Gadget1SInfo = Gadget1SInfo;
  33.  
  34.    stnode->d.bdata->Gadget2.NextGadget = &stnode->d.bdata->Gadget1;
  35.    stnode->d.bdata->Gadget3.NextGadget = &stnode->d.bdata->Gadget2;
  36.    stnode->d.bdata->Gadget1.SpecialInfo = (APTR)&stnode->d.bdata->Gadget1SInfo;
  37.    stnode->d.bdata->pos = 0;
  38.    NewWindowStructure1.FirstGadget = &stnode->d.bdata->Gadget1;
  39.    *it = NULL;
  40.    return;
  41. }
  42.  
  43. #define HEXASC  44
  44.  
  45. /* Display the struct FileHandle */
  46. int stviewdisp(n)
  47. struct STNODE *n;
  48. {
  49. return(stviewmove(n, 0));
  50. }
  51.  
  52. /* Display the struct FileHandle */
  53. int stviewmove(n, adj)
  54. struct STNODE *n;
  55. int adj;
  56. {
  57.    char data[100];
  58.    char *p;
  59.    int i, off, len;
  60.    int dlines, wlines;
  61.    int hpot, hbody;
  62.  
  63.    INITTEXT(14)
  64.  
  65.    BUG(1, ("stviewdisp: Entry, stnode 0x%08x window 0x%08x\n", n, n->w))
  66.    IText.IText = (UBYTE *)data;
  67.  
  68.    wlines = (n->w->Height - 13)/9;
  69.    dlines = n->d.vdata->lines;
  70.    if (wlines >= dlines)
  71.       {
  72.       off = 0;
  73.       hpot = 0;
  74.       hbody = -1;
  75.       }
  76.    else
  77.       {
  78.       if (n->d.bdata->Gadget1SInfo.VertPot == 0xffff)
  79.          off = dlines-wlines+adj;
  80.       else
  81.          off = ((n->d.bdata->Gadget1SInfo.VertPot*(dlines-wlines)+32000) >> 16)+adj;
  82.       if (off >= dlines-wlines)
  83.          {
  84.          hpot = -1;
  85.          off = dlines-wlines;
  86.          }
  87.       else if (off <= 0)
  88.          {
  89.          off = 0;
  90.          hpot = 0;
  91.          }
  92.       else
  93.          hpot = (off<<16)/(dlines-wlines);
  94.       hbody = (wlines<<16)/dlines;
  95.       dlines = wlines;
  96.       }
  97.  
  98.    /* Off is the line number I expect to go to */
  99.    /* n->d.vdata->pos is the current line number */
  100.    /* n->d.vdata->posptr is the pointer to the current line */
  101.    /* wlines is the number of lines on the screen */
  102.    /* dlines is the number of data lines to be displayed */
  103.  
  104.    BUG(3,("hpot=%d hbody=%d dlines=%d wlines=%d\n",hpot,hbody,dlines,wlines))
  105.    ModifyProp(&n->d.bdata->Gadget1, n->w, NULL,
  106.               AUTOKNOB+FREEVERT, -1, hpot, -1, hbody);
  107.  
  108.    /* Now get our pointer to the correct line */
  109.    if (off <= n->d.vdata->pos)
  110.       {
  111.       p = n->d.vdata->buf;
  112.       n->d.vdata->pos = off;
  113.       }
  114.    else
  115.       {
  116.       p = n->d.vdata->posptr;
  117.       if (p == NULL) p = n->d.vdata->buf;
  118.       off -= n->d.vdata->pos;
  119.       n->d.vdata->pos += off;
  120.       }
  121.  
  122.    while(off--)
  123.       p += strlen(p)+1;
  124.  
  125.    /* We are pointing at the first line of the page */
  126.    n->d.vdata->posptr = p;
  127.  
  128.    for(i = 0; i<dlines; i++)
  129.       {
  130.       len = strlen(p);
  131.       memset(data, ' ', 95);
  132.       if (len > 95) len = 95;
  133.       memcpy(data, p, len);
  134.       data[95] = 0;
  135.       p += strlen(p)+1;
  136.       SHOWTEXT
  137.       }
  138.  
  139.    memset(data, ' ', 95);
  140.    data[95] = 0;
  141.    while(i++ < wlines)
  142.       {
  143.       SHOWTEXT
  144.       }
  145.  
  146.    BUG(1, ("stviewdisp: Exit\n"))
  147.    return(RC_OK);
  148. }
  149.