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

  1. //    Zinc Interface Library - MIN.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_MINIMIZE_BUTTON::UIW_MINIMIZE_BUTTON() :
  9.     UIW_BUTTON(0, 0, 0, 0, BTF_NO_FLAGS,
  10.         WOF_BORDER | WOF_JUSTIFY_CENTER | WOF_NON_FIELD_REGION,
  11.         UIW_MINIMIZE_BUTTON::MinimizeUserFunction)
  12. {
  13.     // Initialize the minimize button information.
  14.     windowID[0] = ID_MINIMIZE_BUTTON;
  15.     windowID[1] = ID_BUTTON;
  16.     search.type = ID_MINIMIZE_BUTTON;
  17.     search.numberID = NUMID_MINIMIZE;
  18.     strcpy(search.stringID, "NUMID_MINIMIZE");
  19.  
  20.     hotKey = HOT_KEY_MINIMIZE;
  21.     woAdvancedFlags |= WOAF_NON_CURRENT;
  22. }
  23.  
  24. int UIW_MINIMIZE_BUTTON::Event(const UI_EVENT &event)
  25. {
  26.     // Switch on the event type.
  27.     int ccode = event.type;
  28.     switch (ccode)
  29.     {
  30.     case S_CREATE:
  31.         if (string)
  32.             delete string;
  33.         string = ui_strdup(" ");
  34.         // Continue to S_SIZE.
  35.  
  36.     case S_SIZE:
  37.         string[0] = (FlagSet(parent->woAdvancedStatus, WOAS_MINIMIZED)) ?
  38.             0x12 : 0x19;
  39.         if (display->isText)
  40.         {
  41.             true.top = true.bottom = parent->true.top;
  42.             true.left = parent->true.right - 6;
  43.             true.right = true.left + 2;
  44.             woAdvancedStatus &= ~WOAS_INVALID_REGION;
  45.         }
  46.         else
  47.         {
  48.             int height, width;
  49.              UIW_BUTTON::Information(GET_DEFAULT_HEIGHT, &height);
  50.             UIW_BUTTON::Information(GET_DEFAULT_WIDTH, &width);
  51.             UI_WINDOW_OBJECT::RegionMax(TRUE);
  52.             if (true.top > parent->true.top)
  53.                 true.top -= 1;
  54.             if (true.right < parent->true.right)
  55.                 true.right += 1;
  56.             true.bottom = true.top + height - 1;
  57.             true.left = true.right - width + 1;
  58.         }
  59.         if (FlagSet(parent->woAdvancedStatus, WOAS_MINIMIZED))
  60.             woStatus |= WOS_SELECTED;
  61.         else
  62.             woStatus &= ~WOS_SELECTED;
  63.         if (FlagSet(parent->woAdvancedStatus, WOAS_MAXIMIZED))
  64.             woFlags |= WOF_NON_SELECTABLE;
  65.         else
  66.             woFlags &= ~WOF_NON_SELECTABLE;
  67.         break;
  68.  
  69.     case S_DISPLAY_INACTIVE:
  70.         if (display->isText)
  71.             break;
  72.         // Continue to S_DISPLAY_ACTIVE.
  73.  
  74.     case S_DISPLAY_ACTIVE:
  75.         if (display->isText)
  76.             lastPalette = NULL;
  77.         // Continue to default.
  78.  
  79.     default:
  80.         ccode = UIW_BUTTON::Event(event);
  81.         break;
  82.     }
  83.  
  84.     // Return the control code.
  85.     return (ccode);
  86. }
  87.  
  88. #ifdef ZIL_STORE
  89. #pragma argsused
  90. void UIW_MINIMIZE_BUTTON::Store(const char *name, UI_STORAGE *file, USHORT storeFlags)
  91. {
  92.     file->Store(search.type);
  93.     if (!FlagSet(storeFlags, S_SUB_LEVEL))
  94.         file->ObjectSize(name, search);
  95. }
  96. #endif
  97.