home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1997 May / Pcwk0597.iso / sybase / starbuck / hpp.z / WRICHEDT.HPP < prev    next >
C/C++ Source or Header  |  1996-12-03  |  9KB  |  270 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,8);
  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.         // Font
  183.  
  184.         virtual WBool SetFont( const WFont & font, WBool preserveSize=TRUE );
  185.         virtual WFont GetFont( WBool getResultingFont=TRUE );
  186.  
  187.         // ContextMenuEnabled
  188.  
  189.         WBool GetContextMenuEnabled() const;
  190.         WBool SetContextMenuEnabled( WBool contextMenuEnabled );
  191.  
  192.         /**********************************************************
  193.          * Methods
  194.          *********************************************************/
  195.          
  196.         // FindText
  197.         //
  198.         //     Finds the next occurence of a given string.  Returns the
  199.         //     index of the beginning of the found string.
  200.  
  201.         WLong FindText( const WString & str, WBool caseSensitive=FALSE,
  202.                         WBool matchWholeWord=FALSE, WLong beginAt=0,
  203.                         WLong endAt=-1 );
  204.  
  205.         // Load
  206.  
  207.         WBool Load( const WFilePath & fileName, WBool regularText=FALSE );
  208.         WBool Load( const WBuffer & buffer, WBool regularText=FALSE );
  209.  
  210.         // Save
  211.  
  212.         WBool Save( const WFilePath & fileName, WBool regularText=FALSE );
  213.         WBool Save( WBuffer & buffer, WBool regularText=FALSE );
  214.  
  215.         /**********************************************************
  216.          * Event Handlers
  217.          *********************************************************/
  218.          
  219.         WBool RightButtonUpEventHandler( WWindow * source,
  220.                                          WMouseEventData * event );
  221.  
  222.         /**********************************************************
  223.          * Overrides
  224.          *********************************************************/
  225.          
  226.         virtual const WChar * InitializeClass();
  227.  
  228.         virtual WStyle GetDefaultStyle() const;
  229.  
  230.         virtual WBool CloneWindow( WStyle newStyle, WStyle newExStyle,
  231.                                    void * data=NULL );
  232.  
  233.         virtual WColor GetBackColor( WBool getResultingColor=TRUE ) const;
  234.  
  235.         virtual WBool SetBackColor( const WColor & backColor );
  236.  
  237.         virtual WColor GetForeColor( WBool getResultingColor=TRUE ) const;
  238.  
  239.         virtual WBool SetForeColor( const WColor & foreColor );
  240.  
  241.         virtual WBool LoadWindow( WWindow * parent,
  242.                                   const WResourceID & id,
  243.                                   WModuleHandle module=_ApplicationModule );
  244.     
  245.         virtual WBool MakeWindow( WWindow * parent, WUInt id,
  246.                                   const WChar *className,
  247.                                   const WChar *title, const WRect & r,
  248.                                   WStyle wstyle, WStyle exStyle,
  249.                                   void * data=NULL );
  250.  
  251.         /**********************************************************
  252.          * Data Members
  253.          *********************************************************/
  254.          
  255.     private:
  256.  
  257.         WBool           _contextMenuEnabled;
  258. };
  259.     
  260. #ifndef _WTEMPLAT_HPP_INCLUDED
  261. #  include "wtemplat.hpp"
  262. #endif
  263.  
  264. #ifndef _WNO_PRAGMA_PUSH
  265. #pragma enum pop;
  266. #pragma pack(pop);
  267. #endif
  268.  
  269. #endif // _WRICHEDT_HPP_INCLUDED
  270.