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.
13 #include "FormSearch.h"
14 #include "ControlSearch.h"
15 #include "forms/form_search.h"
18 #include "xforms_helpers.h"
21 #include "lyx_forms.h"
28 typedef FormController<ControlSearch, FormView<FD_search> > base_class;
30 FormSearch::FormSearch(Dialog & parent)
31 : base_class(parent, _("Find and Replace"))
35 void FormSearch::build()
37 dialog_.reset(build_search(this));
39 // Manage the ok, apply and cancel/close buttons
40 bcview().setCancel(dialog_->button_close);
42 // disable for read-only documents
43 bcview().addReadOnly(dialog_->input_replace);
44 bcview().addReadOnly(dialog_->button_replace);
45 bcview().addReadOnly(dialog_->button_replaceall);
47 // set up the tooltips
48 string str = _("Enter the string you want to find.");
49 tooltips().init(dialog_->input_search, str);
50 str = _("Enter the replacement string.");
51 tooltips().init(dialog_->input_replace, str);
52 str = _("Continue to next search result.");
53 tooltips().init(dialog_->button_findnext, str);
54 str = _("Replace search result by replacement string.");
55 tooltips().init(dialog_->button_replace, str);
56 str = _("Replace all by replacement string.");
57 tooltips().init(dialog_->button_replaceall, str);
58 str = _("Do case sensitive search.");
59 tooltips().init(dialog_->check_casesensitive, str);
60 str = _("Search only matching words.");
61 tooltips().init(dialog_->check_matchword, str);
62 str = _("Search backwards.");
63 tooltips().init(dialog_->check_searchbackwards, str);
67 void FormSearch::update()
69 fl_set_input_selected(dialog_->input_search, true);
70 fl_set_focus_object(dialog_->form, dialog_->input_search);
74 ButtonPolicy::SMInput FormSearch::input(FL_OBJECT * ob, long)
76 if (ob == dialog_->button_findnext) {
77 controller().find(getString(dialog_->input_search),
78 fl_get_button(dialog_->check_casesensitive),
79 fl_get_button(dialog_->check_matchword),
80 !fl_get_button(dialog_->check_searchbackwards));
82 } else if (ob == dialog_->button_replace || ob == dialog_->button_replaceall) {
83 bool const all = (ob == dialog_->button_replaceall);
85 controller().replace(getString(dialog_->input_search),
86 getString(dialog_->input_replace),
87 fl_get_button(dialog_->check_casesensitive),
88 fl_get_button(dialog_->check_matchword),
89 !fl_get_button(dialog_->check_searchbackwards),
93 return ButtonPolicy::SMI_VALID;
96 } // namespace frontend