]>
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 | 6 | // Created: 23/03/2001 |
2903e699 | 7 | // RCS-ID: $Id$ |
c41b00c9 | 8 | // Copyright: (c) Markus Greither |
65571936 | 9 | // Licence: wxWindows licence |
c41b00c9 VZ |
10 | ///////////////////////////////////////////////////////////////////////////// |
11 | ||
12 | #ifndef _WX_FINDREPLACEDLG_H_ | |
13 | #define _WX_FINDREPLACEDLG_H_ | |
14 | ||
c41b00c9 VZ |
15 | #include "wx/defs.h" |
16 | ||
17 | #if wxUSE_FINDREPLDLG | |
18 | ||
19 | #include "wx/dialog.h" | |
20 | ||
b5dbe15d VS |
21 | class WXDLLIMPEXP_FWD_CORE wxFindDialogEvent; |
22 | class WXDLLIMPEXP_FWD_CORE wxFindReplaceDialog; | |
23 | class WXDLLIMPEXP_FWD_CORE wxFindReplaceData; | |
24 | class WXDLLIMPEXP_FWD_CORE wxFindReplaceDialogImpl; | |
c41b00c9 VZ |
25 | |
26 | // ---------------------------------------------------------------------------- | |
27 | // Flags for wxFindReplaceData.Flags | |
28 | // ---------------------------------------------------------------------------- | |
29 | ||
30 | // flages used by wxFindDialogEvent::GetFlags() | |
31 | enum wxFindReplaceFlags | |
32 | { | |
33 | // downward search/replace selected (otherwise - upwards) | |
34 | wxFR_DOWN = 1, | |
35 | ||
36 | // whole word search/replace selected | |
8db37e06 | 37 | wxFR_WHOLEWORD = 2, |
c41b00c9 VZ |
38 | |
39 | // case sensitive search/replace selected (otherwise - case insensitive) | |
40 | wxFR_MATCHCASE = 4 | |
41 | }; | |
42 | ||
43 | // these flags can be specified in wxFindReplaceDialog ctor or Create() | |
44 | enum wxFindReplaceDialogStyles | |
45 | { | |
46 | // replace dialog (otherwise find dialog) | |
47 | wxFR_REPLACEDIALOG = 1, | |
48 | ||
49 | // don't allow changing the search direction | |
50 | wxFR_NOUPDOWN = 2, | |
51 | ||
52 | // don't allow case sensitive searching | |
53 | wxFR_NOMATCHCASE = 4, | |
54 | ||
55 | // don't allow whole word searching | |
56 | wxFR_NOWHOLEWORD = 8 | |
57 | }; | |
58 | ||
59 | // ---------------------------------------------------------------------------- | |
60 | // wxFindReplaceData: holds Setup Data/Feedback Data for wxFindReplaceDialog | |
61 | // ---------------------------------------------------------------------------- | |
62 | ||
53a2db12 | 63 | class WXDLLIMPEXP_CORE wxFindReplaceData : public wxObject |
c41b00c9 VZ |
64 | { |
65 | public: | |
761989ff VZ |
66 | wxFindReplaceData() { Init(); } |
67 | wxFindReplaceData(wxUint32 flags) { Init(); SetFlags(flags); } | |
c41b00c9 VZ |
68 | |
69 | // accessors | |
5475b39f VZ |
70 | const wxString& GetFindString() const { return m_FindWhat; } |
71 | const wxString& GetReplaceString() const { return m_ReplaceWith; } | |
c41b00c9 VZ |
72 | |
73 | int GetFlags() const { return m_Flags; } | |
74 | ||
75 | // setters: may only be called before showing the dialog, no effect later | |
76 | void SetFlags(wxUint32 flags) { m_Flags = flags; } | |
77 | ||
78 | void SetFindString(const wxString& str) { m_FindWhat = str; } | |
79 | void SetReplaceString(const wxString& str) { m_ReplaceWith = str; } | |
80 | ||
761989ff VZ |
81 | protected: |
82 | void Init(); | |
83 | ||
c41b00c9 VZ |
84 | private: |
85 | wxUint32 m_Flags; | |
86 | wxString m_FindWhat, | |
87 | m_ReplaceWith; | |
88 | ||
8db37e06 | 89 | friend class wxFindReplaceDialogBase; |
c41b00c9 VZ |
90 | }; |
91 | ||
92 | // ---------------------------------------------------------------------------- | |
8db37e06 | 93 | // wxFindReplaceDialogBase |
c41b00c9 VZ |
94 | // ---------------------------------------------------------------------------- |
95 | ||
53a2db12 | 96 | class WXDLLIMPEXP_CORE wxFindReplaceDialogBase : public wxDialog |
c41b00c9 VZ |
97 | { |
98 | public: | |
99 | // ctors and such | |
8db37e06 VZ |
100 | wxFindReplaceDialogBase() { m_FindReplaceData = NULL; } |
101 | wxFindReplaceDialogBase(wxWindow * WXUNUSED(parent), | |
102 | wxFindReplaceData *data, | |
103 | const wxString& WXUNUSED(title), | |
104 | int WXUNUSED(style) = 0) | |
105 | { | |
106 | m_FindReplaceData = data; | |
107 | } | |
c41b00c9 | 108 | |
8db37e06 | 109 | virtual ~wxFindReplaceDialogBase(); |
c41b00c9 VZ |
110 | |
111 | // find dialog data access | |
112 | const wxFindReplaceData *GetData() const { return m_FindReplaceData; } | |
8db37e06 | 113 | void SetData(wxFindReplaceData *data) { m_FindReplaceData = data; } |
c41b00c9 | 114 | |
8db37e06 VZ |
115 | // implementation only, don't use |
116 | void Send(wxFindDialogEvent& event); | |
c41b00c9 VZ |
117 | |
118 | protected: | |
8db37e06 | 119 | wxFindReplaceData *m_FindReplaceData; |
c41b00c9 | 120 | |
8db37e06 VZ |
121 | // the last string we searched for |
122 | wxString m_lastSearch; | |
22f3361e | 123 | |
c0c133e1 | 124 | wxDECLARE_NO_COPY_CLASS(wxFindReplaceDialogBase); |
8db37e06 | 125 | }; |
c41b00c9 | 126 | |
8db37e06 | 127 | // include wxFindReplaceDialog declaration |
086b3a5b | 128 | #if defined(__WXMSW__) && !defined(__WXUNIVERSAL__) && !defined(__WXWINCE__) |
8db37e06 VZ |
129 | #include "wx/msw/fdrepdlg.h" |
130 | #else | |
131 | #define wxGenericFindReplaceDialog wxFindReplaceDialog | |
c41b00c9 | 132 | |
8db37e06 VZ |
133 | #include "wx/generic/fdrepdlg.h" |
134 | #endif | |
c41b00c9 VZ |
135 | |
136 | // ---------------------------------------------------------------------------- | |
137 | // wxFindReplaceDialog events | |
138 | // ---------------------------------------------------------------------------- | |
139 | ||
53a2db12 | 140 | class WXDLLIMPEXP_CORE wxFindDialogEvent : public wxCommandEvent |
c41b00c9 VZ |
141 | { |
142 | public: | |
143 | wxFindDialogEvent(wxEventType commandType = wxEVT_NULL, int id = 0) | |
144 | : wxCommandEvent(commandType, id) { } | |
f8a5d9da FM |
145 | wxFindDialogEvent(const wxFindDialogEvent& event) |
146 | : wxCommandEvent(event), m_strReplace(event.m_strReplace) { } | |
c41b00c9 VZ |
147 | |
148 | int GetFlags() const { return GetInt(); } | |
149 | wxString GetFindString() const { return GetString(); } | |
150 | const wxString& GetReplaceString() const { return m_strReplace; } | |
151 | ||
761989ff VZ |
152 | wxFindReplaceDialog *GetDialog() const |
153 | { return wxStaticCast(GetEventObject(), wxFindReplaceDialog); } | |
154 | ||
c41b00c9 VZ |
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 | ||
f8a5d9da FM |
160 | virtual wxEvent *Clone() const { return new wxFindDialogEvent(*this); } |
161 | ||
c41b00c9 VZ |
162 | private: |
163 | wxString m_strReplace; | |
164 | ||
f8a5d9da | 165 | DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxFindDialogEvent) |
c41b00c9 VZ |
166 | }; |
167 | ||
ce7fe42e VZ |
168 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_FIND, wxFindDialogEvent ); |
169 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_FIND_NEXT, wxFindDialogEvent ); | |
170 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_FIND_REPLACE, wxFindDialogEvent ); | |
171 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_FIND_REPLACE_ALL, wxFindDialogEvent ); | |
172 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_FIND_CLOSE, wxFindDialogEvent ); | |
c41b00c9 VZ |
173 | |
174 | typedef void (wxEvtHandler::*wxFindDialogEventFunction)(wxFindDialogEvent&); | |
175 | ||
7fa03f04 | 176 | #define wxFindDialogEventHandler(func) \ |
3c778901 | 177 | wxEVENT_HANDLER_CAST(wxFindDialogEventFunction, func) |
7fa03f04 | 178 | |
761989ff | 179 | #define EVT_FIND(id, fn) \ |
ce7fe42e | 180 | wx__DECLARE_EVT1(wxEVT_FIND, id, wxFindDialogEventHandler(fn)) |
761989ff | 181 | |
c41b00c9 | 182 | #define EVT_FIND_NEXT(id, fn) \ |
ce7fe42e | 183 | wx__DECLARE_EVT1(wxEVT_FIND_NEXT, id, wxFindDialogEventHandler(fn)) |
c41b00c9 | 184 | |
761989ff | 185 | #define EVT_FIND_REPLACE(id, fn) \ |
ce7fe42e | 186 | wx__DECLARE_EVT1(wxEVT_FIND_REPLACE, id, wxFindDialogEventHandler(fn)) |
c41b00c9 VZ |
187 | |
188 | #define EVT_FIND_REPLACE_ALL(id, fn) \ | |
ce7fe42e | 189 | wx__DECLARE_EVT1(wxEVT_FIND_REPLACE_ALL, id, wxFindDialogEventHandler(fn)) |
c41b00c9 | 190 | |
761989ff | 191 | #define EVT_FIND_CLOSE(id, fn) \ |
ce7fe42e VZ |
192 | wx__DECLARE_EVT1(wxEVT_FIND_CLOSE, id, wxFindDialogEventHandler(fn)) |
193 | ||
194 | // old wxEVT_COMMAND_* constants | |
195 | #define wxEVT_COMMAND_FIND wxEVT_FIND | |
196 | #define wxEVT_COMMAND_FIND_NEXT wxEVT_FIND_NEXT | |
197 | #define wxEVT_COMMAND_FIND_REPLACE wxEVT_FIND_REPLACE | |
198 | #define wxEVT_COMMAND_FIND_REPLACE_ALL wxEVT_FIND_REPLACE_ALL | |
199 | #define wxEVT_COMMAND_FIND_CLOSE wxEVT_FIND_CLOSE | |
c41b00c9 VZ |
200 | |
201 | #endif // wxUSE_FINDREPLDLG | |
202 | ||
203 | #endif | |
204 | // _WX_FDREPDLG_H |