]> git.lyx.org Git - lyx.git/blob - src/frontends/xforms/FormSearch.C
Introduce LFUN_PRINT.
[lyx.git] / src / frontends / xforms / FormSearch.C
1 /**
2  * \file FormSearch.C
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author Edwin Leuven
7  *
8  * Full author contact details are available in file CREDITS.
9  */
10
11 #include <config.h>
12
13 #include "FormSearch.h"
14 #include "ControlSearch.h"
15 #include "forms/form_search.h"
16
17 #include "Tooltips.h"
18 #include "xforms_helpers.h"
19 #include "xformsBC.h"
20
21 #include "lyx_forms.h"
22
23
24 using std::string;
25
26
27 typedef FormController<ControlSearch, FormView<FD_search> > base_class;
28
29 FormSearch::FormSearch(Dialog & parent)
30         : base_class(parent, _("Find and Replace"))
31 {}
32
33
34 void FormSearch::build()
35 {
36         dialog_.reset(build_search(this));
37
38         // Manage the ok, apply and cancel/close buttons
39         bcview().setCancel(dialog_->button_close);
40
41         // disable for read-only documents
42         bcview().addReadOnly(dialog_->input_replace);
43         bcview().addReadOnly(dialog_->button_replace);
44         bcview().addReadOnly(dialog_->button_replaceall);
45
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);
63 }
64
65
66 void FormSearch::update()
67 {
68         fl_set_input_selected(dialog_->input_search, true);
69         fl_set_focus_object(dialog_->form, dialog_->input_search);
70 }
71
72
73 ButtonPolicy::SMInput FormSearch::input(FL_OBJECT * ob, long)
74 {
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));
80
81         } else if (ob == dialog_->button_replace || ob == dialog_->button_replaceall) {
82                 bool const all = (ob == dialog_->button_replaceall);
83
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),                                 
89                                      all);
90         }
91
92         return ButtonPolicy::SMI_VALID;
93 }