]> git.lyx.org Git - lyx.git/blob - src/frontends/xforms/FormSearch.C
Really dull and boring header shit
[lyx.git] / src / frontends / xforms / FormSearch.C
1 /**
2  * \file FormSearch.C
3  * See the file COPYING.
4  *
5  * \author Edwin Leuven
6  *
7  * Full author contact details are available in file CREDITS
8  */
9
10 #include <config.h>
11
12 #ifdef __GNUG__
13 #pragma implementation
14 #endif
15
16 #include "xformsBC.h"
17 #include "ControlSearch.h"
18 #include "FormSearch.h"
19 #include "forms/form_search.h"
20 #include FORMS_H_LOCATION
21
22 typedef FormCB<ControlSearch, FormDB<FD_search> > base_class;
23
24 FormSearch::FormSearch()
25         : base_class(_("LyX: Find and Replace"))
26 {}
27
28
29 void FormSearch::build()
30 {
31         dialog_.reset(build_search(this));
32
33         // Manage the ok, apply and cancel/close buttons
34         bc().setCancel(dialog_->button_close);
35         bc().addReadOnly(dialog_->input_replace);
36         bc().addReadOnly(dialog_->button_replace);
37         bc().addReadOnly(dialog_->button_replaceall);
38 }
39
40
41 void FormSearch::update()
42 {
43         fl_set_input_selected(dialog_->input_search, true);
44         fl_set_focus_object(dialog_->form, dialog_->input_search);
45 }
46
47
48 ButtonPolicy::SMInput FormSearch::input(FL_OBJECT * obj, long)
49 {
50         if (obj == dialog_->button_findnext ||
51             obj == dialog_->button_findprev) {
52                 bool const forward = (obj == dialog_->button_findnext);
53
54                 controller().find(fl_get_input(dialog_->input_search),
55                                   fl_get_button(dialog_->check_casesensitive),
56                                   fl_get_button(dialog_->check_matchword),
57                                   forward);
58
59         } else if (obj == dialog_->button_replace ||
60                    obj == dialog_->button_replaceall) {
61                 bool const all = (obj == dialog_->button_replaceall);
62
63                 controller().replace(fl_get_input(dialog_->input_search),
64                                      fl_get_input(dialog_->input_replace),
65                                      fl_get_button(dialog_->check_casesensitive),
66                                      fl_get_button(dialog_->check_matchword),
67                                      all);
68         }
69
70         return ButtonPolicy::SMI_VALID;
71 }