home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1997 May / Pcwk0597.iso / sybase / starbuck / hpp.z / WFINDDLG.HPP < prev    next >
C/C++ Source or Header  |  1996-10-18  |  5KB  |  159 lines

  1.  
  2. #ifndef _WFINDDLG_HPP_INCLUDED
  3. #define _WFINDDLG_HPP_INCLUDED
  4.  
  5. #ifndef _WNO_PRAGMA_PUSH
  6. #pragma pack(push,8);
  7. #pragma enum int;
  8. #endif
  9.  
  10. /*************************************************************************
  11.  *
  12.  * WFindReplaceDialog
  13.  *
  14.  *   Events:
  15.  *
  16.  *       FindReplace --
  17.  *
  18.  *************************************************************************/
  19.  
  20. #ifndef _WCOMDLG_HPP_INCLUDED
  21. #  include "wcomdlg.hpp"
  22. #endif
  23.  
  24. // Styles
  25.  
  26. typedef WULong WFRDStyle;
  27.  
  28. #define WFRDSDown                 ((WFRDStyle)0x00000001)
  29. #define WFRDSWholeWord            ((WFRDStyle)0x00000002)
  30. #define WFRDSMatchCase            ((WFRDStyle)0x00000004)
  31. #define WFRDSFindNext             ((WFRDStyle)0x00000008)
  32. #define WFRDSReplace              ((WFRDStyle)0x00000010)
  33. #define WFRDSReplaceAll           ((WFRDStyle)0x00000020)
  34. #define WFRDSDialogTerm           ((WFRDStyle)0x00000040)
  35. #define WFRDSShowHelp             ((WFRDStyle)0x00000080)
  36. #define WFRDSEnableHook           ((WFRDStyle)0x00000100)
  37. #define WFRDSEnableTemplate       ((WFRDStyle)0x00000200)
  38. #define WFRDSNoUpDown             ((WFRDStyle)0x00000400)
  39. #define WFRDSNoMatchCase          ((WFRDStyle)0x00000800)
  40. #define WFRDSNoWholeWord          ((WFRDStyle)0x00001000)
  41. #define WFRDSHideUpDown           ((WFRDStyle)0x00004000)
  42. #define WFRDSHideMatchCase        ((WFRDStyle)0x00008000)
  43. #define WFRDSHideWholeWord        ((WFRDStyle)0x00010000)
  44.  
  45. //
  46. // Event structure
  47. //
  48.  
  49. struct WFindReplaceEventData : public WEventData {
  50.     WBool findNext;       // if TRUE, find next only, otherwise replace
  51.     WBool searchDown;     // if TRUE, search down
  52.     WBool matchCase;      // if TRUE, search with case sensitivity
  53.     WBool wholeWord;      // if TRUE, only consider word matches
  54.     WBool replaceAll;     // if TRUE, replace all occurrences
  55.     WBool replace;        // if TRUE, replace occurrence
  56. };
  57.  
  58. //
  59. // WFindReplaceDialog
  60. //
  61.  
  62. class WCMCLASS WFindReplaceDialog : public WCommonDialog {
  63.     WDeclareSubclass( WFindReplaceDialog, WCommonDialog );
  64.  
  65.     public:
  66.         WFindReplaceDialog();
  67.  
  68.         ~WFindReplaceDialog();
  69.  
  70.         /*******************************************************
  71.          * Properties
  72.          *******************************************************/
  73.  
  74.         // BufferSize
  75.         //
  76.         //    Set/get the minimum buffer size (in bytes) being used for
  77.         //    the find and replace texts.  The minimum size will
  78.         //    always be >= 100.  Set the buffer size before you
  79.         //    set the find & replace texts.
  80.  
  81.         WUShort GetBufferSize() const;
  82.         WBool   SetBufferSize( WUShort minSize );
  83.  
  84.         // FindText
  85.         //
  86.         //    The text to search for.
  87.  
  88.         WString GetFindText() const;
  89.         WBool   SetFindText( const WString & text );
  90.  
  91.         // ReplaceText
  92.         //
  93.         //    The text to replace with.
  94.  
  95.         WString GetReplaceText() const;
  96.         WBool   SetReplaceText( const WString & text );
  97.  
  98.         // Style
  99.         //
  100.         //    Set the styles used by the print dialog.  Note that
  101.         //    the WFRDSEnableHook style will ALWAYS be enabled.
  102.  
  103.         WFRDStyle GetStyle() const;
  104.         WBool     SetStyle( WFRDStyle style );
  105.  
  106.         /*******************************************************
  107.          * Methods
  108.          *******************************************************/
  109.  
  110.         // ChangeStyle
  111.         //
  112.         //    Use to turn a specific style on or off.
  113.  
  114.         WBool ChangeStyle( WFRDStyle style, WBool on );
  115.  
  116.         // PromptForFind
  117.  
  118.         WBool PromptForFind();
  119.         WBool PromptForFind( WWindow *owner, const WChar *title,
  120.                              const WChar *findText );
  121.  
  122.         // PromptForReplace
  123.  
  124.         WBool PromptForReplace();
  125.         WBool PromptForReplace( WWindow *owner, const WChar *title,
  126.                                 const WChar *findText,
  127.                                 const WChar *replaceText );
  128.  
  129.         /************************************************************
  130.          * Notifications
  131.          ************************************************************/
  132.  
  133.         void  OnDialogInitialize( WWindowHandle hWnd, WWindowHandle focus );
  134.         WBool OnFRDestroy( WObject *, WEventData * );
  135.         void  ProcessOwnerMessage( void *msg );
  136.  
  137.     private:
  138.  
  139.         void  *PackFR();
  140.         WBool  UnpackFR( WBool ok );
  141.  
  142.     private:
  143.  
  144.         void     *_fr;
  145.         WUShort   _minSize;
  146.         WChar    *_findBuffer;
  147.         WChar    *_replaceBuffer;
  148.         WUShort   _findLen;
  149.         WUShort   _replaceLen;
  150. };
  151.  
  152.  
  153. #ifndef _WNO_PRAGMA_PUSH
  154. #pragma enum pop;
  155. #pragma pack(pop);
  156. #endif
  157.  
  158. #endif // _WFINDDLG_HPP_INCLUDED
  159.