home *** CD-ROM | disk | FTP | other *** search
/ Piper's Pit BBS/FTP: ibm 0040 - 0049 / ibm0040-0049 / ibm0040.tar / ibm0040 / ZINC_6.ZIP / DOSSRC.ZIP / SYS.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1991-06-01  |  3.8 KB  |  148 lines

  1. //    Zinc Interface Library - SYS.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 <string.h>
  7.  
  8. UIW_SYSTEM_BUTTON::UIW_SYSTEM_BUTTON() :
  9.     UIW_BUTTON(0, 0, 0, 0, BTF_NO_TOGGLE,
  10.         WOF_BORDER | WOF_JUSTIFY_CENTER | WOF_NON_FIELD_REGION,
  11.     UIW_SYSTEM_BUTTON::SystemUserFunction),
  12.     menu(0, 0, MNF_SELECT_ONE, WOF_BORDER, WOAF_TEMPORARY | WOAF_NO_DESTROY)
  13. {
  14.     // Initialize the system button information.
  15.     windowID[0] = ID_SYSTEM_BUTTON;
  16.     windowID[1] = ID_BUTTON;
  17.     search.type = ID_SYSTEM_BUTTON;
  18.     search.numberID = NUMID_SYSTEM;
  19.     strcpy(search.stringID, "NUMID_SYSTEM");
  20.  
  21.     hotKey = HOT_KEY_SYSTEM;
  22.     woAdvancedFlags |= WOAF_NON_CURRENT;
  23. }
  24.  
  25. int UIW_SYSTEM_BUTTON::Event(const UI_EVENT &event)
  26. {
  27.     // Switch on the event type.
  28.     int ccode = event.type;
  29.     switch (ccode)
  30.     {
  31.     case S_CREATE:
  32.         menu.InformationSet(-screenID, display, eventManager, windowManager,
  33.             paletteMapTable, this);
  34.         if (string)
  35.             delete string;
  36.         string = ui_strdup("\007");
  37.         // Continue to S_SIZE.
  38.  
  39.     case S_SIZE:
  40.         if (display->isText)
  41.         {
  42.             true.top = true.bottom = parent->true.top;
  43.             true.left = parent->true.left + 1;
  44.             true.right = true.left + 2;
  45.             woAdvancedStatus &= ~WOAS_INVALID_REGION;
  46.         }
  47.         else
  48.         {
  49.             int height, width;
  50.             UIW_BUTTON::Information(GET_DEFAULT_HEIGHT, &height);
  51.             UIW_BUTTON::Information(GET_DEFAULT_WIDTH, &width);
  52.             UI_WINDOW_OBJECT::RegionMax(TRUE);
  53.             if (true.top > parent->true.top)
  54.                 true.top -= 1;
  55.             if (true.left > parent->true.left)
  56.                 true.left -= 1;
  57.             true.right = true.left + width + 1;
  58.             true.bottom = true.top + height - 1;
  59.         }
  60.         break;
  61.  
  62.     case S_DISPLAY_INACTIVE:
  63.         if (display->isText)
  64.             break;
  65.         // Continue to S_DISPLAY_ACTIVE.
  66.  
  67.     case S_DISPLAY_ACTIVE:
  68.         if (display->isText)
  69.             lastPalette = NULL;
  70.         // Continue to default.
  71.  
  72.     default:
  73.         ccode = UIW_BUTTON::Event(event);
  74.         break;
  75.     }
  76.  
  77.     // Return the control code.
  78.     return (ccode);
  79. }
  80.  
  81. void UIW_SYSTEM_BUTTON::UserFunction(UI_EVENT &event)
  82. {
  83.     // Make sure there are elements in the menu.
  84.     woStatus &= ~WOS_SELECTED;
  85.     if (!menu.First() || ui_time() - time < repeatRate)
  86.     {
  87.         event.type = S_CLOSE;
  88.         eventManager->Put(event, Q_BEGIN);
  89.         return;
  90.     }
  91.  
  92.     // Attach the menu to the screen display.
  93.     menu.true.left = true.left;
  94.     menu.true.top = true.bottom + 1;
  95.     menu.true.right = menu.true.bottom = 0x0FFF;
  96.     if (display->isText)
  97.         menu.woStatus &= ~WOS_GRAPHICS;
  98.     else
  99.         menu.woStatus |= WOS_GRAPHICS;
  100.     *windowManager + &menu;
  101. }
  102.  
  103. void *UIW_SYSTEM_BUTTON::Information(INFORMATION_REQUEST request, void *data)
  104. {
  105.     if (request == GET_NUMBERID_OBJECT || request == GET_STRINGID_OBJECT ||
  106.         request == PRINT_INFORMATION)
  107.         return (menu.Information(request, data));
  108.     else if (request == PRINT_INFORMATION)
  109.     {
  110.         UI_WINDOW_OBJECT::Information(request, data);
  111.         return (menu.Information(request, data));
  112.     }
  113.     else
  114.         return (UI_WINDOW_OBJECT::Information(request, data));
  115. }
  116.  
  117. #ifdef ZIL_LOAD
  118. #pragma argsused
  119. UIW_SYSTEM_BUTTON::UIW_SYSTEM_BUTTON(const char *name, UI_STORAGE *file, USHORT loadFlags) :
  120.     UIW_BUTTON(0, file, L_SUB_LEVEL), menu(0, file, L_SUB_LEVEL)
  121. {
  122.     windowID[0] = ID_SYSTEM_BUTTON;
  123.     windowID[1] = ID_BUTTON;
  124.     hotKey = HOT_KEY_SYSTEM;
  125.     woAdvancedFlags |= WOAF_NON_CURRENT;
  126.     userFunction = UIW_SYSTEM_BUTTON::SystemUserFunction;
  127.     if (menu.First())
  128.         btFlags |= BTF_DOWN_CLICK;
  129.  
  130.     if (!file)
  131.         file = _storage;
  132.     if (!FlagSet(loadFlags, L_SUB_LEVEL) && FlagSet(file->stStatus, STS_TEMPORARY))
  133.         delete file;
  134. }
  135. #endif
  136.  
  137. #ifdef ZIL_STORE
  138. #pragma argsused
  139. void UIW_SYSTEM_BUTTON::Store(const char *name, UI_STORAGE *file, USHORT storeFlags)
  140. {
  141.     UIW_BUTTON::Store(name, file, storeFlags | S_SUB_LEVEL);
  142.     menu.Store(NULL, file, S_SUB_LEVEL | S_SKIP_TYPE);
  143.     if (!FlagSet(storeFlags, S_SUB_LEVEL))
  144.         file->ObjectSize(name, search);
  145. }
  146. #endif
  147.  
  148.