fdrepdlg.h 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: wx/fdrepdlg.h
  3. // Purpose: wxFindReplaceDialog class
  4. // Author: Markus Greither and Vadim Zeitlin
  5. // Modified by:
  6. // Created: 23/03/2001
  7. // Copyright: (c) Markus Greither
  8. // Licence: wxWindows licence
  9. /////////////////////////////////////////////////////////////////////////////
  10. #ifndef _WX_FINDREPLACEDLG_H_
  11. #define _WX_FINDREPLACEDLG_H_
  12. #include "wx/defs.h"
  13. #if wxUSE_FINDREPLDLG
  14. #include "wx/dialog.h"
  15. class WXDLLIMPEXP_FWD_CORE wxFindDialogEvent;
  16. class WXDLLIMPEXP_FWD_CORE wxFindReplaceDialog;
  17. class WXDLLIMPEXP_FWD_CORE wxFindReplaceData;
  18. class WXDLLIMPEXP_FWD_CORE wxFindReplaceDialogImpl;
  19. // ----------------------------------------------------------------------------
  20. // Flags for wxFindReplaceData.Flags
  21. // ----------------------------------------------------------------------------
  22. // flages used by wxFindDialogEvent::GetFlags()
  23. enum wxFindReplaceFlags
  24. {
  25. // downward search/replace selected (otherwise - upwards)
  26. wxFR_DOWN = 1,
  27. // whole word search/replace selected
  28. wxFR_WHOLEWORD = 2,
  29. // case sensitive search/replace selected (otherwise - case insensitive)
  30. wxFR_MATCHCASE = 4
  31. };
  32. // these flags can be specified in wxFindReplaceDialog ctor or Create()
  33. enum wxFindReplaceDialogStyles
  34. {
  35. // replace dialog (otherwise find dialog)
  36. wxFR_REPLACEDIALOG = 1,
  37. // don't allow changing the search direction
  38. wxFR_NOUPDOWN = 2,
  39. // don't allow case sensitive searching
  40. wxFR_NOMATCHCASE = 4,
  41. // don't allow whole word searching
  42. wxFR_NOWHOLEWORD = 8
  43. };
  44. // ----------------------------------------------------------------------------
  45. // wxFindReplaceData: holds Setup Data/Feedback Data for wxFindReplaceDialog
  46. // ----------------------------------------------------------------------------
  47. class WXDLLIMPEXP_CORE wxFindReplaceData : public wxObject
  48. {
  49. public:
  50. wxFindReplaceData() { Init(); }
  51. wxFindReplaceData(wxUint32 flags) { Init(); SetFlags(flags); }
  52. // accessors
  53. const wxString& GetFindString() const { return m_FindWhat; }
  54. const wxString& GetReplaceString() const { return m_ReplaceWith; }
  55. int GetFlags() const { return m_Flags; }
  56. // setters: may only be called before showing the dialog, no effect later
  57. void SetFlags(wxUint32 flags) { m_Flags = flags; }
  58. void SetFindString(const wxString& str) { m_FindWhat = str; }
  59. void SetReplaceString(const wxString& str) { m_ReplaceWith = str; }
  60. protected:
  61. void Init();
  62. private:
  63. wxUint32 m_Flags;
  64. wxString m_FindWhat,
  65. m_ReplaceWith;
  66. friend class wxFindReplaceDialogBase;
  67. };
  68. // ----------------------------------------------------------------------------
  69. // wxFindReplaceDialogBase
  70. // ----------------------------------------------------------------------------
  71. class WXDLLIMPEXP_CORE wxFindReplaceDialogBase : public wxDialog
  72. {
  73. public:
  74. // ctors and such
  75. wxFindReplaceDialogBase() { m_FindReplaceData = NULL; }
  76. wxFindReplaceDialogBase(wxWindow * WXUNUSED(parent),
  77. wxFindReplaceData *data,
  78. const wxString& WXUNUSED(title),
  79. int WXUNUSED(style) = 0)
  80. {
  81. m_FindReplaceData = data;
  82. }
  83. virtual ~wxFindReplaceDialogBase();
  84. // find dialog data access
  85. const wxFindReplaceData *GetData() const { return m_FindReplaceData; }
  86. void SetData(wxFindReplaceData *data) { m_FindReplaceData = data; }
  87. // implementation only, don't use
  88. void Send(wxFindDialogEvent& event);
  89. protected:
  90. wxFindReplaceData *m_FindReplaceData;
  91. // the last string we searched for
  92. wxString m_lastSearch;
  93. wxDECLARE_NO_COPY_CLASS(wxFindReplaceDialogBase);
  94. };
  95. // include wxFindReplaceDialog declaration
  96. #if defined(__WXMSW__) && !defined(__WXUNIVERSAL__) && !defined(__WXWINCE__)
  97. #include "wx/msw/fdrepdlg.h"
  98. #else
  99. #define wxGenericFindReplaceDialog wxFindReplaceDialog
  100. #include "wx/generic/fdrepdlg.h"
  101. #endif
  102. // ----------------------------------------------------------------------------
  103. // wxFindReplaceDialog events
  104. // ----------------------------------------------------------------------------
  105. class WXDLLIMPEXP_CORE wxFindDialogEvent : public wxCommandEvent
  106. {
  107. public:
  108. wxFindDialogEvent(wxEventType commandType = wxEVT_NULL, int id = 0)
  109. : wxCommandEvent(commandType, id) { }
  110. wxFindDialogEvent(const wxFindDialogEvent& event)
  111. : wxCommandEvent(event), m_strReplace(event.m_strReplace) { }
  112. int GetFlags() const { return GetInt(); }
  113. wxString GetFindString() const { return GetString(); }
  114. const wxString& GetReplaceString() const { return m_strReplace; }
  115. wxFindReplaceDialog *GetDialog() const
  116. { return wxStaticCast(GetEventObject(), wxFindReplaceDialog); }
  117. // implementation only
  118. void SetFlags(int flags) { SetInt(flags); }
  119. void SetFindString(const wxString& str) { SetString(str); }
  120. void SetReplaceString(const wxString& str) { m_strReplace = str; }
  121. virtual wxEvent *Clone() const { return new wxFindDialogEvent(*this); }
  122. private:
  123. wxString m_strReplace;
  124. DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxFindDialogEvent)
  125. };
  126. wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_FIND, wxFindDialogEvent );
  127. wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_FIND_NEXT, wxFindDialogEvent );
  128. wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_FIND_REPLACE, wxFindDialogEvent );
  129. wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_FIND_REPLACE_ALL, wxFindDialogEvent );
  130. wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_FIND_CLOSE, wxFindDialogEvent );
  131. typedef void (wxEvtHandler::*wxFindDialogEventFunction)(wxFindDialogEvent&);
  132. #define wxFindDialogEventHandler(func) \
  133. wxEVENT_HANDLER_CAST(wxFindDialogEventFunction, func)
  134. #define EVT_FIND(id, fn) \
  135. wx__DECLARE_EVT1(wxEVT_FIND, id, wxFindDialogEventHandler(fn))
  136. #define EVT_FIND_NEXT(id, fn) \
  137. wx__DECLARE_EVT1(wxEVT_FIND_NEXT, id, wxFindDialogEventHandler(fn))
  138. #define EVT_FIND_REPLACE(id, fn) \
  139. wx__DECLARE_EVT1(wxEVT_FIND_REPLACE, id, wxFindDialogEventHandler(fn))
  140. #define EVT_FIND_REPLACE_ALL(id, fn) \
  141. wx__DECLARE_EVT1(wxEVT_FIND_REPLACE_ALL, id, wxFindDialogEventHandler(fn))
  142. #define EVT_FIND_CLOSE(id, fn) \
  143. wx__DECLARE_EVT1(wxEVT_FIND_CLOSE, id, wxFindDialogEventHandler(fn))
  144. // old wxEVT_COMMAND_* constants
  145. #define wxEVT_COMMAND_FIND wxEVT_FIND
  146. #define wxEVT_COMMAND_FIND_NEXT wxEVT_FIND_NEXT
  147. #define wxEVT_COMMAND_FIND_REPLACE wxEVT_FIND_REPLACE
  148. #define wxEVT_COMMAND_FIND_REPLACE_ALL wxEVT_FIND_REPLACE_ALL
  149. #define wxEVT_COMMAND_FIND_CLOSE wxEVT_FIND_CLOSE
  150. #endif // wxUSE_FINDREPLDLG
  151. #endif
  152. // _WX_FDREPDLG_H