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 // companion to Lars' commenting out in insetcommand.
43 // need a better plan perhaps since there seems to be a small
44 // flaw here if we copy an inset while it's visible
45 // ih_ = inset_->hide.connect(slot(this, &FormCommand::hide));
47 params = inset->params();
52 void FormCommand::createInset( string const & arg )
54 if( dialogIsOpen ) return;
56 params.setFromString( arg );
61 void FormCommand::show()
65 fl_set_form_atclose(form(),
66 C_FormCommandWMHideCB, 0);
69 fl_freeze_form( form() );
70 update(); // make sure its up-to-date
71 fl_unfreeze_form( form() );
74 if (form()->visible) {
75 fl_raise_form(form());
78 FL_PLACE_MOUSE | FL_FREE_SIZE,
81 u_ = d_->updateBufferDependent.
82 connect(slot(this, &FormCommand::update));
83 h_ = d_->hideBufferDependent.
84 connect(slot(this, &FormCommand::hide));
89 void FormCommand::free()
91 // we don't need to delete u and h here because
92 // hide() does that after disconnecting.
101 void FormCommand::hide()
103 if (form() && form()->visible) {
104 fl_hide_form(form());
109 // free up the dialog for another inset
112 dialogIsOpen = false;
116 int FormCommand::WMHideCB(FL_FORM * form, void *)
118 // Ensure that the signals (u and h) are disconnected even if the
119 // window manager is used to close the dialog.
120 FormCommand * pre = static_cast<FormCommand*>(form->u_vdata);
126 void FormCommand::ApplyCB(FL_OBJECT * ob, long)
128 FormCommand * pre = static_cast<FormCommand*>(ob->form->u_vdata);
133 void FormCommand::CancelCB(FL_OBJECT * ob, long)
135 FormCommand * pre = static_cast<FormCommand*>(ob->form->u_vdata);
140 void FormCommand::InputCB(FL_OBJECT * ob, long data )
142 FormCommand * pre = static_cast<FormCommand*>(ob->form->u_vdata);
147 void FormCommand::OKCB(FL_OBJECT * ob, long)
149 FormCommand * pre = static_cast<FormCommand*>(ob->form->u_vdata);