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
28 #include "lyxscreen.h"
32 #include "LyXView.h" // only because of form_main
34 //---------------------------------------------------------------
35 // I hate global variables, but the same search object must be used everywhere,
36 // and the form is also global, so...
39 // This one should be a protected member of LyXFindReplace1
40 // Form creation/destruction must also be done in LyXFindReplace1
41 extern FD_form_search *fd_form_search;
43 //---------------------------------------------------------------
46 // callbacks for form form_search
47 void SearchCancelCB(FL_OBJECT *, long)
53 void SearchForwardCB(FL_OBJECT *, long)
59 void SearchBackwardCB(FL_OBJECT *, long)
65 void SearchReplaceAllCB(FL_OBJECT *, long)
67 _FR.SearchReplaceAllCB();
71 void SearchReplaceCB(FL_OBJECT *, long)
73 _FR.SearchReplaceCB();
77 //--------------------- LyXFindReplace0's implementation ------------
79 LyXFindReplace0::LyXFindReplace0()
81 fCaseSensitive = false;
86 void LyXFindReplace0::StartSearch()
88 static int ow = -1, oh;
90 FD_form_search *fd_fs = fd_form_search;
92 if (fd_fs->form_search->visible) {
93 fl_raise_form(fd_fs->form_search);
95 fl_show_form(fd_fs->form_search,
96 FL_PLACE_MOUSE | FL_FREE_SIZE, FL_FULLBORDER,
97 _("Find & Replace")); // RVDK_PATCH_5
99 ow = fd_form_search->form_search->w;
100 oh = fd_form_search->form_search->h;
102 fl_set_form_minsize(fd_form_search->form_search, ow, oh);
108 void LyXFindReplace0::ReInitFromForm()
110 FD_form_search *fd_fs = fd_form_search;
112 lsSearch = fl_get_input(fd_fs->input_search);
113 fCaseSensitive = fl_get_button(fd_fs->btnCaseSensitive);
114 fMatchWord = fl_get_button(fd_fs->btnMatchWord);
118 // Returns the value of the replace string in the form
119 string const LyXFindReplace0::ReplaceString()
121 return string(fl_get_input(fd_form_search->input_replace));
125 void LyXFindReplace0::SearchCancelCB()
127 fl_hide_form(fd_form_search->form_search);
131 void LyXFindReplace0::SetReplaceEnabled(bool fEnable)
133 FD_form_search *fd_fs = fd_form_search;
134 fReplaceEnabled = fEnable;
136 fl_activate_object(fd_fs->replace_button);
137 fl_activate_object(fd_fs->replaceall_button);
138 fl_activate_object(fd_fs->input_replace);
139 fl_set_object_lcol(fd_fs->replace_button, FL_BLACK);
140 fl_set_object_lcol(fd_fs->replaceall_button, FL_BLACK);
141 fl_set_object_lcol(fd_fs->input_replace, FL_BLACK);
143 fl_deactivate_object(fd_fs->replace_button);
144 fl_deactivate_object(fd_fs->replaceall_button);
145 fl_deactivate_object(fd_fs->input_replace);
146 fl_set_object_lcol(fd_fs->replace_button,FL_INACTIVE);
147 fl_set_object_lcol(fd_fs->replaceall_button,FL_INACTIVE);
148 fl_set_object_lcol(fd_fs->input_replace, FL_INACTIVE);
153 void LyXFindReplace0::SetSearchString(string const &ls)
156 fl_set_input(fd_form_search->input_search, ls.c_str());
160 //---------------------------------------------------------------
161 //HB??: Maybe _FR.StartSearch should be called in lyxfunc.C instead of MenuSearch() ?