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), u_(0), h_(0), ih_(0),
33 inset_(0), 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::free()
88 // we don't need to delete u and h here because
89 // hide() does that after disconnecting.
98 void FormCommand::hide()
100 if (form() && form()->visible) {
101 fl_hide_form(form());
106 // free up the dialog for another inset
109 dialogIsOpen = false;
114 int FormCommand::WMHideCB(FL_FORM * form, void *)
116 // Ensure that the signals (u and h) are disconnected even if the
117 // window manager is used to close the dialog.
118 FormCommand * pre = static_cast<FormCommand*>(form->u_vdata);
124 void FormCommand::ApplyCB(FL_OBJECT * ob, long)
126 FormCommand * pre = static_cast<FormCommand*>(ob->form->u_vdata);
131 void FormCommand::CancelCB(FL_OBJECT * ob, long)
133 FormCommand * pre = static_cast<FormCommand*>(ob->form->u_vdata);
138 void FormCommand::InputCB(FL_OBJECT * ob, long data )
140 FormCommand * pre = static_cast<FormCommand*>(ob->form->u_vdata);
145 void FormCommand::OKCB(FL_OBJECT * ob, long)
147 FormCommand * pre = static_cast<FormCommand*>(ob->form->u_vdata);