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