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
|
|
|
|
|
|
|
class Dialogs;
|
|
|
|
class LyXView;
|
|
|
|
|
|
|
|
#ifdef __GNUG__
|
|
|
|
#pragma interface
|
|
|
|
#endif
|
|
|
|
|
2000-09-27 05:40:29 +00:00
|
|
|
#ifdef SIGC_CXX_NAMESPACES
|
|
|
|
using SigC::Signal0;
|
|
|
|
#endif
|
|
|
|
|
2000-09-22 15:09:51 +00:00
|
|
|
/** This class is an XForms GUI base class
|
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-09-27 05:40:29 +00:00
|
|
|
///
|
|
|
|
enum BufferDependency {
|
|
|
|
///
|
|
|
|
BUFFER_DEPENDENT,
|
|
|
|
///
|
|
|
|
BUFFER_INDEPENDENT
|
|
|
|
};
|
|
|
|
|
2000-10-02 00:10:25 +00:00
|
|
|
/** Constructor.
|
|
|
|
#FormBase(lv, d, BUFFER_DEPENDENT, _("DialogName"), new ButtonPolicy)#
|
|
|
|
*/
|
|
|
|
FormBase(LyXView *, Dialogs *, BufferDependency, string const &,
|
|
|
|
ButtonPolicy * bp = new OkApplyCancelReadOnlyPolicy,
|
|
|
|
char const * close = N_("Close"),
|
|
|
|
char const * cancel = N_("Cancel"));
|
|
|
|
///
|
|
|
|
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
|
|
|
|
|
|
|
protected:
|
|
|
|
/// 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-09-29 06:34:04 +00:00
|
|
|
/// Connect signals
|
|
|
|
virtual void connect();
|
|
|
|
/// Disconnect signals
|
|
|
|
virtual void disconnect();
|
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.
|
|
|
|
*/
|
|
|
|
virtual bool input( long ) {
|
|
|
|
return true;
|
|
|
|
}
|
2000-09-22 15:09:51 +00:00
|
|
|
/// Update dialog before showing it
|
|
|
|
virtual void update() {}
|
|
|
|
/// 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
|
|
|
|
virtual void restore() {}
|
2000-09-22 15:09:51 +00:00
|
|
|
/// delete derived class variables when hide()ing
|
|
|
|
virtual void clearStore() {}
|
|
|
|
/// Pointer to the actual instantiation of xform's form
|
|
|
|
virtual FL_FORM * const form() const = 0;
|
|
|
|
|
2000-09-27 05:40:29 +00:00
|
|
|
/// block opening of form twice at the same time
|
|
|
|
bool dialogIsOpen;
|
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-02 00:10:25 +00:00
|
|
|
/// Useable even in derived-class's const functions
|
|
|
|
mutable ButtonController bc_;
|
2000-09-27 05:40:29 +00:00
|
|
|
|
2000-09-22 15:09:51 +00:00
|
|
|
private:
|
2000-09-27 05:40:29 +00:00
|
|
|
/// Hide signal
|
|
|
|
Signal0<void> * hSignal_;
|
|
|
|
/// Update signal
|
|
|
|
Signal0<void> * uSignal_;
|
2000-09-22 15:09:51 +00:00
|
|
|
/// Update connection.
|
|
|
|
Connection u_;
|
|
|
|
/// 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
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|