home *** CD-ROM | disk | FTP | other *** search
- // Zinc Interface Library - PROMPT.CPP
- // COPYRIGHT (C) 1990, 1991. All Rights Reserved.
- // Zinc Software Incorporated. Pleasant Grove, Utah USA
-
- #include "ui_win.hpp"
- #include <ctype.h>
- #include <string.h>
-
- UIW_PROMPT::UIW_PROMPT(int left, int top, char *_prompt, USHORT _woFlags) :
- UI_WINDOW_OBJECT(left, top, ui_strlen(_prompt), 1, _woFlags | WOF_NON_SELECTABLE, WOAF_NO_FLAGS),
- borderWidth(0), borderHeight(0)
- {
- // Initialize the prompt information.
- windowID[0] = ID_PROMPT;
- search.type = ID_PROMPT;
- prompt = ui_strdup(_prompt);
- }
-
- UIW_PROMPT::UIW_PROMPT(int left, int top, int width, int height, char *_prompt, USHORT _woFlags) :
- UI_WINDOW_OBJECT(left, top, width, height, _woFlags | WOF_NON_SELECTABLE, WOAF_NO_FLAGS),
- borderWidth(width), borderHeight(height)
- {
- // Initialize the prompt information.
- windowID[0] = ID_PROMPT;
- search.type = ID_PROMPT;
- prompt = ui_strdup(_prompt);
- }
-
- void UIW_PROMPT::DataSet(char *_prompt)
- {
- // Reset the prompt's string information.
- if (prompt)
- delete prompt;
- prompt = ui_strdup(_prompt);
- UI_WINDOW_OBJECT::Redisplay(FALSE);
- }
-
- int UIW_PROMPT::Event(const UI_EVENT &event)
- {
- // Switch on the event type.
- int ccode = event.type;
- switch (ccode)
- {
- case S_CREATE:
- case S_SIZE:
- char *tHotKey = strchr(prompt, '~');
- display->RegionConvert(relative, &woStatus, WOS_GRAPHICS);
- relative.right = relative.left + display->TextWidth(prompt) - 1;
- if (display->isText && FlagSet(woFlags, WOF_BORDER))
- relative.right += 2;
- UI_WINDOW_OBJECT::RegionMax(TRUE);
- if (tHotKey && next)
- {
- UI_WINDOW_OBJECT *object = Next();
- object->hotKey = toupper(tHotKey[1]);
- }
- break;
-
- case S_CURRENT:
- case S_NON_CURRENT:
- case S_DISPLAY_ACTIVE:
- case S_DISPLAY_INACTIVE:
- if (!UI_WINDOW_OBJECT::NeedsUpdate(event, ccode))
- break;
- else if (borderWidth && borderHeight)
- {
- display->Rectangle(screenID, true.left, true.top,
- true.left + borderWidth * display->cellWidth - 1,
- true.top + borderHeight * display->cellHeight - 1,
- lastPalette, 1);
- display->Text(screenID, true.left + display->cellWidth, true.top, prompt, lastPalette, -1);
- }
- else
- UI_WINDOW_OBJECT::Text(prompt, 0, ccode, lastPalette);
- break;
-
- default:
- ccode = UI_WINDOW_OBJECT::Event(event);
- break;
- }
-
- // Return the control code.
- return (ccode);
- }
-
- #ifdef ZIL_LOAD
- UIW_PROMPT::UIW_PROMPT(const char *name, UI_STORAGE *file, USHORT loadFlags) :
- UI_WINDOW_OBJECT(name, file, loadFlags | L_SUB_LEVEL),
- borderWidth(0), borderHeight(0)
- {
- windowID[0] = ID_PROMPT;
-
- if (!file)
- file = _storage;
- file->Load(&prompt);
- if (!FlagSet(loadFlags, L_SUB_LEVEL) && FlagSet(file->stStatus, STS_TEMPORARY))
- delete file;
- }
- #endif
-
- #ifdef ZIL_STORE
- void UIW_PROMPT::Store(const char *name, UI_STORAGE *file, USHORT storeFlags)
- {
- UI_WINDOW_OBJECT::Store(name, file, storeFlags | S_SUB_LEVEL);
- file->Store(prompt);
- if (!FlagSet(storeFlags, S_SUB_LEVEL))
- file->ObjectSize(name, search);
- }
- #endif
-