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"
|
2000-10-10 01:33:42 +00:00
|
|
|
#include "LyXView.h"
|
2000-09-22 15:09:51 +00:00
|
|
|
#include "xform_macros.h"
|
2000-11-08 09:39:46 +00:00
|
|
|
#include "support/LAssert.h"
|
2000-11-14 02:01:57 +00:00
|
|
|
//#include "debug.h"
|
2000-11-08 09:39:46 +00:00
|
|
|
|
|
|
|
// The current scheme muddles debugging.
|
|
|
|
// Can we please use some other means to create these functions?
|
|
|
|
// I really don't like to use the preprossessor for this.
|
|
|
|
// My suggestion: First of all move these functions into their own
|
|
|
|
// file (that can be included here if wanted, and use m4 to expand
|
|
|
|
// that file. So create a m4 function to do the expansion, a file
|
|
|
|
// that contains the calls to to this function and a script to run
|
|
|
|
// it and create the C++ file with the expanded functions. (Lgb)
|
|
|
|
// Possible startoff point:
|
|
|
|
// define([C_RETURNCB],[extern "C" int C_$1$2(FL_FORM * ob, void * d) { return $1::$2(ob, d); }])
|
2000-09-22 15:09:51 +00:00
|
|
|
|
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-10 01:33:42 +00:00
|
|
|
FormBase::FormBase(LyXView * lv, Dialogs * d, string const & t,
|
2000-10-02 00:10:25 +00:00
|
|
|
ButtonPolicy * bp, char const * close, char const * cancel)
|
2000-11-21 21:51:25 +00:00
|
|
|
: lv_(lv), bc_(bp, cancel, close), d_(d), h_(0), r_(0), title(t),
|
|
|
|
bp_(bp), minw_(0), minh_(0)
|
2000-11-08 09:39:46 +00:00
|
|
|
{
|
|
|
|
Assert(lv && d && bp);
|
|
|
|
}
|
2000-09-22 15:09:51 +00:00
|
|
|
|
2000-10-02 00:10:25 +00:00
|
|
|
|
|
|
|
FormBase::~FormBase()
|
|
|
|
{
|
2000-11-14 02:01:57 +00:00
|
|
|
//lyxerr << "bp_[" << bp_ << "]" << endl;
|
2000-10-02 00:10:25 +00:00
|
|
|
delete bp_;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-11-10 17:29:47 +00:00
|
|
|
void FormBase::redraw()
|
|
|
|
{
|
2000-11-14 02:01:57 +00:00
|
|
|
if (form() && form()->visible)
|
|
|
|
fl_redraw_form(form());
|
2000-11-10 17:29:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-10-20 09:50:09 +00:00
|
|
|
void FormBase::connect()
|
|
|
|
{
|
2000-11-14 02:01:57 +00:00
|
|
|
fl_set_form_minsize(form(), minw_, minh_);
|
2000-11-21 21:51:25 +00:00
|
|
|
r_ = Dialogs::redrawGUI.connect(slot(this, &FormBase::redraw));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void FormBase::disconnect()
|
|
|
|
{
|
|
|
|
h_.disconnect();
|
|
|
|
r_.disconnect();
|
2000-10-20 09:50:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-09-22 15:09:51 +00:00
|
|
|
void FormBase::show()
|
|
|
|
{
|
|
|
|
if (!form()) {
|
|
|
|
build();
|
|
|
|
fl_set_form_atclose(form(),
|
|
|
|
C_FormBaseWMHideCB, 0);
|
|
|
|
}
|
|
|
|
|
2000-11-14 02:01:57 +00:00
|
|
|
fl_freeze_form(form());
|
2000-09-22 15:09:51 +00:00
|
|
|
update(); // make sure its up-to-date
|
2000-11-14 02:01:57 +00:00
|
|
|
fl_unfreeze_form(form());
|
2000-09-22 15:09:51 +00:00
|
|
|
|
|
|
|
if (form()->visible) {
|
|
|
|
fl_raise_form(form());
|
|
|
|
} else {
|
2000-10-20 09:50:09 +00:00
|
|
|
// calls to fl_set_form_minsize/maxsize apply only to the next
|
|
|
|
// fl_show_form(), so connect() comes first.
|
|
|
|
connect();
|
2000-09-22 15:09:51 +00:00
|
|
|
fl_show_form(form(),
|
|
|
|
FL_PLACE_MOUSE | FL_FREE_SIZE,
|
|
|
|
FL_TRANSIENT,
|
|
|
|
title.c_str());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void FormBase::hide()
|
|
|
|
{
|
|
|
|
if (form() && form()->visible) {
|
2000-10-13 05:57:05 +00:00
|
|
|
// some dialogs might do things to the form first
|
|
|
|
// such as the nested tabfolder problem in Preferences
|
2000-09-29 06:34:04 +00:00
|
|
|
disconnect();
|
2000-10-13 05:57:05 +00:00
|
|
|
fl_hide_form(form());
|
2000-09-22 15:09:51 +00:00
|
|
|
}
|
2000-09-29 06:34:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-09-22 15:09:51 +00:00
|
|
|
int FormBase::WMHideCB(FL_FORM * form, void *)
|
|
|
|
{
|
2000-11-08 09:39:46 +00:00
|
|
|
Assert(form);
|
2000-09-22 15:09:51 +00:00
|
|
|
// 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);
|
2000-11-08 09:39:46 +00:00
|
|
|
Assert(pre);
|
2000-09-22 15:09:51 +00:00
|
|
|
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)
|
|
|
|
{
|
2000-11-08 09:39:46 +00:00
|
|
|
Assert(ob && ob->form);
|
2000-09-22 15:09:51 +00:00
|
|
|
FormBase * pre = static_cast<FormBase*>(ob->form->u_vdata);
|
2000-11-08 09:39:46 +00:00
|
|
|
Assert(pre);
|
2000-09-22 15:09:51 +00:00
|
|
|
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
|
|
|
{
|
2000-11-08 09:39:46 +00:00
|
|
|
Assert(ob && ob->form);
|
2000-09-22 15:09:51 +00:00
|
|
|
FormBase * pre = static_cast<FormBase*>(ob->form->u_vdata);
|
2000-11-08 09:39:46 +00:00
|
|
|
Assert(pre);
|
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
|
|
|
{
|
2000-11-08 09:39:46 +00:00
|
|
|
Assert(ob && ob->form);
|
2000-09-22 15:09:51 +00:00
|
|
|
FormBase * pre = static_cast<FormBase*>(ob->form->u_vdata);
|
2000-11-08 09:39:46 +00:00
|
|
|
Assert(pre);
|
2000-10-02 00:10:25 +00:00
|
|
|
pre->cancel();
|
|
|
|
pre->bc_.cancel();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-11-14 02:01:57 +00:00
|
|
|
void FormBase::InputCB(FL_OBJECT * ob, long data)
|
2000-10-02 00:10:25 +00:00
|
|
|
{
|
2000-11-08 09:39:46 +00:00
|
|
|
Assert(ob && ob->form);
|
2000-10-02 00:10:25 +00:00
|
|
|
FormBase * pre = static_cast<FormBase*>(ob->form->u_vdata);
|
2000-11-08 09:39:46 +00:00
|
|
|
Assert(ob);
|
|
|
|
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
|
|
|
{
|
2000-11-08 09:39:46 +00:00
|
|
|
Assert(ob && ob->form);
|
2000-09-22 15:09:51 +00:00
|
|
|
FormBase * pre = static_cast<FormBase*>(ob->form->u_vdata);
|
2000-11-08 09:39:46 +00:00
|
|
|
Assert(ob);
|
2000-10-02 00:10:25 +00:00
|
|
|
pre->restore();
|
|
|
|
pre->bc_.undoAll();
|
2000-09-22 15:09:51 +00:00
|
|
|
}
|
2000-10-13 05:57:05 +00:00
|
|
|
|
|
|
|
|
|
|
|
FormBaseBI::FormBaseBI(LyXView * lv, Dialogs * d, string const & t,
|
|
|
|
ButtonPolicy * bp,
|
|
|
|
char const * close, char const * cancel)
|
2000-11-14 02:01:57 +00:00
|
|
|
: FormBase(lv, d, t, bp, close, cancel)
|
2000-11-10 17:29:47 +00:00
|
|
|
{}
|
2000-10-13 05:57:05 +00:00
|
|
|
|
|
|
|
|
|
|
|
void FormBaseBI::connect()
|
|
|
|
{
|
|
|
|
h_ = d_->hideAll.connect(slot(this, &FormBaseBI::hide));
|
2000-10-20 09:50:09 +00:00
|
|
|
FormBase::connect();
|
2000-10-13 05:57:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
FormBaseBD::FormBaseBD(LyXView * lv, Dialogs * d, string const & t,
|
|
|
|
ButtonPolicy * bp,
|
|
|
|
char const * close, char const * cancel)
|
2000-11-14 02:01:57 +00:00
|
|
|
: FormBase(lv, d, t, bp, close, cancel),
|
2000-10-13 05:57:05 +00:00
|
|
|
u_(0)
|
2000-11-10 17:29:47 +00:00
|
|
|
{}
|
2000-10-13 05:57:05 +00:00
|
|
|
|
|
|
|
|
|
|
|
void FormBaseBD::connect()
|
|
|
|
{
|
|
|
|
u_ = d_->updateBufferDependent.
|
2000-10-24 13:13:59 +00:00
|
|
|
connect(slot(this, &FormBaseBD::updateSlot));
|
2000-10-13 05:57:05 +00:00
|
|
|
h_ = d_->hideBufferDependent.
|
|
|
|
connect(slot(this, &FormBaseBD::hide));
|
2000-10-20 09:50:09 +00:00
|
|
|
FormBase::connect();
|
2000-10-13 05:57:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void FormBaseBD::disconnect()
|
|
|
|
{
|
|
|
|
u_.disconnect();
|
2000-11-21 21:51:25 +00:00
|
|
|
FormBase::disconnect();
|
2000-10-13 05:57:05 +00:00
|
|
|
}
|