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