1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/msw/fdrepdlg.h
3 // Purpose: wxFindReplaceDialog class
4 // Author: Markus Greither
5 // Modified by: 31.07.01: VZ: integrated into wxWindows
8 // Copyright: (c) Markus Greither
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_FINDREPLACEDLG_H_
13 #define _WX_FINDREPLACEDLG_H_
16 #pragma interface "fdrepdlg.h"
23 #include "wx/dialog.h"
25 class WXDLLEXPORT wxFindReplaceDialog
;
26 class WXDLLEXPORT wxFindReplaceData
;
27 class WXDLLEXPORT wxFindReplaceDialogImpl
;
29 // ----------------------------------------------------------------------------
30 // Flags for wxFindReplaceData.Flags
31 // ----------------------------------------------------------------------------
33 // flages used by wxFindDialogEvent::GetFlags()
34 enum wxFindReplaceFlags
36 // downward search/replace selected (otherwise - upwards)
39 // whole word search/replace selected
42 // case sensitive search/replace selected (otherwise - case insensitive)
46 // these flags can be specified in wxFindReplaceDialog ctor or Create()
47 enum wxFindReplaceDialogStyles
49 // replace dialog (otherwise find dialog)
50 wxFR_REPLACEDIALOG
= 1,
52 // don't allow changing the search direction
55 // don't allow case sensitive searching
58 // don't allow whole word searching
62 // ----------------------------------------------------------------------------
63 // wxFindReplaceData: holds Setup Data/Feedback Data for wxFindReplaceDialog
64 // ----------------------------------------------------------------------------
66 class WXDLLEXPORT wxFindReplaceData
: public wxObject
69 wxFindReplaceData() { Init(); }
70 wxFindReplaceData(wxUint32 flags
) { Init(); SetFlags(flags
); }
73 const wxString
& GetFindString() { return m_FindWhat
; }
74 const wxString
& GetReplaceString() { return m_ReplaceWith
; }
76 int GetFlags() const { return m_Flags
; }
78 // setters: may only be called before showing the dialog, no effect later
79 void SetFlags(wxUint32 flags
) { m_Flags
= flags
; }
81 void SetFindString(const wxString
& str
) { m_FindWhat
= str
; }
82 void SetReplaceString(const wxString
& str
) { m_ReplaceWith
= str
; }
92 friend class wxFindReplaceDialog
;
95 // ----------------------------------------------------------------------------
96 // wxFindReplaceDialog: dialog for searching / replacing text
97 // ----------------------------------------------------------------------------
99 class WXDLLEXPORT wxFindReplaceDialog
: public wxDialog
103 wxFindReplaceDialog() { Init(); }
104 wxFindReplaceDialog(wxWindow
*parent
,
105 wxFindReplaceData
*data
,
106 const wxString
&title
,
109 bool Create(wxWindow
*parent
,
110 wxFindReplaceData
*data
,
111 const wxString
&title
,
114 virtual ~wxFindReplaceDialog();
116 // find dialog data access
117 const wxFindReplaceData
*GetData() const { return m_FindReplaceData
; }
118 void SetData(wxFindReplaceData
*data
);
120 // implementation only from now on
122 wxFindReplaceDialogImpl
*GetImpl() const { return m_impl
; }
124 // override some base class virtuals
125 virtual bool Show(bool show
= TRUE
);
126 virtual void SetTitle( const wxString
& title
);
127 virtual wxString
GetTitle() const;
130 virtual void DoGetSize(int *width
, int *height
) const;
131 virtual void DoGetClientSize(int *width
, int *height
) const;
132 virtual void DoSetSize(int x
, int y
,
133 int width
, int height
,
134 int sizeFlags
= wxSIZE_AUTO
);
138 wxFindReplaceData
*m_FindReplaceData
;
141 wxFindReplaceDialogImpl
*m_impl
;
143 DECLARE_DYNAMIC_CLASS(wxFindReplaceDialog
)
146 // ----------------------------------------------------------------------------
147 // wxFindReplaceDialog events
148 // ----------------------------------------------------------------------------
150 class WXDLLEXPORT wxFindDialogEvent
: public wxCommandEvent
153 wxFindDialogEvent(wxEventType commandType
= wxEVT_NULL
, int id
= 0)
154 : wxCommandEvent(commandType
, id
) { }
156 int GetFlags() const { return GetInt(); }
157 wxString
GetFindString() const { return GetString(); }
158 const wxString
& GetReplaceString() const { return m_strReplace
; }
160 wxFindReplaceDialog
*GetDialog() const
161 { return wxStaticCast(GetEventObject(), wxFindReplaceDialog
); }
163 // implementation only
164 void SetFlags(int flags
) { SetInt(flags
); }
165 void SetFindString(const wxString
& str
) { SetString(str
); }
166 void SetReplaceString(const wxString
& str
) { m_strReplace
= str
; }
169 wxString m_strReplace
;
171 DECLARE_DYNAMIC_CLASS(wxFindDialogEvent
)
174 BEGIN_DECLARE_EVENT_TYPES()
175 DECLARE_EVENT_TYPE(wxEVT_COMMAND_FIND
, 510)
176 DECLARE_EVENT_TYPE(wxEVT_COMMAND_FIND_NEXT
, 511)
177 DECLARE_EVENT_TYPE(wxEVT_COMMAND_FIND_REPLACE
, 512)
178 DECLARE_EVENT_TYPE(wxEVT_COMMAND_FIND_REPLACE_ALL
, 513)
179 DECLARE_EVENT_TYPE(wxEVT_COMMAND_FIND_CLOSE
, 514)
180 END_DECLARE_EVENT_TYPES()
182 typedef void (wxEvtHandler::*wxFindDialogEventFunction
)(wxFindDialogEvent
&);
184 #define EVT_FIND(id, fn) \
185 DECLARE_EVENT_TABLE_ENTRY( \
186 wxEVT_COMMAND_FIND, id, -1, \
187 (wxObjectEventFunction)(wxEventFunction)(wxFindDialogEventFunction) \
192 #define EVT_FIND_NEXT(id, fn) \
193 DECLARE_EVENT_TABLE_ENTRY( \
194 wxEVT_COMMAND_FIND_NEXT, id, -1, \
195 (wxObjectEventFunction)(wxEventFunction)(wxFindDialogEventFunction) \
200 #define EVT_FIND_REPLACE(id, fn) \
201 DECLARE_EVENT_TABLE_ENTRY( \
202 wxEVT_COMMAND_FIND_REPLACE, id, -1, \
203 (wxObjectEventFunction)(wxEventFunction)(wxFindDialogEventFunction) \
208 #define EVT_FIND_REPLACE_ALL(id, fn) \
209 DECLARE_EVENT_TABLE_ENTRY( \
210 wxEVT_COMMAND_FIND_REPLACE_ALL, id, -1, \
211 (wxObjectEventFunction)(wxEventFunction)(wxFindDialogEventFunction) \
216 #define EVT_FIND_CLOSE(id, fn) \
217 DECLARE_EVENT_TABLE_ENTRY( \
218 wxEVT_COMMAND_FIND_CLOSE, id, -1, \
219 (wxObjectEventFunction)(wxEventFunction)(wxFindDialogEventFunction) \
224 #endif // wxUSE_FINDREPLDLG