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
33 class FormBase : public DialogBase, public noncopyable {
36 enum BufferDependency {
43 enum ChangedBufferAction {
51 #FormBase(lv, d, _("DialogName"), BUFFER_DEPENDENT, new ButtonPolicy)#
53 FormBase(LyXView *, Dialogs *, string const &,
54 BufferDependency, ChangedBufferAction,
55 ButtonPolicy * bp = new OkApplyCancelReadOnlyPolicy,
56 char const * close = N_("Close"),
57 char const * cancel = N_("Cancel"));
61 /// Callback functions
62 static int WMHideCB(FL_FORM *, void *);
64 static void ApplyCB(FL_OBJECT *, long);
66 static void OKCB(FL_OBJECT *, long);
68 static void CancelCB(FL_OBJECT *, long);
70 static void InputCB(FL_OBJECT *, long);
72 static void RestoreCB(FL_OBJECT *, long);
75 /// Create the dialog if necessary, update it and display it.
80 virtual void connect();
81 /// Disconnect signals
82 virtual void disconnect();
84 virtual void build() = 0;
85 /** Filter the inputs on callback from xforms
86 Return true if inputs are valid.
88 virtual bool input( FL_OBJECT *, long ) {
91 /// Update dialog before showing it
92 virtual void update() {}
93 /// Apply from dialog (modify or create inset)
94 virtual void apply() {}
100 /// Cancel from dialog
101 virtual void cancel() {
104 /// Restore from dialog
105 virtual void restore() {
108 /// delete derived class variables when hide()ing
109 virtual void clearStore() {}
110 /// Pointer to the actual instantiation of xform's form
111 virtual FL_FORM * form() const = 0;
114 /// method connected to updateBufferDependent signal.
118 /// block opening of form twice at the same time.
120 /** Which LyXFunc do we use?
121 We could modify Dialogs to have a visible LyXFunc* instead and
122 save a couple of bytes per dialog.
125 /// Useable even in derived-class's const functions.
126 mutable ButtonController bc_;
129 /// Used so we can get at the signals we have to connect to.
131 /// flag whether dialog is buffer dependent or not.
132 BufferDependency const bd_;
133 /// flag whether to hide or update on updateBufferDependent signal.
134 ChangedBufferAction const cba_;
135 /// stores parent buffer when popup was launched.
137 /// Update connection.
141 /// dialog title, displayed by WM.