2000-09-22 15:09:51 +00:00
|
|
|
// -*- C++ -*-
|
|
|
|
/* This file is part of
|
|
|
|
* ======================================================
|
|
|
|
*
|
|
|
|
* LyX, The Document Processor
|
|
|
|
*
|
|
|
|
* Copyright 2000 The LyX Team.
|
|
|
|
*
|
|
|
|
* ======================================================
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
#include FORMS_H_LOCATION
|
|
|
|
|
|
|
|
#ifdef __GNUG__
|
|
|
|
#pragma implementation
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "Dialogs.h"
|
|
|
|
#include "FormBase.h"
|
|
|
|
#include "xform_macros.h"
|
|
|
|
|
2000-09-27 05:40:29 +00:00
|
|
|
C_RETURNCB (FormBase, WMHideCB)
|
2000-09-22 15:09:51 +00:00
|
|
|
C_GENERICCB(FormBase, ApplyCB)
|
2000-10-02 00:10:25 +00:00
|
|
|
C_GENERICCB(FormBase, OKCB)
|
|
|
|
C_GENERICCB(FormBase, CancelCB)
|
2000-09-22 15:09:51 +00:00
|
|
|
C_GENERICCB(FormBase, InputCB)
|
2000-10-02 00:10:25 +00:00
|
|
|
C_GENERICCB(FormBase, RestoreCB)
|
2000-09-22 15:09:51 +00:00
|
|
|
|
|
|
|
|
2000-10-02 00:10:25 +00:00
|
|
|
FormBase::FormBase(LyXView * lv, Dialogs * d, BufferDependency bd, string const & t,
|
|
|
|
ButtonPolicy * bp, char const * close, char const * cancel)
|
|
|
|
: dialogIsOpen(false), lv_(lv), bc_(bp, cancel, close),
|
|
|
|
u_(0), h_(0), title(t), bp_(bp)
|
2000-09-27 05:40:29 +00:00
|
|
|
{
|
|
|
|
switch( bd ) {
|
|
|
|
case BUFFER_DEPENDENT:
|
|
|
|
hSignal_ = &d->hideBufferDependent;
|
|
|
|
uSignal_ = &d->updateBufferDependent;
|
|
|
|
break;
|
|
|
|
case BUFFER_INDEPENDENT:
|
|
|
|
hSignal_ = &d->hideAll;
|
|
|
|
uSignal_ = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2000-09-22 15:09:51 +00:00
|
|
|
|
2000-10-02 00:10:25 +00:00
|
|
|
|
|
|
|
FormBase::~FormBase()
|
|
|
|
{
|
|
|
|
delete bp_;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-09-22 15:09:51 +00:00
|
|
|
void FormBase::show()
|
|
|
|
{
|
|
|
|
if (!form()) {
|
|
|
|
build();
|
|
|
|
fl_set_form_atclose(form(),
|
|
|
|
C_FormBaseWMHideCB, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
fl_freeze_form( form() );
|
|
|
|
update(); // make sure its up-to-date
|
|
|
|
fl_unfreeze_form( form() );
|
|
|
|
|
|
|
|
dialogIsOpen = true;
|
|
|
|
if (form()->visible) {
|
|
|
|
fl_raise_form(form());
|
|
|
|
} else {
|
|
|
|
fl_show_form(form(),
|
|
|
|
FL_PLACE_MOUSE | FL_FREE_SIZE,
|
|
|
|
FL_TRANSIENT,
|
|
|
|
title.c_str());
|
2000-09-29 06:34:04 +00:00
|
|
|
connect();
|
2000-09-22 15:09:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void FormBase::hide()
|
|
|
|
{
|
|
|
|
if (form() && form()->visible) {
|
|
|
|
fl_hide_form(form());
|
2000-09-29 06:34:04 +00:00
|
|
|
disconnect();
|
2000-09-22 15:09:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// free up the dialog for another inset
|
|
|
|
dialogIsOpen = false;
|
|
|
|
clearStore();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-09-29 06:34:04 +00:00
|
|
|
void FormBase::connect()
|
|
|
|
{
|
|
|
|
if ( uSignal_ ) {
|
|
|
|
u_ = uSignal_->connect(slot(this, &FormBase::update));
|
|
|
|
}
|
|
|
|
h_ = hSignal_->connect(slot(this, &FormBase::hide));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void FormBase::disconnect()
|
|
|
|
{
|
2000-09-29 13:58:45 +00:00
|
|
|
u_.disconnect();
|
2000-09-29 06:34:04 +00:00
|
|
|
h_.disconnect();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-09-22 15:09:51 +00:00
|
|
|
int FormBase::WMHideCB(FL_FORM * form, void *)
|
|
|
|
{
|
|
|
|
// Ensure that the signals (u and h) are disconnected even if the
|
|
|
|
// window manager is used to close the dialog.
|
|
|
|
FormBase * pre = static_cast<FormBase*>(form->u_vdata);
|
|
|
|
pre->hide();
|
2000-10-02 00:10:25 +00:00
|
|
|
pre->bc_.hide();
|
2000-09-22 15:09:51 +00:00
|
|
|
return FL_CANCEL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void FormBase::ApplyCB(FL_OBJECT * ob, long)
|
|
|
|
{
|
|
|
|
FormBase * pre = static_cast<FormBase*>(ob->form->u_vdata);
|
|
|
|
pre->apply();
|
2000-10-02 00:10:25 +00:00
|
|
|
pre->bc_.apply();
|
2000-09-22 15:09:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-10-02 00:10:25 +00:00
|
|
|
void FormBase::OKCB(FL_OBJECT * ob, long)
|
2000-09-22 15:09:51 +00:00
|
|
|
{
|
|
|
|
FormBase * pre = static_cast<FormBase*>(ob->form->u_vdata);
|
2000-10-02 00:10:25 +00:00
|
|
|
pre->ok();
|
|
|
|
pre->bc_.ok();
|
2000-09-22 15:09:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-10-02 00:10:25 +00:00
|
|
|
void FormBase::CancelCB(FL_OBJECT * ob, long)
|
2000-09-22 15:09:51 +00:00
|
|
|
{
|
|
|
|
FormBase * pre = static_cast<FormBase*>(ob->form->u_vdata);
|
2000-10-02 00:10:25 +00:00
|
|
|
pre->cancel();
|
|
|
|
pre->bc_.cancel();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void FormBase::InputCB(FL_OBJECT * ob, long data )
|
|
|
|
{
|
|
|
|
FormBase * pre = static_cast<FormBase*>(ob->form->u_vdata);
|
2000-10-05 07:57:00 +00:00
|
|
|
pre->bc_.valid( pre->input( ob, data ) );
|
2000-09-22 15:09:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-10-02 00:10:25 +00:00
|
|
|
void FormBase::RestoreCB(FL_OBJECT * ob, long)
|
2000-09-22 15:09:51 +00:00
|
|
|
{
|
|
|
|
FormBase * pre = static_cast<FormBase*>(ob->form->u_vdata);
|
2000-10-02 00:10:25 +00:00
|
|
|
pre->restore();
|
|
|
|
pre->bc_.undoAll();
|
2000-09-22 15:09:51 +00:00
|
|
|
}
|