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"
21 #include <sigc++/signal_system.h>
31 /** This class is an XForms GUI base class.
32 It is meant to be used solely as the parent class to FormBaseBI
37 class FormBase : public DialogBase, public noncopyable {
39 /// Callback functions
40 static int WMHideCB(FL_FORM *, void *);
42 static void ApplyCB(FL_OBJECT *, long);
44 static void OKCB(FL_OBJECT *, long);
46 static void CancelCB(FL_OBJECT *, long);
48 static void InputCB(FL_OBJECT *, long);
50 static void RestoreCB(FL_OBJECT *, long);
54 FormBase(LyXView *, Dialogs *, string const &,
55 ButtonPolicy *, char const *, char const *);
59 /** Redraw the form (on receipt of a Signal indicating, for example,
60 that the xform colors have been re-mapped).
61 Must be virtual because dialogs with tabbed folders will need to
62 redraw the form for each tab.
64 virtual void redraw();
66 /// Create the dialog if necessary, update it and display it.
70 /// Update the dialog.
71 virtual void update() {}
72 /// Connect signals. Also perform any necessary initialisation.
73 virtual void connect();
74 /// Disconnect signals. Also perform any necessary housekeeping.
75 virtual void disconnect();
77 virtual void build() = 0;
78 /** Filter the inputs on callback from xforms
79 Return true if inputs are valid.
81 virtual bool input( FL_OBJECT *, long) {
84 /// Apply from dialog (modify or create inset)
85 virtual void apply() {}
91 /// Cancel from dialog
92 virtual void cancel() {
95 /// Restore from dialog
96 virtual void restore() {
99 /// Pointer to the actual instantiation of xform's form
100 virtual FL_FORM * form() const = 0;
102 /** Which LyXFunc do we use?
103 We could modify Dialogs to have a visible LyXFunc* instead and
104 save a couple of bytes per dialog.
107 /// Useable even in derived-class's const functions.
108 mutable ButtonController bc_;
109 /// Used so we can get at the signals we have to connect to.
113 /// Redraw connection.
115 /// dialog title, displayed by WM.
121 /// Overcome a dumb xforms sizing bug
128 /** This class is an XForms GUI base class for Buffer Independent dialogs.
129 Such dialogs do not require an update Connection although they may use
130 an update() function which is also supported by restore().
132 class FormBaseBI : public FormBase {
135 FormBaseBI(LyXView *, Dialogs *, string const &,
137 char const * close = N_("Close"),
138 char const * cancel = N_("Cancel"));
141 virtual void connect();
145 /** This class is an XForms GUI base class for Buffer Dependent dialogs
147 class FormBaseBD : public FormBase {
150 FormBaseBD(LyXView *, Dialogs *, string const &,
152 char const * close = N_("Close"),
153 char const * cancel = N_("Cancel"));
156 virtual void connect();
157 /// Disconnect signals
158 virtual void disconnect();
159 /// bool indicates if a buffer switch took place
160 virtual void updateSlot(bool) { update(); }
162 /// Update connection.