1 /* This file is part of
2 * ======================================================
4 * LyX, The Document Processor
6 * Copyright 1995 Matthias Ettrich,
7 * Copyright 1995-2000 The LyX Team.
9 * ====================================================== */
14 #pragma implementation
19 #include "lyx_gui_misc.h"
20 #include "frontends/Dialogs.h" // redrawGUI
22 #ifdef SIGC_CXX_NAMESPACES
26 // callbacks for form form_search
27 void SearchCancelCB(FL_OBJECT * ob, long)
29 fl_hide_form(ob->form);
33 void SearchForwardCB(FL_OBJECT * ob, long)
35 LyXFindReplace * lfr = static_cast<LyXFindReplace*>(ob->form->u_vdata);
40 void SearchBackwardCB(FL_OBJECT * ob, long)
42 LyXFindReplace * lfr = static_cast<LyXFindReplace*>(ob->form->u_vdata);
47 void SearchReplaceAllCB(FL_OBJECT * ob, long)
49 LyXFindReplace * lfr = static_cast<LyXFindReplace*>(ob->form->u_vdata);
50 lfr->SearchReplaceAllCB();
54 void SearchReplaceCB(FL_OBJECT * ob, long)
56 LyXFindReplace * lfr = static_cast<LyXFindReplace*>(ob->form->u_vdata);
57 lfr->SearchReplaceCB();
62 SearchForm::SearchForm()
65 r_ = Dialogs::redrawGUI.connect(slot(this, &SearchForm::redraw));
69 SearchForm::~SearchForm()
71 // The search_form should be closed and freed when SearchForm
77 void SearchForm::redraw()
79 if (search_form && search_form->form_search->visible)
80 fl_redraw_form(search_form->form_search);
84 void SearchForm::SearchCancelCB()
86 fl_hide_form(search_form->form_search);
90 void SearchForm::StartSearch(LyXFindReplace * lfr)
92 static int ow = -1, oh;
95 search_form = create_form_form_search();
96 fl_set_form_atclose(search_form->form_search,
100 search_form->form_search->u_vdata = lfr;
103 if (search_form->form_search->visible) {
104 fl_raise_form(search_form->form_search);
106 fl_show_form(search_form->form_search,
107 FL_PLACE_MOUSE | FL_FREE_SIZE, FL_TRANSIENT,
108 _("Find & Replace")); // RVDK_PATCH_5
110 ow = search_form->form_search->w;
111 oh = search_form->form_search->h;
113 fl_set_form_minsize(search_form->form_search, ow, oh);
118 // Returns the value of the replace string in the form
119 string const SearchForm::ReplaceString() const
121 return fl_get_input(search_form->input_replace);
125 void SearchForm::replaceEnabled(bool fEnable)
127 fReplaceEnabled = fEnable;
129 fl_activate_object(search_form->replace_button);
130 fl_activate_object(search_form->replaceall_button);
131 fl_activate_object(search_form->input_replace);
132 fl_set_object_lcol(search_form->replace_button, FL_BLACK);
133 fl_set_object_lcol(search_form->replaceall_button, FL_BLACK);
134 fl_set_object_lcol(search_form->input_replace, FL_BLACK);
136 fl_deactivate_object(search_form->replace_button);
137 fl_deactivate_object(search_form->replaceall_button);
138 fl_deactivate_object(search_form->input_replace);
139 fl_set_object_lcol(search_form->replace_button, FL_INACTIVE);
140 fl_set_object_lcol(search_form->replaceall_button, FL_INACTIVE);
141 fl_set_object_lcol(search_form->input_replace, FL_INACTIVE);
146 void SearchForm::SetSearchString(string const & ls)
148 fl_set_input(search_form->input_search, ls.c_str());