home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / opendc12.zip / od124os2.exe / od12osp1.exe / src / dynamicp / binit / iinitpfs.c < prev    next >
C/C++ Source or Header  |  1997-04-02  |  6KB  |  125 lines

  1. /*====START_GENERATED_PROLOG======================================
  2.  */
  3. /*
  4.  *   COMPONENT_NAME: oddynamicpart
  5.  *
  6.  *   CLASSES: none
  7.  *
  8.  *   ORIGINS: 82,27
  9.  *
  10.  *
  11.  *   (C) COPYRIGHT International Business Machines Corp. 1995,1996
  12.  *   All Rights Reserved
  13.  *   Licensed Materials - Property of IBM
  14.  *   US Government Users Restricted Rights - Use, duplication or
  15.  *   disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  16.  *       
  17.  *   IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  18.  *   ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  19.  *   PURPOSE. IN NO EVENT SHALL IBM BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  20.  *   CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
  21.  *   USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
  22.  *   OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE
  23.  *   OR PERFORMANCE OF THIS SOFTWARE.
  24.  */
  25. /*====END_GENERATED_PROLOG========================================
  26.  */
  27. /* @(#) 1.4 com/src/samples/dynamicp/binit/iinitpfs.c, oddynamicpart, od96os2, odos29712d 11/1/96 08:49:41 [3/21/97 17:44:46]
  28. *******************************************************************
  29. ** Name: void InitPartFromStorage
  30. **
  31. ** Description:  "Read" persistend instance data from the storage
  32. **               unit.
  33. **
  34. *******************************************************************
  35. */
  36. try {
  37.  
  38.     if (_fIsInitialized)
  39.       // Already done this -- don't do it again.
  40.       return;
  41.  
  42.     _fIsInitialized = kODTrue;
  43.  
  44.     // save self-reference for later use.
  45.     _fPartWrapper = partWrapper;
  46.  
  47.     if(!storageUnit->Exists(ev, kODPropContents, kKindTestDynamicPart, 0))
  48.     {
  49.         storageUnit->AddProperty(ev, kODPropContents)->AddValue(ev, kKindTestDynamicPart);
  50.     } else {
  51.       storageUnit->Focus(ev, kODPropContents, kODPosUndefined, kKindTestDynamicPart, 0, kODPosUndefined);
  52.       _scrollTimerRate  = ODGetSLongProp(ev, storageUnit, kODNULL, kODNULL);
  53.       _rotateTimerRate  = ODGetSLongProp(ev, storageUnit, kODNULL, kODNULL);
  54.       _JumpRate         = ODGetSLongProp(ev, storageUnit, kODNULL, kODNULL);
  55.       _ScrollPos        = ODGetSLongProp(ev, storageUnit, kODNULL, kODNULL);
  56.       _fFrameNegotiated = ODGetBooleanProp(ev, storageUnit, kODNULL, kODNULL);
  57.     // saved color attributes.
  58.       ODSByte colorMix = 0;
  59.       _customBackground = ODGetBooleanProp(ev, storageUnit, kODNULL, kODNULL);
  60.       if (_customBackground) {
  61.         StorageUnitGetValue(storageUnit, ev, sizeof(colorMix), &colorMix); _BackColor.setRed(colorMix);
  62.         StorageUnitGetValue(storageUnit, ev, sizeof(colorMix), &colorMix); _BackColor.setGreen(colorMix);
  63.         StorageUnitGetValue(storageUnit, ev, sizeof(colorMix), &colorMix); _BackColor.setBlue(colorMix);
  64.       } /* endif */
  65.       _customTextColor  = ODGetBooleanProp(ev, storageUnit, kODNULL, kODNULL);
  66.       if (_customTextColor) {
  67.         StorageUnitGetValue(storageUnit, ev, sizeof(colorMix), &colorMix); _TextColor.setRed(colorMix);
  68.         StorageUnitGetValue(storageUnit, ev, sizeof(colorMix), &colorMix); _TextColor.setGreen(colorMix);
  69.         StorageUnitGetValue(storageUnit, ev, sizeof(colorMix), &colorMix); _TextColor.setBlue(colorMix);
  70.       } /* endif */
  71.     // saved angles in degrees -- must convert to radians for c trig functions.
  72.       ODSLong degrees = 0;
  73.       degrees = ODGetSLongProp(ev, storageUnit, kODNULL, kODNULL);
  74.       _xRotAngle = degrees * pi / 180;
  75.       degrees = ODGetSLongProp(ev, storageUnit, kODNULL, kODNULL);
  76.       _xAngleDelta = degrees * pi / 180;
  77.       degrees = ODGetSLongProp(ev, storageUnit, kODNULL, kODNULL);
  78.       _hShearAngle = degrees * pi / 180;
  79.       degrees = ODGetSLongProp(ev, storageUnit, kODNULL, kODNULL);
  80.       _vShearAngle = degrees * pi / 180;
  81.  
  82.     // are we scrolling/rotating
  83.       _scrolling     = ODGetBooleanProp(ev, storageUnit, kODNULL, kODNULL);
  84.       _xRotateActive = ODGetBooleanProp(ev, storageUnit, kODNULL, kODNULL);
  85.       _hShearActive  = ODGetBooleanProp(ev, storageUnit, kODNULL, kODNULL);
  86.       _vShearActive  = ODGetBooleanProp(ev, storageUnit, kODNULL, kODNULL);
  87.     // which directions
  88.       _xRotateClockwise = ODGetBooleanProp(ev, storageUnit, kODNULL, kODNULL);
  89.       _hShearRight      = ODGetBooleanProp(ev, storageUnit, kODNULL, kODNULL);
  90.       _vShearUp         = ODGetBooleanProp(ev, storageUnit, kODNULL, kODNULL);
  91.  
  92.     // now get the font
  93.       _customFont = ODGetBooleanProp(ev, storageUnit, kODNULL, kODNULL);
  94.       if (_customFont) {
  95.         ODULong fontNameLength = 0;
  96.         char *fontName = NULL;
  97.         fontName = ODGetISOStrProp(ev, storageUnit, kODPropContents, kODISOStr, fontName, &fontNameLength);
  98.         if (fontName) {
  99.            _Font->setName(fontName);
  100.            _Message->setFont(*_Font);
  101.            // memory was allocated by ODGetISOStrProp, so use SOMFree to free it.
  102.            SOMFree(fontName);
  103.         } /* endif */
  104.       } /* endif */
  105.  
  106.     // now get the text value
  107.       ODULong msgLength = 0;
  108.       char *msgText = NULL;
  109.       msgText = ODGetISOStrProp(ev, storageUnit, kODPropContents, kODISOStr, msgText, &msgLength);
  110.       if (msgText) {
  111.          _Message->setText(msgText);
  112.          // memory was allocated by ODGetISOStrProp, so use SOMFree to free it.
  113.          SOMFree(msgText);
  114.       } else {
  115.         // couldn't read the text, so turn off scrolling
  116.         _scrolling = kODFalse;
  117.       } /* endif */
  118.       msgText = NULL;
  119.     } /* endif */
  120.     storageUnit->Focus(ev, kODPropContents, kODPosUndefined, kKindTestDynamicPart, 0, kODPosUndefined);
  121. } catch (...) {
  122.     reportAnyException(ev);
  123. } /* end try */
  124. // end initfs.frg
  125.