43
44
#define chkOptionsUseRegexps CTRL_CHECKBOX("chkOptionsUseRegexps")
45
46
dlgFindReplace::dlgFindReplace(ctlSQLBox *parent) :
50
wxWindowBase::SetFont(settings->GetSystemFont());
51
LoadResource(parent, wxT("dlgFindReplace"));
55
appearanceFactory->SetIcons(this);
58
wxAcceleratorEntry entries[1];
59
entries[0].Set(wxACCEL_NORMAL, WXK_F3, wxID_FIND);
60
wxAcceleratorTable accel(1, entries);
61
SetAcceleratorTable(accel);
64
// Load up the defaults
68
// Find/Replace values
69
settings->Read(wxT("FindReplace/Find"), &val, wxT(""));
70
txtFind->SetValue(val);
72
settings->Read(wxT("FindReplace/Replace"), &val, wxT(""));
73
txtReplace->SetValue(val);
76
settings->Read(wxT("FindReplace/Origin"), &val, wxT("c"));
79
rdOriginCursor->SetValue(false);
80
rdOriginTop->SetValue(true);
84
rdOriginCursor->SetValue(true);
85
rdOriginTop->SetValue(false);
89
settings->Read(wxT("FindReplace/Direction"), &val, wxT("f"));
92
rdDirectionForward->SetValue(false);
93
rdDirectionBackward->SetValue(true);
97
rdDirectionForward->SetValue(true);
98
rdDirectionBackward->SetValue(false);
102
settings->Read(wxT("FindReplace/WholeWord"), &bVal, false);
103
chkOptionsWholeWord->SetValue(bVal);
106
settings->Read(wxT("FindReplace/MatchCase"), &bVal, false);
107
chkOptionsMatchCase->SetValue(bVal);
110
settings->Read(wxT("FindReplace/UseRegexps"), &bVal, false);
111
chkOptionsUseRegexps->SetValue(bVal);
51
wxWindowBase::SetFont(settings->GetSystemFont());
52
LoadResource(parent, wxT("dlgFindReplace"));
56
appearanceFactory->SetIcons(this);
59
wxAcceleratorEntry entries[1];
60
entries[0].Set(wxACCEL_NORMAL, WXK_F3, wxID_FIND);
61
wxAcceleratorTable accel(1, entries);
62
SetAcceleratorTable(accel);
65
// Load up the defaults
69
// Find/Replace values
70
settings->Read(wxT("FindReplace/Find"), &val, wxT(""));
71
txtFind->SetValue(val);
73
settings->Read(wxT("FindReplace/Replace"), &val, wxT(""));
74
txtReplace->SetValue(val);
77
settings->Read(wxT("FindReplace/Origin"), &val, wxT("c"));
80
rdOriginCursor->SetValue(false);
81
rdOriginTop->SetValue(true);
85
rdOriginCursor->SetValue(true);
86
rdOriginTop->SetValue(false);
90
settings->Read(wxT("FindReplace/Direction"), &val, wxT("f"));
93
rdDirectionForward->SetValue(false);
94
rdDirectionBackward->SetValue(true);
98
rdDirectionForward->SetValue(true);
99
rdDirectionBackward->SetValue(false);
103
settings->Read(wxT("FindReplace/WholeWord"), &bVal, false);
104
chkOptionsWholeWord->SetValue(bVal);
107
settings->Read(wxT("FindReplace/MatchCase"), &bVal, false);
108
chkOptionsMatchCase->SetValue(bVal);
111
settings->Read(wxT("FindReplace/UseRegexps"), &bVal, false);
112
chkOptionsUseRegexps->SetValue(bVal);
117
119
dlgFindReplace::~dlgFindReplace()
122
124
void dlgFindReplace::FocusSearch()
125
txtFind->SetSelection(-1, -1);
128
void dlgFindReplace::OnClose(wxCloseEvent& ev)
131
settings->Write(wxT("FindReplace/Find"), txtFind->GetValue());
132
settings->Write(wxT("FindReplace/Replace"), txtReplace->GetValue());
134
if (rdOriginTop->GetValue())
135
settings->Write(wxT("FindReplace/Origin"), wxT("t"));
137
settings->Write(wxT("FindReplace/Origin"), wxT("c"));
139
if (rdDirectionBackward->GetValue())
140
settings->Write(wxT("FindReplace/Direction"), wxT("b"));
142
settings->Write(wxT("FindReplace/Direction"), wxT("f"));
144
settings->Write(wxT("FindReplace/WholeWord"), chkOptionsWholeWord->GetValue());
145
settings->Write(wxT("FindReplace/MatchCase"), chkOptionsMatchCase->GetValue());
146
settings->Write(wxT("FindReplace/UseRegexps"), chkOptionsUseRegexps->GetValue());
153
void dlgFindReplace::OnCancel(wxCommandEvent& ev)
158
void dlgFindReplace::OnChange(wxCommandEvent& ev)
160
if (chkOptionsUseRegexps->GetValue() == true || rdOriginTop->GetValue() == true)
162
rdDirectionForward->SetValue(true);
163
rdDirectionBackward->SetValue(false);
164
rdDirectionBackward->Enable(false);
168
rdDirectionBackward->Enable(true);
171
if (chkOptionsUseRegexps->GetValue() == true)
173
chkOptionsWholeWord->Enable(false);
174
chkOptionsMatchCase->Enable(false);
178
chkOptionsWholeWord->Enable(true);
179
chkOptionsMatchCase->Enable(true);
183
void dlgFindReplace::OnFind(wxCommandEvent& ev)
185
if (txtFind->GetValue().IsEmpty())
188
bool wholeWord = false,
194
if (rdOriginTop->GetValue() == true)
197
if (rdDirectionBackward->GetValue() == true)
200
if (chkOptionsWholeWord->GetValue() == true)
203
if (chkOptionsMatchCase->GetValue() == true)
206
if (chkOptionsUseRegexps->GetValue() == true)
209
if (sqlbox->Find(txtFind->GetValue(), wholeWord, matchCase, useRegexps, startAtTop, reverse))
213
rdOriginTop->SetValue(false);
214
rdOriginCursor->SetValue(true);
215
wxCommandEvent nullEvent;
221
void dlgFindReplace::OnReplace(wxCommandEvent& ev)
223
if (txtFind->GetValue().IsEmpty())
226
bool wholeWord = false,
232
if (rdOriginTop->GetValue() == true)
235
if (rdDirectionBackward->GetValue() == true)
238
if (chkOptionsWholeWord->GetValue() == true)
241
if (chkOptionsMatchCase->GetValue() == true)
244
if (chkOptionsUseRegexps->GetValue() == true)
247
if (sqlbox->Replace(txtFind->GetValue(), txtReplace->GetValue(), wholeWord, matchCase, useRegexps, startAtTop, reverse))
251
rdOriginTop->SetValue(false);
252
rdOriginCursor->SetValue(true);
253
wxCommandEvent nullEvent;
259
void dlgFindReplace::OnReplaceAll(wxCommandEvent& ev)
261
if (txtFind->GetValue().IsEmpty())
264
bool wholeWord = false,
268
if (chkOptionsWholeWord->GetValue() == true)
271
if (chkOptionsMatchCase->GetValue() == true)
274
if (chkOptionsUseRegexps->GetValue() == true)
277
sqlbox->ReplaceAll(txtFind->GetValue(), txtReplace->GetValue(), wholeWord, matchCase, useRegexps);
280
void dlgFindReplace::FindNext()
282
if (btnFind->IsEnabled() && !txtFind->IsEmpty())
127
txtFind->SetSelection(-1, -1);
130
void dlgFindReplace::OnClose(wxCloseEvent &ev)
133
settings->Write(wxT("FindReplace/Find"), txtFind->GetValue());
134
settings->Write(wxT("FindReplace/Replace"), txtReplace->GetValue());
136
if (rdOriginTop->GetValue())
137
settings->Write(wxT("FindReplace/Origin"), wxT("t"));
139
settings->Write(wxT("FindReplace/Origin"), wxT("c"));
141
if (rdDirectionBackward->GetValue())
142
settings->Write(wxT("FindReplace/Direction"), wxT("b"));
144
settings->Write(wxT("FindReplace/Direction"), wxT("f"));
146
settings->WriteBool(wxT("FindReplace/WholeWord"), chkOptionsWholeWord->GetValue());
147
settings->WriteBool(wxT("FindReplace/MatchCase"), chkOptionsMatchCase->GetValue());
148
settings->WriteBool(wxT("FindReplace/UseRegexps"), chkOptionsUseRegexps->GetValue());
155
void dlgFindReplace::OnCancel(wxCommandEvent &ev)
160
void dlgFindReplace::OnChange(wxCommandEvent &ev)
162
if (chkOptionsUseRegexps->GetValue() == true || rdOriginTop->GetValue() == true)
164
rdDirectionForward->SetValue(true);
165
rdDirectionBackward->SetValue(false);
166
rdDirectionBackward->Enable(false);
170
rdDirectionBackward->Enable(true);
173
if (chkOptionsUseRegexps->GetValue() == true)
175
chkOptionsWholeWord->Enable(false);
176
chkOptionsMatchCase->Enable(false);
180
chkOptionsWholeWord->Enable(true);
181
chkOptionsMatchCase->Enable(true);
185
void dlgFindReplace::OnFind(wxCommandEvent &ev)
187
if (txtFind->GetValue().IsEmpty())
190
bool wholeWord = false,
196
if (rdOriginTop->GetValue() == true)
199
if (rdDirectionBackward->GetValue() == true)
202
if (chkOptionsWholeWord->GetValue() == true)
205
if (chkOptionsMatchCase->GetValue() == true)
208
if (chkOptionsUseRegexps->GetValue() == true)
211
if (sqlbox->Find(txtFind->GetValue(), wholeWord, matchCase, useRegexps, startAtTop, reverse))
215
rdOriginTop->SetValue(false);
216
rdOriginCursor->SetValue(true);
217
wxCommandEvent nullEvent;
223
void dlgFindReplace::OnReplace(wxCommandEvent &ev)
225
if (txtFind->GetValue().IsEmpty())
228
bool wholeWord = false,
234
if (rdOriginTop->GetValue() == true)
237
if (rdDirectionBackward->GetValue() == true)
240
if (chkOptionsWholeWord->GetValue() == true)
243
if (chkOptionsMatchCase->GetValue() == true)
246
if (chkOptionsUseRegexps->GetValue() == true)
249
if (sqlbox->Replace(txtFind->GetValue(), txtReplace->GetValue(), wholeWord, matchCase, useRegexps, startAtTop, reverse))
253
rdOriginTop->SetValue(false);
254
rdOriginCursor->SetValue(true);
255
wxCommandEvent nullEvent;
261
void dlgFindReplace::OnReplaceAll(wxCommandEvent &ev)
263
if (txtFind->GetValue().IsEmpty())
266
bool wholeWord = false,
270
if (chkOptionsWholeWord->GetValue() == true)
273
if (chkOptionsMatchCase->GetValue() == true)
276
if (chkOptionsUseRegexps->GetValue() == true)
279
sqlbox->ReplaceAll(txtFind->GetValue(), txtReplace->GetValue(), wholeWord, matchCase, useRegexps);
282
void dlgFindReplace::FindNext()
284
if (btnFind->IsEnabled() && !txtFind->IsEmpty())
291
void dlgFindReplace::SetFindString(const wxString &val)
293
txtFind->SetValue(val);
296
void dlgFindReplace::ResetTabOrder()
298
btnFind->MoveAfterInTabOrder(chkOptionsUseRegexps);
299
btnReplace->MoveAfterInTabOrder(btnFind);
300
btnReplaceAll->MoveAfterInTabOrder(btnReplace);
301
btnCancel->MoveAfterInTabOrder(btnReplaceAll);