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_
19 #include "wx/dialog.h"
21 class WXDLLEXPORT wxFindDialogEvent
;
22 class WXDLLEXPORT wxFindReplaceDialog
;
23 class WXDLLEXPORT wxFindReplaceData
;
24 class WXDLLEXPORT wxFindReplaceDialogImpl
;
26 // ----------------------------------------------------------------------------
27 // Flags for wxFindReplaceData.Flags
28 // ----------------------------------------------------------------------------
30 // flages used by wxFindDialogEvent::GetFlags()
31 enum wxFindReplaceFlags
33 // downward search/replace selected (otherwise - upwards)
36 // whole word search/replace selected
39 // case sensitive search/replace selected (otherwise - case insensitive)
43 // these flags can be specified in wxFindReplaceDialog ctor or Create()
44 enum wxFindReplaceDialogStyles
46 // replace dialog (otherwise find dialog)
47 wxFR_REPLACEDIALOG
= 1,
49 // don't allow changing the search direction
52 // don't allow case sensitive searching
55 // don't allow whole word searching
59 // ----------------------------------------------------------------------------
60 // wxFindReplaceData: holds Setup Data/Feedback Data for wxFindReplaceDialog
61 // ----------------------------------------------------------------------------
63 class WXDLLEXPORT wxFindReplaceData
: public wxObject
66 wxFindReplaceData() { Init(); }
67 wxFindReplaceData(wxUint32 flags
) { Init(); SetFlags(flags
); }
70 const wxString
& GetFindString() { return m_FindWhat
; }
71 const wxString
& GetReplaceString() { return m_ReplaceWith
; }
73 int GetFlags() const { return m_Flags
; }
75 // setters: may only be called before showing the dialog, no effect later
76 void SetFlags(wxUint32 flags
) { m_Flags
= flags
; }
78 void SetFindString(const wxString
& str
) { m_FindWhat
= str
; }
79 void SetReplaceString(const wxString
& str
) { m_ReplaceWith
= str
; }
89 friend class wxFindReplaceDialogBase
;
92 // ----------------------------------------------------------------------------
93 // wxFindReplaceDialogBase
94 // ----------------------------------------------------------------------------
96 class WXDLLEXPORT wxFindReplaceDialogBase
: public wxDialog
100 wxFindReplaceDialogBase() { m_FindReplaceData
= NULL
; }
101 wxFindReplaceDialogBase(wxWindow
* WXUNUSED(parent
),
102 wxFindReplaceData
*data
,
103 const wxString
& WXUNUSED(title
),
104 int WXUNUSED(style
) = 0)
106 m_FindReplaceData
= data
;
109 virtual ~wxFindReplaceDialogBase();
111 // find dialog data access
112 const wxFindReplaceData
*GetData() const { return m_FindReplaceData
; }
113 void SetData(wxFindReplaceData
*data
) { m_FindReplaceData
= data
; }
115 // implementation only, don't use
116 void Send(wxFindDialogEvent
& event
);
119 wxFindReplaceData
*m_FindReplaceData
;
121 // the last string we searched for
122 wxString m_lastSearch
;
124 DECLARE_NO_COPY_CLASS(wxFindReplaceDialogBase
)
127 // include wxFindReplaceDialog declaration
128 #if defined(__WXMSW__) && !defined(__WXUNIVERSAL__) && !defined(__WXWINCE__)
129 #include "wx/msw/fdrepdlg.h"
131 #define wxGenericFindReplaceDialog wxFindReplaceDialog
133 #include "wx/generic/fdrepdlg.h"
136 // ----------------------------------------------------------------------------
137 // wxFindReplaceDialog events
138 // ----------------------------------------------------------------------------
140 class WXDLLEXPORT wxFindDialogEvent
: public wxCommandEvent
143 wxFindDialogEvent(wxEventType commandType
= wxEVT_NULL
, int id
= 0)
144 : wxCommandEvent(commandType
, id
) { }
146 int GetFlags() const { return GetInt(); }
147 wxString
GetFindString() const { return GetString(); }
148 const wxString
& GetReplaceString() const { return m_strReplace
; }
150 wxFindReplaceDialog
*GetDialog() const
151 { return wxStaticCast(GetEventObject(), wxFindReplaceDialog
); }
153 // implementation only
154 void SetFlags(int flags
) { SetInt(flags
); }
155 void SetFindString(const wxString
& str
) { SetString(str
); }
156 void SetReplaceString(const wxString
& str
) { m_strReplace
= str
; }
159 wxString m_strReplace
;
161 DECLARE_DYNAMIC_CLASS_NO_COPY(wxFindDialogEvent
)
164 BEGIN_DECLARE_EVENT_TYPES()
165 DECLARE_EVENT_TYPE(wxEVT_COMMAND_FIND
, 510)
166 DECLARE_EVENT_TYPE(wxEVT_COMMAND_FIND_NEXT
, 511)
167 DECLARE_EVENT_TYPE(wxEVT_COMMAND_FIND_REPLACE
, 512)
168 DECLARE_EVENT_TYPE(wxEVT_COMMAND_FIND_REPLACE_ALL
, 513)
169 DECLARE_EVENT_TYPE(wxEVT_COMMAND_FIND_CLOSE
, 514)
170 END_DECLARE_EVENT_TYPES()
172 typedef void (wxEvtHandler::*wxFindDialogEventFunction
)(wxFindDialogEvent
&);
174 #define wxFindDialogEventHandler(func) \
175 (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxFindDialogEventFunction, &func)
177 #define EVT_FIND(id, fn) \
178 wx__DECLARE_EVT1(wxEVT_COMMAND_FIND, id, wxFindDialogEventHandler(fn))
180 #define EVT_FIND_NEXT(id, fn) \
181 wx__DECLARE_EVT1(wxEVT_COMMAND_FIND_NEXT, id, wxFindDialogEventHandler(fn))
183 #define EVT_FIND_REPLACE(id, fn) \
184 wx__DECLARE_EVT1(wxEVT_COMMAND_FIND_REPLACE, id, wxFindDialogEventHandler(fn))
186 #define EVT_FIND_REPLACE_ALL(id, fn) \
187 wx__DECLARE_EVT1(wxEVT_COMMAND_FIND_REPLACE_ALL, id, wxFindDialogEventHandler(fn))
189 #define EVT_FIND_CLOSE(id, fn) \
190 wx__DECLARE_EVT1(wxEVT_COMMAND_FIND_CLOSE, id, wxFindDialogEventHandler(fn))
192 #endif // wxUSE_FINDREPLDLG