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

  1. //    Zinc Interface Library - BORDER.CPP
  2. //    COPYRIGHT (C) 1990, 1991.  All Rights Reserved.
  3. //    Zinc Software Incorporated.  Pleasant Grove, Utah  USA
  4.  
  5. #include "ui_win.hpp"
  6. #include <string.h>
  7.  
  8. int UIW_BORDER::width = 6;
  9.  
  10. UIW_BORDER::UIW_BORDER() :
  11.     UI_WINDOW_OBJECT(0, 0, 0, 0, WOF_NON_FIELD_REGION, WOAF_OUTSIDE_REGION | WOAF_NON_CURRENT)
  12. {
  13.     // Initialize the border information.
  14.     windowID[0] = ID_BORDER;
  15.     search.type = ID_BORDER;
  16.     search.numberID = NUMID_BORDER;
  17.     strcpy(search.stringID, "NUMID_BORDER");
  18. }
  19.  
  20. void UIW_BORDER::DataSet(int _width)
  21. {
  22.     width = (_width > 0) ? _width : 1;
  23.     if (eventManager)
  24.     {
  25.         UI_EVENT event;
  26.         event.type = S_REDISPLAY;
  27.         eventManager->Put(event, Q_END);
  28.     }
  29. }
  30.  
  31. int UIW_BORDER::Event(const UI_EVENT &event)
  32. {
  33.     // Switch on the event type.
  34.     int tSize;
  35.     UI_WINDOW_OBJECT::Information(GET_DEFAULT_HEIGHT, &tSize);
  36.     tSize /= 2;
  37.     UI_REGION region;
  38.     int ccode = UI_WINDOW_OBJECT::LogicalEvent(event, ID_BORDER);
  39.     switch (ccode)
  40.     {
  41.     case S_CREATE:
  42.     case S_SIZE:
  43.         UI_WINDOW_OBJECT::RegionMax(TRUE);
  44.         if (!display->isText)
  45.         {
  46.             true.left += width;
  47.             true.top += width;
  48.             true.right -= width;
  49.             true.bottom -= width;
  50.         }
  51.         break;
  52.  
  53.     case S_DISPLAY_INACTIVE:
  54.     case S_DISPLAY_ACTIVE:
  55.         // Draw the borders around the object.
  56.         if (!display->isText && !UI_WINDOW_OBJECT::NeedsUpdate(event, ccode))
  57.             break;
  58.         UI_PALETTE *palette = UI_WINDOW_OBJECT::LogicalPalette(ccode);
  59.         lastPalette = palette;
  60.         if (display->isText)
  61.             display->Rectangle(screenID, true, palette, (ccode == S_DISPLAY_ACTIVE) ? 2 : 1);
  62.         else
  63.         {
  64.             region = parent->true;
  65.             eventManager->DevicesHide(parent->true);
  66.             UI_PALETTE *outlinePalette = MapPalette(paletteMapTable,
  67.                 PM_ACTIVE, ID_BLACK_SHADOW);
  68.             display->Rectangle(screenID, true, outlinePalette);
  69.             display->Rectangle(screenID, region, outlinePalette);
  70.             UI_WINDOW_OBJECT::Shadow(region, 1);
  71.  
  72.             // Display the top and bottom lines.
  73.             int temp = region.bottom;
  74.             region.bottom = true.top - 1;
  75.             display->Rectangle(screenID, region, palette, 0, TRUE);
  76.             region.bottom = temp;
  77.  
  78.             temp = region.top;
  79.             region.top = true.bottom + 1;
  80.             display->Rectangle(screenID, region, palette, 0, TRUE);
  81.             region.top = temp;
  82.  
  83.             // Display the left and right columns.
  84.             temp = region.right;
  85.             region.right = true.left - 1;
  86.             display->Rectangle(screenID, region, palette, 0, TRUE);
  87.             region.right = temp;
  88.  
  89.             temp = region.left;
  90.             region.left = true.right + 1;
  91.             display->Rectangle(screenID, region, palette, 0, TRUE);
  92.  
  93.             // Draw the corner identifiers.
  94.             if (FlagSet(parent->woAdvancedFlags, WOAF_NO_SIZE))
  95.             {
  96.                 eventManager->DevicesShow(parent->true);
  97.                 break;
  98.             }
  99.             region = parent->true;
  100.             region.left = true.left + tSize;
  101.             region.right = true.right - tSize;
  102.             if (region.left > region.right)
  103.                 region.left = region.right = (true.left + true.right) / 2;
  104.             region.bottom = true.top;
  105.             display->Rectangle(screenID, region, outlinePalette);
  106.             region.top = true.bottom;
  107.             region.bottom = parent->true.bottom;
  108.             display->Rectangle(screenID, region, outlinePalette);
  109.  
  110.             region = parent->true;
  111.             region.top = true.top + tSize;
  112.             region.bottom = true.bottom - tSize;
  113.             if (region.top > region.bottom)
  114.                 region.top = region.bottom = (true.top + true.bottom) / 2;
  115.             region.right = true.left;
  116.             display->Rectangle(screenID, region, outlinePalette);
  117.             region.left = true.right;
  118.             region.right = parent->true.right;
  119.             display->Rectangle(screenID, region, outlinePalette);
  120.             eventManager->DevicesShow(parent->true);
  121.         }
  122.         break;
  123.  
  124.     case L_VIEW:
  125.     case L_BEGIN_SELECT:
  126.         UI_EVENT tEvent = event;
  127.         tEvent.rawCode = DM_VIEW;
  128.         if (FlagSet(parent->woAdvancedFlags, WOAF_NO_SIZE))
  129.         {
  130.             eventManager->Event(tEvent);
  131.             break;
  132.         }
  133.         region = true;
  134.         region.left += tSize;
  135.         region.right -= tSize;
  136.         if (region.left > region.right)
  137.             region.left = region.right = (true.left + true.right) / 2;
  138.         region.top += tSize;
  139.         region.bottom -= tSize;
  140.         if (region.top > region.bottom)
  141.             region.top = region.bottom = (true.top + true.bottom) / 2;
  142.  
  143.         int sizeFlags = 0;
  144.         if (event.position.column <= region.left)
  145.             sizeFlags |= M_LEFT_CHANGE;
  146.         else if (event.position.column >= region.right)
  147.             sizeFlags |= M_RIGHT_CHANGE;
  148.         if (event.position.line <= region.top)
  149.             sizeFlags |= M_TOP_CHANGE;
  150.         else if (event.position.line >= region.bottom)
  151.             sizeFlags |= M_BOTTOM_CHANGE;
  152.  
  153.          if (FlagsSet(sizeFlags, M_LEFT_CHANGE | M_TOP_CHANGE) ||
  154.             FlagsSet(sizeFlags, M_RIGHT_CHANGE | M_BOTTOM_CHANGE))
  155.             tEvent.rawCode = DM_DIAGONAL_ULLR;
  156.         else if (FlagsSet(sizeFlags, M_LEFT_CHANGE | M_BOTTOM_CHANGE) ||
  157.             FlagsSet(sizeFlags, M_RIGHT_CHANGE | M_TOP_CHANGE))
  158.             tEvent.rawCode = DM_DIAGONAL_LLUR;
  159.         else if (FlagSet(sizeFlags, M_LEFT_CHANGE | M_RIGHT_CHANGE))
  160.             tEvent.rawCode = DM_HORIZONTAL;
  161.         else if (FlagSet(sizeFlags, M_TOP_CHANGE | M_BOTTOM_CHANGE))
  162.             tEvent.rawCode = DM_VERTICAL;
  163.         eventManager->Event(tEvent);
  164.  
  165.         if (ccode == L_BEGIN_SELECT && sizeFlags)
  166.         {
  167.             UI_EVENT tEvent = event;
  168.             tEvent.type = S_SIZE;
  169.             tEvent.rawCode = sizeFlags;
  170.             eventManager->Put(tEvent, Q_BEGIN);
  171.         }
  172.         break;
  173.  
  174.     default:
  175.         ccode = UI_WINDOW_OBJECT::Event(event);
  176.         break;
  177.     }
  178.  
  179.     // Return the control code.
  180.      return (ccode);
  181. }
  182.  
  183. #ifdef ZIL_STORE
  184. #pragma argsused
  185. void UIW_BORDER::Store(const char *name, UI_STORAGE *file, USHORT storeFlags)
  186. {
  187.     file->Store(search.type);
  188.     if (!FlagSet(storeFlags, S_SUB_LEVEL))
  189.         file->ObjectSize(name, search);
  190. }
  191. #endif
  192.  
  193.