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

  1. //    Zinc Interface Library - PULLDN.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. UIW_PULL_DOWN_MENU::UIW_PULL_DOWN_MENU(int a_indentation, USHORT a_woFlags,
  9.     USHORT a_woAdvancedFlags) :
  10.     UIW_WINDOW(0, 0, 1, 1, a_woFlags | WOF_NON_FIELD_REGION | WOF_NON_SELECTABLE,
  11.         a_woAdvancedFlags | WOAF_NORMAL_HOT_KEYS | WOAF_NO_SIZE | WOAF_NO_MOVE)
  12. {
  13.     // Initialize the pull-down menu information.
  14.     windowID[0] = ID_PULL_DOWN_MENU;
  15.     windowID[1] = ID_MENU;
  16.     windowID[2] = ID_WINDOW;
  17.     search.type = ID_PULL_DOWN_MENU;
  18.  
  19.     hotKey = HOT_KEY_SUB_WINDOW;
  20.     indentation = a_indentation;
  21. }
  22.  
  23. UIW_PULL_DOWN_MENU::Event(const UI_EVENT &event)
  24. {
  25.     // Switch on the event type.
  26.     UI_EVENT tEvent = event;
  27.     UIW_PULL_DOWN_ITEM *item;
  28.     int ccode = event.type;
  29.     switch (ccode)
  30.     {
  31.     case S_INITIALIZE:
  32.         if (parent && !parent->hMenu)
  33.         {
  34.             //Create the MS Windows menu.
  35.             hMenu = CreateMenu();
  36.  
  37.             parent->hMenu = hMenu;
  38.  
  39.             // Initialize each pull down item with the list index.
  40.             tEvent.rawCode = 0x0000;
  41.             for (item = First(); item; item = item->Next())
  42.             {
  43.                 item->Event(tEvent);
  44.                 tEvent.rawCode += 0x100;
  45.             }
  46.         }
  47.         break;
  48.  
  49.     case S_CREATE:
  50.         if (parent && !parent->hMenu)
  51.         {
  52.             parent->hMenu = hMenu;
  53.  
  54.             // Initialize each pull down item with the list index.
  55.             tEvent.rawCode = 0x0000;
  56.             UI_WINDOW_OBJECT *object;
  57.             for (item = First(); item; item = item->Next())
  58.             {
  59.                 item->Event(tEvent);
  60.                 tEvent.rawCode += 0x100;
  61.             }
  62.             SetMenu(parent->hWnd, hMenu);
  63.             DrawMenuBar(parent->hWnd);
  64.         }
  65.         // Continue on to S_SIZE.
  66.  
  67.     case S_SIZE:
  68.         UI_WINDOW_OBJECT::RegionMax(TRUE);
  69.  
  70.         // Calculate menu height by subtracting client region, border, and title.
  71.         true.left -= 1;
  72.         true.right += 1;
  73.         int height = GetSystemMetrics(SM_CYMENU);
  74.         true.bottom = true.top + height;
  75.  
  76.         for (item = First(); item; item = item->Next())
  77.         {
  78.             item->InformationSet(screenID, display, eventManager,
  79.                 windowManager, paletteMapTable, this);
  80.             item->Event(event);
  81.         }
  82.         break;
  83.  
  84.     case S_CLEAR:
  85.         hMenu = 0;
  86.         for (item = First(); item; item = item->Next())
  87.             item->hMenu = 0;
  88.         break;
  89.  
  90.     case S_MENU_SELECT:
  91.         if (parent->hMenu)
  92.         {
  93.             // Get the menu element from the event.rawCode index.
  94.             item = (UIW_PULL_DOWN_ITEM *)UI_LIST::Get(event.rawCode >> 8);
  95.             if (item)
  96.                 item->Event(event);
  97.         }
  98.         break;
  99.  
  100.     default:
  101.         ccode = UI_WINDOW_OBJECT::Event(event);
  102.         break;
  103.     }
  104.  
  105.     // Return the event control code.
  106.     return (ccode);
  107. }
  108.  
  109. #ifdef ZIL_LOAD
  110. UIW_PULL_DOWN_MENU::UIW_PULL_DOWN_MENU(const char *name, UI_STORAGE *file, USHORT loadFlags) :
  111.     UIW_WINDOW(name, file, loadFlags | L_SUB_LEVEL)
  112. {
  113.     windowID[0] = ID_PULL_DOWN_MENU;
  114.     windowID[1] = ID_MENU;
  115.     windowID[2] = ID_WINDOW;
  116.     hotKey = HOT_KEY_SUB_WINDOW;
  117.  
  118.     if (!file)
  119.         file = _storage;
  120.     file->Load(&indentation);
  121.     if (!FlagSet(loadFlags, L_SUB_LEVEL) && FlagSet(file->stStatus, STS_TEMPORARY))
  122.         delete file;
  123. }
  124. #endif
  125.  
  126. #ifdef ZIL_STORE
  127. void UIW_PULL_DOWN_MENU::Store(const char *name, UI_STORAGE *file, USHORT storeFlags)
  128. {
  129.     UIW_WINDOW::Store(name, file, storeFlags | S_SUB_LEVEL);
  130.     file->Store(indentation);
  131.     if (!FlagSet(storeFlags, S_SUB_LEVEL))
  132.         file->ObjectSize(name, search);
  133. }
  134. #endif
  135.