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
35 class FormBase : public DialogBase, public noncopyable {
37 /// Callback functions
38 static int WMHideCB(FL_FORM *, void *);
40 static void ApplyCB(FL_OBJECT *, long);
42 static void OKCB(FL_OBJECT *, long);
44 static void CancelCB(FL_OBJECT *, long);
46 static void InputCB(FL_OBJECT *, long);
48 static void RestoreCB(FL_OBJECT *, long);
52 #FormBase(lv, d, _("DialogName"), BUFFER_DEPENDENT, new ButtonPolicy)#
54 FormBase(LyXView *, Dialogs *, string const &,
55 ButtonPolicy *, char const *, char const *);
59 /// Create the dialog if necessary, update it and display it.
63 /// Update the dialog.
64 virtual void update() {}
65 /// Connect signals. Also perform any necessary initialisation.
66 virtual void connect();
67 /// Disconnect signals. Also perform any necessary housekeeping.
68 virtual void disconnect() = 0;
70 virtual void build() = 0;
71 /** Filter the inputs on callback from xforms
72 Return true if inputs are valid.
74 virtual bool input( FL_OBJECT *, long) {
77 /// Apply from dialog (modify or create inset)
78 virtual void apply() {}
84 /// Cancel from dialog
85 virtual void cancel() {
88 /// Restore from dialog
89 virtual void restore() {
92 /// Pointer to the actual instantiation of xform's form
93 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.
110 /// Overcome a dumb xforms sizing bug
117 /** This class is an XForms GUI base class for Buffer Independent dialogs.
118 Such dialogs do not require an update Connection although they may use
119 an update() function which is also supported by restore().
121 class FormBaseBI : public FormBase {
124 FormBaseBI(LyXView *, Dialogs *, string const &,
125 ButtonPolicy * bp = new OkApplyCancelPolicy,
126 char const * close = N_("Close"),
127 char const * cancel = N_("Cancel"));
130 virtual void connect();
131 /// Disconnect signals
132 virtual void disconnect();
136 /** This class is an XForms GUI base class for Buffer Dependent dialogs
138 class FormBaseBD : public FormBase {
141 FormBaseBD(LyXView *, Dialogs *, string const &,
142 ButtonPolicy * bp = new OkApplyCancelReadOnlyPolicy,
143 char const * close = N_("Close"),
144 char const * cancel = N_("Cancel"));
147 virtual void connect();
148 /// Disconnect signals
149 virtual void disconnect();
150 /// bool indicates if a buffer switch took place
151 virtual void updateSlot(bool) { update(); }
153 /// Update connection.