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