home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / odtlktv4.zip / ODTLKT / TOOLKIT / SAMPLES / OPENDOC / PARTS / TTAPE1 / TEXTDATA.HPP < prev    next >
Text File  |  1995-12-15  |  7KB  |  225 lines

  1. /***********************************************************************
  2. *
  3. *  File Name   : TEXTDATA.HPP
  4. *
  5. *  Description : Header file for the TextData class.  Contains the
  6. *                TextData class definition.
  7. *
  8. *  Notes       : N/A
  9. *
  10. *  Entry Points: DefaultOutlineFont
  11. *                TextData::TextData
  12. *                TextData::~TextData
  13. *                TextData::DrawTape
  14. *                TextData::GetTextBuffer
  15. *                TextData::GetTextArea
  16. *                TextData::GetGap
  17. *                TextData::GetScrollPos
  18. *                TextData::GetScrollRate
  19. *                TextData::GetBackText
  20. *                TextData::GetTextFileSize
  21. *                TextData::NeedToScroll
  22. *                TextData::SetSize
  23. *                TextData::SetTextBuffer
  24. *                TextData::SetTextArea
  25. *                TextData::SetNeedToScroll
  26. *                TextData::SetScrollRate
  27. *                TextData::SetBackText
  28. *
  29. *    (C) COPYRIGHT International Business Machines Corp. 1995
  30. *    All Rights Reserved
  31. *    Licensed Materials - Property of IBM
  32. *
  33. *    US Government Users Restricted Rights - Use, duplication or
  34. *    disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  35. *
  36. *    DISCLAIMER OF WARRANTIES.  The following [enclosed] code is
  37. *    sample code created by IBM Corporation. This sample code is not
  38. *    part of any standard or IBM product and is provided to you solely
  39. *    for the purpose of assisting you in the development of your
  40. *    applications.  The code is provided "AS IS", without
  41. *    warranty of any kind.  IBM shall not be liable for any damages
  42. *    arising out of your use of the sample code, even if they have been
  43. *    advised of the possibility of such damages.
  44. *
  45. ***********************************************************************/
  46. #ifndef _TEXTDATA_
  47. #define _TEXTDATA_
  48. #define INCL_WIN
  49. #define INCL_GPI
  50. #define INCL_DOS
  51. #include <os2.h>
  52.  
  53. const USHORT MAXSIZETEXTFILE = 32000;   /* Maximum size of text file. */
  54. const ULONG       RATE       = 200UL;   /* Initial text scroll rate.  */
  55.  
  56. typedef struct
  57. {
  58.       HPS         hps;
  59.       FONTMETRICS fmFont;
  60.       FATTRS      fAttr;
  61.       RECTL       rectlBox;
  62.       LONG        lColorText,
  63.                   lBackText;
  64.       LONG        lScrollRate;
  65.       SHORT       sNeedToScroll;
  66. } TEXTAREA;
  67.  
  68. class TextData
  69. {
  70. public:
  71.     TextData(TextData *initData = NULL); /* Constructor. */
  72.  
  73.     virtual ~TextData()  /* Destructor.  */
  74.     { if (textBuffer != NULL)
  75.           delete [] textBuffer;
  76.       if (textArea != NULL)
  77.           delete textArea; }
  78.  
  79.     /* Draw method. */
  80.     virtual VOID  DrawTape(HPS hps);
  81.  
  82.     /* Accessor methods. */
  83.     CHAR  *GetTextBuffer(int bufferIndex) const;
  84.     VOID   GetTextArea(TEXTAREA& textOut);
  85.  
  86.     /*
  87.      *
  88.      *    Method(s) :  TextData::GetGap
  89.      *
  90.      *  Description :  Get the current starting location of the text
  91.      *                 within the Ticker Tape window.
  92.      *
  93.      *   Parameters :  None.
  94.      *
  95.      *      Returns :  SHORT - the starting location of text within
  96.      *                         the Ticker Tape window.
  97.      */
  98.     SHORT GetGap () { return sGap; }
  99.  
  100.     /*
  101.      *
  102.      *    Method(s) :  TextData::GetScrollPos
  103.      *
  104.      *  Description :  Get position of the first character to display
  105.      *                 within the Ticker Tape window.
  106.      *
  107.      *   Parameters :  None.
  108.      *
  109.      *      Returns :  SHORT - the current Scroll Position.
  110.      */
  111.     SHORT GetScrollPos () { return sScrollPos; }
  112.  
  113.     /*
  114.      *
  115.      *    Method(s) :  TextData::GetScrollRate
  116.      *
  117.      *  Description :  Get the Ticker Tape text scroll rate.
  118.      *
  119.      *   Parameters :  None.
  120.      *
  121.      *      Returns :  LONG - the Ticker Tape text scroll rate.
  122.      */
  123.     LONG  GetScrollRate () { return textArea->lScrollRate; }
  124.  
  125.     /*
  126.      *
  127.      *    Method(s) :  TextData::GetBackText
  128.      *
  129.      *  Description :  Get the Ticker Tape text background color.
  130.      *
  131.      *   Parameters :  None.
  132.      *
  133.      *      Returns :  LONG - the Ticker Tape text background color.
  134.      */
  135.     LONG GetBackText () { return textArea->lBackText; }
  136.  
  137.     /*
  138.      *
  139.      *    Method(s) :  TextData::GetTextFileSize
  140.      *
  141.      *  Description :  Return the length of the textBuffer buffer.
  142.      *
  143.      *   Parameters :  None.
  144.      *
  145.      *      Returns :  SHORT - the length of the Ticker Tape text string
  146.      *                         stored in textBuffer.
  147.      */
  148.     SHORT GetTextFileSize () { return sTextFileSize; }
  149.  
  150.     /*
  151.      *
  152.      *    Method(s) :  TextData::NeedToScroll
  153.      *
  154.      *  Description :  Get whether there should be scrolling the next
  155.      *                 time the text is drawn with TextData::DrawTape.
  156.      *
  157.      *   Parameters :  None.
  158.      *
  159.      *      Returns :  SHORT - the current need to scroll value.
  160.      */
  161.     SHORT NeedToScroll () { return textArea->sNeedToScroll; }
  162.  
  163.     /* Set methods. */
  164.     VOID  SetSize(RECTL *rclFrame);
  165.     SHORT SetTextBuffer(CHAR *text,
  166.                                 SHORT sInitGap,
  167.                                 SHORT sInitScrollPos);
  168.     VOID  SetTextArea(TEXTAREA textIn);
  169.  
  170.     /*
  171.      *
  172.      *    Method(s) :  TextData::SetNeedToScroll
  173.      *
  174.      *  Description :  Set whether there should be scrolling the next
  175.      *                 time the text is drawn with TextData::DrawTape.
  176.      *
  177.      *   Parameters :  SHORT sNeed - the new need to scroll value.
  178.      *
  179.      *      Returns :  VOID
  180.      */
  181.     VOID  SetNeedToScroll (SHORT sNeed)
  182.           { textArea->sNeedToScroll = sNeed; }
  183.  
  184.     /*
  185.      *
  186.      *    Method(s) :  TextData::SetScrollRate
  187.      *
  188.      *  Description :  Set the Ticker Tape text scroll rate.
  189.      *
  190.      *   Parameters :  LONG lScroll - the new scroll rate.
  191.      *
  192.      *      Returns :  VOID.
  193.      */
  194.     VOID  SetScrollRate (LONG lScroll)
  195.           { textArea->lScrollRate = lScroll; }
  196.  
  197.     /*
  198.      *
  199.      *    Method(s) :  TextData::SetBackText
  200.      *
  201.      *  Description :  Set the text background color attribute stored
  202.      *                 in the lBackText field within the text area.
  203.      *
  204.      *   Parameters :  LONG lBackText
  205.      *
  206.      *      Returns :  VOID
  207.      */
  208.     VOID  SetBackText (LONG lBackText)
  209.           { textArea->lBackText = lBackText; }
  210.  
  211. protected:
  212.     TEXTAREA* textArea;        /*  The text attributes structure.         */
  213.     CHAR*     textBuffer;      /*  Buffer for containing the text.        */
  214.     SHORT     sTextFileSize;   /*  Current size of the text buffer.       */
  215.     SHORT     sGap,            /*  Position of first character in window. */
  216.               sScrollPos;      /*  Index-position of the first character. */
  217. };
  218.  
  219. /*
  220.  *  Prototype for the DefaultOutlineFont utility routine.
  221.  */
  222. void DefaultOutlineFont(TEXTAREA *textarea);
  223.  
  224. #endif  /* _TEXTDATA_ */
  225.