2 /* This file is part of
3 * ======================================================
5 * LyX, The Document Processor
7 * Copyright 2000 The LyX Team.
9 * ======================================================
15 #include "DialogBase.h"
17 #include <boost/utility.hpp>
18 #include FORMS_H_LOCATION
19 #include "ButtonController.h"
30 /** This class is an XForms GUI base class.
31 It is meant to be used solely as the parent class to FormBaseBI and FormBaseBD
34 class FormBase : public DialogBase, public noncopyable {
37 #FormBase(lv, d, _("DialogName"), BUFFER_DEPENDENT, new ButtonPolicy)#
39 FormBase(LyXView *, Dialogs *, string const &,
40 ButtonPolicy *, char const *, char const *);
44 /// Callback functions
45 static int WMHideCB(FL_FORM *, void *);
47 static void ApplyCB(FL_OBJECT *, long);
49 static void OKCB(FL_OBJECT *, long);
51 static void CancelCB(FL_OBJECT *, long);
53 static void InputCB(FL_OBJECT *, long);
55 static void RestoreCB(FL_OBJECT *, long);
58 /// Create the dialog if necessary, update it and display it.
62 /// bool indicates if a buffer switch took place
63 virtual void update(bool = false) {}
64 /// Connect signals. Also perform any necessary initialisation.
65 virtual void connect() = 0;
66 /// Disconnect signals. Also perform any necessary housekeeping.
67 virtual void disconnect() = 0;
69 virtual void build() = 0;
70 /** Filter the inputs on callback from xforms
71 Return true if inputs are valid.
73 virtual bool input( FL_OBJECT *, long ) {
76 /// Apply from dialog (modify or create inset)
77 virtual void apply() {}
83 /// Cancel from dialog
84 virtual void cancel() {
87 /// Restore from dialog
88 virtual void restore() {
91 /// Pointer to the actual instantiation of xform's form
92 virtual FL_FORM * form() const = 0;
95 /** Which LyXFunc do we use?
96 We could modify Dialogs to have a visible LyXFunc* instead and
97 save a couple of bytes per dialog.
100 /// Useable even in derived-class's const functions.
101 mutable ButtonController bc_;
102 /// Used so we can get at the signals we have to connect to.
106 /// dialog title, displayed by WM.
113 /** This class is an XForms GUI base class for Buffer Independent dialogs.
114 Such dialogs do not require an update Connection although they may use
115 an update() function which is also supported by restore().
117 class FormBaseBI : public FormBase {
120 FormBaseBI(LyXView *, Dialogs *, string const &,
121 ButtonPolicy * bp = new OkApplyCancelPolicy,
122 char const * close = N_("Close"),
123 char const * cancel = N_("Cancel"));
127 virtual void connect();
128 /// Disconnect signals
129 virtual void disconnect();
133 /** This class is an XForms GUI base class for Buffer Dependent dialogs
135 class FormBaseBD : public FormBase {
138 FormBaseBD(LyXView *, Dialogs *, string const &,
139 ButtonPolicy * bp = new OkApplyCancelReadOnlyPolicy,
140 char const * close = N_("Close"),
141 char const * cancel = N_("Cancel"));
145 virtual void connect();
146 /// Disconnect signals
147 virtual void disconnect();
149 /// Update connection.