2 /* This file is part of
3 * ======================================================
5 * LyX, The Document Processor
7 * Copyright 2000 The LyX Team.
9 * ======================================================
14 #include FORMS_H_LOCATION
17 #pragma implementation
23 #include "support/LAssert.h"
26 extern "C" int C_FormBaseWMHideCB(FL_FORM * ob, void * d)
28 return FormBase::WMHideCB(ob, d);
30 extern "C" void C_FormBaseApplyCB(FL_OBJECT * ob, long d)
32 FormBase::ApplyCB(ob, d);
34 extern "C" void C_FormBaseOKCB(FL_OBJECT * ob, long d)
36 FormBase::OKCB(ob, d);
38 extern "C" void C_FormBaseCancelCB(FL_OBJECT * ob, long d)
40 FormBase::CancelCB(ob, d);
42 extern "C" void C_FormBaseInputCB(FL_OBJECT * ob, long d)
44 FormBase::InputCB(ob, d);
46 extern "C" void C_FormBaseRestoreCB(FL_OBJECT * ob, long d)
48 FormBase::RestoreCB(ob, d);
52 FormBase::FormBase(LyXView * lv, Dialogs * d, string const & t,
53 ButtonPolicy * bp, char const * close, char const * cancel)
54 : lv_(lv), bc_(bp, cancel, close), d_(d), h_(0), r_(0), title(t),
55 bp_(bp), minw_(0), minh_(0)
57 Assert(lv && d && bp);
63 //lyxerr << "bp_[" << bp_ << "]" << endl;
68 void FormBase::redraw()
70 if (form() && form()->visible)
71 fl_redraw_form(form());
75 void FormBase::connect()
77 fl_set_form_minsize(form(), minw_, minh_);
78 r_ = Dialogs::redrawGUI.connect(slot(this, &FormBase::redraw));
82 void FormBase::disconnect()
93 fl_set_form_atclose(form(),
94 C_FormBaseWMHideCB, 0);
97 fl_freeze_form(form());
98 update(); // make sure its up-to-date
99 fl_unfreeze_form(form());
101 if (form()->visible) {
102 fl_raise_form(form());
104 // calls to fl_set_form_minsize/maxsize apply only to the next
105 // fl_show_form(), so connect() comes first.
108 FL_PLACE_MOUSE | FL_FREE_SIZE,
115 void FormBase::hide()
117 if (form() && form()->visible) {
118 // some dialogs might do things to the form first
119 // such as the nested tabfolder problem in Preferences
121 fl_hide_form(form());
126 int FormBase::WMHideCB(FL_FORM * form, void *)
129 // Ensure that the signals (u and h) are disconnected even if the
130 // window manager is used to close the dialog.
131 FormBase * pre = static_cast<FormBase*>(form->u_vdata);
139 void FormBase::ApplyCB(FL_OBJECT * ob, long)
141 Assert(ob && ob->form);
142 FormBase * pre = static_cast<FormBase*>(ob->form->u_vdata);
149 void FormBase::OKCB(FL_OBJECT * ob, long)
151 Assert(ob && ob->form);
152 FormBase * pre = static_cast<FormBase*>(ob->form->u_vdata);
159 void FormBase::CancelCB(FL_OBJECT * ob, long)
161 Assert(ob && ob->form);
162 FormBase * pre = static_cast<FormBase*>(ob->form->u_vdata);
169 void FormBase::InputCB(FL_OBJECT * ob, long data)
171 Assert(ob && ob->form);
172 FormBase * pre = static_cast<FormBase*>(ob->form->u_vdata);
174 pre->bc_.valid(pre->input(ob, data));
178 void FormBase::RestoreCB(FL_OBJECT * ob, long)
180 Assert(ob && ob->form);
181 FormBase * pre = static_cast<FormBase*>(ob->form->u_vdata);
188 FormBaseBI::FormBaseBI(LyXView * lv, Dialogs * d, string const & t,
190 char const * close, char const * cancel)
191 : FormBase(lv, d, t, bp, close, cancel)
195 void FormBaseBI::connect()
197 h_ = d_->hideAll.connect(slot(this, &FormBaseBI::hide));
202 FormBaseBD::FormBaseBD(LyXView * lv, Dialogs * d, string const & t,
204 char const * close, char const * cancel)
205 : FormBase(lv, d, t, bp, close, cancel),
210 void FormBaseBD::connect()
212 u_ = d_->updateBufferDependent.
213 connect(slot(this, &FormBaseBD::updateSlot));
214 h_ = d_->hideBufferDependent.
215 connect(slot(this, &FormBaseBD::hide));
220 void FormBaseBD::disconnect()
223 FormBase::disconnect();