of the buffer, LaTeX, Literate, LinuxDoc or DocBook.
* ControlRef.[Ch]:
- * ControlTabularCreate.[Ch]: new files; controller for the Ref and
- TabularCreate popups, respectively.
+ * ControlSearch.[Ch]:
+ * ControlTabularCreate.[Ch]: new files; controller for the Ref,
+ Search and TabularCreate popups, respectively.
* GUI.h:
* Makefile.am: associated changes.
--- /dev/null
+/* This file is part of
+ * ======================================================
+ *
+ * LyX, The Document Processor
+ *
+ * Copyright 2001 The LyX Team.
+ *
+ * ======================================================
+ *
+ * \file ControlSearch.C
+ * \author Angus Leeming <a.leeming@ic.ac.uk>
+ */
+
+#include <config.h>
+
+#ifdef __GNUG__
+#pragma implementation
+#endif
+
+#include "ControlSearch.h"
+#include "Dialogs.h"
+#include "Liason.h"
+#include "LyXView.h"
+#include "buffer.h"
+#include "lyxfind.h"
+#include "debug.h"
+
+using Liason::setMinibuffer;
+using SigC::slot;
+
+ControlSearch::ControlSearch(LyXView & lv, Dialogs & d)
+ : ControlDialog<ControlConnectBD>(lv, d)
+{
+ d_.showSearch.connect(SigC::slot(this, &ControlSearch::show));
+
+ // perhaps in the future we'd like a
+ // "search again" button/keybinding
+ // d_.searchAgain.connect(SigC::slot(this, &ControlSearch::FindNext));
+}
+
+
+void ControlSearch::find(string const & search,
+ bool casesensitive, bool matchword, bool forward) const
+{
+ bool const found = LyXFind(lv_.view(), search, casesensitive,
+ matchword, forward);
+
+ if (!found)
+ setMinibuffer(&lv_, _("String not found!"));
+}
+
+
+void ControlSearch::replace(string const & search, string const & replace,
+ bool casesensitive, bool matchword, bool all) const
+{
+ int const replace_count = LyXReplace(lv_.view(),
+ search, replace, casesensitive,
+ matchword, true, all);
+
+ if (replace_count == 0) {
+ setMinibuffer(&lv_, _("String not found!"));
+ } else {
+ if (replace_count == 1) {
+ setMinibuffer(&lv_, _("String has been replaced."));
+ } else {
+ string str = tostr(replace_count);
+ str += _(" strings have been replaced.");
+ setMinibuffer(&lv_, str.c_str());
+ }
+ }
+}
--- /dev/null
+/* This file is part of
+ * ======================================================
+ *
+ * LyX, The Document Processor
+ *
+ * Copyright 2001 The LyX Team.
+ *
+ * ======================================================
+ *
+ * \file ControlSearch.h
+ * \author Angus Leeming <a.leeming@ic.ac.uk>
+ */
+
+#ifndef CONTROLSEARCH_H
+#define CONTROLSEARCH_H
+
+#ifdef __GNUG__
+#pragma interface
+#endif
+
+#include "ControlDialogs.h"
+
+/** A controller for Search dialogs.
+ */
+class ControlSearch : public ControlDialog<ControlConnectBD> {
+public:
+ ///
+ ControlSearch(LyXView &, Dialogs &);
+
+ /// Searches occurence of string
+ void find(string const & search,
+ bool casesensitive, bool matchword, bool forward) const;
+
+ /// Replaces occurence of string
+ void replace(string const & search, string const & replace,
+ bool casesensitive, bool matchword, bool all) const;
+
+private:
+ /// not needed.
+ virtual void apply() {}
+ ///
+ virtual void clearDaughterParams() {}
+};
+
+#endif // CONTROLSEARCH_H
#pragma implementation
#endif
-#include "Dialogs.h"
#include "ControlUrl.h"
#include "Dialogs.h"
#include "LyXView.h"
};
+/** Specialization for Search dialog
+ */
+class ControlSearch;
+
+template <class GUIview, class GUIbc>
+class GUISearch :
+ public GUI<ControlSearch, GUIview, NoRepeatedApplyReadOnlyPolicy, GUIbc> {
+public:
+ ///
+ GUISearch(LyXView & lv, Dialogs & d)
+ : GUI<ControlSearch, GUIview, NoRepeatedApplyReadOnlyPolicy, GUIbc>(lv, d) {}
+};
+
+
/** Specialization for TabularCreate dialog
*/
class ControlTabularCreate;
ControlLog.h \
ControlRef.C \
ControlRef.h \
+ ControlSearch.C \
+ ControlSearch.h \
ControlTabularCreate.C \
ControlTabularCreate.h \
ControlUrl.C \
* FormRef.[Ch]:
* forms/form_ref.fd:
+ * FormSearch.[Ch]:
+ * forms/form_search.fd:
* FormTabularCreate.[Ch]:
* forms/form_tabular_create.fd: implemented controller-view split.
#include "ControlLog.h"
#include "ControlUrl.h"
#include "ControlRef.h"
+#include "ControlSearch.h"
#include "ControlTabularCreate.h"
#include "ControlVCLog.h"
#include "form_error.h"
#include "form_include.h"
#include "form_ref.h"
+#include "form_search.h"
#include "form_tabular_create.h"
#include "form_url.h"
#include "FormInclude.h"
#include "FormLog.h"
#include "FormRef.h"
+#include "FormSearch.h"
#include "FormTabularCreate.h"
#include "FormUrl.h"
#include "FormVCLog.h"
#include "FormPreamble.h"
#include "FormPreferences.h"
#include "FormPrint.h"
-#include "FormSearch.h"
#include "FormSplash.h"
#include "FormTabular.h"
#include "FormToc.h"
add(new GUIInclude<FormInclude, xformsBC>(*lv, *this));
add(new GUILog<FormLog, xformsBC>(*lv, *this));
add(new GUIRef<FormRef, xformsBC>(*lv, *this));
+ add(new GUISearch<FormSearch, xformsBC>(*lv, *this));
+ add(new GUITabularCreate<FormTabularCreate, xformsBC>(*lv, *this));
add(new GUIUrl<FormUrl, xformsBC>(*lv, *this));
add(new GUIVCLog<FormVCLog, xformsBC>(*lv, *this));
- add(new GUITabularCreate<FormTabularCreate, xformsBC>(*lv, *this));
add(new FormDocument(lv, this));
add(new FormExternal(lv, this));
add(new FormPreamble(lv, this));
add(new FormPreferences(lv, this));
add(new FormPrint(lv, this));
- add(new FormSearch(lv, this));
add(new FormSplash(lv, this));
add(new FormTabular(lv, this));
add(new FormToc(lv, this));
vector<string>::const_iterator start = bibkeys.begin();
int const sel = fl_get_browser(dialog_->browser_bib);
- if (sel >= 1 && sel <= bibkeys.size())
+ if (sel >= 1 && sel <= int(bibkeys.size()))
start += sel-1;
// Find the NEXT instance...
private:
/// not needed.
virtual void apply() {}
- /// not needed.
- virtual void update() {}
/// Build the dialog
virtual void build();
+ /// not needed.
+ virtual void update() {}
/// Fdesign generated method
FD_form_copyright * build_copyright();
#pragma implementation
#endif
+#include "xformsBC.h"
+#include "ControlSearch.h"
#include "FormSearch.h"
#include "form_search.h"
-#include "gettext.h"
-#include "Dialogs.h"
-#include "Liason.h"
-#include "LyXView.h"
-#include "buffer.h"
-#include "gettext.h"
-#include "lyxfind.h"
-#include "debug.h"
-using Liason::setMinibuffer;
-using SigC::slot;
-
-FormSearch::FormSearch(LyXView * lv, Dialogs * d)
- : FormBaseBD(lv, d, _("LyX: Find and Replace"))
-{
- // let the popup be shown
- // This is a permanent connection so we won't bother
- // storing a copy because we won't be disconnecting.
- d->showSearch.connect(slot(this, &FormSearch::show));
- // perhaps in the future we'd like a
- // "search again" button/keybinding
-// d->searchAgain.connect(slot(this, &FormSearch::FindNext));
-}
+typedef FormCB<ControlSearch, FormDB<FD_form_search> > base_class;
+FormSearch::FormSearch(ControlSearch & c)
+ : base_class(c, _("LyX: Find and Replace"))
+{}
-FL_FORM * FormSearch::form() const
-{
- if (dialog_.get())
- return dialog_->form;
- return 0;
-}
void FormSearch::build()
{
- dialog_.reset(build_search());
+ dialog_.reset(build_search());
- // 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);
- bc_.refresh();
+ // 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);
+ bc().refresh();
}
-void FormSearch::update()
-{
- if (!dialog_.get())
- return;
- bc_.readOnly(lv_->buffer()->isReadonly());
-}
-
-bool FormSearch::input(FL_OBJECT * obj, long)
+ButtonPolicy::SMInput FormSearch::input(FL_OBJECT * obj, long)
{
- if (obj == dialog_->findnext)
- Find();
- else if (obj == dialog_->findprev)
- Find(false);
- else if (obj == dialog_->replace)
- Replace();
- else if (obj == dialog_->replaceall)
- Replace(true);
-
- return 0;
-}
+ 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);
-void FormSearch::Find(bool const next)
-{
- bool found = LyXFind(lv_->view(),
- fl_get_input(dialog_->input_search),
- fl_get_button(dialog_->casesensitive),
- fl_get_button(dialog_->matchword),
- next);
+ } 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),
+ all);
+ }
- if (!found)
- setMinibuffer(lv_, _("String not found!"));
-}
-
-
-void FormSearch::Replace(bool const all)
-{
- int replace_count = LyXReplace(lv_->view(),
- fl_get_input(dialog_->input_search),
- fl_get_input(dialog_->input_replace),
- fl_get_button(dialog_->casesensitive),
- fl_get_button(dialog_->matchword),
- true,
- all);
-
- if (replace_count == 0) {
- setMinibuffer(lv_, _("String not found!"));
- } else {
- if (replace_count == 1) {
- setMinibuffer(lv_, _("String has been replaced."));
- } else {
- string str = tostr(replace_count);
- str += _(" strings have been replaced.");
- setMinibuffer(lv_, str.c_str());
- }
- }
+ return ButtonPolicy::SMI_VALID;
}
-
-
#ifndef FORMSEARCH_H
#define FORMSEARCH_H
-#include <boost/smart_ptr.hpp>
-
#ifdef __GNUG__
#pragma interface
#endif
-#include "FormBaseDeprecated.h"
+#include "FormBase.h"
+class ControlSearch;
struct FD_form_search;
/** This class provides an XForms implementation of the FormSearch Dialog.
*/
-class FormSearch : public FormBaseBD {
+class FormSearch : public FormCB<ControlSearch, FormDB<FD_form_search> > {
public:
///
- FormSearch(LyXView *, Dialogs *);
+ FormSearch(ControlSearch &);
private:
- /// Pointer to the actual instantiation of the ButtonController.
- virtual xformsBC & bc();
-
- /// Filter the inputs
- virtual bool input(FL_OBJECT *, long);
-
- /// Build the popup
+ /// not needed.
+ virtual void apply() {}
+ /// Build the dialog
virtual void build();
+ /// not needed.
+ virtual void update() {}
- /// Update the popup
- virtual void update();
-
- /// Searches occurance of string
- /// if argument=true forward search otherwise backward search
- void Find(bool const = true);
- /// if argument=false replace once otherwise replace all
- /// Replaces occurance of string
- void Replace(bool const = false);
-
- ///
- virtual FL_FORM * form() const;
+ /// Filter the inputs
+ virtual ButtonPolicy::SMInput input(FL_OBJECT *, long);
- /// Typedefinitions from the fdesign produced Header file
+ /// Fdesign generated method
FD_form_search * build_search();
-
- /// Real GUI implementation.
- boost::scoped_ptr<FD_form_search> dialog_;
- /// The ButtonController
- ButtonController<NoRepeatedApplyReadOnlyPolicy, xformsBC> bc_;
};
-
-inline
-xformsBC & FormSearch::bc()
-{
- return bc_;
-}
-#endif
+#endif // FORMSEARCH_H
fl_set_object_lsize(obj, FL_NORMAL_SIZE);
fl_set_object_gravity(obj, FL_NorthWest, FL_NorthEast);
fl_set_object_resize(obj, FL_RESIZE_X);
- fl_set_object_callback(obj, C_FormBaseDeprecatedInputCB, 0);
+ fl_set_object_callback(obj, C_FormBaseInputCB, 0);
{
char const * const dummy = N_("Replace with|#W");
fdui->input_replace = obj = fl_add_input(FL_NORMAL_INPUT, 110, 40, 180, 30, idex(_(dummy)));
fl_set_object_lsize(obj, FL_NORMAL_SIZE);
fl_set_object_gravity(obj, FL_NorthWest, FL_NorthEast);
fl_set_object_resize(obj, FL_RESIZE_X);
- fl_set_object_callback(obj, C_FormBaseDeprecatedInputCB, 0);
+ fl_set_object_callback(obj, C_FormBaseInputCB, 0);
{
char const * const dummy = N_(" >|#F^s");
fdui->findnext = obj = fl_add_button(FL_NORMAL_BUTTON, 200, 80, 90, 30, idex(_(dummy)));
}
fl_set_object_lsize(obj, FL_NORMAL_SIZE);
fl_set_object_gravity(obj, FL_SouthEast, FL_SouthEast);
- fl_set_object_callback(obj, C_FormBaseDeprecatedInputCB, 0);
+ fl_set_object_callback(obj, C_FormBaseInputCB, 0);
{
char const * const dummy = N_(" <|#B^r");
fdui->findprev = obj = fl_add_button(FL_NORMAL_BUTTON, 110, 80, 90, 30, idex(_(dummy)));
}
fl_set_object_lsize(obj, FL_NORMAL_SIZE);
fl_set_object_gravity(obj, FL_SouthEast, FL_SouthEast);
- fl_set_object_callback(obj, C_FormBaseDeprecatedInputCB, 0);
+ fl_set_object_callback(obj, C_FormBaseInputCB, 0);
{
char const * const dummy = N_("Replace|#R#r");
fdui->replace = obj = fl_add_button(FL_NORMAL_BUTTON, 110, 120, 90, 30, idex(_(dummy)));
}
fl_set_object_lsize(obj, FL_NORMAL_SIZE);
fl_set_object_gravity(obj, FL_SouthEast, FL_SouthEast);
- fl_set_object_callback(obj, C_FormBaseDeprecatedInputCB, 0);
+ fl_set_object_callback(obj, C_FormBaseInputCB, 0);
{
char const * const dummy = N_("Close|^[");
fdui->button_cancel = obj = fl_add_button(FL_NORMAL_BUTTON, 350, 120, 80, 30, idex(_(dummy)));
}
fl_set_object_lsize(obj, FL_NORMAL_SIZE);
fl_set_object_gravity(obj, FL_SouthEast, FL_SouthEast);
- fl_set_object_callback(obj, C_FormBaseDeprecatedCancelCB, 0);
+ fl_set_object_callback(obj, C_FormBaseCancelCB, 0);
{
char const * const dummy = N_("Case sensitive|#s#S");
fdui->casesensitive = obj = fl_add_checkbutton(FL_PUSH_BUTTON, 300, 20, 150, 30, idex(_(dummy)));
fl_set_button_shortcut(obj, scex(_(dummy)), 1);
}
fl_set_object_gravity(obj, FL_NorthEast, FL_NorthEast);
- fl_set_object_callback(obj, C_FormBaseDeprecatedInputCB, 0);
+ fl_set_object_callback(obj, C_FormBaseInputCB, 0);
{
char const * const dummy = N_("Match word|#M#m");
fdui->matchword = obj = fl_add_checkbutton(FL_PUSH_BUTTON, 300, 50, 150, 30, idex(_(dummy)));
fl_set_button_shortcut(obj, scex(_(dummy)), 1);
}
fl_set_object_gravity(obj, FL_NorthEast, FL_NorthEast);
- fl_set_object_callback(obj, C_FormBaseDeprecatedInputCB, 0);
+ fl_set_object_callback(obj, C_FormBaseInputCB, 0);
{
char const * const dummy = N_("Replace All|#A#a");
fdui->replaceall = obj = fl_add_button(FL_NORMAL_BUTTON, 200, 120, 90, 30, idex(_(dummy)));
}
fl_set_object_lsize(obj, FL_NORMAL_SIZE);
fl_set_object_gravity(obj, FL_SouthEast, FL_SouthEast);
- fl_set_object_callback(obj, C_FormBaseDeprecatedInputCB, 0);
+ fl_set_object_callback(obj, C_FormBaseInputCB, 0);
fl_end_form();
fdui->form->fdui = fdui;
#define FD_form_search_h_
/** Callbacks, globals and object handlers **/
-extern "C" void C_FormBaseDeprecatedInputCB(FL_OBJECT *, long);
-extern "C" void C_FormBaseDeprecatedCancelCB(FL_OBJECT *, long);
+extern "C" void C_FormBaseInputCB(FL_OBJECT *, long);
+extern "C" void C_FormBaseCancelCB(FL_OBJECT *, long);
/**** Forms and Objects ****/
resize: FL_RESIZE_X
gravity: FL_NorthWest FL_NorthEast
name: input_search
-callback: C_FormBaseDeprecatedInputCB
+callback: C_FormBaseInputCB
argument: 0
--------------------
resize: FL_RESIZE_X
gravity: FL_NorthWest FL_NorthEast
name: input_replace
-callback: C_FormBaseDeprecatedInputCB
+callback: C_FormBaseInputCB
argument: 0
--------------------
resize: FL_RESIZE_NONE
gravity: FL_SouthEast FL_SouthEast
name: findnext
-callback: C_FormBaseDeprecatedInputCB
+callback: C_FormBaseInputCB
argument: 0
--------------------
resize: FL_RESIZE_NONE
gravity: FL_SouthEast FL_SouthEast
name: findprev
-callback: C_FormBaseDeprecatedInputCB
+callback: C_FormBaseInputCB
argument: 0
--------------------
resize: FL_RESIZE_NONE
gravity: FL_SouthEast FL_SouthEast
name: replace
-callback: C_FormBaseDeprecatedInputCB
+callback: C_FormBaseInputCB
argument: 0
--------------------
resize: FL_RESIZE_NONE
gravity: FL_SouthEast FL_SouthEast
name: button_cancel
-callback: C_FormBaseDeprecatedCancelCB
+callback: C_FormBaseCancelCB
argument: 0
--------------------
resize: FL_RESIZE_NONE
gravity: FL_NorthEast FL_NorthEast
name: casesensitive
-callback: C_FormBaseDeprecatedInputCB
+callback: C_FormBaseInputCB
argument: 0
--------------------
resize: FL_RESIZE_NONE
gravity: FL_NorthEast FL_NorthEast
name: matchword
-callback: C_FormBaseDeprecatedInputCB
+callback: C_FormBaseInputCB
argument: 0
--------------------
resize: FL_RESIZE_NONE
gravity: FL_SouthEast FL_SouthEast
name: replaceall
-callback: C_FormBaseDeprecatedInputCB
+callback: C_FormBaseInputCB
argument: 0
==============================