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 {
36 /// Callback functions
37 static int WMHideCB(FL_FORM *, void *);
39 static void ApplyCB(FL_OBJECT *, long);
41 static void OKCB(FL_OBJECT *, long);
43 static void CancelCB(FL_OBJECT *, long);
45 static void InputCB(FL_OBJECT *, long);
47 static void RestoreCB(FL_OBJECT *, long);
51 #FormBase(lv, d, _("DialogName"), BUFFER_DEPENDENT, new ButtonPolicy)#
53 FormBase(LyXView *, Dialogs *, string const &,
54 ButtonPolicy *, char const *, char const *);
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();
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;
94 /** Which LyXFunc do we use?
95 We could modify Dialogs to have a visible LyXFunc* instead and
96 save a couple of bytes per dialog.
99 /// Useable even in derived-class's const functions.
100 mutable ButtonController bc_;
101 /// Used so we can get at the signals we have to connect to.
105 /// dialog title, displayed by WM.
109 /// Overcome a dumb xforms sizing bug
116 /** This class is an XForms GUI base class for Buffer Independent dialogs.
117 Such dialogs do not require an update Connection although they may use
118 an update() function which is also supported by restore().
120 class FormBaseBI : public FormBase {
123 FormBaseBI(LyXView *, Dialogs *, string const &,
124 ButtonPolicy * bp = new OkApplyCancelPolicy,
125 char const * close = N_("Close"),
126 char const * cancel = N_("Cancel"));
129 virtual void connect();
130 /// Disconnect signals
131 virtual void disconnect();
135 /** This class is an XForms GUI base class for Buffer Dependent dialogs
137 class FormBaseBD : public FormBase {
140 FormBaseBD(LyXView *, Dialogs *, string const &,
141 ButtonPolicy * bp = new OkApplyCancelReadOnlyPolicy,
142 char const * close = N_("Close"),
143 char const * cancel = N_("Cancel"));
146 virtual void connect();
147 /// Disconnect signals
148 virtual void disconnect();
150 /// Update connection.