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 "support/LAssert.h"
30 // Callback function invoked by xforms when the dialog is closed by the
32 static int C_FormBaseDeprecatedWMHideCB(FL_FORM *, void *);
37 FormBaseDeprecated::FormBaseDeprecated(LyXView * lv, Dialogs * d,
38 string const & t, bool allowResize)
39 : lv_(lv), d_(d), h_(0), r_(0), title_(t),
40 minw_(0), minh_(0), allow_resize_(allowResize)
46 void FormBaseDeprecated::redraw()
48 if (form() && form()->visible)
49 fl_redraw_form(form());
53 void FormBaseDeprecated::connect()
55 fl_set_form_minsize(form(), minw_, minh_);
56 r_ = Dialogs::redrawGUI.connect(slot(this,&FormBaseDeprecated::redraw));
60 void FormBaseDeprecated::disconnect()
67 void FormBaseDeprecated::show()
74 // work around dumb xforms sizing bug
78 fl_set_form_atclose(form(),
79 C_FormBaseDeprecatedWMHideCB, 0);
82 fl_freeze_form(form());
83 update(); // make sure its up-to-date
84 fl_unfreeze_form(form());
86 if (form()->visible) {
87 fl_raise_form(form());
88 /* This XMapWindow() will hopefully ensure that
89 * iconified dialogs are de-iconified. Mad props
90 * out to those crazy Xlib guys for forgetting a
91 * XDeiconifyWindow(). At least WindowMaker, when
92 * being notified of the redirected MapRequest will
93 * specifically de-iconify. From source, fvwm2 seems
96 XMapWindow(fl_get_display(), form()->window);
100 // calls to fl_set_form_minsize/maxsize apply only to the next
101 // fl_show_form(), so this comes first.
102 fl_set_form_minsize(form(), minw_, minh_);
104 fl_set_form_maxsize(form(), minw_, minh_);
107 FL_PLACE_MOUSE | FL_FREE_SIZE,
108 (lyxrc.dialogs_iconify_with_main ? FL_TRANSIENT : 0),
114 void FormBaseDeprecated::hide()
116 if (form() && form()->visible) {
117 // some dialogs might do things to the form first
118 // such as the nested tabfolder problem in Preferences
120 fl_hide_form(form());
125 int FormBaseDeprecated::WMHideCB(FL_FORM * form, void *)
128 // Ensure that the signals (u and h) are disconnected even if the
129 // window manager is used to close the dialog.
130 FormBaseDeprecated * pre =
131 static_cast<FormBaseDeprecated*>(form->u_vdata);
139 void FormBaseDeprecated::ApplyCB(FL_OBJECT * ob, long)
141 lyx::Assert(ob && ob->form);
142 FormBaseDeprecated * pre =
143 static_cast<FormBaseDeprecated*>(ob->form->u_vdata);
150 void FormBaseDeprecated::OKCB(FL_OBJECT * ob, long)
152 lyx::Assert(ob && ob->form);
153 FormBaseDeprecated * pre =
154 static_cast<FormBaseDeprecated*>(ob->form->u_vdata);
161 void FormBaseDeprecated::CancelCB(FL_OBJECT * ob, long)
163 lyx::Assert(ob && ob->form);
164 FormBaseDeprecated * pre =
165 static_cast<FormBaseDeprecated*>(ob->form->u_vdata);
172 void FormBaseDeprecated::InputCB(FL_OBJECT * ob, long data)
174 lyx::Assert(ob && ob->form);
175 FormBaseDeprecated * pre =
176 static_cast<FormBaseDeprecated*>(ob->form->u_vdata);
179 // It is possible to set the choice to 0 when using the
180 // keyboard shortcuts. This work-around deals with the problem.
181 if (ob && ob->objclass == FL_CHOICE && fl_get_choice(ob) < 1) {
182 fl_set_choice(ob, 1);
185 pre->bc().valid(pre->input(ob, data));
189 void FormBaseDeprecated::RestoreCB(FL_OBJECT * ob, long)
191 lyx::Assert(ob && ob->form);
192 FormBaseDeprecated * pre =
193 static_cast<FormBaseDeprecated*>(ob->form->u_vdata);
200 FormBaseBI::FormBaseBI(LyXView * lv, Dialogs * d, string const & t,
202 : FormBaseDeprecated(lv, d, t, allowResize)
206 void FormBaseBI::connect()
208 h_ = d_->hideAll.connect(slot(this, &FormBaseBI::hide));
209 FormBaseDeprecated::connect();
213 FormBaseBD::FormBaseBD(LyXView * lv, Dialogs * d, string const & t,
215 : FormBaseDeprecated(lv, d, t, allowResize),
220 void FormBaseBD::connect()
222 u_ = d_->updateBufferDependent.
223 connect(slot(this, &FormBaseBD::updateSlot));
224 h_ = d_->hideBufferDependent.
225 connect(slot(this, &FormBaseBD::hide));
226 FormBaseDeprecated::connect();
230 void FormBaseBD::disconnect()
233 FormBaseDeprecated::disconnect();
239 static int C_FormBaseDeprecatedWMHideCB(FL_FORM * ob, void * d)
241 return FormBaseDeprecated::WMHideCB(ob, d);
245 void C_FormBaseDeprecatedApplyCB(FL_OBJECT * ob, long d)
247 FormBaseDeprecated::ApplyCB(ob, d);
251 void C_FormBaseDeprecatedOKCB(FL_OBJECT * ob, long d)
253 FormBaseDeprecated::OKCB(ob, d);
257 void C_FormBaseDeprecatedCancelCB(FL_OBJECT * ob, long d)
259 FormBaseDeprecated::CancelCB(ob, d);
263 void C_FormBaseDeprecatedInputCB(FL_OBJECT * ob, long d)
265 FormBaseDeprecated::InputCB(ob, d);
269 void C_FormBaseDeprecatedRestoreCB(FL_OBJECT * ob, long d)
271 FormBaseDeprecated::RestoreCB(ob, d);