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 "support/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() {}
101 /// delete derived class variables when hide()ing
102 virtual void clearStore() {}
103 /// Pointer to the actual instantiation of xform's form
104 virtual FL_FORM * const form() const = 0;
106 /// block opening of form twice at the same time
108 /** Which LyXFunc do we use?
109 We could modify Dialogs to have a visible LyXFunc* instead and
110 save a couple of bytes per dialog.
113 /// Useable even in derived-class's const functions
114 mutable ButtonController bc_;
118 Signal0<void> * hSignal_;
120 Signal0<void> * uSignal_;
121 /// Update connection.
125 /// dialog title, displayed by WM.