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
15 #include "ControlSearch.h"
16 #include "FormSearch.h"
17 #include "forms/form_search.h"
19 #include "xforms_helpers.h"
21 #include "lyx_forms.h"
23 typedef FormCB<ControlSearch, FormDB<FD_search> > base_class;
25 FormSearch::FormSearch()
26 : base_class(_("Find and Replace"))
30 void FormSearch::build()
32 dialog_.reset(build_search(this));
34 // Manage the ok, apply and cancel/close buttons
35 bcview().setCancel(dialog_->button_close);
37 // disable for read-only documents
38 bcview().addReadOnly(dialog_->input_replace);
39 bcview().addReadOnly(dialog_->button_replace);
40 bcview().addReadOnly(dialog_->button_replaceall);
42 // set up the tooltips
43 string str = _("Enter the string you want to find.");
44 tooltips().init(dialog_->input_search, str);
45 str = _("Enter the replacement string.");
46 tooltips().init(dialog_->input_replace, str);
47 str = _("Continue to next search result.");
48 tooltips().init(dialog_->button_findnext, str);
49 str = _("Replace search result by replacement string.");
50 tooltips().init(dialog_->button_replace, str);
51 str = _("Replace all by replacement string.");
52 tooltips().init(dialog_->button_replaceall, str);
53 str = _("Do case sensitive search.");
54 tooltips().init(dialog_->check_casesensitive, str);
55 str = _("Search only matching words.");
56 tooltips().init(dialog_->check_matchword, str);
57 str = _("Search backwards.");
58 tooltips().init(dialog_->check_searchbackwards, str);
62 void FormSearch::update()
64 fl_set_input_selected(dialog_->input_search, true);
65 fl_set_focus_object(dialog_->form, dialog_->input_search);
69 ButtonPolicy::SMInput FormSearch::input(FL_OBJECT * ob, long)
71 if (ob == dialog_->button_findnext) {
72 controller().find(getString(dialog_->input_search),
73 fl_get_button(dialog_->check_casesensitive),
74 fl_get_button(dialog_->check_matchword),
75 !fl_get_button(dialog_->check_searchbackwards));
77 } else if (ob == dialog_->button_replace || ob == dialog_->button_replaceall) {
78 bool const all = (ob == dialog_->button_replaceall);
80 controller().replace(getString(dialog_->input_search),
81 getString(dialog_->input_replace),
82 fl_get_button(dialog_->check_casesensitive),
83 fl_get_button(dialog_->check_matchword),
87 return ButtonPolicy::SMI_VALID;