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

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