]> git.lyx.org Git - lyx.git/blob - src/frontends/xforms/FormBaseDeprecated.C
Remove some xforms cruft from BufferView.h BufferView_pimpl.h.
[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
89                 // work around dumb xforms sizing bug
90                 minw_ = form()->w;
91                 minh_ = form()->h;
92
93                 fl_set_form_atclose(form(),
94                                     C_FormBaseDeprecatedWMHideCB, 0);
95         }
96
97         fl_freeze_form(form());
98         update();  // make sure its up-to-date
99         fl_unfreeze_form(form());
100
101         if (form()->visible) {
102                 fl_raise_form(form());
103                 /* This XMapWindow() will hopefully ensure that
104                  * iconified dialogs are de-iconified. Mad props
105                  * out to those crazy Xlib guys for forgetting a
106                  * XDeiconifyWindow(). At least WindowMaker, when
107                  * being notified of the redirected MapRequest will
108                  * specifically de-iconify. From source, fvwm2 seems
109                  * to do the same.
110                  */
111                 XMapWindow(fl_get_display(), form()->window);
112         } else {
113                 // calls to fl_set_form_minsize/maxsize apply only to the next
114                 // fl_show_form(), so connect() comes first.
115                 connect();
116                 fl_show_form(form(),
117                              FL_PLACE_MOUSE | FL_FREE_SIZE, 0,
118                              title_.c_str());
119         }
120 }
121
122
123 void FormBaseDeprecated::hide()
124 {
125         if (form() && form()->visible) {
126                 // some dialogs might do things to the form first
127                 // such as the nested tabfolder problem in Preferences
128                 disconnect();
129                 fl_hide_form(form());
130         }
131 }
132
133
134 int FormBaseDeprecated::WMHideCB(FL_FORM * form, void *)
135 {
136         Assert(form);
137         // Ensure that the signals (u and h) are disconnected even if the
138         // window manager is used to close the dialog.
139         FormBaseDeprecated * pre =
140                 static_cast<FormBaseDeprecated*>(form->u_vdata);
141         Assert(pre);
142         pre->hide();
143         pre->bc().hide();
144         return FL_CANCEL;
145 }
146
147
148 void FormBaseDeprecated::ApplyCB(FL_OBJECT * ob, long)
149 {
150         Assert(ob && ob->form);
151         FormBaseDeprecated * pre =
152                 static_cast<FormBaseDeprecated*>(ob->form->u_vdata);
153         Assert(pre);
154         pre->apply();
155         pre->bc().apply();
156 }
157
158
159 void FormBaseDeprecated::OKCB(FL_OBJECT * ob, long)
160 {
161         Assert(ob && ob->form);
162         FormBaseDeprecated * pre =
163                 static_cast<FormBaseDeprecated*>(ob->form->u_vdata);
164         Assert(pre);
165         pre->ok();
166         pre->bc().ok();
167 }
168
169
170 void FormBaseDeprecated::CancelCB(FL_OBJECT * ob, long)
171 {
172         Assert(ob && ob->form);
173         FormBaseDeprecated * pre =
174                 static_cast<FormBaseDeprecated*>(ob->form->u_vdata);
175         Assert(pre);
176         pre->cancel();
177         pre->bc().cancel();
178 }
179
180
181 void FormBaseDeprecated::InputCB(FL_OBJECT * ob, long data)
182 {
183         Assert(ob && ob->form);
184         FormBaseDeprecated * pre =
185                 static_cast<FormBaseDeprecated*>(ob->form->u_vdata);
186         Assert(pre);
187         pre->bc().valid(pre->input(ob, data));
188 }
189
190
191 void FormBaseDeprecated::RestoreCB(FL_OBJECT * ob, long)
192 {
193         Assert(ob && ob->form);
194         FormBaseDeprecated * pre =
195                 static_cast<FormBaseDeprecated*>(ob->form->u_vdata);
196         Assert(pre);
197         pre->bc().restore();
198         pre->restore();
199 }
200
201
202 FormBaseBI::FormBaseBI(LyXView * lv, Dialogs * d, string const & t)
203         : FormBaseDeprecated(lv, d, t)
204 {}
205
206
207 void FormBaseBI::connect()
208 {
209         h_ = d_->hideAll.connect(slot(this, &FormBaseBI::hide));
210         FormBaseDeprecated::connect();
211 }
212
213
214 FormBaseBD::FormBaseBD(LyXView * lv, Dialogs * d, string const & t)
215         : FormBaseDeprecated(lv, d, t),
216           u_(0)
217 {}
218
219
220 void FormBaseBD::connect()
221 {
222         u_ = d_->updateBufferDependent.
223                  connect(slot(this, &FormBaseBD::updateSlot));
224         h_ = d_->hideBufferDependent.
225                  connect(slot(this, &FormBaseBD::hide));
226         FormBaseDeprecated::connect();
227 }
228
229
230 void FormBaseBD::disconnect()
231 {
232         u_.disconnect();
233         FormBaseDeprecated::disconnect();
234 }