1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxFindReplaceDialog class
4 // Author: Markus Greither and Vadim Zeitlin
8 // Copyright: (c) Markus Greither
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_FINDREPLACEDLG_H_
13 #define _WX_FINDREPLACEDLG_H_
15 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
16 #pragma interface "fdrepdlg.h"
23 #include "wx/dialog.h"
25 class WXDLLEXPORT wxFindDialogEvent
;
26 class WXDLLEXPORT wxFindReplaceDialog
;
27 class WXDLLEXPORT wxFindReplaceData
;
28 class WXDLLEXPORT wxFindReplaceDialogImpl
;
30 // ----------------------------------------------------------------------------
31 // Flags for wxFindReplaceData.Flags
32 // ----------------------------------------------------------------------------
34 // flages used by wxFindDialogEvent::GetFlags()
35 enum wxFindReplaceFlags
37 // downward search/replace selected (otherwise - upwards)
40 // whole word search/replace selected
43 // case sensitive search/replace selected (otherwise - case insensitive)
47 // these flags can be specified in wxFindReplaceDialog ctor or Create()
48 enum wxFindReplaceDialogStyles
50 // replace dialog (otherwise find dialog)
51 wxFR_REPLACEDIALOG
= 1,
53 // don't allow changing the search direction
56 // don't allow case sensitive searching
59 // don't allow whole word searching
63 // ----------------------------------------------------------------------------
64 // wxFindReplaceData: holds Setup Data/Feedback Data for wxFindReplaceDialog
65 // ----------------------------------------------------------------------------
67 class WXDLLEXPORT wxFindReplaceData
: public wxObject
70 wxFindReplaceData() { Init(); }
71 wxFindReplaceData(wxUint32 flags
) { Init(); SetFlags(flags
); }
74 const wxString
& GetFindString() { return m_FindWhat
; }
75 const wxString
& GetReplaceString() { return m_ReplaceWith
; }
77 int GetFlags() const { return m_Flags
; }
79 // setters: may only be called before showing the dialog, no effect later
80 void SetFlags(wxUint32 flags
) { m_Flags
= flags
; }
82 void SetFindString(const wxString
& str
) { m_FindWhat
= str
; }
83 void SetReplaceString(const wxString
& str
) { m_ReplaceWith
= str
; }
93 friend class wxFindReplaceDialogBase
;
96 // ----------------------------------------------------------------------------
97 // wxFindReplaceDialogBase
98 // ----------------------------------------------------------------------------
100 class WXDLLEXPORT wxFindReplaceDialogBase
: public wxDialog
104 wxFindReplaceDialogBase() { m_FindReplaceData
= NULL
; }
105 wxFindReplaceDialogBase(wxWindow
* WXUNUSED(parent
),
106 wxFindReplaceData
*data
,
107 const wxString
& WXUNUSED(title
),
108 int WXUNUSED(style
) = 0)
110 m_FindReplaceData
= data
;
113 virtual ~wxFindReplaceDialogBase();
115 // find dialog data access
116 const wxFindReplaceData
*GetData() const { return m_FindReplaceData
; }
117 void SetData(wxFindReplaceData
*data
) { m_FindReplaceData
= data
; }
119 // implementation only, don't use
120 void Send(wxFindDialogEvent
& event
);
123 wxFindReplaceData
*m_FindReplaceData
;
125 // the last string we searched for
126 wxString m_lastSearch
;
128 DECLARE_NO_COPY_CLASS(wxFindReplaceDialogBase
)
131 // include wxFindReplaceDialog declaration
132 #if defined(__WXMSW__) && !defined(__WXUNIVERSAL__) && !defined(__WXWINCE__)
133 #include "wx/msw/fdrepdlg.h"
135 #define wxGenericFindReplaceDialog wxFindReplaceDialog
137 #include "wx/generic/fdrepdlg.h"
140 // ----------------------------------------------------------------------------
141 // wxFindReplaceDialog events
142 // ----------------------------------------------------------------------------
144 class WXDLLEXPORT wxFindDialogEvent
: public wxCommandEvent
147 wxFindDialogEvent(wxEventType commandType
= wxEVT_NULL
, int id
= 0)
148 : wxCommandEvent(commandType
, id
) { }
150 int GetFlags() const { return GetInt(); }
151 wxString
GetFindString() const { return GetString(); }
152 const wxString
& GetReplaceString() const { return m_strReplace
; }
154 wxFindReplaceDialog
*GetDialog() const
155 { return wxStaticCast(GetEventObject(), wxFindReplaceDialog
); }
157 // implementation only
158 void SetFlags(int flags
) { SetInt(flags
); }
159 void SetFindString(const wxString
& str
) { SetString(str
); }
160 void SetReplaceString(const wxString
& str
) { m_strReplace
= str
; }
163 wxString m_strReplace
;
165 DECLARE_DYNAMIC_CLASS_NO_COPY(wxFindDialogEvent
)
168 BEGIN_DECLARE_EVENT_TYPES()
169 DECLARE_EVENT_TYPE(wxEVT_COMMAND_FIND
, 510)
170 DECLARE_EVENT_TYPE(wxEVT_COMMAND_FIND_NEXT
, 511)
171 DECLARE_EVENT_TYPE(wxEVT_COMMAND_FIND_REPLACE
, 512)
172 DECLARE_EVENT_TYPE(wxEVT_COMMAND_FIND_REPLACE_ALL
, 513)
173 DECLARE_EVENT_TYPE(wxEVT_COMMAND_FIND_CLOSE
, 514)
174 END_DECLARE_EVENT_TYPES()
176 typedef void (wxEvtHandler::*wxFindDialogEventFunction
)(wxFindDialogEvent
&);
178 #define EVT_FIND(id, fn) \
179 DECLARE_EVENT_TABLE_ENTRY( \
180 wxEVT_COMMAND_FIND, id, -1, \
181 (wxObjectEventFunction)(wxEventFunction)(wxFindDialogEventFunction) \
186 #define EVT_FIND_NEXT(id, fn) \
187 DECLARE_EVENT_TABLE_ENTRY( \
188 wxEVT_COMMAND_FIND_NEXT, id, -1, \
189 (wxObjectEventFunction)(wxEventFunction)(wxFindDialogEventFunction) \
194 #define EVT_FIND_REPLACE(id, fn) \
195 DECLARE_EVENT_TABLE_ENTRY( \
196 wxEVT_COMMAND_FIND_REPLACE, id, -1, \
197 (wxObjectEventFunction)(wxEventFunction)(wxFindDialogEventFunction) \
202 #define EVT_FIND_REPLACE_ALL(id, fn) \
203 DECLARE_EVENT_TABLE_ENTRY( \
204 wxEVT_COMMAND_FIND_REPLACE_ALL, id, -1, \
205 (wxObjectEventFunction)(wxEventFunction)(wxFindDialogEventFunction) \
210 #define EVT_FIND_CLOSE(id, fn) \
211 DECLARE_EVENT_TABLE_ENTRY( \
212 wxEVT_COMMAND_FIND_CLOSE, id, -1, \
213 (wxObjectEventFunction)(wxEventFunction)(wxFindDialogEventFunction) \
218 #endif // wxUSE_FINDREPLDLG