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, 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);
-
- MSWindowsStyle |= SS_LEFT;
- if (FlagSet(woFlags, WOF_BORDER))
- MSWindowsStyle |= WS_BORDER;
- }
-
- 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);
-
- MSWindowsStyle |= SS_LEFT;
- if (FlagSet(woFlags, WOF_BORDER))
- MSWindowsStyle |= WS_BORDER;
- }
-
- 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:
- ccode = UI_WINDOW_OBJECT::Event(event);
- true.bottom -= 2;
- char *tHotKey;
- if (prompt)
- tHotKey = strchr(prompt, '~');
- 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))
- 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),
- {
- 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
-