1 /* This file is part of
2 * ======================================================
4 * LyX, The Document Processor
6 * Copyright 2000-2001 The LyX Team.
8 * ======================================================
13 #include FORMS_H_LOCATION
16 #pragma implementation
20 #include "FormBaseDeprecated.h"
22 #include "GUIRunTime.h"
23 #include "support/LAssert.h"
31 // Callback function invoked by xforms when the dialog is closed by the
33 static int C_FormBaseDeprecatedWMHideCB(FL_FORM *, void *);
38 FormBaseDeprecated::FormBaseDeprecated(LyXView * lv, Dialogs * d,
39 string const & t, bool allowResize)
40 : lv_(lv), d_(d), h_(0), r_(0), title_(t),
41 minw_(0), minh_(0), allow_resize_(allowResize)
47 void FormBaseDeprecated::redraw()
49 if (form() && form()->visible)
50 fl_redraw_form(form());
54 void FormBaseDeprecated::connect()
56 fl_set_form_minsize(form(), minw_, minh_);
57 r_ = Dialogs::redrawGUI.connect(slot(this,&FormBaseDeprecated::redraw));
61 void FormBaseDeprecated::disconnect()
68 void FormBaseDeprecated::show()
75 // work around dumb xforms sizing bug
79 fl_set_form_atclose(form(),
80 C_FormBaseDeprecatedWMHideCB, 0);
83 fl_freeze_form(form());
84 update(); // make sure its up-to-date
85 fl_unfreeze_form(form());
87 if (form()->visible) {
88 fl_raise_form(form());
89 /* This XMapWindow() will hopefully ensure that
90 * iconified dialogs are de-iconified. Mad props
91 * out to those crazy Xlib guys for forgetting a
92 * XDeiconifyWindow(). At least WindowMaker, when
93 * being notified of the redirected MapRequest will
94 * specifically de-iconify. From source, fvwm2 seems
97 XMapWindow(fl_get_display(), form()->window);
101 // calls to fl_set_form_minsize/maxsize apply only to the next
102 // fl_show_form(), so this comes first.
103 fl_set_form_minsize(form(), minw_, minh_);
105 fl_set_form_maxsize(form(), minw_, minh_);
108 FL_PLACE_MOUSE | FL_FREE_SIZE,
109 (lyxrc.dialogs_iconify_with_main ? FL_TRANSIENT : 0),
115 void FormBaseDeprecated::hide()
117 // xforms sometimes tries to process a hint-type MotionNotify, and
118 // use XQueryPointer, without verifying if the window still exists.
119 // So we try to clear out motion events in the queue before the
121 XSync(fl_get_display(), false);
122 GUIRunTime::processEvents();
124 if (form() && form()->visible) {
125 // some dialogs might do things to the form first
126 // such as the nested tabfolder problem in Preferences
128 fl_hide_form(form());
133 int FormBaseDeprecated::WMHideCB(FL_FORM * form, void *)
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);
147 void FormBaseDeprecated::ApplyCB(FL_OBJECT * ob, long)
149 lyx::Assert(ob && ob->form);
150 FormBaseDeprecated * pre =
151 static_cast<FormBaseDeprecated*>(ob->form->u_vdata);
158 void FormBaseDeprecated::OKCB(FL_OBJECT * ob, long)
160 lyx::Assert(ob && ob->form);
161 FormBaseDeprecated * pre =
162 static_cast<FormBaseDeprecated*>(ob->form->u_vdata);
169 void FormBaseDeprecated::CancelCB(FL_OBJECT * ob, long)
171 lyx::Assert(ob && ob->form);
172 FormBaseDeprecated * pre =
173 static_cast<FormBaseDeprecated*>(ob->form->u_vdata);
180 void FormBaseDeprecated::InputCB(FL_OBJECT * ob, long data)
182 lyx::Assert(ob && ob->form);
183 FormBaseDeprecated * pre =
184 static_cast<FormBaseDeprecated*>(ob->form->u_vdata);
187 // It is possible to set the choice to 0 when using the
188 // keyboard shortcuts. This work-around deals with the problem.
189 if (ob && ob->objclass == FL_CHOICE && fl_get_choice(ob) < 1) {
190 fl_set_choice(ob, 1);
193 pre->bc().valid(pre->input(ob, data));
197 void FormBaseDeprecated::RestoreCB(FL_OBJECT * ob, long)
199 lyx::Assert(ob && ob->form);
200 FormBaseDeprecated * pre =
201 static_cast<FormBaseDeprecated*>(ob->form->u_vdata);
208 FormBaseBI::FormBaseBI(LyXView * lv, Dialogs * d, string const & t,
210 : FormBaseDeprecated(lv, d, t, allowResize)
214 void FormBaseBI::connect()
216 h_ = d_->hideAll.connect(slot(this, &FormBaseBI::hide));
217 FormBaseDeprecated::connect();
221 FormBaseBD::FormBaseBD(LyXView * lv, Dialogs * d, string const & t,
223 : FormBaseDeprecated(lv, d, t, allowResize),
228 void FormBaseBD::connect()
230 u_ = d_->updateBufferDependent.
231 connect(slot(this, &FormBaseBD::updateSlot));
232 h_ = d_->hideBufferDependent.
233 connect(slot(this, &FormBaseBD::hide));
234 FormBaseDeprecated::connect();
238 void FormBaseBD::disconnect()
241 FormBaseDeprecated::disconnect();
247 static int C_FormBaseDeprecatedWMHideCB(FL_FORM * ob, void * d)
249 return FormBaseDeprecated::WMHideCB(ob, d);
253 void C_FormBaseDeprecatedApplyCB(FL_OBJECT * ob, long d)
255 FormBaseDeprecated::ApplyCB(ob, d);
259 void C_FormBaseDeprecatedOKCB(FL_OBJECT * ob, long d)
261 FormBaseDeprecated::OKCB(ob, d);
265 void C_FormBaseDeprecatedCancelCB(FL_OBJECT * ob, long d)
267 FormBaseDeprecated::CancelCB(ob, d);
271 void C_FormBaseDeprecatedInputCB(FL_OBJECT * ob, long d)
273 FormBaseDeprecated::InputCB(ob, d);
277 void C_FormBaseDeprecatedRestoreCB(FL_OBJECT * ob, long d)
279 FormBaseDeprecated::RestoreCB(ob, d);