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
|
|
|
|
|
|
|
|
/** 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-10 01:33:42 +00:00
|
|
|
///
|
|
|
|
enum ChangedBufferAction {
|
|
|
|
///
|
|
|
|
UPDATE,
|
|
|
|
///
|
|
|
|
HIDE
|
|
|
|
};
|
2000-09-27 05:40:29 +00:00
|
|
|
|
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 &,
|
|
|
|
BufferDependency, ChangedBufferAction,
|
2000-10-02 00:10:25 +00:00
|
|
|
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
|
|
|
|
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-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.
|
|
|
|
*/
|
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
|
|
|
/// 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
|
2000-10-02 04:21:44 +00:00
|
|
|
virtual void restore() {
|
|
|
|
update();
|
|
|
|
}
|
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
|
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
|
|
|
private: // methods
|
|
|
|
/// method connected to updateBufferDependent signal.
|
|
|
|
void updateOrHide();
|
|
|
|
|
|
|
|
protected: // data
|
|
|
|
/// block opening of form twice at the same time.
|
2000-09-27 05:40:29 +00:00
|
|
|
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-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-09-27 05:40:29 +00:00
|
|
|
|
2000-10-10 01:33:42 +00:00
|
|
|
private: // data
|
|
|
|
/// Used so we can get at the signals we have to connect to.
|
|
|
|
Dialogs * d_;
|
|
|
|
/// flag whether dialog is buffer dependent or not.
|
|
|
|
BufferDependency const bd_;
|
|
|
|
/// flag whether to hide or update on updateBufferDependent signal.
|
|
|
|
ChangedBufferAction const cba_;
|
|
|
|
/// stores parent buffer when popup was launched.
|
|
|
|
Buffer * parent_;
|
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
|