]> git.lyx.org Git - lyx.git/blob - src/lyxfr0.C
More fixes to insettabular/text (and some missing features added).
[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 #include "frontends/Dialogs.h" // redrawGUI
21
22 #ifdef SIGC_CXX_NAMESPACES
23 using SigC::slot;
24 #endif
25
26 // callbacks for form form_search
27 void SearchCancelCB(FL_OBJECT * ob, long)
28 {
29         fl_hide_form(ob->form);
30 }
31
32
33 void SearchForwardCB(FL_OBJECT * ob, long)
34 {
35         LyXFindReplace * lfr = static_cast<LyXFindReplace*>(ob->form->u_vdata);
36         lfr->SearchCB(true);
37 }
38
39
40 void SearchBackwardCB(FL_OBJECT * ob, long)
41 {
42         LyXFindReplace * lfr = static_cast<LyXFindReplace*>(ob->form->u_vdata);
43         lfr->SearchCB(false);
44 }
45
46
47 void SearchReplaceAllCB(FL_OBJECT * ob, long)
48 {
49         LyXFindReplace * lfr = static_cast<LyXFindReplace*>(ob->form->u_vdata);
50         lfr->SearchReplaceAllCB();
51 }
52
53
54 void SearchReplaceCB(FL_OBJECT * ob, long)
55 {
56         LyXFindReplace * lfr = static_cast<LyXFindReplace*>(ob->form->u_vdata);
57         lfr->SearchReplaceCB();
58 }
59
60
61
62 SearchForm::SearchForm()
63         : search_form(0)
64 {
65         r_ = Dialogs::redrawGUI.connect(slot(this, &SearchForm::redraw));
66 }
67
68
69 SearchForm::~SearchForm()
70 {
71         // The search_form should be closed and freed when SearchForm
72         // is destructed.
73         r_.disconnect();
74 }
75
76
77 void SearchForm::redraw()
78 {
79         if (search_form && search_form->form_search->visible)
80                 fl_redraw_form(search_form->form_search);
81 }
82
83
84 void SearchForm::SearchCancelCB()
85 {
86         fl_hide_form(search_form->form_search);
87 }
88
89
90 void SearchForm::StartSearch(LyXFindReplace * lfr)
91 {
92         static int ow = -1, oh;
93
94         if (!search_form) {
95                 search_form = create_form_form_search();
96                 fl_set_form_atclose(search_form->form_search,
97                                     CancelCloseBoxCB, 0);
98         }
99         // Set the u_vdata
100         search_form->form_search->u_vdata = lfr;
101                 
102         
103         if (search_form->form_search->visible) {
104                 fl_raise_form(search_form->form_search);
105         } else {
106                 fl_show_form(search_form->form_search,
107                              FL_PLACE_MOUSE | FL_FREE_SIZE, FL_TRANSIENT,
108                              _("Find & Replace"));      // RVDK_PATCH_5
109                 if (ow < 0) {
110                         ow = search_form->form_search->w;
111                         oh = search_form->form_search->h;
112                 }
113                 fl_set_form_minsize(search_form->form_search, ow, oh);
114         }
115 }
116
117
118 // Returns the value of the replace string in the form
119 string const SearchForm::ReplaceString() const
120 {
121         return fl_get_input(search_form->input_replace);
122 }
123
124
125 void SearchForm::replaceEnabled(bool fEnable)
126 {
127         fReplaceEnabled = fEnable;
128         if (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);
135         } else {
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);
142         }
143 }
144
145
146 void SearchForm::SetSearchString(string const & ls)
147 {
148         fl_set_input(search_form->input_search, ls.c_str());    
149 }