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-11-10 17:29:47 +00:00
|
|
|
#include <sigc++/signal_system.h> // temporary
|
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.
|
2000-11-08 09:39:46 +00:00
|
|
|
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
|
|
|
*/
|
2000-11-10 17:29:47 +00:00
|
|
|
|
2000-09-22 15:09:51 +00:00
|
|
|
class FormBase : public DialogBase, public noncopyable {
|
|
|
|
public:
|
|
|
|
/// 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-11-10 17:29:47 +00:00
|
|
|
///
|
2000-10-20 09:50:09 +00:00
|
|
|
FormBase(LyXView *, Dialogs *, string const &,
|
|
|
|
ButtonPolicy *, char const *, char const *);
|
|
|
|
///
|
|
|
|
virtual ~FormBase();
|
|
|
|
|
2000-11-10 17:29:47 +00:00
|
|
|
/** Redraw the form (on receipt of a Signal indicating, for example,
|
|
|
|
that the xform colours have been re-mapped).
|
|
|
|
Must be virtual because dialogs with tabbed folders will need to
|
|
|
|
redraw the form for each tab.
|
|
|
|
*/
|
|
|
|
virtual void redraw();
|
|
|
|
|
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-24 13:13:59 +00:00
|
|
|
/// Update the dialog.
|
|
|
|
virtual void update() {}
|
2000-10-13 05:57:05 +00:00
|
|
|
/// Connect signals. Also perform any necessary initialisation.
|
2000-10-20 09:50:09 +00:00
|
|
|
virtual void connect();
|
2000-10-13 05:57:05 +00:00
|
|
|
/// Disconnect signals. Also perform any necessary housekeeping.
|
2000-11-21 21:51:25 +00:00
|
|
|
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-11-04 10:00:12 +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
|
|
|
|
|
|
|
/** 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_;
|
2000-11-21 21:51:25 +00:00
|
|
|
/// Redraw connection.
|
|
|
|
Connection r_;
|
2000-09-22 15:09:51 +00:00
|
|
|
/// dialog title, displayed by WM.
|
|
|
|
string title;
|
2000-11-14 02:01:57 +00:00
|
|
|
private:
|
2000-10-02 00:10:25 +00:00
|
|
|
///
|
|
|
|
ButtonPolicy * bp_;
|
2000-11-14 02:01:57 +00:00
|
|
|
public:
|
2000-10-20 09:50:09 +00:00
|
|
|
/// Overcome a dumb xforms sizing bug
|
|
|
|
mutable int minw_;
|
|
|
|
///
|
|
|
|
mutable int minh_;
|
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 {
|
2000-10-20 09:50:09 +00:00
|
|
|
protected:
|
2000-10-13 05:57:05 +00:00
|
|
|
/// Constructor
|
|
|
|
FormBaseBI(LyXView *, Dialogs *, string const &,
|
2000-11-14 02:01:57 +00:00
|
|
|
ButtonPolicy * bp,
|
2000-10-13 05:57:05 +00:00
|
|
|
char const * close = N_("Close"),
|
|
|
|
char const * cancel = N_("Cancel"));
|
|
|
|
|
|
|
|
/// Connect signals
|
|
|
|
virtual void connect();
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/** This class is an XForms GUI base class for Buffer Dependent dialogs
|
|
|
|
*/
|
|
|
|
class FormBaseBD : public FormBase {
|
2000-10-20 09:50:09 +00:00
|
|
|
protected:
|
2000-10-13 05:57:05 +00:00
|
|
|
/// Constructor
|
|
|
|
FormBaseBD(LyXView *, Dialogs *, string const &,
|
2000-11-14 02:01:57 +00:00
|
|
|
ButtonPolicy * bp,
|
2000-10-13 05:57:05 +00:00
|
|
|
char const * close = N_("Close"),
|
|
|
|
char const * cancel = N_("Cancel"));
|
|
|
|
|
|
|
|
/// Connect signals
|
|
|
|
virtual void connect();
|
|
|
|
/// Disconnect signals
|
|
|
|
virtual void disconnect();
|
2000-10-24 13:13:59 +00:00
|
|
|
/// bool indicates if a buffer switch took place
|
|
|
|
virtual void updateSlot(bool) { update(); }
|
2000-10-13 05:57:05 +00:00
|
|
|
|
|
|
|
/// Update connection.
|
|
|
|
Connection u_;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2000-09-22 15:09:51 +00:00
|
|
|
#endif
|