]> git.lyx.org Git - lyx.git/blob - src/frontends/xforms/FormSearch.C
xforms clean-up, described in detail in my mail of 31 May. See
[lyx.git] / src / frontends / xforms / FormSearch.C
1 /**
2  * \file FormSearch.C
3  * Copyright 2001 The LyX Team.
4  * See the file COPYING.
5  *
6  * \author Edwin Leuven, leuven@fee.uva.nl
7  */
8
9 #include <config.h>
10
11 #ifdef __GNUG__
12 #pragma implementation
13 #endif
14
15 #include "xformsBC.h"
16 #include "ControlSearch.h"
17 #include "FormSearch.h"
18 #include "forms/form_search.h"
19 #include FORMS_H_LOCATION
20
21 typedef FormCB<ControlSearch, FormDB<FD_search> > base_class;
22
23 FormSearch::FormSearch(ControlSearch & c)
24         : base_class(c, _("LyX: Find and Replace"))
25 {}
26
27
28 void FormSearch::build()
29 {
30         dialog_.reset(build_search(this));
31
32         // Manage the ok, apply and cancel/close buttons
33         bc().setCancel(dialog_->button_close);
34         bc().addReadOnly(dialog_->input_replace);
35         bc().addReadOnly(dialog_->button_replace);
36         bc().addReadOnly(dialog_->button_replaceall);
37 }
38
39
40 ButtonPolicy::SMInput FormSearch::input(FL_OBJECT * obj, long)
41 {
42         if (obj == dialog_->button_findnext ||
43             obj == dialog_->button_findprev) {
44                 bool const forward = (obj == dialog_->button_findnext);
45
46                 controller().find(fl_get_input(dialog_->input_search),
47                                   fl_get_button(dialog_->check_casesensitive),
48                                   fl_get_button(dialog_->check_matchword),
49                                   forward);
50
51         } else if (obj == dialog_->button_replace ||
52                    obj == dialog_->button_replaceall) {
53                 bool const all = (obj == dialog_->button_replaceall);
54
55                 controller().replace(fl_get_input(dialog_->input_search),
56                                      fl_get_input(dialog_->input_replace),
57                                      fl_get_button(dialog_->check_casesensitive),
58                                      fl_get_button(dialog_->check_matchword),
59                                      all);
60         }
61
62         return ButtonPolicy::SMI_VALID;
63 }