home *** CD-ROM | disk | FTP | other *** search
- // Zinc Interface Library - PULLDN.CPP
- // COPYRIGHT (C) 1990, 1991. All Rights Reserved.
- // Zinc Software Incorporated. Pleasant Grove, Utah USA
-
- #include "ui_win.hpp"
- #include <string.h>
-
- UIW_PULL_DOWN_MENU::UIW_PULL_DOWN_MENU(int a_indentation, USHORT a_woFlags,
- USHORT a_woAdvancedFlags) :
- UIW_WINDOW(0, 0, 1, 1, a_woFlags | WOF_NON_FIELD_REGION | WOF_NON_SELECTABLE,
- a_woAdvancedFlags | WOAF_NORMAL_HOT_KEYS | WOAF_NO_SIZE | WOAF_NO_MOVE)
- {
- // Initialize the pull-down menu information.
- windowID[0] = ID_PULL_DOWN_MENU;
- windowID[1] = ID_MENU;
- windowID[2] = ID_WINDOW;
- search.type = ID_PULL_DOWN_MENU;
-
- hotKey = HOT_KEY_SUB_WINDOW;
- indentation = a_indentation;
- }
-
- UIW_PULL_DOWN_MENU::Event(const UI_EVENT &event)
- {
- // Switch on the event type.
- UI_EVENT tEvent = event;
- UIW_PULL_DOWN_ITEM *item;
- int ccode = event.type;
- switch (ccode)
- {
- case S_INITIALIZE:
- if (parent && !parent->hMenu)
- {
- //Create the MS Windows menu.
- hMenu = CreateMenu();
-
- parent->hMenu = hMenu;
-
- // Initialize each pull down item with the list index.
- tEvent.rawCode = 0x0000;
- for (item = First(); item; item = item->Next())
- {
- item->Event(tEvent);
- tEvent.rawCode += 0x100;
- }
- }
- break;
-
- case S_CREATE:
- if (parent && !parent->hMenu)
- {
- parent->hMenu = hMenu;
-
- // Initialize each pull down item with the list index.
- tEvent.rawCode = 0x0000;
- UI_WINDOW_OBJECT *object;
- for (item = First(); item; item = item->Next())
- {
- item->Event(tEvent);
- tEvent.rawCode += 0x100;
- }
- SetMenu(parent->hWnd, hMenu);
- DrawMenuBar(parent->hWnd);
- }
- // Continue on to S_SIZE.
-
- case S_SIZE:
- UI_WINDOW_OBJECT::RegionMax(TRUE);
-
- // Calculate menu height by subtracting client region, border, and title.
- true.left -= 1;
- true.right += 1;
- int height = GetSystemMetrics(SM_CYMENU);
- true.bottom = true.top + height;
-
- for (item = First(); item; item = item->Next())
- {
- item->InformationSet(screenID, display, eventManager,
- windowManager, paletteMapTable, this);
- item->Event(event);
- }
- break;
-
- case S_CLEAR:
- hMenu = 0;
- for (item = First(); item; item = item->Next())
- item->hMenu = 0;
- break;
-
- case S_MENU_SELECT:
- if (parent->hMenu)
- {
- // Get the menu element from the event.rawCode index.
- item = (UIW_PULL_DOWN_ITEM *)UI_LIST::Get(event.rawCode >> 8);
- if (item)
- item->Event(event);
- }
- break;
-
- default:
- ccode = UI_WINDOW_OBJECT::Event(event);
- break;
- }
-
- // Return the event control code.
- return (ccode);
- }
-
- #ifdef ZIL_LOAD
- UIW_PULL_DOWN_MENU::UIW_PULL_DOWN_MENU(const char *name, UI_STORAGE *file, USHORT loadFlags) :
- UIW_WINDOW(name, file, loadFlags | L_SUB_LEVEL)
- {
- windowID[0] = ID_PULL_DOWN_MENU;
- windowID[1] = ID_MENU;
- windowID[2] = ID_WINDOW;
- hotKey = HOT_KEY_SUB_WINDOW;
-
- if (!file)
- file = _storage;
- file->Load(&indentation);
- if (!FlagSet(loadFlags, L_SUB_LEVEL) && FlagSet(file->stStatus, STS_TEMPORARY))
- delete file;
- }
- #endif
-
- #ifdef ZIL_STORE
- void UIW_PULL_DOWN_MENU::Store(const char *name, UI_STORAGE *file, USHORT storeFlags)
- {
- UIW_WINDOW::Store(name, file, storeFlags | S_SUB_LEVEL);
- file->Store(indentation);
- if (!FlagSet(storeFlags, S_SUB_LEVEL))
- file->ObjectSize(name, search);
- }
- #endif
-