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"
27 typedef FormCB<ControlSearch, FormDB<FD_search> > base_class;
29 FormSearch::FormSearch()
30 : base_class(_("Find and Replace"))
34 void FormSearch::build()
36 dialog_.reset(build_search(this));
38 // Manage the ok, apply and cancel/close buttons
39 bcview().setCancel(dialog_->button_close);
41 // disable for read-only documents
42 bcview().addReadOnly(dialog_->input_replace);
43 bcview().addReadOnly(dialog_->button_replace);
44 bcview().addReadOnly(dialog_->button_replaceall);
46 // set up the tooltips
47 string str = _("Enter the string you want to find.");
48 tooltips().init(dialog_->input_search, str);
49 str = _("Enter the replacement string.");
50 tooltips().init(dialog_->input_replace, str);
51 str = _("Continue to next search result.");
52 tooltips().init(dialog_->button_findnext, str);
53 str = _("Replace search result by replacement string.");
54 tooltips().init(dialog_->button_replace, str);
55 str = _("Replace all by replacement string.");
56 tooltips().init(dialog_->button_replaceall, str);
57 str = _("Do case sensitive search.");
58 tooltips().init(dialog_->check_casesensitive, str);
59 str = _("Search only matching words.");
60 tooltips().init(dialog_->check_matchword, str);
61 str = _("Search backwards.");
62 tooltips().init(dialog_->check_searchbackwards, str);
66 void FormSearch::update()
68 fl_set_input_selected(dialog_->input_search, true);
69 fl_set_focus_object(dialog_->form, dialog_->input_search);
73 ButtonPolicy::SMInput FormSearch::input(FL_OBJECT * ob, long)
75 if (ob == dialog_->button_findnext) {
76 controller().find(getString(dialog_->input_search),
77 fl_get_button(dialog_->check_casesensitive),
78 fl_get_button(dialog_->check_matchword),
79 !fl_get_button(dialog_->check_searchbackwards));
81 } else if (ob == dialog_->button_replace || ob == dialog_->button_replaceall) {
82 bool const all = (ob == dialog_->button_replaceall);
84 controller().replace(getString(dialog_->input_search),
85 getString(dialog_->input_replace),
86 fl_get_button(dialog_->check_casesensitive),
87 fl_get_button(dialog_->check_matchword),
88 !fl_get_button(dialog_->check_searchbackwards),
92 return ButtonPolicy::SMI_VALID;