]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/xforms/FormSearch.C
Change glob() API to accept a dir parameter.
[lyx.git] / src / frontends / xforms / FormSearch.C
index 78ffcf5ab93a27c03f4db33855af39b1304518a0..375dc0e21e6c97e5d880869269efa78410b50f0a 100644 (file)
@@ -1,61 +1,97 @@
-// -*- C++ -*-
 /**
  * \file FormSearch.C
- * Copyright 2001 The LyX Team.
- * See the file COPYING.
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
  *
  * \author Edwin Leuven
+ *
+ * Full author contact details are available in file CREDITS.
  */
 
 #include <config.h>
 
-#ifdef __GNUG__
-#pragma implementation
-#endif
+#include "FormSearch.h"
+#include "ControlSearch.h"
+#include "forms/form_search.h"
 
+#include "Tooltips.h"
+#include "xforms_helpers.h"
 #include "xformsBC.h"
-#include "ControlSearch.h"
-#include "FormSearch.h"
-#include "form_search.h"
 
-typedef FormCB<ControlSearch, FormDB<FD_form_search> > base_class;
+#include "lyx_forms.h"
 
-FormSearch::FormSearch(ControlSearch & c)
-       : base_class(c, _("LyX: Find and Replace"))
+using std::string;
+
+namespace lyx {
+namespace frontend {
+
+typedef FormController<ControlSearch, FormView<FD_search> > base_class;
+
+FormSearch::FormSearch(Dialog & parent)
+       : base_class(parent, _("Find and Replace"))
 {}
 
 
 void FormSearch::build()
 {
-       dialog_.reset(build_search());
-       
+       dialog_.reset(build_search(this));
+
        // Manage the ok, apply and cancel/close buttons
-       bc().setCancel(dialog_->button_cancel);
-       bc().addReadOnly(dialog_->input_replace);
-       bc().addReadOnly(dialog_->replace);
-       bc().addReadOnly(dialog_->replaceall);
+       bcview().setCancel(dialog_->button_close);
+
+       // disable for read-only documents
+       bcview().addReadOnly(dialog_->input_replace);
+       bcview().addReadOnly(dialog_->button_replace);
+       bcview().addReadOnly(dialog_->button_replaceall);
+
+       // set up the tooltips
+       string str = _("Enter the string you want to find.");
+       tooltips().init(dialog_->input_search, str);
+       str = _("Enter the replacement string.");
+       tooltips().init(dialog_->input_replace, str);
+       str = _("Continue to next search result.");
+       tooltips().init(dialog_->button_findnext, str);
+       str = _("Replace search result by replacement string.");
+       tooltips().init(dialog_->button_replace, str);
+       str = _("Replace all by replacement string.");
+       tooltips().init(dialog_->button_replaceall, str);
+       str = _("Do case sensitive search.");
+       tooltips().init(dialog_->check_casesensitive, str);
+       str = _("Search only matching words.");
+       tooltips().init(dialog_->check_matchword, str);
+       str = _("Search backwards.");
+       tooltips().init(dialog_->check_searchbackwards, str);
+}
+
+
+void FormSearch::update()
+{
+       fl_set_input_selected(dialog_->input_search, true);
+       fl_set_focus_object(dialog_->form, dialog_->input_search);
 }
 
 
-ButtonPolicy::SMInput FormSearch::input(FL_OBJECT * obj, long)
+ButtonPolicy::SMInput FormSearch::input(FL_OBJECT * ob, long)
 {
-       if (obj == dialog_->findnext || obj == dialog_->findprev) {
-               bool const forward = (obj == dialog_->findnext);
-       
-               controller().find(fl_get_input(dialog_->input_search),
-                                 fl_get_button(dialog_->casesensitive),
-                                 fl_get_button(dialog_->matchword),
-                                 forward);
-
-       } else if (obj == dialog_->replace || obj == dialog_->replaceall) {
-               bool const all = (obj == dialog_->replaceall);
-       
-               controller().replace(fl_get_input(dialog_->input_search),
-                                    fl_get_input(dialog_->input_replace),
-                                    fl_get_button(dialog_->casesensitive),
-                                    fl_get_button(dialog_->matchword),
+       if (ob == dialog_->button_findnext) {
+               controller().find(getString(dialog_->input_search),
+                                 fl_get_button(dialog_->check_casesensitive),
+                                 fl_get_button(dialog_->check_matchword),
+                                 !fl_get_button(dialog_->check_searchbackwards));
+
+       } else if (ob == dialog_->button_replace || ob == dialog_->button_replaceall) {
+               bool const all = (ob == dialog_->button_replaceall);
+
+               controller().replace(getString(dialog_->input_search),
+                                    getString(dialog_->input_replace),
+                                    fl_get_button(dialog_->check_casesensitive),
+                                    fl_get_button(dialog_->check_matchword),
+                                    !fl_get_button(dialog_->check_searchbackwards),
                                     all);
        }
-   
+
        return ButtonPolicy::SMI_VALID;
 }
+
+} // namespace frontend
+} // namespace lyx