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"
29 #ifdef SIGC_CXX_NAMESPACES
33 /** This class is an XForms GUI base class
36 class FormBase : public DialogBase, public noncopyable {
39 enum BufferDependency {
47 #FormBase(lv, d, BUFFER_DEPENDENT, _("DialogName"), new ButtonPolicy)#
49 FormBase(LyXView *, Dialogs *, BufferDependency, string const &,
50 ButtonPolicy * bp = new OkApplyCancelReadOnlyPolicy,
51 char const * close = N_("Close"),
52 char const * cancel = N_("Cancel"));
56 /// Callback functions
57 static int WMHideCB(FL_FORM *, void *);
59 static void ApplyCB(FL_OBJECT *, long);
61 static void OKCB(FL_OBJECT *, long);
63 static void CancelCB(FL_OBJECT *, long);
65 static void InputCB(FL_OBJECT *, long);
67 static void RestoreCB(FL_OBJECT *, long);
70 /// Create the dialog if necessary, update it and display it.
75 virtual void connect();
76 /// Disconnect signals
77 virtual void disconnect();
79 virtual void build() = 0;
80 /** Filter the inputs on callback from xforms
81 Return true if inputs are valid.
83 virtual bool input( long ) {
86 /// Update dialog before showing it
87 virtual void update() {}
88 /// Apply from dialog (modify or create inset)
89 virtual void apply() {}
95 /// Cancel from dialog
96 virtual void cancel() {
99 /// Restore from dialog
100 virtual void restore() {
103 /// delete derived class variables when hide()ing
104 virtual void clearStore() {}
105 /// Pointer to the actual instantiation of xform's form
106 virtual FL_FORM * const form() const = 0;
108 /// block opening of form twice at the same time
110 /** Which LyXFunc do we use?
111 We could modify Dialogs to have a visible LyXFunc* instead and
112 save a couple of bytes per dialog.
115 /// Useable even in derived-class's const functions
116 mutable ButtonController bc_;
120 Signal0<void> * hSignal_;
122 Signal0<void> * uSignal_;
123 /// Update connection.
127 /// dialog title, displayed by WM.