1 /* This file is part of
2 * ======================================================
4 * LyX, The Document Processor
6 * Copyright 1995 Matthias Ettrich,
7 * Copyright 1995-1999 The LyX Team.
9 * ====================================================== */
18 #pragma implementation
23 #include FORMS_H_LOCATION
31 #include "LyXView.h" // only because of form_main
33 //---------------------------------------------------------------
34 // I hate global variables, but the same search object must be used everywhere,
35 // and the form is also global, so...
38 // This one should be a protected member of LyXFindReplace1
39 // Form creation/destruction must also be done in LyXFindReplace1
40 extern FD_form_search *fd_form_search;
42 //---------------------------------------------------------------
45 // callbacks for form form_search
46 void SearchCancelCB(FL_OBJECT *, long)
52 void SearchForwardCB(FL_OBJECT *, long)
58 void SearchBackwardCB(FL_OBJECT *, long)
64 void SearchReplaceAllCB(FL_OBJECT *, long)
66 _FR.SearchReplaceAllCB();
70 void SearchReplaceCB(FL_OBJECT *, long)
72 _FR.SearchReplaceCB();
76 //--------------------- LyXFindReplace0's implementation ------------
78 LyXFindReplace0::LyXFindReplace0()
80 fCaseSensitive = false;
85 void LyXFindReplace0::StartSearch()
87 static int ow = -1, oh;
89 FD_form_search *fd_fs = fd_form_search;
91 if (fd_fs->form_search->visible) {
92 fl_raise_form(fd_fs->form_search);
94 fl_show_form(fd_fs->form_search,
95 FL_PLACE_MOUSE | FL_FREE_SIZE, FL_FULLBORDER,
96 _("Find & Replace")); // RVDK_PATCH_5
98 ow = fd_form_search->form_search->w;
99 oh = fd_form_search->form_search->h;
101 fl_set_form_minsize(fd_form_search->form_search, ow, oh);
107 void LyXFindReplace0::ReInitFromForm()
109 FD_form_search *fd_fs = fd_form_search;
111 lsSearch = fl_get_input(fd_fs->input_search);
112 fCaseSensitive = fl_get_button(fd_fs->btnCaseSensitive);
113 fMatchWord = fl_get_button(fd_fs->btnMatchWord);
117 // Returns the value of the replace string in the form
118 string const LyXFindReplace0::ReplaceString()
120 return string(fl_get_input(fd_form_search->input_replace));
124 void LyXFindReplace0::SearchCancelCB()
126 fl_hide_form(fd_form_search->form_search);
130 void LyXFindReplace0::SetReplaceEnabled(bool fEnable)
132 FD_form_search *fd_fs = fd_form_search;
133 fReplaceEnabled = fEnable;
135 fl_activate_object(fd_fs->replace_button);
136 fl_activate_object(fd_fs->replaceall_button);
137 fl_activate_object(fd_fs->input_replace);
138 fl_set_object_lcol(fd_fs->replace_button, FL_BLACK);
139 fl_set_object_lcol(fd_fs->replaceall_button, FL_BLACK);
140 fl_set_object_lcol(fd_fs->input_replace, FL_BLACK);
142 fl_deactivate_object(fd_fs->replace_button);
143 fl_deactivate_object(fd_fs->replaceall_button);
144 fl_deactivate_object(fd_fs->input_replace);
145 fl_set_object_lcol(fd_fs->replace_button, FL_INACTIVE);
146 fl_set_object_lcol(fd_fs->replaceall_button, FL_INACTIVE);
147 fl_set_object_lcol(fd_fs->input_replace, FL_INACTIVE);
152 void LyXFindReplace0::SetSearchString(string const &ls)
155 fl_set_input(fd_form_search->input_search, ls.c_str());
159 //---------------------------------------------------------------
160 //HB??: Maybe _FR.StartSearch should be called in lyxfunc.C instead of MenuSearch() ?