1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxFindReplaceDialog class
4 // Author: Markus Greither and Vadim Zeitlin
7 // Copyright: (c) Markus Greither
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
11 #ifndef _WX_FINDREPLACEDLG_H_
12 #define _WX_FINDREPLACEDLG_H_
18 #include "wx/dialog.h"
20 class WXDLLIMPEXP_FWD_CORE wxFindDialogEvent
;
21 class WXDLLIMPEXP_FWD_CORE wxFindReplaceDialog
;
22 class WXDLLIMPEXP_FWD_CORE wxFindReplaceData
;
23 class WXDLLIMPEXP_FWD_CORE wxFindReplaceDialogImpl
;
25 // ----------------------------------------------------------------------------
26 // Flags for wxFindReplaceData.Flags
27 // ----------------------------------------------------------------------------
29 // flages used by wxFindDialogEvent::GetFlags()
30 enum wxFindReplaceFlags
32 // downward search/replace selected (otherwise - upwards)
35 // whole word search/replace selected
38 // case sensitive search/replace selected (otherwise - case insensitive)
42 // these flags can be specified in wxFindReplaceDialog ctor or Create()
43 enum wxFindReplaceDialogStyles
45 // replace dialog (otherwise find dialog)
46 wxFR_REPLACEDIALOG
= 1,
48 // don't allow changing the search direction
51 // don't allow case sensitive searching
54 // don't allow whole word searching
58 // ----------------------------------------------------------------------------
59 // wxFindReplaceData: holds Setup Data/Feedback Data for wxFindReplaceDialog
60 // ----------------------------------------------------------------------------
62 class WXDLLIMPEXP_CORE wxFindReplaceData
: public wxObject
65 wxFindReplaceData() { Init(); }
66 wxFindReplaceData(wxUint32 flags
) { Init(); SetFlags(flags
); }
69 const wxString
& GetFindString() const { return m_FindWhat
; }
70 const wxString
& GetReplaceString() const { return m_ReplaceWith
; }
72 int GetFlags() const { return m_Flags
; }
74 // setters: may only be called before showing the dialog, no effect later
75 void SetFlags(wxUint32 flags
) { m_Flags
= flags
; }
77 void SetFindString(const wxString
& str
) { m_FindWhat
= str
; }
78 void SetReplaceString(const wxString
& str
) { m_ReplaceWith
= str
; }
88 friend class wxFindReplaceDialogBase
;
91 // ----------------------------------------------------------------------------
92 // wxFindReplaceDialogBase
93 // ----------------------------------------------------------------------------
95 class WXDLLIMPEXP_CORE wxFindReplaceDialogBase
: public wxDialog
99 wxFindReplaceDialogBase() { m_FindReplaceData
= NULL
; }
100 wxFindReplaceDialogBase(wxWindow
* WXUNUSED(parent
),
101 wxFindReplaceData
*data
,
102 const wxString
& WXUNUSED(title
),
103 int WXUNUSED(style
) = 0)
105 m_FindReplaceData
= data
;
108 virtual ~wxFindReplaceDialogBase();
110 // find dialog data access
111 const wxFindReplaceData
*GetData() const { return m_FindReplaceData
; }
112 void SetData(wxFindReplaceData
*data
) { m_FindReplaceData
= data
; }
114 // implementation only, don't use
115 void Send(wxFindDialogEvent
& event
);
118 wxFindReplaceData
*m_FindReplaceData
;
120 // the last string we searched for
121 wxString m_lastSearch
;
123 wxDECLARE_NO_COPY_CLASS(wxFindReplaceDialogBase
);
126 // include wxFindReplaceDialog declaration
127 #if defined(__WXMSW__) && !defined(__WXUNIVERSAL__) && !defined(__WXWINCE__)
128 #include "wx/msw/fdrepdlg.h"
130 #define wxGenericFindReplaceDialog wxFindReplaceDialog
132 #include "wx/generic/fdrepdlg.h"
135 // ----------------------------------------------------------------------------
136 // wxFindReplaceDialog events
137 // ----------------------------------------------------------------------------
139 class WXDLLIMPEXP_CORE wxFindDialogEvent
: public wxCommandEvent
142 wxFindDialogEvent(wxEventType commandType
= wxEVT_NULL
, int id
= 0)
143 : wxCommandEvent(commandType
, id
) { }
144 wxFindDialogEvent(const wxFindDialogEvent
& event
)
145 : wxCommandEvent(event
), m_strReplace(event
.m_strReplace
) { }
147 int GetFlags() const { return GetInt(); }
148 wxString
GetFindString() const { return GetString(); }
149 const wxString
& GetReplaceString() const { return m_strReplace
; }
151 wxFindReplaceDialog
*GetDialog() const
152 { return wxStaticCast(GetEventObject(), wxFindReplaceDialog
); }
154 // implementation only
155 void SetFlags(int flags
) { SetInt(flags
); }
156 void SetFindString(const wxString
& str
) { SetString(str
); }
157 void SetReplaceString(const wxString
& str
) { m_strReplace
= str
; }
159 virtual wxEvent
*Clone() const { return new wxFindDialogEvent(*this); }
162 wxString m_strReplace
;
164 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxFindDialogEvent
)
167 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE
, wxEVT_FIND
, wxFindDialogEvent
);
168 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE
, wxEVT_FIND_NEXT
, wxFindDialogEvent
);
169 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE
, wxEVT_FIND_REPLACE
, wxFindDialogEvent
);
170 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE
, wxEVT_FIND_REPLACE_ALL
, wxFindDialogEvent
);
171 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE
, wxEVT_FIND_CLOSE
, wxFindDialogEvent
);
173 typedef void (wxEvtHandler::*wxFindDialogEventFunction
)(wxFindDialogEvent
&);
175 #define wxFindDialogEventHandler(func) \
176 wxEVENT_HANDLER_CAST(wxFindDialogEventFunction, func)
178 #define EVT_FIND(id, fn) \
179 wx__DECLARE_EVT1(wxEVT_FIND, id, wxFindDialogEventHandler(fn))
181 #define EVT_FIND_NEXT(id, fn) \
182 wx__DECLARE_EVT1(wxEVT_FIND_NEXT, id, wxFindDialogEventHandler(fn))
184 #define EVT_FIND_REPLACE(id, fn) \
185 wx__DECLARE_EVT1(wxEVT_FIND_REPLACE, id, wxFindDialogEventHandler(fn))
187 #define EVT_FIND_REPLACE_ALL(id, fn) \
188 wx__DECLARE_EVT1(wxEVT_FIND_REPLACE_ALL, id, wxFindDialogEventHandler(fn))
190 #define EVT_FIND_CLOSE(id, fn) \
191 wx__DECLARE_EVT1(wxEVT_FIND_CLOSE, id, wxFindDialogEventHandler(fn))
193 // old wxEVT_COMMAND_* constants
194 #define wxEVT_COMMAND_FIND wxEVT_FIND
195 #define wxEVT_COMMAND_FIND_NEXT wxEVT_FIND_NEXT
196 #define wxEVT_COMMAND_FIND_REPLACE wxEVT_FIND_REPLACE
197 #define wxEVT_COMMAND_FIND_REPLACE_ALL wxEVT_FIND_REPLACE_ALL
198 #define wxEVT_COMMAND_FIND_CLOSE wxEVT_FIND_CLOSE
200 #endif // wxUSE_FINDREPLDLG