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

  1. //    Zinc Interface Library - PROMPT.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 <ctype.h>
  7. #include <string.h>
  8.  
  9. UIW_PROMPT::UIW_PROMPT(int left, int top, char *_prompt, USHORT _woFlags) :
  10.     UI_WINDOW_OBJECT(left, top, strlen(_prompt), 1, _woFlags | WOF_NON_SELECTABLE, WOAF_NO_FLAGS),
  11.     borderWidth(0), borderHeight(0)
  12. {
  13.     // Initialize the prompt information.
  14.     windowID[0] = ID_PROMPT;
  15.     search.type = ID_PROMPT;
  16.     prompt = ui_strdup(_prompt);
  17.  
  18.     MSWindowsStyle |= SS_LEFT;
  19.     if (FlagSet(woFlags, WOF_BORDER))
  20.         MSWindowsStyle |= WS_BORDER;
  21. }
  22.  
  23. UIW_PROMPT::UIW_PROMPT(int left, int top, int width, int height, char *_prompt, USHORT _woFlags) :
  24.     UI_WINDOW_OBJECT(left, top, width, height, _woFlags | WOF_NON_SELECTABLE, WOAF_NO_FLAGS), 
  25.     borderWidth(width), borderHeight(height)
  26. {
  27.     // Initialize the prompt information.
  28.     windowID[0] = ID_PROMPT;
  29.     search.type = ID_PROMPT;
  30.     prompt = ui_strdup(_prompt);
  31.  
  32.     MSWindowsStyle |= SS_LEFT;
  33.     if (FlagSet(woFlags, WOF_BORDER))
  34.         MSWindowsStyle |= WS_BORDER;
  35. }
  36.  
  37. void UIW_PROMPT::DataSet(char *_prompt)
  38. {
  39.     // Reset the prompt's string information.
  40.     if (prompt)
  41.         delete prompt;
  42.     prompt = ui_strdup(_prompt);
  43.     UI_WINDOW_OBJECT::Redisplay(FALSE);
  44. }
  45.  
  46. int UIW_PROMPT::Event(const UI_EVENT &event)
  47. {
  48.     // Switch on the event type.
  49.     int ccode = event.type;
  50.     switch (ccode)
  51.     {
  52.     case S_CREATE:
  53.         ccode = UI_WINDOW_OBJECT::Event(event);
  54.         true.bottom -= 2;
  55.         char *tHotKey;
  56.         if (prompt)
  57.             tHotKey = strchr(prompt, '~');
  58.         if (tHotKey && next)
  59.         {
  60.             UI_WINDOW_OBJECT *object = Next();
  61.             object->hotKey = toupper(tHotKey[1]);
  62.         }
  63.         break;
  64.  
  65.     case S_CURRENT:
  66.     case S_NON_CURRENT:
  67.     case S_DISPLAY_ACTIVE:
  68.     case S_DISPLAY_INACTIVE:
  69.         if (UI_WINDOW_OBJECT::NeedsUpdate(event, ccode))
  70.             UI_WINDOW_OBJECT::Text(prompt, 0, ccode, lastPalette);
  71.         break;
  72.  
  73.     default:
  74.         ccode = UI_WINDOW_OBJECT::Event(event);
  75.         break;
  76.     }
  77.  
  78.     // Return the control code.
  79.     return (ccode);
  80. }
  81.  
  82. #ifdef ZIL_LOAD
  83. UIW_PROMPT::UIW_PROMPT(const char *name, UI_STORAGE *file, USHORT loadFlags) :
  84.     UI_WINDOW_OBJECT(name, file, loadFlags | L_SUB_LEVEL),
  85. {
  86.     windowID[0] = ID_PROMPT;
  87.  
  88.     if (!file)
  89.         file = _storage;
  90.     file->Load(&prompt);
  91.     if (!FlagSet(loadFlags, L_SUB_LEVEL) && FlagSet(file->stStatus, STS_TEMPORARY))
  92.         delete file;
  93. }
  94. #endif
  95.  
  96. #ifdef ZIL_STORE
  97. void UIW_PROMPT::Store(const char *name, UI_STORAGE *file, USHORT storeFlags)
  98. {
  99.     UI_WINDOW_OBJECT::Store(name, file, storeFlags | S_SUB_LEVEL);
  100.     file->Store(prompt);
  101.     if (!FlagSet(storeFlags, S_SUB_LEVEL))
  102.         file->ObjectSize(name, search);
  103. }
  104. #endif
  105.