started applying patch 410826
[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() { }
70 wxFindReplaceData(wxUint32 flags) { 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 private:
85 wxUint32 m_Flags;
86 wxString m_FindWhat,
87 m_ReplaceWith;
88
89 friend class wxFindReplaceDialog;
90 };
91
92 // ----------------------------------------------------------------------------
93 // wxFindReplaceDialog: dialog for searching / replacing text
94 // ----------------------------------------------------------------------------
95
96 class WXDLLEXPORT wxFindReplaceDialog : public wxDialog
97 {
98 public:
99 // ctors and such
100 wxFindReplaceDialog() { Init(); }
101 wxFindReplaceDialog(wxWindow *parent,
102 wxFindReplaceData *data,
103 const wxString &title);
104
105 bool Create(wxWindow *parent,
106 wxFindReplaceData *data,
107 const wxString &title);
108
109 virtual ~wxFindReplaceDialog();
110
111 // find dialog data access
112 const wxFindReplaceData *GetData() const { return m_FindReplaceData; }
113 void SetData(wxFindReplaceData *data);
114
115 // implementation only from now on
116
117 wxFindReplaceDialogImpl *GetImpl() const { return m_impl; }
118
119 // override some base class virtuals
120 virtual bool Show(bool show);
121 virtual void SetTitle( const wxString& title);
122 virtual wxString GetTitle() const;
123
124 protected:
125 virtual void DoGetSize(int *width, int *height) const;
126 virtual void DoGetClientSize(int *width, int *height) const;
127 virtual void DoSetSize(int x, int y,
128 int width, int height,
129 int sizeFlags = wxSIZE_AUTO);
130
131 void Init();
132
133 wxFindReplaceData *m_FindReplaceData;
134 wxString m_title;
135
136 wxFindReplaceDialogImpl *m_impl;
137
138 DECLARE_DYNAMIC_CLASS(wxFindReplaceDialog)
139 };
140
141 // ----------------------------------------------------------------------------
142 // wxFindReplaceDialog events
143 // ----------------------------------------------------------------------------
144
145 class WXDLLEXPORT wxFindDialogEvent : public wxCommandEvent
146 {
147 public:
148 wxFindDialogEvent(wxEventType commandType = wxEVT_NULL, int id = 0)
149 : wxCommandEvent(commandType, id) { }
150
151 int GetFlags() const { return GetInt(); }
152 wxString GetFindString() const { return GetString(); }
153 const wxString& GetReplaceString() const { return m_strReplace; }
154
155 // implementation only
156 void SetFlags(int flags) { SetInt(flags); }
157 void SetFindString(const wxString& str) { SetString(str); }
158 void SetReplaceString(const wxString& str) { m_strReplace = str; }
159
160 private:
161 wxString m_strReplace;
162
163 DECLARE_DYNAMIC_CLASS(wxFindDialogEvent)
164 };
165
166 BEGIN_DECLARE_EVENT_TYPES()
167 DECLARE_EVENT_TYPE(wxEVT_COMMAND_FIND_NEXT, 510)
168 DECLARE_EVENT_TYPE(wxEVT_COMMAND_REPLACE, 511)
169 DECLARE_EVENT_TYPE(wxEVT_COMMAND_REPLACE_ALL, 512)
170 DECLARE_EVENT_TYPE(wxEVT_COMMAND_FIND_CLOSE, 513)
171 END_DECLARE_EVENT_TYPES()
172
173 typedef void (wxEvtHandler::*wxFindDialogEventFunction)(wxFindDialogEvent&);
174
175 #define EVT_FIND_NEXT(id, fn) \
176 DECLARE_EVENT_TABLE_ENTRY( \
177 wxEVT_COMMAND_FIND_NEXT, id, -1, \
178 (wxObjectEventFunction)(wxEventFunction)(wxFindDialogEventFunction) \
179 & fn, \
180 (wxObject *) NULL \
181 ),
182
183 #define EVT_REPLACE(id, fn) \
184 DECLARE_EVENT_TABLE_ENTRY( \
185 wxEVT_COMMAND_REPLACE, id, -1, \
186 (wxObjectEventFunction)(wxEventFunction)(wxFindDialogEventFunction) \
187 & fn, \
188 (wxObject *) NULL \
189 ),
190
191 #define EVT_FIND_REPLACE_ALL(id, fn) \
192 DECLARE_EVENT_TABLE_ENTRY( \
193 wxEVT_COMMAND_REPLACE_ALL, id, -1, \
194 (wxObjectEventFunction)(wxEventFunction)(wxFindDialogEventFunction) \
195 & fn, \
196 (wxObject *) NULL \
197 ),
198
199 #define EVT_FIND_FIND_CLOSE(id, fn) \
200 DECLARE_EVENT_TABLE_ENTRY( \
201 wxEVT_COMMAND_FIND_CLOSE, id, -1, \
202 (wxObjectEventFunction)(wxEventFunction)(wxFindDialogEventFunction) \
203 & fn, \
204 (wxObject *) NULL \
205 ),
206
207 #endif // wxUSE_FINDREPLDLG
208
209 #endif
210 // _WX_FDREPDLG_H