lyx_mirror/src/frontends/xforms/FormBaseDeprecated.C

235 lines
4.9 KiB
C++
Raw Normal View History

// -*- 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 "FormBaseDeprecated.h"
#include "LyXView.h"
#include "support/LAssert.h"
#include "xformsBC.h"
//#include "debug.h"
using SigC::slot;
extern "C" int C_FormBaseDeprecatedWMHideCB(FL_FORM * ob, void * d)
{
return FormBaseDeprecated::WMHideCB(ob, d);
}
extern "C" void C_FormBaseDeprecatedApplyCB(FL_OBJECT * ob, long d)
{
FormBaseDeprecated::ApplyCB(ob, d);
}
extern "C" void C_FormBaseDeprecatedOKCB(FL_OBJECT * ob, long d)
{
FormBaseDeprecated::OKCB(ob, d);
}
extern "C" void C_FormBaseDeprecatedCancelCB(FL_OBJECT * ob, long d)
{
FormBaseDeprecated::CancelCB(ob, d);
}
extern "C" void C_FormBaseDeprecatedInputCB(FL_OBJECT * ob, long d)
{
FormBaseDeprecated::InputCB(ob, d);
}
extern "C" void C_FormBaseDeprecatedRestoreCB(FL_OBJECT * ob, long d)
{
FormBaseDeprecated::RestoreCB(ob, d);
}
FormBaseDeprecated::FormBaseDeprecated(LyXView * lv, Dialogs * d,
string const & t)
: lv_(lv), d_(d), h_(0), r_(0), title_(t), minw_(0), minh_(0)
{
Assert(lv && d);
}
void FormBaseDeprecated::redraw()
{
if (form() && form()->visible)
fl_redraw_form(form());
}
void FormBaseDeprecated::connect()
{
fl_set_form_minsize(form(), minw_, minh_);
r_ = Dialogs::redrawGUI.connect(slot(this,&FormBaseDeprecated::redraw));
}
void FormBaseDeprecated::disconnect()
{
h_.disconnect();
r_.disconnect();
}
void FormBaseDeprecated::show()
{
if (!form()) {
build();
// work around dumb xforms sizing bug
minw_ = form()->w;
minh_ = form()->h;
fl_set_form_atclose(form(),
C_FormBaseDeprecatedWMHideCB, 0);
}
fl_freeze_form(form());
update(); // make sure its up-to-date
fl_unfreeze_form(form());
if (form()->visible) {
fl_raise_form(form());
/* This XMapWindow() will hopefully ensure that
* iconified dialogs are de-iconified. Mad props
* out to those crazy Xlib guys for forgetting a
* XDeiconifyWindow(). At least WindowMaker, when
* being notified of the redirected MapRequest will
* specifically de-iconify. From source, fvwm2 seems
* to do the same.
*/
XMapWindow(fl_get_display(), form()->window);
} else {
// calls to fl_set_form_minsize/maxsize apply only to the next
// fl_show_form(), so connect() comes first.
connect();
fl_show_form(form(),
FL_PLACE_MOUSE | FL_FREE_SIZE, 0,
title_.c_str());
}
}
void FormBaseDeprecated::hide()
{
if (form() && form()->visible) {
// some dialogs might do things to the form first
// such as the nested tabfolder problem in Preferences
disconnect();
fl_hide_form(form());
}
}
int FormBaseDeprecated::WMHideCB(FL_FORM * form, void *)
{
Assert(form);
// Ensure that the signals (u and h) are disconnected even if the
// window manager is used to close the dialog.
FormBaseDeprecated * pre =
static_cast<FormBaseDeprecated*>(form->u_vdata);
Assert(pre);
pre->hide();
pre->bc().hide();
return FL_CANCEL;
}
void FormBaseDeprecated::ApplyCB(FL_OBJECT * ob, long)
{
Assert(ob && ob->form);
FormBaseDeprecated * pre =
static_cast<FormBaseDeprecated*>(ob->form->u_vdata);
Assert(pre);
pre->apply();
pre->bc().apply();
}
void FormBaseDeprecated::OKCB(FL_OBJECT * ob, long)
{
Assert(ob && ob->form);
FormBaseDeprecated * pre =
static_cast<FormBaseDeprecated*>(ob->form->u_vdata);
Assert(pre);
pre->ok();
pre->bc().ok();
}
void FormBaseDeprecated::CancelCB(FL_OBJECT * ob, long)
{
Assert(ob && ob->form);
FormBaseDeprecated * pre =
static_cast<FormBaseDeprecated*>(ob->form->u_vdata);
Assert(pre);
pre->cancel();
pre->bc().cancel();
}
void FormBaseDeprecated::InputCB(FL_OBJECT * ob, long data)
{
Assert(ob && ob->form);
FormBaseDeprecated * pre =
static_cast<FormBaseDeprecated*>(ob->form->u_vdata);
Assert(pre);
pre->bc().valid(pre->input(ob, data));
}
void FormBaseDeprecated::RestoreCB(FL_OBJECT * ob, long)
{
Assert(ob && ob->form);
FormBaseDeprecated * pre =
static_cast<FormBaseDeprecated*>(ob->form->u_vdata);
Assert(pre);
pre->bc().undoAll();
pre->restore();
}
FormBaseBI::FormBaseBI(LyXView * lv, Dialogs * d, string const & t)
: FormBaseDeprecated(lv, d, t)
{}
void FormBaseBI::connect()
{
h_ = d_->hideAll.connect(slot(this, &FormBaseBI::hide));
FormBaseDeprecated::connect();
}
FormBaseBD::FormBaseBD(LyXView * lv, Dialogs * d, string const & t)
: FormBaseDeprecated(lv, d, t),
u_(0)
{}
void FormBaseBD::connect()
{
u_ = d_->updateBufferDependent.
connect(slot(this, &FormBaseBD::updateSlot));
h_ = d_->hideBufferDependent.
connect(slot(this, &FormBaseBD::hide));
FormBaseDeprecated::connect();
}
void FormBaseBD::disconnect()
{
u_.disconnect();
FormBaseDeprecated::disconnect();
}