home *** CD-ROM | disk | FTP | other *** search
/ Piper's Pit BBS/FTP: ibm 0040 - 0049 / ibm0040-0049 / ibm0040.tar / ibm0040 / ZINC_5.ZIP / WINSRC.ZIP / DISPLAY.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1991-06-01  |  1.6 KB  |  60 lines

  1. //    Zinc Interface Library - DISPLAY.CPP
  2. //    COPYRIGHT (C) 1990, 1991.  All Rights Reserved.
  3. //    Zinc Software Incorporated.  Pleasant Grove, Utah  USA
  4.  
  5. #include "ui_dsp.hpp"
  6.  
  7. UI_DISPLAY::UI_DISPLAY(int _isText, int _cellWidth, int _cellHeight) :
  8.     UI_REGION_LIST(),
  9.     isText(_isText), cellWidth(_cellWidth), cellHeight(_cellHeight),
  10.     installed(FALSE), lines(0), columns(0), eventManager(NULL)
  11. {
  12. }
  13.  
  14. UI_DISPLAY::~UI_DISPLAY(void)
  15. {
  16. }
  17.  
  18. void UI_DISPLAY::RegionDefine(SCREENID screenID, int left, int top, int right,
  19.     int bottom)
  20. {
  21.     UI_REGION region;
  22.     region.left = left;
  23.     region.top = top;
  24.     region.right = right;
  25.     region.bottom = bottom;
  26.  
  27.     // See if it is a full screen definition.
  28.     if (region.left <= 0 && region.top <= 0 && region.right >= columns - 1 && region.bottom >= lines - 1)
  29.     {
  30.         UI_REGION_LIST::Destroy();
  31.         Add(0, new UI_REGION_ELEMENT(screenID, 0, 0, columns - 1, lines - 1));
  32.         return;
  33.     }
  34.  
  35.     // Throw away regions with a negative width or height.
  36.     if (region.right < region.left || region.bottom < region.top)
  37.         return;
  38.     
  39.     // Throw away regions that are completely off the screen.
  40.     if (region.left >= columns || region.right < 0 ||
  41.         region.top >= lines || region.bottom < 0)
  42.         return;
  43.  
  44.     // Clip regions partially off the screen to fit on the screen.
  45.     if (region.left < 0)
  46.         region.left = 0;
  47.     if (region.right >= columns)
  48.         region.right = columns - 1;
  49.     if (region.top < 0)
  50.         region.top = 0;
  51.     if (region.bottom >= lines)
  52.         region.bottom = lines - 1;
  53.  
  54.     // Split any overlapping regions.
  55.     Split(screenID, region);
  56.  
  57.     // Define the new display region.
  58.     Add(0, new UI_REGION_ELEMENT(screenID, ®ion));
  59. }
  60.