home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c185 / 2.ddi / OWLSRC.EXE / CSCAPE / SOURCE / WINSCROL.C < prev    next >
Encoding:
C/C++ Source or Header  |  1989-09-06  |  2.7 KB  |  113 lines

  1. /*
  2.     winscrol.c    10/30/88
  3.  
  4.     % functions scroll a window on the display.
  5.  
  6.     Consolidated from other files.
  7.     Ted.
  8.  
  9.     OWL 1.1
  10.     Copyright (c) 1988, by Oakland Group, Inc.
  11.     ALL RIGHTS RESERVED.
  12.  
  13.     Revision History:
  14.     -----------------
  15. */
  16. /* -------------------------------------------------------------------------- */
  17. #include "oakhead.h"
  18. #include "disppriv.h"
  19.  
  20. /* -------------------------------------------------------------------------- */
  21.  
  22. void win_ScrollPix(win, nx, ny)
  23.     win_type win;
  24.     opcoord nx;
  25.     opcoord ny;
  26.  
  27. /*    Scrolls all unobscured parts of win. Scrolls win cursor position too. */
  28. {
  29.     opoint tpn;
  30.     boolean cursin;
  31.     opbox cursbox;
  32.     boolean wasshown;
  33. /*
  34.  Update curspos first to ensure that painting portion can paint it in the
  35.  right place. Hide it to make sure it will be shown or in case it's a text
  36.  cursor that got scrolled out of the window, and show it in case it's a
  37.  text cursor and was in the scrolled region.
  38. */
  39.  
  40. /* If the cursor is in the window getting exposed, save and restore it */
  41.     win_GetCursorPixBox(win, &cursbox);
  42.     cursin = (win_clipbox(win, &cursbox) != 0);
  43.  
  44.     if (cursin) {
  45.         disp_Cache();
  46.         wasshown = win_HideCursor(win);
  47.     }
  48.     win_setcursx(win, win_GetCursx(win) - nx);
  49.     win_setcursy(win, win_GetCursy(win) - ny);
  50.     tpn.x = nx; tpn.y = ny;
  51.     win_Expose(win, WINM_SCROLL, &tpn);
  52.  
  53.     if (cursin) {
  54.         if (wasshown) win_ShowCursor(win);
  55.         disp_Flush();
  56.     }
  57. }
  58. /* -------------------------------------------------------------------------- */
  59.  
  60. void win_ScrollPixBox(win, boxp, nx, ny)
  61.     win_type win;
  62.     opbox* boxp;
  63.     opcoord nx;
  64.     opcoord ny;
  65. /*
  66.     Scrolls all unobscured parts of win in relbox.
  67.     Does not scroll win cursor position.
  68. */
  69. {
  70.     opoint tpn;
  71.     boolean cursin;
  72.     opbox cursbox;
  73.     boolean wasshown;
  74.  
  75. /* If the cursor is in the box getting exposed, save and restore it */
  76.     win_GetCursorPixBox(win, &cursbox);
  77.     cursin = (opbox_clipbox(boxp, &cursbox) != 0);
  78.  
  79.     if (cursin) {
  80.         disp_Cache();
  81.         wasshown = win_HideCursor(win);
  82.     }
  83.     tpn.x = nx; tpn.y = ny;
  84.     win_ExposePixBox(win, boxp, WINM_SCROLL, &tpn);
  85.  
  86.     if (cursin) {
  87.         if (wasshown) win_ShowCursor(win);
  88.         disp_Flush();
  89.     }
  90. }
  91. /* -------------------------------------------------------------------------- */
  92.  
  93. void win_ScrollBox(win, cboxp, nrows, ncols)
  94.     win_type win;
  95.     ocbox *cboxp;    /* Clipping coords relative to win */
  96.     int nrows;
  97.     int ncols;
  98. {
  99.     opbox box;        /* display coords */
  100.  
  101.     if (win == NULL) return;
  102.  
  103.     ocbox_pixcoords(cboxp, win_GetFont(win), &box);
  104.  
  105.     /* Quit if box is not in window */
  106.     if (!win_clipbox(win, &box)) return;
  107.  
  108.     win_ScrollPixBox(win, &box, ncols * win_GetFontWidth(win),
  109.                              nrows * win_GetFontHeight(win));
  110. }
  111. /* -------------------------------------------------------------------------- */
  112.  
  113.