]>
Commit | Line | Data |
---|---|---|
c41b00c9 | 1 | ///////////////////////////////////////////////////////////////////////////// |
8db37e06 | 2 | // Name: wx/fdrepdlg.h |
c41b00c9 | 3 | // Purpose: wxFindReplaceDialog class |
8db37e06 VZ |
4 | // Author: Markus Greither and Vadim Zeitlin |
5 | // Modified by: | |
c41b00c9 VZ |
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 | ||
12028905 | 15 | #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) |
c41b00c9 VZ |
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 | ||
8db37e06 | 25 | class WXDLLEXPORT wxFindDialogEvent; |
c41b00c9 VZ |
26 | class WXDLLEXPORT wxFindReplaceDialog; |
27 | class WXDLLEXPORT wxFindReplaceData; | |
28 | class WXDLLEXPORT wxFindReplaceDialogImpl; | |
29 | ||
30 | // ---------------------------------------------------------------------------- | |
31 | // Flags for wxFindReplaceData.Flags | |
32 | // ---------------------------------------------------------------------------- | |
33 | ||
34 | // flages used by wxFindDialogEvent::GetFlags() | |
35 | enum wxFindReplaceFlags | |
36 | { | |
37 | // downward search/replace selected (otherwise - upwards) | |
38 | wxFR_DOWN = 1, | |
39 | ||
40 | // whole word search/replace selected | |
8db37e06 | 41 | wxFR_WHOLEWORD = 2, |
c41b00c9 VZ |
42 | |
43 | // case sensitive search/replace selected (otherwise - case insensitive) | |
44 | wxFR_MATCHCASE = 4 | |
45 | }; | |
46 | ||
47 | // these flags can be specified in wxFindReplaceDialog ctor or Create() | |
48 | enum wxFindReplaceDialogStyles | |
49 | { | |
50 | // replace dialog (otherwise find dialog) | |
51 | wxFR_REPLACEDIALOG = 1, | |
52 | ||
53 | // don't allow changing the search direction | |
54 | wxFR_NOUPDOWN = 2, | |
55 | ||
56 | // don't allow case sensitive searching | |
57 | wxFR_NOMATCHCASE = 4, | |
58 | ||
59 | // don't allow whole word searching | |
60 | wxFR_NOWHOLEWORD = 8 | |
61 | }; | |
62 | ||
63 | // ---------------------------------------------------------------------------- | |
64 | // wxFindReplaceData: holds Setup Data/Feedback Data for wxFindReplaceDialog | |
65 | // ---------------------------------------------------------------------------- | |
66 | ||
67 | class WXDLLEXPORT wxFindReplaceData : public wxObject | |
68 | { | |
69 | public: | |
761989ff VZ |
70 | wxFindReplaceData() { Init(); } |
71 | wxFindReplaceData(wxUint32 flags) { Init(); SetFlags(flags); } | |
c41b00c9 VZ |
72 | |
73 | // accessors | |
74 | const wxString& GetFindString() { return m_FindWhat; } | |
75 | const wxString& GetReplaceString() { return m_ReplaceWith; } | |
76 | ||
77 | int GetFlags() const { return m_Flags; } | |
78 | ||
79 | // setters: may only be called before showing the dialog, no effect later | |
80 | void SetFlags(wxUint32 flags) { m_Flags = flags; } | |
81 | ||
82 | void SetFindString(const wxString& str) { m_FindWhat = str; } | |
83 | void SetReplaceString(const wxString& str) { m_ReplaceWith = str; } | |
84 | ||
761989ff VZ |
85 | protected: |
86 | void Init(); | |
87 | ||
c41b00c9 VZ |
88 | private: |
89 | wxUint32 m_Flags; | |
90 | wxString m_FindWhat, | |
91 | m_ReplaceWith; | |
92 | ||
8db37e06 | 93 | friend class wxFindReplaceDialogBase; |
c41b00c9 VZ |
94 | }; |
95 | ||
96 | // ---------------------------------------------------------------------------- | |
8db37e06 | 97 | // wxFindReplaceDialogBase |
c41b00c9 VZ |
98 | // ---------------------------------------------------------------------------- |
99 | ||
8db37e06 | 100 | class WXDLLEXPORT wxFindReplaceDialogBase : public wxDialog |
c41b00c9 VZ |
101 | { |
102 | public: | |
103 | // ctors and such | |
8db37e06 VZ |
104 | wxFindReplaceDialogBase() { m_FindReplaceData = NULL; } |
105 | wxFindReplaceDialogBase(wxWindow * WXUNUSED(parent), | |
106 | wxFindReplaceData *data, | |
107 | const wxString& WXUNUSED(title), | |
108 | int WXUNUSED(style) = 0) | |
109 | { | |
110 | m_FindReplaceData = data; | |
111 | } | |
c41b00c9 | 112 | |
8db37e06 | 113 | virtual ~wxFindReplaceDialogBase(); |
c41b00c9 VZ |
114 | |
115 | // find dialog data access | |
116 | const wxFindReplaceData *GetData() const { return m_FindReplaceData; } | |
8db37e06 | 117 | void SetData(wxFindReplaceData *data) { m_FindReplaceData = data; } |
c41b00c9 | 118 | |
8db37e06 VZ |
119 | // implementation only, don't use |
120 | void Send(wxFindDialogEvent& event); | |
c41b00c9 VZ |
121 | |
122 | protected: | |
8db37e06 | 123 | wxFindReplaceData *m_FindReplaceData; |
c41b00c9 | 124 | |
8db37e06 VZ |
125 | // the last string we searched for |
126 | wxString m_lastSearch; | |
22f3361e VZ |
127 | |
128 | DECLARE_NO_COPY_CLASS(wxFindReplaceDialogBase) | |
8db37e06 | 129 | }; |
c41b00c9 | 130 | |
8db37e06 | 131 | // include wxFindReplaceDialog declaration |
086b3a5b | 132 | #if defined(__WXMSW__) && !defined(__WXUNIVERSAL__) && !defined(__WXWINCE__) |
8db37e06 VZ |
133 | #include "wx/msw/fdrepdlg.h" |
134 | #else | |
135 | #define wxGenericFindReplaceDialog wxFindReplaceDialog | |
136 | #define sm_classwxGenericFindReplaceDialog sm_classwxFindReplaceDialog | |
c41b00c9 | 137 | |
8db37e06 VZ |
138 | #include "wx/generic/fdrepdlg.h" |
139 | #endif | |
c41b00c9 VZ |
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 | ||
761989ff VZ |
155 | wxFindReplaceDialog *GetDialog() const |
156 | { return wxStaticCast(GetEventObject(), wxFindReplaceDialog); } | |
157 | ||
c41b00c9 VZ |
158 | // implementation only |
159 | void SetFlags(int flags) { SetInt(flags); } | |
160 | void SetFindString(const wxString& str) { SetString(str); } | |
161 | void SetReplaceString(const wxString& str) { m_strReplace = str; } | |
162 | ||
163 | private: | |
164 | wxString m_strReplace; | |
165 | ||
fc7a2a60 | 166 | DECLARE_DYNAMIC_CLASS_NO_COPY(wxFindDialogEvent) |
c41b00c9 VZ |
167 | }; |
168 | ||
169 | BEGIN_DECLARE_EVENT_TYPES() | |
761989ff VZ |
170 | DECLARE_EVENT_TYPE(wxEVT_COMMAND_FIND, 510) |
171 | DECLARE_EVENT_TYPE(wxEVT_COMMAND_FIND_NEXT, 511) | |
172 | DECLARE_EVENT_TYPE(wxEVT_COMMAND_FIND_REPLACE, 512) | |
173 | DECLARE_EVENT_TYPE(wxEVT_COMMAND_FIND_REPLACE_ALL, 513) | |
174 | DECLARE_EVENT_TYPE(wxEVT_COMMAND_FIND_CLOSE, 514) | |
c41b00c9 VZ |
175 | END_DECLARE_EVENT_TYPES() |
176 | ||
177 | typedef void (wxEvtHandler::*wxFindDialogEventFunction)(wxFindDialogEvent&); | |
178 | ||
761989ff VZ |
179 | #define EVT_FIND(id, fn) \ |
180 | DECLARE_EVENT_TABLE_ENTRY( \ | |
181 | wxEVT_COMMAND_FIND, id, -1, \ | |
182 | (wxObjectEventFunction)(wxEventFunction)(wxFindDialogEventFunction) \ | |
183 | & fn, \ | |
184 | (wxObject *) NULL \ | |
185 | ), | |
186 | ||
c41b00c9 VZ |
187 | #define EVT_FIND_NEXT(id, fn) \ |
188 | DECLARE_EVENT_TABLE_ENTRY( \ | |
189 | wxEVT_COMMAND_FIND_NEXT, id, -1, \ | |
190 | (wxObjectEventFunction)(wxEventFunction)(wxFindDialogEventFunction) \ | |
191 | & fn, \ | |
192 | (wxObject *) NULL \ | |
193 | ), | |
194 | ||
761989ff | 195 | #define EVT_FIND_REPLACE(id, fn) \ |
c41b00c9 | 196 | DECLARE_EVENT_TABLE_ENTRY( \ |
761989ff | 197 | wxEVT_COMMAND_FIND_REPLACE, id, -1, \ |
c41b00c9 VZ |
198 | (wxObjectEventFunction)(wxEventFunction)(wxFindDialogEventFunction) \ |
199 | & fn, \ | |
200 | (wxObject *) NULL \ | |
201 | ), | |
202 | ||
203 | #define EVT_FIND_REPLACE_ALL(id, fn) \ | |
204 | DECLARE_EVENT_TABLE_ENTRY( \ | |
761989ff | 205 | wxEVT_COMMAND_FIND_REPLACE_ALL, id, -1, \ |
c41b00c9 VZ |
206 | (wxObjectEventFunction)(wxEventFunction)(wxFindDialogEventFunction) \ |
207 | & fn, \ | |
208 | (wxObject *) NULL \ | |
209 | ), | |
210 | ||
761989ff | 211 | #define EVT_FIND_CLOSE(id, fn) \ |
c41b00c9 VZ |
212 | DECLARE_EVENT_TABLE_ENTRY( \ |
213 | wxEVT_COMMAND_FIND_CLOSE, id, -1, \ | |
214 | (wxObjectEventFunction)(wxEventFunction)(wxFindDialogEventFunction) \ | |
215 | & fn, \ | |
216 | (wxObject *) NULL \ | |
217 | ), | |
218 | ||
219 | #endif // wxUSE_FINDREPLDLG | |
220 | ||
221 | #endif | |
222 | // _WX_FDREPDLG_H |