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 / MAP.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1991-06-01  |  1.2 KB  |  45 lines

  1. //    Zinc Interface Library - MAP.CPP
  2. //    COPYRIGHT (C) 1990, 1991.  All Rights Reserved.
  3. //    Zinc Software Incorporated.  Pleasant Grove, Utah  USA
  4.  
  5. #include "ui_map.hpp"
  6.  
  7. int EXPORT MapEvent(UI_EVENT_MAP *mapTable, const UI_EVENT &event, int currentID,
  8.     int id1, int id2, int id3, int id4, int id5)
  9. {
  10.     int level = 4;
  11.     int eventType = event.type;
  12.     int logicalValue = eventType;
  13.     USHORT eventRawCode = event.rawCode;
  14.     int id[4] = { id2, id3, id4, id5 };
  15.     if (currentID == id1)
  16.         currentID = 0;
  17.     else if (currentID == id2)
  18.         currentID = 1;
  19.     else if (currentID == id3)
  20.         currentID = 2;
  21.     else if (currentID == id4)
  22.         currentID = 3;
  23.     else
  24.         currentID = 4;
  25.  
  26.     // Try to find a matching event.
  27.     for (UI_EVENT_MAP *map = mapTable; map->windowID != ID_END; map++)
  28.         if (map->rawCode == eventRawCode && map->eventType == eventType)
  29.         {
  30.             if (map->windowID == id1 && currentID == 0)
  31.                 return(map->logicalValue);
  32.             int i = (currentID == 0) ? 0 : currentID - 1;
  33.             for ( ; i < 4; i++)
  34.                 if (map->windowID == id[i] && level > i)
  35.                 {
  36.                     level = i;
  37.                     logicalValue = map->logicalValue;
  38.                     break;
  39.                 }
  40.         }
  41.  
  42.     // Return the logical match value.
  43.     return (logicalValue);
  44. }
  45.