1999-09-27 18:44:28 +00:00
|
|
|
/* This file is part of
|
1999-11-15 12:01:38 +00:00
|
|
|
* ======================================================
|
1999-10-02 16:21:10 +00:00
|
|
|
*
|
|
|
|
* LyX, The Document Processor
|
|
|
|
*
|
|
|
|
* Copyright 1995 Matthias Ettrich,
|
2000-03-16 04:29:22 +00:00
|
|
|
* Copyright 1995-2000 The LyX Team.
|
1999-10-02 16:21:10 +00:00
|
|
|
*
|
1999-11-15 12:01:38 +00:00
|
|
|
* ====================================================== */
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
#ifdef __GNUG__
|
|
|
|
#pragma implementation
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "lyxfr0.h"
|
|
|
|
#include "lyxfr1.h"
|
2000-03-01 04:56:55 +00:00
|
|
|
#include "lyx_gui_misc.h"
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
|
|
|
// callbacks for form form_search
|
2000-03-01 04:56:55 +00:00
|
|
|
void SearchCancelCB(FL_OBJECT * ob, long)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
2000-03-01 04:56:55 +00:00
|
|
|
fl_hide_form(ob->form);
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-03-01 04:56:55 +00:00
|
|
|
void SearchForwardCB(FL_OBJECT * ob, long)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
2000-03-01 04:56:55 +00:00
|
|
|
LyXFindReplace * lfr = static_cast<LyXFindReplace*>(ob->form->u_vdata);
|
|
|
|
lfr->SearchCB(true);
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-03-01 04:56:55 +00:00
|
|
|
void SearchBackwardCB(FL_OBJECT * ob, long)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
2000-03-01 04:56:55 +00:00
|
|
|
LyXFindReplace * lfr = static_cast<LyXFindReplace*>(ob->form->u_vdata);
|
|
|
|
lfr->SearchCB(false);
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-03-01 04:56:55 +00:00
|
|
|
void SearchReplaceAllCB(FL_OBJECT * ob, long)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
2000-03-01 04:56:55 +00:00
|
|
|
LyXFindReplace * lfr = static_cast<LyXFindReplace*>(ob->form->u_vdata);
|
|
|
|
lfr->SearchReplaceAllCB();
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-03-01 04:56:55 +00:00
|
|
|
void SearchReplaceCB(FL_OBJECT * ob, long)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
2000-03-01 04:56:55 +00:00
|
|
|
LyXFindReplace * lfr = static_cast<LyXFindReplace*>(ob->form->u_vdata);
|
|
|
|
lfr->SearchReplaceCB();
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2000-03-01 04:56:55 +00:00
|
|
|
SearchForm::SearchForm()
|
|
|
|
: search_form(0)
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
|
|
SearchForm::~SearchForm()
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
2000-03-01 04:56:55 +00:00
|
|
|
// The search_form should be closed and freed when SearchForm
|
|
|
|
// is destructed.
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-03-01 04:56:55 +00:00
|
|
|
void SearchForm::SearchCancelCB()
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
2000-03-01 04:56:55 +00:00
|
|
|
fl_hide_form(search_form->form_search);
|
|
|
|
}
|
|
|
|
|
1999-10-25 14:50:26 +00:00
|
|
|
|
2000-03-01 04:56:55 +00:00
|
|
|
void SearchForm::StartSearch(LyXFindReplace * lfr)
|
|
|
|
{
|
|
|
|
static int ow = -1, oh;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2000-03-01 04:56:55 +00:00
|
|
|
if (!search_form) {
|
|
|
|
search_form = create_form_form_search();
|
|
|
|
fl_set_form_atclose(search_form->form_search,
|
|
|
|
CancelCloseBoxCB, 0);
|
|
|
|
}
|
|
|
|
// Set the u_vdata
|
|
|
|
search_form->form_search->u_vdata = lfr;
|
|
|
|
|
|
|
|
|
|
|
|
if (search_form->form_search->visible) {
|
|
|
|
fl_raise_form(search_form->form_search);
|
1999-09-27 18:44:28 +00:00
|
|
|
} else {
|
2000-03-01 04:56:55 +00:00
|
|
|
fl_show_form(search_form->form_search,
|
1999-09-27 18:44:28 +00:00
|
|
|
FL_PLACE_MOUSE | FL_FREE_SIZE, FL_FULLBORDER,
|
|
|
|
_("Find & Replace")); // RVDK_PATCH_5
|
1999-10-25 14:50:26 +00:00
|
|
|
if (ow < 0) {
|
2000-03-01 04:56:55 +00:00
|
|
|
ow = search_form->form_search->w;
|
|
|
|
oh = search_form->form_search->h;
|
1999-10-25 14:50:26 +00:00
|
|
|
}
|
2000-03-01 04:56:55 +00:00
|
|
|
fl_set_form_minsize(search_form->form_search, ow, oh);
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Returns the value of the replace string in the form
|
2000-03-01 04:56:55 +00:00
|
|
|
string SearchForm::ReplaceString() const
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
2000-03-01 04:56:55 +00:00
|
|
|
return fl_get_input(search_form->input_replace);
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-03-01 04:56:55 +00:00
|
|
|
void SearchForm::replaceEnabled(bool fEnable)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
|
|
|
fReplaceEnabled = fEnable;
|
|
|
|
if (fEnable) {
|
2000-03-01 04:56:55 +00:00
|
|
|
fl_activate_object(search_form->replace_button);
|
|
|
|
fl_activate_object(search_form->replaceall_button);
|
|
|
|
fl_activate_object(search_form->input_replace);
|
|
|
|
fl_set_object_lcol(search_form->replace_button, FL_BLACK);
|
|
|
|
fl_set_object_lcol(search_form->replaceall_button, FL_BLACK);
|
|
|
|
fl_set_object_lcol(search_form->input_replace, FL_BLACK);
|
1999-09-27 18:44:28 +00:00
|
|
|
} else {
|
2000-03-01 04:56:55 +00:00
|
|
|
fl_deactivate_object(search_form->replace_button);
|
|
|
|
fl_deactivate_object(search_form->replaceall_button);
|
|
|
|
fl_deactivate_object(search_form->input_replace);
|
|
|
|
fl_set_object_lcol(search_form->replace_button, FL_INACTIVE);
|
|
|
|
fl_set_object_lcol(search_form->replaceall_button, FL_INACTIVE);
|
|
|
|
fl_set_object_lcol(search_form->input_replace, FL_INACTIVE);
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-03-01 04:56:55 +00:00
|
|
|
void SearchForm::SetSearchString(string const & ls)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
2000-03-01 04:56:55 +00:00
|
|
|
fl_set_input(search_form->input_search, ls.c_str());
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|