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 "xform_macros.h"
25 C_RETURNCB (FormBase, WMHideCB)
26 C_GENERICCB(FormBase, ApplyCB)
27 C_GENERICCB(FormBase, OKCB)
28 C_GENERICCB(FormBase, CancelCB)
29 C_GENERICCB(FormBase, InputCB)
30 C_GENERICCB(FormBase, RestoreCB)
33 FormBase::FormBase(LyXView * lv, Dialogs * d, string const & t,
34 BufferDependency bd, ChangedBufferAction cba,
35 ButtonPolicy * bp, char const * close, char const * cancel)
36 : dialogIsOpen(false), lv_(lv), bc_(bp, cancel, close),
37 d_(d), bd_(bd), cba_(cba), parent_(0), u_(0), h_(0), title(t), bp_(bp)
51 fl_set_form_atclose(form(),
52 C_FormBaseWMHideCB, 0);
55 parent_ = lv_->buffer();
57 fl_freeze_form( form() );
58 update(); // make sure its up-to-date
59 fl_unfreeze_form( form() );
62 if (form()->visible) {
63 fl_raise_form(form());
66 FL_PLACE_MOUSE | FL_FREE_SIZE,
76 if (form() && form()->visible) {
81 // free up the dialog for another inset
88 void FormBase::connect()
91 case BUFFER_DEPENDENT:
92 u_ = d_->updateBufferDependent.
93 connect(slot(this, &FormBase::updateOrHide));
94 h_ = d_->hideBufferDependent.
95 connect(slot(this, &FormBase::hide));
97 case BUFFER_INDEPENDENT:
98 h_ = d_->hideAll.connect(slot(this, &FormBase::hide));
104 void FormBase::disconnect()
111 void FormBase::updateOrHide()
115 else if( parent_ == lv_->buffer() )
122 int FormBase::WMHideCB(FL_FORM * form, void *)
124 // Ensure that the signals (u and h) are disconnected even if the
125 // window manager is used to close the dialog.
126 FormBase * pre = static_cast<FormBase*>(form->u_vdata);
133 void FormBase::ApplyCB(FL_OBJECT * ob, long)
135 FormBase * pre = static_cast<FormBase*>(ob->form->u_vdata);
141 void FormBase::OKCB(FL_OBJECT * ob, long)
143 FormBase * pre = static_cast<FormBase*>(ob->form->u_vdata);
149 void FormBase::CancelCB(FL_OBJECT * ob, long)
151 FormBase * pre = static_cast<FormBase*>(ob->form->u_vdata);
157 void FormBase::InputCB(FL_OBJECT * ob, long data )
159 FormBase * pre = static_cast<FormBase*>(ob->form->u_vdata);
160 pre->bc_.valid( pre->input( ob, data ) );
164 void FormBase::RestoreCB(FL_OBJECT * ob, long)
166 FormBase * pre = static_cast<FormBase*>(ob->form->u_vdata);