home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / opendc12.zip / od124os2.exe / od12osp1.exe / src / dynamicp / bdraw / scroll.c < prev   
Text File  |  1997-04-02  |  5KB  |  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.7 com/src/samples/dynamicp/bdraw/scroll.c, oddynamicpart, od96os2, odos29712d 2/18/97 13:54:05 [3/21/97 17:44:35]
  28. *******************************************************************
  29. ** Name: void ScrollTicker
  30. **
  31. ** Description:  Scrolls the message across the bottom of the
  32. **               part by JumpRate pixels.
  33. **
  34. *******************************************************************
  35. */
  36. try {
  37.    int contentExtent;   // use this to hide differences between OS/2 and Windows origins
  38.    #ifdef _PLATFORM_OS2_
  39.      contentExtent = 0; // OS/2 origin is bottom left
  40.    #elif defined(_PLATFORM_WIN32_)
  41.      contentExtent = drawYdimension; // Windows origin is (strangely) top right
  42.    #endif
  43.  
  44.    IODLinkedList *displayFrames = somSelf->GetDisplayFrames(ev);
  45.    IODLink *listItem;
  46.    ODFrame *frame;
  47.  
  48.    if ( _ScrollPos <= -(ODSLong)(_Font->textWidth((char *)(_Message->text())) ) )
  49.    {
  50.       _ScrollPos = drawXdimension;
  51.    } else {
  52.       _ScrollPos -= _JumpRate;
  53.    }
  54.  
  55.    // calculate new position for dynamic message
  56.    IPoint newMsgPos = _Message->position();
  57.    newMsgPos.setX(_ScrollPos);
  58.  
  59.    for (listItem = displayFrames->First(ev);
  60.         (listItem != kODNULL) && (frame = (ODFrame *)(listItem->Content(ev)));
  61.         listItem = listItem->Next(ev))
  62.    {
  63.      // We only have one facet per frame, so get a pointer to it for this frame.
  64.      ODFrameFacetIterator* facets = frame->CreateFacetIterator(ev);
  65.      ODFacet* facet = facets->First(ev);
  66.      delete facets;
  67.  
  68.      ODShape *shape = kODNULL;
  69.      HPS hps;
  70.      CFocus f(facet, shape, &hps);          // Set up drawing environment
  71.  
  72.      // Use the Integer Constuctor to create a presentation sapce handle using the hps returned from CFocus
  73.      IPresSpaceHandle DrawHps(hps);
  74.  
  75.      // Use the IPresSpaceHandle Constructor to create my Graphic Context
  76.      IGraphicContext DrawConText(DrawHps);
  77.  
  78.      // Setting the Background and Fill color for the Graphic Context to
  79.      // redraw dynamic message
  80.  
  81.      ODHighlight highlight = facet->GetHighlight(ev);
  82.      if (highlight==kODNoHighlight) {
  83.        DrawConText.setBackgroundColor(_BackColor);
  84.        DrawConText.setPenColor(_TextColor);
  85.      } else {
  86.        if (highlight==kODFullHighlight) {
  87.          DrawConText.setBackgroundColor(_TextColor);
  88.          DrawConText.setPenColor(_BackColor);
  89.        } else {
  90.          if (highlight==kODDimHighlight) {
  91.            DrawConText.setBackgroundColor(_BackColor);
  92.            DrawConText.setPenColor(_TextColor);
  93.          } /* endif */
  94.        } /* endif */
  95.      } /* endif */
  96.      DrawConText.setBackgroundMixMode(IGraphicBundle::backOverPaint);
  97.      DrawConText.setMixMode(IGraphicBundle::overPaint);
  98.  
  99.      IRectangle DrawBotRect(0,                        //left
  100.                             contentExtent,            //bottom
  101.                             drawXdimension+1,         //right
  102. #ifdef _PLATFORM_OS2_
  103.                             abs(contentExtent  - (_Font->maxCharHeight()+_Font->maxDescender()))+7
  104. #elif defined(_PLATFORM_WIN32_)
  105.                             abs(contentExtent  -  _Font->maxCharHeight()   )
  106. #endif
  107.                            );
  108.      _Message->setClippingRect(DrawBotRect);
  109.  
  110.      try {
  111.        // draw dynamic message at new position
  112.        _Message->moveTo(newMsgPos);
  113.        _Message->drawOn(DrawConText);
  114.      } catch (IException &exc) {
  115.          reportIException(exc);
  116.      } /* end try */
  117.    } /* endfor */
  118.    // do NOT delete displayFrames;
  119.  
  120. } catch (IException &exc) {
  121.     reportIException(exc);
  122. } catch (...) {
  123.     reportAnyException(ev);
  124. } /* end try */
  125.