home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / opendc12.zip / od124os2.exe / od12osp1.exe / src / dynamicp / bimaglay / getcprop.c < prev    next >
C/C++ Source or Header  |  1997-04-02  |  4KB  |  99 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.3 com/src/samples/dynamicp/bimaglay/getcprop.c, oddynamicpart, od96os2, odos29712d 97/03/21 17:44:43 (96/11/01 08:49:16)
  28. *******************************************************************
  29. ** Name: void FacetAdded
  30. **
  31. ** Description:  Get the containing frame's properties (background
  32. **               and foreground colors, etc.); this seems like a
  33. **               good place to do so.
  34. **
  35. *******************************************************************
  36. */
  37. #ifdef _OS2_OD_GA_
  38. // If facet is not in a root frame, get the container's properties.
  39. try {
  40.   ODFrame * frame = facet->GetFrame(ev);
  41.   if (!frame->IsRoot(ev)) {
  42.     // now lets get our container's std properties
  43.     ODFrame *containingFrame = frame->AcquireContainingFrame(ev);
  44.     ODPart  *containingPart  = containingFrame->AcquirePart(ev);
  45.     ODStorageUnit *propertyUnit = containingPart->
  46.                                 AcquireContainingPartProperties(ev, frame);
  47.     containingFrame->Release(ev);
  48.     containingPart->Release(ev);
  49.  
  50.     if (propertyUnit != kODNULL) {
  51.       // Is the background color in there?
  52.       RGBColor rgb;
  53.       if (!_customBackground) {
  54.         if (ODSUExistsThenFocus(ev, propertyUnit, kODBackgroundColor, kODRGB2)) {
  55.           StorageUnitGetValue(propertyUnit, ev, sizeof(rgb), &rgb);
  56.             //_BackColor = rgb
  57.             ODSByte colorMix = 0;
  58.             colorMix = rgb / 0x10000;       _BackColor.setRed(colorMix);
  59.             colorMix = rgb / 0x100 % 0x100; _BackColor.setGreen(colorMix);
  60.             colorMix = rgb % 0x100;         _BackColor.setBlue(colorMix);
  61.         } /* endif */
  62.       } /* endif */
  63.       // text foreground color
  64.       if (!_customTextColor) {
  65.         if (ODSUExistsThenFocus(ev, propertyUnit, kODForegroundColor, kODRGB2)) {
  66.           StorageUnitGetValue(propertyUnit, ev, sizeof(rgb), &rgb);
  67.             //_TextColor = rgb
  68.             ODSByte colorMix = 0;
  69.             colorMix = rgb / 0x10000;       _TextColor.setRed(colorMix);
  70.             colorMix = rgb / 0x100 % 0x100; _TextColor.setGreen(colorMix);
  71.             colorMix = rgb % 0x100;         _TextColor.setBlue(colorMix);
  72.         } /* endif */
  73.       } /* endif */
  74.       // text font
  75.       if (!_customFont) {
  76.         if (ODSUExistsThenFocus(ev, propertyUnit, kODFont, kODFontNameSize)) {
  77.           ODULong fontNameLength = 0;
  78.           char *fontNameSize = NULL;
  79.           fontNameSize = ODGetISOStrProp(ev, propertyUnit, kODNULL, kODNULL, fontNameSize, &fontNameLength);
  80.           if (fontNameSize) {
  81.              char *fontName = strchr(fontNameSize, '.');
  82.              if (fontName==kODNULL) {
  83.                fontName = fontNameSize;
  84.              } /* endif */
  85.              _Font->setName(fontName);
  86.              _Message->setFont(*_Font);
  87.              // memory was allocated by ODGetISOStrProp, so use SOMFree to free it.
  88.              SOMFree(fontNameSize);
  89.           } /* endif */
  90.         } /* endif */
  91.       } /* endif */
  92.       propertyUnit->Release(ev);
  93.     } /* endif */
  94.   } /* endif */
  95. } catch (...) {
  96.   reportAnyException(ev);
  97. } /* end try */
  98. #endif
  99.