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
22 #include "FormCommand.h"
23 #include "xform_macros.h"
25 C_RETURNCB(FormCommand, WMHideCB)
26 C_GENERICCB(FormCommand, ApplyCB)
27 C_GENERICCB(FormCommand, CancelCB)
28 C_GENERICCB(FormCommand, InputCB)
29 C_GENERICCB(FormCommand, OKCB)
31 FormCommand::FormCommand(LyXView * lv, Dialogs * d, string const & t)
32 : lv_(lv), d_(d), inset_(0), u_(0), h_(0), ih_(0),
33 dialogIsOpen(false), title(t)
37 void FormCommand::showInset( InsetCommand * const inset )
39 if( dialogIsOpen || inset == 0 ) return;
42 ih_ = inset_->hide.connect(slot(this, &FormCommand::hide));
44 params = inset->params();
49 void FormCommand::createInset( string const & arg )
51 if( dialogIsOpen ) return;
53 params.setFromString( arg );
58 void FormCommand::show()
62 fl_set_form_atclose(form(),
63 C_FormCommandWMHideCB, 0);
66 fl_freeze_form( form() );
67 update(); // make sure its up-to-date
68 fl_unfreeze_form( form() );
71 if (form()->visible) {
72 fl_raise_form(form());
75 FL_PLACE_MOUSE | FL_FREE_SIZE,
78 u_ = d_->updateBufferDependent.
79 connect(slot(this, &FormCommand::update));
80 h_ = d_->hideBufferDependent.
81 connect(slot(this, &FormCommand::hide));
86 void FormCommand::hide()
88 if (form() && form()->visible) {
94 // free up the dialog for another inset
102 int FormCommand::WMHideCB(FL_FORM * form, void *)
104 // Ensure that the signals (u and h) are disconnected even if the
105 // window manager is used to close the dialog.
106 FormCommand * pre = static_cast<FormCommand*>(form->u_vdata);
112 void FormCommand::ApplyCB(FL_OBJECT * ob, long)
114 FormCommand * pre = static_cast<FormCommand*>(ob->form->u_vdata);
119 void FormCommand::CancelCB(FL_OBJECT * ob, long)
121 FormCommand * pre = static_cast<FormCommand*>(ob->form->u_vdata);
126 void FormCommand::InputCB(FL_OBJECT * ob, long data )
128 FormCommand * pre = static_cast<FormCommand*>(ob->form->u_vdata);
133 void FormCommand::OKCB(FL_OBJECT * ob, long)
135 FormCommand * pre = static_cast<FormCommand*>(ob->form->u_vdata);