2000-09-22 15:09:51 +00:00
|
|
|
// -*- C++ -*-
|
|
|
|
/* This file is part of
|
|
|
|
* ======================================================
|
|
|
|
*
|
|
|
|
* LyX, The Document Processor
|
|
|
|
*
|
|
|
|
* Copyright 2000 The LyX Team.
|
|
|
|
*
|
|
|
|
* ======================================================
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef FORMBASE_H
|
|
|
|
#define FORMBASE_H
|
|
|
|
|
|
|
|
#include "DialogBase.h"
|
|
|
|
#include "LString.h"
|
2000-10-02 00:55:02 +00:00
|
|
|
#include <boost/utility.hpp>
|
2000-09-22 15:09:51 +00:00
|
|
|
#include FORMS_H_LOCATION
|
2000-10-02 00:10:25 +00:00
|
|
|
#include "ButtonController.h"
|
|
|
|
#include "gettext.h"
|
2000-09-22 15:09:51 +00:00
|
|
|
|
2000-10-10 01:33:42 +00:00
|
|
|
class Buffer;
|
2000-09-22 15:09:51 +00:00
|
|
|
class Dialogs;
|
|
|
|
class LyXView;
|
|
|
|
|
|
|
|
#ifdef __GNUG__
|
|
|
|
#pragma interface
|
|
|
|
#endif
|
|
|
|
|
2000-10-13 05:57:05 +00:00
|
|
|
/** This class is an XForms GUI base class.
|
|
|
|
It is meant to be used solely as the parent class to FormBaseBI and FormBaseBD
|
2000-09-29 06:34:04 +00:00
|
|
|
@author Angus Leeming
|
2000-09-22 15:09:51 +00:00
|
|
|
*/
|
|
|
|
class FormBase : public DialogBase, public noncopyable {
|
|
|
|
public:
|
2000-10-02 00:10:25 +00:00
|
|
|
/** Constructor.
|
2000-10-10 01:33:42 +00:00
|
|
|
#FormBase(lv, d, _("DialogName"), BUFFER_DEPENDENT, new ButtonPolicy)#
|
2000-10-02 00:10:25 +00:00
|
|
|
*/
|
2000-10-10 01:33:42 +00:00
|
|
|
FormBase(LyXView *, Dialogs *, string const &,
|
2000-10-13 05:57:05 +00:00
|
|
|
ButtonPolicy *, char const *, char const *);
|
2000-10-02 00:10:25 +00:00
|
|
|
///
|
|
|
|
virtual ~FormBase();
|
2000-09-22 15:09:51 +00:00
|
|
|
|
|
|
|
/// Callback functions
|
|
|
|
static int WMHideCB(FL_FORM *, void *);
|
|
|
|
///
|
|
|
|
static void ApplyCB(FL_OBJECT *, long);
|
|
|
|
///
|
2000-10-02 00:10:25 +00:00
|
|
|
static void OKCB(FL_OBJECT *, long);
|
2000-09-22 15:09:51 +00:00
|
|
|
///
|
2000-10-02 00:10:25 +00:00
|
|
|
static void CancelCB(FL_OBJECT *, long);
|
2000-09-22 15:09:51 +00:00
|
|
|
///
|
2000-09-27 05:40:29 +00:00
|
|
|
static void InputCB(FL_OBJECT *, long);
|
2000-10-02 00:10:25 +00:00
|
|
|
///
|
|
|
|
static void RestoreCB(FL_OBJECT *, long);
|
2000-09-22 15:09:51 +00:00
|
|
|
|
2000-10-10 01:33:42 +00:00
|
|
|
protected: // methods
|
2000-09-22 15:09:51 +00:00
|
|
|
/// Create the dialog if necessary, update it and display it.
|
|
|
|
void show();
|
|
|
|
/// Hide the dialog.
|
2000-10-02 00:10:25 +00:00
|
|
|
virtual void hide();
|
2000-10-13 05:57:05 +00:00
|
|
|
/// bool indicates if a buffer switch took place
|
|
|
|
virtual void update(bool = false) {}
|
|
|
|
/// Connect signals. Also perform any necessary initialisation.
|
|
|
|
virtual void connect() = 0;
|
|
|
|
/// Disconnect signals. Also perform any necessary housekeeping.
|
|
|
|
virtual void disconnect() = 0;
|
2000-09-22 15:09:51 +00:00
|
|
|
/// Build the dialog
|
|
|
|
virtual void build() = 0;
|
2000-10-02 00:10:25 +00:00
|
|
|
/** Filter the inputs on callback from xforms
|
|
|
|
Return true if inputs are valid.
|
|
|
|
*/
|
2000-10-05 07:57:00 +00:00
|
|
|
virtual bool input( FL_OBJECT *, long ) {
|
2000-10-02 00:10:25 +00:00
|
|
|
return true;
|
|
|
|
}
|
2000-09-22 15:09:51 +00:00
|
|
|
/// Apply from dialog (modify or create inset)
|
|
|
|
virtual void apply() {}
|
2000-10-02 00:10:25 +00:00
|
|
|
/// OK from dialog
|
|
|
|
virtual void ok() {
|
|
|
|
apply();
|
|
|
|
hide();
|
|
|
|
}
|
|
|
|
/// Cancel from dialog
|
|
|
|
virtual void cancel() {
|
|
|
|
hide();
|
|
|
|
}
|
|
|
|
/// Restore from dialog
|
2000-10-02 04:21:44 +00:00
|
|
|
virtual void restore() {
|
|
|
|
update();
|
|
|
|
}
|
2000-09-22 15:09:51 +00:00
|
|
|
/// Pointer to the actual instantiation of xform's form
|
2000-10-03 05:53:25 +00:00
|
|
|
virtual FL_FORM * form() const = 0;
|
2000-09-22 15:09:51 +00:00
|
|
|
|
2000-10-10 01:33:42 +00:00
|
|
|
protected: // data
|
2000-09-22 15:09:51 +00:00
|
|
|
/** Which LyXFunc do we use?
|
|
|
|
We could modify Dialogs to have a visible LyXFunc* instead and
|
|
|
|
save a couple of bytes per dialog.
|
|
|
|
*/
|
|
|
|
LyXView * lv_;
|
2000-10-10 01:33:42 +00:00
|
|
|
/// Useable even in derived-class's const functions.
|
2000-10-02 00:10:25 +00:00
|
|
|
mutable ButtonController bc_;
|
2000-10-10 01:33:42 +00:00
|
|
|
/// Used so we can get at the signals we have to connect to.
|
|
|
|
Dialogs * d_;
|
2000-09-22 15:09:51 +00:00
|
|
|
/// Hide connection.
|
|
|
|
Connection h_;
|
|
|
|
/// dialog title, displayed by WM.
|
|
|
|
string title;
|
2000-10-02 00:10:25 +00:00
|
|
|
///
|
|
|
|
ButtonPolicy * bp_;
|
2000-09-22 15:09:51 +00:00
|
|
|
};
|
|
|
|
|
2000-10-13 05:57:05 +00:00
|
|
|
|
|
|
|
/** This class is an XForms GUI base class for Buffer Independent dialogs.
|
|
|
|
Such dialogs do not require an update Connection although they may use
|
|
|
|
an update() function which is also supported by restore().
|
|
|
|
*/
|
|
|
|
class FormBaseBI : public FormBase {
|
|
|
|
public:
|
|
|
|
/// Constructor
|
|
|
|
FormBaseBI(LyXView *, Dialogs *, string const &,
|
|
|
|
ButtonPolicy * bp = new OkApplyCancelPolicy,
|
|
|
|
char const * close = N_("Close"),
|
|
|
|
char const * cancel = N_("Cancel"));
|
|
|
|
|
|
|
|
protected:
|
|
|
|
/// Connect signals
|
|
|
|
virtual void connect();
|
|
|
|
/// Disconnect signals
|
|
|
|
virtual void disconnect();
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/** This class is an XForms GUI base class for Buffer Dependent dialogs
|
|
|
|
*/
|
|
|
|
class FormBaseBD : public FormBase {
|
|
|
|
public:
|
|
|
|
/// Constructor
|
|
|
|
FormBaseBD(LyXView *, Dialogs *, string const &,
|
|
|
|
ButtonPolicy * bp = new OkApplyCancelReadOnlyPolicy,
|
|
|
|
char const * close = N_("Close"),
|
|
|
|
char const * cancel = N_("Cancel"));
|
|
|
|
|
|
|
|
protected:
|
|
|
|
/// Connect signals
|
|
|
|
virtual void connect();
|
|
|
|
/// Disconnect signals
|
|
|
|
virtual void disconnect();
|
|
|
|
|
|
|
|
/// Update connection.
|
|
|
|
Connection u_;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2000-09-22 15:09:51 +00:00
|
|
|
#endif
|