]> git.saurik.com Git - wxWidgets.git/blame - include/wx/fdrepdlg.h
Don't define __STRICT_ANSI__, we should build both with and without it.
[wxWidgets.git] / include / wx / fdrepdlg.h
CommitLineData
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
c41b00c9 7// Copyright: (c) Markus Greither
65571936 8// Licence: wxWindows licence
c41b00c9
VZ
9/////////////////////////////////////////////////////////////////////////////
10
11#ifndef _WX_FINDREPLACEDLG_H_
12#define _WX_FINDREPLACEDLG_H_
13
c41b00c9
VZ
14#include "wx/defs.h"
15
16#if wxUSE_FINDREPLDLG
17
18#include "wx/dialog.h"
19
b5dbe15d
VS
20class WXDLLIMPEXP_FWD_CORE wxFindDialogEvent;
21class WXDLLIMPEXP_FWD_CORE wxFindReplaceDialog;
22class WXDLLIMPEXP_FWD_CORE wxFindReplaceData;
23class WXDLLIMPEXP_FWD_CORE wxFindReplaceDialogImpl;
c41b00c9
VZ
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
8db37e06 36 wxFR_WHOLEWORD = 2,
c41b00c9
VZ
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
53a2db12 62class WXDLLIMPEXP_CORE wxFindReplaceData : public wxObject
c41b00c9
VZ
63{
64public:
761989ff
VZ
65 wxFindReplaceData() { Init(); }
66 wxFindReplaceData(wxUint32 flags) { Init(); SetFlags(flags); }
c41b00c9
VZ
67
68 // accessors
5475b39f
VZ
69 const wxString& GetFindString() const { return m_FindWhat; }
70 const wxString& GetReplaceString() const { return m_ReplaceWith; }
c41b00c9
VZ
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
761989ff
VZ
80protected:
81 void Init();
82
c41b00c9
VZ
83private:
84 wxUint32 m_Flags;
85 wxString m_FindWhat,
86 m_ReplaceWith;
87
8db37e06 88 friend class wxFindReplaceDialogBase;
c41b00c9
VZ
89};
90
91// ----------------------------------------------------------------------------
8db37e06 92// wxFindReplaceDialogBase
c41b00c9
VZ
93// ----------------------------------------------------------------------------
94
53a2db12 95class WXDLLIMPEXP_CORE wxFindReplaceDialogBase : public wxDialog
c41b00c9
VZ
96{
97public:
98 // ctors and such
8db37e06
VZ
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 }
c41b00c9 107
8db37e06 108 virtual ~wxFindReplaceDialogBase();
c41b00c9
VZ
109
110 // find dialog data access
111 const wxFindReplaceData *GetData() const { return m_FindReplaceData; }
8db37e06 112 void SetData(wxFindReplaceData *data) { m_FindReplaceData = data; }
c41b00c9 113
8db37e06
VZ
114 // implementation only, don't use
115 void Send(wxFindDialogEvent& event);
c41b00c9
VZ
116
117protected:
8db37e06 118 wxFindReplaceData *m_FindReplaceData;
c41b00c9 119
8db37e06
VZ
120 // the last string we searched for
121 wxString m_lastSearch;
22f3361e 122
c0c133e1 123 wxDECLARE_NO_COPY_CLASS(wxFindReplaceDialogBase);
8db37e06 124};
c41b00c9 125
8db37e06 126// include wxFindReplaceDialog declaration
086b3a5b 127#if defined(__WXMSW__) && !defined(__WXUNIVERSAL__) && !defined(__WXWINCE__)
8db37e06
VZ
128 #include "wx/msw/fdrepdlg.h"
129#else
130 #define wxGenericFindReplaceDialog wxFindReplaceDialog
c41b00c9 131
8db37e06
VZ
132 #include "wx/generic/fdrepdlg.h"
133#endif
c41b00c9
VZ
134
135// ----------------------------------------------------------------------------
136// wxFindReplaceDialog events
137// ----------------------------------------------------------------------------
138
53a2db12 139class WXDLLIMPEXP_CORE wxFindDialogEvent : public wxCommandEvent
c41b00c9
VZ
140{
141public:
142 wxFindDialogEvent(wxEventType commandType = wxEVT_NULL, int id = 0)
143 : wxCommandEvent(commandType, id) { }
f8a5d9da
FM
144 wxFindDialogEvent(const wxFindDialogEvent& event)
145 : wxCommandEvent(event), m_strReplace(event.m_strReplace) { }
c41b00c9
VZ
146
147 int GetFlags() const { return GetInt(); }
148 wxString GetFindString() const { return GetString(); }
149 const wxString& GetReplaceString() const { return m_strReplace; }
150
761989ff
VZ
151 wxFindReplaceDialog *GetDialog() const
152 { return wxStaticCast(GetEventObject(), wxFindReplaceDialog); }
153
c41b00c9
VZ
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
f8a5d9da
FM
159 virtual wxEvent *Clone() const { return new wxFindDialogEvent(*this); }
160
c41b00c9
VZ
161private:
162 wxString m_strReplace;
163
f8a5d9da 164 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxFindDialogEvent)
c41b00c9
VZ
165};
166
ce7fe42e
VZ
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 );
c41b00c9
VZ
172
173typedef void (wxEvtHandler::*wxFindDialogEventFunction)(wxFindDialogEvent&);
174
7fa03f04 175#define wxFindDialogEventHandler(func) \
3c778901 176 wxEVENT_HANDLER_CAST(wxFindDialogEventFunction, func)
7fa03f04 177
761989ff 178#define EVT_FIND(id, fn) \
ce7fe42e 179 wx__DECLARE_EVT1(wxEVT_FIND, id, wxFindDialogEventHandler(fn))
761989ff 180
c41b00c9 181#define EVT_FIND_NEXT(id, fn) \
ce7fe42e 182 wx__DECLARE_EVT1(wxEVT_FIND_NEXT, id, wxFindDialogEventHandler(fn))
c41b00c9 183
761989ff 184#define EVT_FIND_REPLACE(id, fn) \
ce7fe42e 185 wx__DECLARE_EVT1(wxEVT_FIND_REPLACE, id, wxFindDialogEventHandler(fn))
c41b00c9
VZ
186
187#define EVT_FIND_REPLACE_ALL(id, fn) \
ce7fe42e 188 wx__DECLARE_EVT1(wxEVT_FIND_REPLACE_ALL, id, wxFindDialogEventHandler(fn))
c41b00c9 189
761989ff 190#define EVT_FIND_CLOSE(id, fn) \
ce7fe42e
VZ
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
c41b00c9
VZ
199
200#endif // wxUSE_FINDREPLDLG
201
202#endif
203 // _WX_FDREPDLG_H