home *** CD-ROM | disk | FTP | other *** search
- // Zinc Interface Library - PULLDN1.CPP
- // COPYRIGHT (C) 1990, 1991. All Rights Reserved.
- // Zinc Software Incorporated. Pleasant Grove, Utah USA
-
- #include "ui_win.hpp"
- #include <string.h>
-
- #pragma argsused
- void UIW_PULL_DOWN_ITEM::UserFunction(UI_EVENT &event)
- {
- woStatus &= ~WOS_SELECTED;
- if (!menu.First())
- return;
-
- for (UIW_POP_UP_ITEM *item = menu.First(); item; item = item->Next())
- item->woStatus &= ~WOS_CURRENT;
-
- menu.true.left = (!previous && !display->isText) ? true.left - 1 : true.left;
- menu.true.top = true.bottom + 1;
- menu.true.right = menu.true.bottom = 0x0FFF;
- if (display->isText)
- menu.woStatus &= ~WOS_GRAPHICS;
- else
- menu.woStatus |= WOS_GRAPHICS;
- event.type = S_CLOSE_TEMPORARY;
- windowManager->Event(event);
- *windowManager + &menu;
- }
-
- UIW_PULL_DOWN_ITEM::UIW_PULL_DOWN_ITEM(char *_string, USHORT _mnFlags,
- void (*_userFunction)(void *object, UI_EVENT &event), USHORT _value) :
- UIW_BUTTON(0, 0, strlen(_string), _string, BTF_DOWN_CLICK | BTF_NO_TOGGLE | BTF_NO_3D,
- WOF_NON_FIELD_REGION, UIW_PULL_DOWN_ITEM::PullDownUserFunction, _value),
- menu(0, 0, _mnFlags | MNF_SELECT_LEFT | MNF_SELECT_RIGHT, WOF_BORDER, WOAF_TEMPORARY | WOAF_NO_DESTROY)
- {
- // Initialize the menu item information.
- windowID[0] = ID_PULL_DOWN_ITEM;
- windowID[1] = ID_MENU_ITEM;
- windowID[2] = ID_BUTTON;
- search.type = ID_PULL_DOWN_ITEM;
-
- woFlags &= ~WOF_BORDER;
- userFunction = _userFunction ? _userFunction : UIW_PULL_DOWN_ITEM::PullDownUserFunction;
- }
-
- UIW_PULL_DOWN_ITEM::UIW_PULL_DOWN_ITEM(char *_string, USHORT _mnFlags, UI_ITEM *flagItem) :
- UIW_BUTTON(0, 0, strlen(_string), _string, BTF_DOWN_CLICK | BTF_NO_TOGGLE | BTF_NO_3D,
- WOF_NON_FIELD_REGION, UIW_PULL_DOWN_ITEM::PullDownUserFunction, 0),
- menu(0, 0, _mnFlags | MNF_SELECT_LEFT | MNF_SELECT_RIGHT, WOF_BORDER, WOAF_TEMPORARY | WOAF_NO_DESTROY)
- {
- // Initialize the menu item information.
- windowID[0] = ID_PULL_DOWN_ITEM;
- windowID[1] = ID_MENU_ITEM;
- windowID[2] = ID_BUTTON;
- search.type = ID_PULL_DOWN_ITEM;
-
- woFlags &= ~WOF_BORDER;
- userFunction = UIW_PULL_DOWN_ITEM::PullDownUserFunction;
- for (int i = 0; flagItem[i].string; i++)
- {
- UIW_POP_UP_ITEM *item = (flagItem[i].string[0] != '\0') ?
- new UIW_POP_UP_ITEM(flagItem[i].string, MNIF_NO_FLAGS,
- BTF_NO_TOGGLE, WOF_NO_FLAGS, flagItem[i].userFunction) :
- new UIW_POP_UP_ITEM;
- item->value = flagItem[i].value;
- menu.Add(item);
- }
- }
-
- void UIW_PULL_DOWN_ITEM::DataSet(char *newString)
- {
- // Reset the button's string information.
- if (newString)
- {
- if (FlagSet(woFlags, WOF_NO_ALLOCATE_DATA))
- string = newString;
- else
- {
- if (string)
- delete string;
- string = (newString) ? ui_strdup(newString) : 0;
- }
- }
- UI_WINDOW_OBJECT::Redisplay(TRUE);
- }
-
- UIW_PULL_DOWN_ITEM::Event(const UI_EVENT &event)
- {
- int ccode = event.type;
- switch (ccode)
- {
- case S_CREATE:
- menu.InformationSet(-screenID, display, eventManager, windowManager,
- paletteMapTable, this);
- relative.left = relative.top = 0;
- relative.right = display->TextWidth(string) - 1;
- if (strchr(string, '~'))
- relative.right -= display->cellWidth;
- relative.bottom = display->cellHeight - 1;
- if (display->isText)
- woStatus &= ~WOS_GRAPHICS;
- else
- woStatus |= WOS_GRAPHICS;
- ccode = UIW_BUTTON::Event(event);
- break;
-
- default:
- ccode = UIW_BUTTON::Event(event);
- break;
- }
-
- // Return the event control code.
- return (ccode);
- }
-
- void *UIW_PULL_DOWN_ITEM::Information(INFORMATION_REQUEST request, void *data)
- {
- if (request == GET_NUMBERID_OBJECT || request == GET_STRINGID_OBJECT)
- return (menu.Information(request, data));
- else if (request == PRINT_INFORMATION)
- {
- UI_WINDOW_OBJECT::Information(request, data);
- return (menu.Information(request, data));
- }
- else
- return (UI_WINDOW_OBJECT::Information(request, data));
- }
-
- #ifdef ZIL_LOAD
- UIW_PULL_DOWN_ITEM::UIW_PULL_DOWN_ITEM(const char *name, UI_STORAGE *file, USHORT loadFlags) :
- UIW_BUTTON(name, file, loadFlags | L_SUB_LEVEL), menu(0, file, L_SUB_LEVEL)
- {
- windowID[0] = ID_PULL_DOWN_ITEM;
- windowID[1] = ID_MENU_ITEM;
- windowID[2] = ID_BUTTON;
-
- userFunction = UIW_PULL_DOWN_ITEM::PullDownUserFunction;
- if (!file)
- file = _storage;
- if (!FlagSet(loadFlags, L_SUB_LEVEL) && FlagSet(file->stStatus, STS_TEMPORARY))
- delete file;
- }
- #endif
-
- #ifdef ZIL_STORE
- void UIW_PULL_DOWN_ITEM::Store(const char *name, UI_STORAGE *file, USHORT storeFlags)
- {
- UIW_BUTTON::Store(name, file, storeFlags | S_SUB_LEVEL);
- menu.Store(0, file, S_SUB_LEVEL | S_SKIP_TYPE);
- if (!FlagSet(storeFlags, S_SUB_LEVEL))
- file->ObjectSize(name, search);
- }
- #endif
-