3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
8 * Full author contact details are available in file CREDITS
14 #pragma implementation
18 #include "ControlSearch.h"
19 #include "FormSearch.h"
20 #include "forms/form_search.h"
22 #include "xforms_helpers.h"
24 #include FORMS_H_LOCATION
26 typedef FormCB<ControlSearch, FormDB<FD_search> > base_class;
28 FormSearch::FormSearch()
29 : base_class(_("Find and Replace"))
33 void FormSearch::build()
35 dialog_.reset(build_search(this));
37 // Manage the ok, apply and cancel/close buttons
38 bc().setCancel(dialog_->button_close);
40 // disable for read-only documents
41 bc().addReadOnly(dialog_->input_replace);
42 bc().addReadOnly(dialog_->button_replace);
43 bc().addReadOnly(dialog_->button_replaceall);
45 // set up the tooltips
46 string str = _("Enter the string you want to find.");
47 tooltips().init(dialog_->input_search, str);
48 str = _("Enter the replacement string.");
49 tooltips().init(dialog_->input_replace, str);
50 str = _("Continue to next search result.");
51 tooltips().init(dialog_->button_findnext, str);
52 str = _("Replace search result by replacement string.");
53 tooltips().init(dialog_->button_replace, str);
54 str = _("Replace all by replacement string.");
55 tooltips().init(dialog_->button_replaceall, str);
56 str = _("Do case sensitive search.");
57 tooltips().init(dialog_->check_casesensitive, str);
58 str = _("Search only matching words.");
59 tooltips().init(dialog_->check_matchword, str);
60 str = _("Search backwards.");
61 tooltips().init(dialog_->check_searchbackwards, str);
65 void FormSearch::update()
67 fl_set_input_selected(dialog_->input_search, true);
68 fl_set_focus_object(dialog_->form, dialog_->input_search);
72 ButtonPolicy::SMInput FormSearch::input(FL_OBJECT * ob, long)
74 if (ob == dialog_->button_findnext) {
75 controller().find(getString(dialog_->input_search),
76 fl_get_button(dialog_->check_casesensitive),
77 fl_get_button(dialog_->check_matchword),
78 !fl_get_button(dialog_->check_searchbackwards));
80 } else if (ob == dialog_->button_replace || ob == dialog_->button_replaceall) {
81 bool const all = (ob == dialog_->button_replaceall);
83 controller().replace(getString(dialog_->input_search),
84 getString(dialog_->input_replace),
85 fl_get_button(dialog_->check_casesensitive),
86 fl_get_button(dialog_->check_matchword),
90 return ButtonPolicy::SMI_VALID;