]> git.lyx.org Git - lyx.git/blob - src/frontends/xforms/FormSearch.C
Added // -*- C++ -*- to the top of all files in controllers/ and xforms/
[lyx.git] / src / frontends / xforms / FormSearch.C
1 // -*- C++ -*-
2 /**
3  * \file FormSearch.C
4  * Copyright 2001 The LyX Team.
5  * See the file COPYING.
6  *
7  * \author Edwin Leuven
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 "form_search.h"
20
21 typedef FormCB<ControlSearch, FormDB<FD_form_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());
31         
32         // Manage the ok, apply and cancel/close buttons
33         bc().setCancel(dialog_->button_cancel);
34         bc().addReadOnly(dialog_->input_replace);
35         bc().addReadOnly(dialog_->replace);
36         bc().addReadOnly(dialog_->replaceall);
37 }
38
39
40 ButtonPolicy::SMInput FormSearch::input(FL_OBJECT * obj, long)
41 {
42         if (obj == dialog_->findnext || obj == dialog_->findprev) {
43                 bool const forward = (obj == dialog_->findnext);
44         
45                 controller().find(fl_get_input(dialog_->input_search),
46                                   fl_get_button(dialog_->casesensitive),
47                                   fl_get_button(dialog_->matchword),
48                                   forward);
49
50         } else if (obj == dialog_->replace || obj == dialog_->replaceall) {
51                 bool const all = (obj == dialog_->replaceall);
52         
53                 controller().replace(fl_get_input(dialog_->input_search),
54                                      fl_get_input(dialog_->input_replace),
55                                      fl_get_button(dialog_->casesensitive),
56                                      fl_get_button(dialog_->matchword),
57                                      all);
58         }
59    
60         return ButtonPolicy::SMI_VALID;
61 }