Vain attempts to make kbd navigation work inside find/replace dialog - it
[wxWidgets.git] / include / wx / fdrepdlg.h
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
6 // Created: 23/03/2001
7 // RCS-ID:
8 // Copyright: (c) Markus Greither
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_FINDREPLACEDLG_H_
13 #define _WX_FINDREPLACEDLG_H_
14
15 #ifdef __GNUG__
16 #pragma interface "fdrepdlg.h"
17 #endif
18
19 #include "wx/defs.h"
20
21 #if wxUSE_FINDREPLDLG
22
23 #include "wx/dialog.h"
24
25 class WXDLLEXPORT wxFindReplaceDialog;
26 class WXDLLEXPORT wxFindReplaceData;
27 class WXDLLEXPORT wxFindReplaceDialogImpl;
28
29 // ----------------------------------------------------------------------------
30 // Flags for wxFindReplaceData.Flags
31 // ----------------------------------------------------------------------------
32
33 // flages used by wxFindDialogEvent::GetFlags()
34 enum wxFindReplaceFlags
35 {
36 // downward search/replace selected (otherwise - upwards)
37 wxFR_DOWN = 1,
38
39 // whole word search/replace selected
40 wxFR_WHOLEWORD = 2,
41
42 // case sensitive search/replace selected (otherwise - case insensitive)
43 wxFR_MATCHCASE = 4
44 };
45
46 // these flags can be specified in wxFindReplaceDialog ctor or Create()
47 enum wxFindReplaceDialogStyles
48 {
49 // replace dialog (otherwise find dialog)
50 wxFR_REPLACEDIALOG = 1,
51
52 // don't allow changing the search direction
53 wxFR_NOUPDOWN = 2,
54
55 // don't allow case sensitive searching
56 wxFR_NOMATCHCASE = 4,
57
58 // don't allow whole word searching
59 wxFR_NOWHOLEWORD = 8
60 };
61
62 // ----------------------------------------------------------------------------
63 // wxFindReplaceData: holds Setup Data/Feedback Data for wxFindReplaceDialog
64 // ----------------------------------------------------------------------------
65
66 class WXDLLEXPORT wxFindReplaceData : public wxObject
67 {
68 public:
69 wxFindReplaceData() { Init(); }
70 wxFindReplaceData(wxUint32 flags) { Init(); SetFlags(flags); }
71
72 // accessors
73 const wxString& GetFindString() { return m_FindWhat; }
74 const wxString& GetReplaceString() { return m_ReplaceWith; }
75
76 int GetFlags() const { return m_Flags; }
77
78 // setters: may only be called before showing the dialog, no effect later
79 void SetFlags(wxUint32 flags) { m_Flags = flags; }
80
81 void SetFindString(const wxString& str) { m_FindWhat = str; }
82 void SetReplaceString(const wxString& str) { m_ReplaceWith = str; }
83
84 protected:
85 void Init();
86
87 private:
88 wxUint32 m_Flags;
89 wxString m_FindWhat,
90 m_ReplaceWith;
91
92 friend class wxFindReplaceDialog;
93 };
94
95 // ----------------------------------------------------------------------------
96 // wxFindReplaceDialog: dialog for searching / replacing text
97 // ----------------------------------------------------------------------------
98
99 class WXDLLEXPORT wxFindReplaceDialog : public wxDialog
100 {
101 public:
102 // ctors and such
103 wxFindReplaceDialog() { Init(); }
104 wxFindReplaceDialog(wxWindow *parent,
105 wxFindReplaceData *data,
106 const wxString &title,
107 int style = 0);
108
109 bool Create(wxWindow *parent,
110 wxFindReplaceData *data,
111 const wxString &title,
112 int style = 0);
113
114 virtual ~wxFindReplaceDialog();
115
116 // find dialog data access
117 const wxFindReplaceData *GetData() const { return m_FindReplaceData; }
118 void SetData(wxFindReplaceData *data);
119
120 // implementation only from now on
121
122 wxFindReplaceDialogImpl *GetImpl() const { return m_impl; }
123
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;
128
129 protected:
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);
135
136 void Init();
137
138 wxFindReplaceData *m_FindReplaceData;
139 wxString m_title;
140
141 wxFindReplaceDialogImpl *m_impl;
142
143 DECLARE_DYNAMIC_CLASS(wxFindReplaceDialog)
144 };
145
146 // ----------------------------------------------------------------------------
147 // wxFindReplaceDialog events
148 // ----------------------------------------------------------------------------
149
150 class WXDLLEXPORT wxFindDialogEvent : public wxCommandEvent
151 {
152 public:
153 wxFindDialogEvent(wxEventType commandType = wxEVT_NULL, int id = 0)
154 : wxCommandEvent(commandType, id) { }
155
156 int GetFlags() const { return GetInt(); }
157 wxString GetFindString() const { return GetString(); }
158 const wxString& GetReplaceString() const { return m_strReplace; }
159
160 wxFindReplaceDialog *GetDialog() const
161 { return wxStaticCast(GetEventObject(), wxFindReplaceDialog); }
162
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; }
167
168 private:
169 wxString m_strReplace;
170
171 DECLARE_DYNAMIC_CLASS(wxFindDialogEvent)
172 };
173
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()
181
182 typedef void (wxEvtHandler::*wxFindDialogEventFunction)(wxFindDialogEvent&);
183
184 #define EVT_FIND(id, fn) \
185 DECLARE_EVENT_TABLE_ENTRY( \
186 wxEVT_COMMAND_FIND, id, -1, \
187 (wxObjectEventFunction)(wxEventFunction)(wxFindDialogEventFunction) \
188 & fn, \
189 (wxObject *) NULL \
190 ),
191
192 #define EVT_FIND_NEXT(id, fn) \
193 DECLARE_EVENT_TABLE_ENTRY( \
194 wxEVT_COMMAND_FIND_NEXT, id, -1, \
195 (wxObjectEventFunction)(wxEventFunction)(wxFindDialogEventFunction) \
196 & fn, \
197 (wxObject *) NULL \
198 ),
199
200 #define EVT_FIND_REPLACE(id, fn) \
201 DECLARE_EVENT_TABLE_ENTRY( \
202 wxEVT_COMMAND_FIND_REPLACE, id, -1, \
203 (wxObjectEventFunction)(wxEventFunction)(wxFindDialogEventFunction) \
204 & fn, \
205 (wxObject *) NULL \
206 ),
207
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) \
212 & fn, \
213 (wxObject *) NULL \
214 ),
215
216 #define EVT_FIND_CLOSE(id, fn) \
217 DECLARE_EVENT_TABLE_ENTRY( \
218 wxEVT_COMMAND_FIND_CLOSE, id, -1, \
219 (wxObjectEventFunction)(wxEventFunction)(wxFindDialogEventFunction) \
220 & fn, \
221 (wxObject *) NULL \
222 ),
223
224 #endif // wxUSE_FINDREPLDLG
225
226 #endif
227 // _WX_FDREPDLG_H