]> git.lyx.org Git - lyx.git/blob - src/frontends/xforms/FormBaseDeprecated.C
Merging BRANCH_MVC back into HEAD.
[lyx.git] / src / frontends / xforms / FormBaseDeprecated.C
1 // -*- C++ -*-
2 /* This file is part of
3  * ====================================================== 
4  *
5  *           LyX, The Document Processor
6  *
7  *           Copyright 2000 The LyX Team.
8  *
9  * ======================================================
10  */
11
12 #include <config.h>
13
14 #include FORMS_H_LOCATION
15
16 #ifdef __GNUG__
17 #pragma implementation
18 #endif
19
20 #include "Dialogs.h"
21 #include "FormBaseDeprecated.h"
22 #include "LyXView.h"
23 #include "support/LAssert.h"
24 #include "xformsBC.h"
25 //#include "debug.h"
26
27 extern "C" int C_FormBaseDeprecatedWMHideCB(FL_FORM * ob, void * d)
28 {
29         return FormBaseDeprecated::WMHideCB(ob, d);
30 }
31 extern "C" void C_FormBaseDeprecatedApplyCB(FL_OBJECT * ob, long d)
32 {
33         FormBaseDeprecated::ApplyCB(ob, d);
34 }
35 extern "C" void C_FormBaseDeprecatedOKCB(FL_OBJECT * ob, long d)
36 {
37         FormBaseDeprecated::OKCB(ob, d);
38 }
39 extern "C" void C_FormBaseDeprecatedCancelCB(FL_OBJECT * ob, long d)
40 {
41         FormBaseDeprecated::CancelCB(ob, d);
42 }
43 extern "C" void C_FormBaseDeprecatedInputCB(FL_OBJECT * ob, long d)
44 {
45         FormBaseDeprecated::InputCB(ob, d);
46 }
47 extern "C" void C_FormBaseDeprecatedRestoreCB(FL_OBJECT * ob, long d)
48 {
49         FormBaseDeprecated::RestoreCB(ob, d);
50 }
51
52
53 FormBaseDeprecated::FormBaseDeprecated(LyXView * lv, Dialogs * d,
54                                        string const & t)
55         : lv_(lv), d_(d), h_(0), r_(0), title(t), minw_(0), minh_(0)
56 {
57         Assert(lv && d);
58 }
59
60
61 void FormBaseDeprecated::redraw()
62 {
63         if (form() && form()->visible)
64                 fl_redraw_form(form());
65 }
66
67
68 void FormBaseDeprecated::connect()
69 {
70         fl_set_form_minsize(form(), minw_, minh_);
71         r_ = Dialogs::redrawGUI.connect(slot(this,&FormBaseDeprecated::redraw));
72 }
73
74
75 void FormBaseDeprecated::disconnect()
76 {
77         h_.disconnect();
78         r_.disconnect();
79 }
80
81
82 void FormBaseDeprecated::show()
83 {
84         if (!form()) {
85                 build();
86                 fl_set_form_atclose(form(),
87                                     C_FormBaseDeprecatedWMHideCB, 0);
88         }
89
90         fl_freeze_form(form());
91         update();  // make sure its up-to-date
92         fl_unfreeze_form(form());
93
94         if (form()->visible) {
95                 fl_raise_form(form());
96         } else {
97                 // calls to fl_set_form_minsize/maxsize apply only to the next
98                 // fl_show_form(), so connect() comes first.
99                 connect();
100                 fl_show_form(form(),
101                              FL_PLACE_MOUSE | FL_FREE_SIZE,
102                              FL_TRANSIENT,
103                              title.c_str());
104         }
105 }
106
107
108 void FormBaseDeprecated::hide()
109 {
110         if (form() && form()->visible) {
111                 // some dialogs might do things to the form first
112                 // such as the nested tabfolder problem in Preferences
113                 disconnect();
114                 fl_hide_form(form());
115         }
116 }
117
118
119 int FormBaseDeprecated::WMHideCB(FL_FORM * form, void *)
120 {
121         Assert(form);
122         // Ensure that the signals (u and h) are disconnected even if the
123         // window manager is used to close the dialog.
124         FormBaseDeprecated * pre =
125                 static_cast<FormBaseDeprecated*>(form->u_vdata);
126         Assert(pre);
127         pre->hide();
128         pre->bc().hide();
129         return FL_CANCEL;
130 }
131
132
133 void FormBaseDeprecated::ApplyCB(FL_OBJECT * ob, long)
134 {
135         Assert(ob && ob->form);
136         FormBaseDeprecated * pre =
137                 static_cast<FormBaseDeprecated*>(ob->form->u_vdata);
138         Assert(pre);
139         pre->apply();
140         pre->bc().apply();
141 }
142
143
144 void FormBaseDeprecated::OKCB(FL_OBJECT * ob, long)
145 {
146         Assert(ob && ob->form);
147         FormBaseDeprecated * pre =
148                 static_cast<FormBaseDeprecated*>(ob->form->u_vdata);
149         Assert(pre);
150         pre->ok();
151         pre->bc().ok();
152 }
153
154
155 void FormBaseDeprecated::CancelCB(FL_OBJECT * ob, long)
156 {
157         Assert(ob && ob->form);
158         FormBaseDeprecated * pre =
159                 static_cast<FormBaseDeprecated*>(ob->form->u_vdata);
160         Assert(pre);
161         pre->cancel();
162         pre->bc().cancel();
163 }
164
165
166 void FormBaseDeprecated::InputCB(FL_OBJECT * ob, long data)
167 {
168         Assert(ob && ob->form);
169         FormBaseDeprecated * pre =
170                 static_cast<FormBaseDeprecated*>(ob->form->u_vdata);
171         Assert(ob);
172         pre->bc().valid(pre->input(ob, data));
173 }
174
175
176 void FormBaseDeprecated::RestoreCB(FL_OBJECT * ob, long)
177 {
178         Assert(ob && ob->form);
179         FormBaseDeprecated * pre =
180                 static_cast<FormBaseDeprecated*>(ob->form->u_vdata);
181         Assert(ob);
182         pre->bc().undoAll();
183         pre->restore();
184 }
185
186
187 FormBaseBI::FormBaseBI(LyXView * lv, Dialogs * d, string const & t)
188         : FormBaseDeprecated(lv, d, t)
189 {}
190
191
192 void FormBaseBI::connect()
193 {
194         h_ = d_->hideAll.connect(slot(this, &FormBaseBI::hide));
195         FormBaseDeprecated::connect();
196 }
197
198
199 FormBaseBD::FormBaseBD(LyXView * lv, Dialogs * d, string const & t)
200         : FormBaseDeprecated(lv, d, t),
201           u_(0)
202 {}
203
204
205 void FormBaseBD::connect()
206 {
207         u_ = d_->updateBufferDependent.
208                  connect(slot(this, &FormBaseBD::updateSlot));
209         h_ = d_->hideBufferDependent.
210                  connect(slot(this, &FormBaseBD::hide));
211         FormBaseDeprecated::connect();
212 }
213
214
215 void FormBaseBD::disconnect()
216 {
217         u_.disconnect();
218         FormBaseDeprecated::disconnect();
219 }