]> git.lyx.org Git - lyx.git/blob - src/frontends/xforms/FormSearch.C
fix tooltips in toolbar
[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, Dialogs & d)
24         : base_class(c, d, _("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 void FormSearch::update()
41 {
42         fl_set_input_selected(dialog_->input_search, true);
43         fl_set_focus_object(dialog_->form, dialog_->input_search);
44 }
45
46
47 ButtonPolicy::SMInput FormSearch::input(FL_OBJECT * obj, long)
48 {
49         if (obj == dialog_->button_findnext ||
50             obj == dialog_->button_findprev) {
51                 bool const forward = (obj == dialog_->button_findnext);
52
53                 controller().find(fl_get_input(dialog_->input_search),
54                                   fl_get_button(dialog_->check_casesensitive),
55                                   fl_get_button(dialog_->check_matchword),
56                                   forward);
57
58         } else if (obj == dialog_->button_replace ||
59                    obj == dialog_->button_replaceall) {
60                 bool const all = (obj == dialog_->button_replaceall);
61
62                 controller().replace(fl_get_input(dialog_->input_search),
63                                      fl_get_input(dialog_->input_replace),
64                                      fl_get_button(dialog_->check_casesensitive),
65                                      fl_get_button(dialog_->check_matchword),
66                                      all);
67         }
68
69         return ButtonPolicy::SMI_VALID;
70 }