home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 10 / ioProg_10.iso / soft / optima / hpp.z / WRICHEDT.HPP < prev    next >
Encoding:
C/C++ Source or Header  |  1996-05-06  |  8.0 KB  |  245 lines

  1. /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  2.    %     Copyright (C) 1994, by WATCOM International Inc.  All rights    %
  3.    %     reserved.  No part of this software may be reproduced or        %
  4.    %     used in any form or by any means - graphic, electronic or       %
  5.    %     mechanical, including photocopying, recording, taping or        %
  6.    %     information storage and retrieval systems - except with the     %
  7.    %     written permission of WATCOM International Inc.                 %
  8.    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  9. */
  10.  
  11. /*************************************************************************
  12.  *
  13.  * WRichTextBox -- Wrapper for the Windows 95 RichTextBox control.
  14.  *
  15.  * Events:
  16.  *
  17.  *************************************************************************/
  18.  
  19. #ifndef _WRICHEDT_HPP_INCLUDED
  20. #define _WRICHEDT_HPP_INCLUDED
  21.  
  22. #ifndef _WNO_PRAGMA_PUSH
  23. #pragma pack(push,4);
  24. #pragma enum int;
  25. #endif
  26.  
  27. #ifndef _WCOLOR_HPP_INCLUDED
  28. #  include "wcolor.hpp"
  29. #endif
  30. #ifndef _WCONTROL_HPP_INCLUDED
  31. #  include "wcontrol.hpp"
  32. #endif
  33. #ifndef _WTEXTBOX_HPP_INCLUDED
  34. #  include "wtextbox.hpp"
  35. #endif
  36. #ifndef _WFONT_HPP_INCLUDED
  37. #  include "wfont.hpp"
  38. #endif
  39. #ifndef _WARRAY_HPP_INCLUDED
  40. #  include "warray.hpp"
  41. #endif
  42.  
  43. class WRichTextBox;
  44.  
  45. enum WCharacterFormatType {             /* for Get/SetCharacterFormat() */
  46.     WCFDefault,
  47.     WCFCurrentSelection,
  48.     WCFCurrentWord                      /* for SetCharacterFormat() only */
  49. };
  50.  
  51. enum WParagraphAlignType {              /* for Get/SetParagraphFormat() */
  52.     WPALeft,
  53.     WPACenter,
  54.     WPARight
  55. };
  56.  
  57. typedef WArray< WLong >         WLongArray;
  58.  
  59. typedef struct WParagraphFormat {       /* for Get/SetParagraphFormat() */
  60.     WParagraphAlignType align;
  61.     WFloat              startIndent;            /* in inches */
  62.     WFloat              subsequentIndent;       /* in inches */
  63.     WFloat              rightIndent;            /* in inches */
  64.     WLongArray          tabStopsArray;
  65.     WBool               bullet;
  66. } WParagraphFormat;
  67.  
  68. enum WCFMaskType {
  69.     WCFMBold            = 0x00000001,
  70.     WCFMItalic          = 0x00000002,
  71.     WCFMUnderline       = 0x00000004,
  72.     WCFMStrikeout       = 0x00000008,
  73.     WCFMProtect         = 0x00000010,
  74.     WCFMFontCharacterSet= 0x08000000,
  75.     WCFMBaselineOffset  = 0x10000000,
  76.     WCFMFontFaceName    = 0x20000000,
  77.     WCFMFontPitch       = 0x20000000,
  78.     WCFMFontFamily      = 0x20000000,
  79.     WCFMColor           = 0x40000000,
  80.     WCFMHeight          = 0x80000000,
  81.     WCFMAll             = 0xF800001F
  82. };
  83. typedef WULong WCFMask;
  84.  
  85. class WCMCLASS WCharacterFormat {       /* for Get/SetCharacterFormat() */
  86.  
  87.     public:
  88.  
  89.         /**********************************************************
  90.          * Constructors and Destructors
  91.          *********************************************************/
  92.          
  93.         WCharacterFormat() {}
  94.     
  95.         WCharacterFormat( const WFont & font, WBool autoColr=TRUE,
  96.                           WBool protct=FALSE, WLong baselineOffst=0 );
  97.     
  98.         ~WCharacterFormat() {}
  99.  
  100.         /**********************************************************
  101.          * Properties
  102.          *********************************************************/
  103.  
  104.         // Font
  105.  
  106.         WBool SetFont( const WFont & font, WBool autoColr=TRUE,
  107.                        WBool protct=FALSE, WLong baselineOffst=0 );
  108.         WFont GetFont();
  109.  
  110.         /**********************************************************
  111.          * Data Members
  112.          *********************************************************/
  113.  
  114.     public:
  115.  
  116.         WBool           autoColor;
  117.         WBool           bold;
  118.         WBool           italic;
  119.         WBool           strikeout;
  120.         WBool           underline;
  121.         WBool           protect;
  122.         WLong           height;
  123.         WLong           baselineOffset;  /* +ve => superscript, -ve => subscript */
  124.         WColor          color;           /* ignored if autoColor on */
  125.         WFCharSetType   fontCharacterSet;
  126.         WFPitchType     fontPitch;
  127.         WFFamilyType    fontFamily;
  128.         WString         fontFaceName;
  129. };
  130.  
  131. #undef FindText
  132. #if defined( _UNICODE )
  133. #define FindText        FindTextW
  134. #else
  135. #define FindText        FindTextA
  136. #endif
  137.  
  138. //
  139. // RichTextBox styles
  140. //
  141.  
  142. #define WRESDisableNoScroll     ((WStyle)0x00002000L) // ES_DISABLENOSCROLL
  143. #define WRESSunken              ((WStyle)0x00004000L) // ES_SUNKEN
  144. #define WRESSaveSelection       ((WStyle)0x00008000L) // ES_SAVESEL
  145. #define WRESSelectionBar        ((WStyle)0x01000000L) // ES_SELECTIONBAR
  146.  
  147. class WCMCLASS WRichTextBox : public WTextBox {
  148.     WDeclareSubclass( WRichTextBox, WTextBox );
  149.     
  150.     public:
  151.  
  152.         /**********************************************************
  153.          * Constructors and Destructors
  154.          *********************************************************/
  155.          
  156.         WRichTextBox();
  157.     
  158.         ~WRichTextBox();
  159.  
  160.         /**********************************************************
  161.          * Properties
  162.          *********************************************************/
  163.          
  164.         // CharacterFormat - The formatting of characters
  165.  
  166.         WBool SetCharacterFormat( const WCharacterFormat & format,
  167.                                   WCharacterFormatType type=WCFDefault,
  168.                                   WCFMask mask=WCFMAll );
  169.         WCharacterFormat GetCharacterFormat(
  170.                                   WCharacterFormatType type=WCFDefault );
  171.  
  172.         // ParagraphFormat -- The formatting of paragraphs
  173.  
  174.         WBool SetParagraphFormat( const WParagraphFormat & format );
  175.         WParagraphFormat GetParagraphFormat();
  176.         
  177.         // SelectedText -- The currently selected
  178.         //                 (i.e. highlighted) text.
  179.  
  180.         WString GetSelectedText() const;
  181.  
  182.         /**********************************************************
  183.          * Methods
  184.          *********************************************************/
  185.          
  186.         // FindText
  187.         //
  188.         //     Finds the next occurence of a given string.  Returns the
  189.         //     index of the beginning of the found string.
  190.  
  191.         WLong FindText( const WString & str, WBool caseSensitive=FALSE,
  192.                         WBool matchWholeWord=FALSE, WLong beginAt=0,
  193.                         WLong endAt=-1 );
  194.  
  195.         // Load
  196.  
  197.         WBool Load( const WFilePath & fileName, WBool regularText=FALSE );
  198.         WBool Load( const WBuffer & buffer, WBool regularText=FALSE );
  199.  
  200.         // Save
  201.  
  202.         WBool Save( const WFilePath & fileName, WBool regularText=FALSE );
  203.         WBool Save( WBuffer & buffer, WBool regularText=FALSE );
  204.  
  205.         /**********************************************************
  206.          * Overrides
  207.          *********************************************************/
  208.          
  209.         virtual const WChar * InitializeClass();
  210.  
  211.         virtual WStyle GetDefaultStyle() const;
  212.  
  213.         virtual WBool CloneWindow( WStyle newStyle, WStyle newExStyle,
  214.                                    void * data=NULL );
  215.  
  216.         virtual WColor GetBackColor( WBool getResultingColor=TRUE ) const;
  217.  
  218.         virtual WBool SetBackColor( const WColor & backColor );
  219.  
  220.         virtual WColor GetForeColor( WBool getResultingColor=TRUE ) const;
  221.  
  222.         virtual WBool SetForeColor( const WColor & foreColor );
  223.  
  224.         virtual WBool LoadWindow( WWindow * parent,
  225.                                   const WResourceID & id,
  226.                                   WModuleHandle module=_ApplicationModule );
  227.     
  228.         virtual WBool MakeWindow( WWindow * parent, WUInt id,
  229.                                   const WChar *className,
  230.                                   const WChar *title, const WRect & r,
  231.                                   WStyle wstyle, WStyle exStyle,
  232.                                   void * data=NULL );
  233. };
  234.     
  235. #ifndef _WTEMPLAT_HPP_INCLUDED
  236. #  include "wtemplat.hpp"
  237. #endif
  238.  
  239. #ifndef _WNO_PRAGMA_PUSH
  240. #pragma enum pop;
  241. #pragma pack(pop);
  242. #endif
  243.  
  244. #endif // _WRICHEDT_HPP_INCLUDED
  245.