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);
67 void FormBase::redraw()
69 if (form() && form()->visible)
70 fl_redraw_form(form());
74 void FormBase::connect()
76 fl_set_form_minsize(form(), minw_, minh_);
77 r_ = Dialogs::redrawGUI.connect(slot(this, &FormBase::redraw));
81 void FormBase::disconnect()
92 fl_set_form_atclose(form(),
93 C_FormBaseWMHideCB, 0);
96 fl_freeze_form(form());
97 update(); // make sure its up-to-date
98 fl_unfreeze_form(form());
100 if (form()->visible) {
101 fl_raise_form(form());
103 // calls to fl_set_form_minsize/maxsize apply only to the next
104 // fl_show_form(), so connect() comes first.
107 FL_PLACE_MOUSE | FL_FREE_SIZE,
114 void FormBase::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 FormBase::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 FormBase * pre = static_cast<FormBase*>(form->u_vdata);
138 void FormBase::ApplyCB(FL_OBJECT * ob, long)
140 Assert(ob && ob->form);
141 FormBase * pre = static_cast<FormBase*>(ob->form->u_vdata);
148 void FormBase::OKCB(FL_OBJECT * ob, long)
150 Assert(ob && ob->form);
151 FormBase * pre = static_cast<FormBase*>(ob->form->u_vdata);
158 void FormBase::CancelCB(FL_OBJECT * ob, long)
160 Assert(ob && ob->form);
161 FormBase * pre = static_cast<FormBase*>(ob->form->u_vdata);
168 void FormBase::InputCB(FL_OBJECT * ob, long data)
170 Assert(ob && ob->form);
171 FormBase * pre = static_cast<FormBase*>(ob->form->u_vdata);
173 pre->bc_.valid(pre->input(ob, data));
177 void FormBase::RestoreCB(FL_OBJECT * ob, long)
179 Assert(ob && ob->form);
180 FormBase * pre = static_cast<FormBase*>(ob->form->u_vdata);
187 FormBaseBI::FormBaseBI(LyXView * lv, Dialogs * d, string const & t,
189 char const * close, char const * cancel)
190 : FormBase(lv, d, t, bp, close, cancel)
194 void FormBaseBI::connect()
196 h_ = d_->hideAll.connect(slot(this, &FormBaseBI::hide));
201 FormBaseBD::FormBaseBD(LyXView * lv, Dialogs * d, string const & t,
203 char const * close, char const * cancel)
204 : FormBase(lv, d, t, bp, close, cancel),
209 void FormBaseBD::connect()
211 u_ = d_->updateBufferDependent.
212 connect(slot(this, &FormBaseBD::updateSlot));
213 h_ = d_->hideBufferDependent.
214 connect(slot(this, &FormBaseBD::hide));
219 void FormBaseBD::disconnect()
222 FormBase::disconnect();