]> git.lyx.org Git - lyx.git/blob - src/lyxfr0.C
Fix configure bug with gettext
[lyx.git] / src / lyxfr0.C
1 /* This file is part of
2  * ====================================================== 
3  * 
4  *           LyX, The Document Processor
5  *       
6  *          Copyright 1995 Matthias Ettrich,
7  *          Copyright 1995-2000 The LyX Team.
8  *
9  * ====================================================== */
10
11 #include <config.h>
12
13 #ifdef __GNUG__
14 #pragma implementation
15 #endif
16
17 #include "lyxfr0.h"
18 #include "lyxfr1.h"
19 #include "lyx_gui_misc.h"
20
21
22 // callbacks for form form_search
23 void SearchCancelCB(FL_OBJECT * ob, long)
24 {
25         fl_hide_form(ob->form);
26 }
27
28
29 void SearchForwardCB(FL_OBJECT * ob, long)
30 {
31         LyXFindReplace * lfr = static_cast<LyXFindReplace*>(ob->form->u_vdata);
32         lfr->SearchCB(true);
33 }
34
35
36 void SearchBackwardCB(FL_OBJECT * ob, long)
37 {
38         LyXFindReplace * lfr = static_cast<LyXFindReplace*>(ob->form->u_vdata);
39         lfr->SearchCB(false);
40 }
41
42
43 void SearchReplaceAllCB(FL_OBJECT * ob, long)
44 {
45         LyXFindReplace * lfr = static_cast<LyXFindReplace*>(ob->form->u_vdata);
46         lfr->SearchReplaceAllCB();
47 }
48
49
50 void SearchReplaceCB(FL_OBJECT * ob, long)
51 {
52         LyXFindReplace * lfr = static_cast<LyXFindReplace*>(ob->form->u_vdata);
53         lfr->SearchReplaceCB();
54 }
55
56
57
58 SearchForm::SearchForm()
59         : search_form(0)
60 {}
61
62
63 SearchForm::~SearchForm()
64 {
65         // The search_form should be closed and freed when SearchForm
66         // is destructed.
67 }
68
69
70 void SearchForm::SearchCancelCB()
71 {
72         fl_hide_form(search_form->form_search);
73 }
74
75
76 void SearchForm::StartSearch(LyXFindReplace * lfr)
77 {
78         static int ow = -1, oh;
79
80         if (!search_form) {
81                 search_form = create_form_form_search();
82                 fl_set_form_atclose(search_form->form_search,
83                                     CancelCloseBoxCB, 0);
84         }
85         // Set the u_vdata
86         search_form->form_search->u_vdata = lfr;
87                 
88         
89         if (search_form->form_search->visible) {
90                 fl_raise_form(search_form->form_search);
91         } else {
92                 fl_show_form(search_form->form_search,
93                              FL_PLACE_MOUSE | FL_FREE_SIZE, FL_FULLBORDER,
94                              _("Find & Replace"));      // RVDK_PATCH_5
95                 if (ow < 0) {
96                         ow = search_form->form_search->w;
97                         oh = search_form->form_search->h;
98                 }
99                 fl_set_form_minsize(search_form->form_search, ow, oh);
100         }
101 }
102
103
104 // Returns the value of the replace string in the form
105 string SearchForm::ReplaceString() const
106 {
107         return fl_get_input(search_form->input_replace);
108 }
109
110
111 void SearchForm::replaceEnabled(bool fEnable)
112 {
113         fReplaceEnabled = fEnable;
114         if (fEnable) {
115                 fl_activate_object(search_form->replace_button);
116                 fl_activate_object(search_form->replaceall_button);
117                 fl_activate_object(search_form->input_replace);
118                 fl_set_object_lcol(search_form->replace_button, FL_BLACK);
119                 fl_set_object_lcol(search_form->replaceall_button, FL_BLACK);
120                 fl_set_object_lcol(search_form->input_replace, FL_BLACK);
121         } else {
122                 fl_deactivate_object(search_form->replace_button);
123                 fl_deactivate_object(search_form->replaceall_button);
124                 fl_deactivate_object(search_form->input_replace);
125                 fl_set_object_lcol(search_form->replace_button, FL_INACTIVE);
126                 fl_set_object_lcol(search_form->replaceall_button, FL_INACTIVE);
127                 fl_set_object_lcol(search_form->input_replace, FL_INACTIVE);
128         }
129 }
130
131
132 void SearchForm::SetSearchString(string const & ls)
133 {
134         fl_set_input(search_form->input_search, ls.c_str());    
135 }