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 FORMS_H_LOCATION
18 #include "ButtonController.h"
20 #include <sigc++/signal_system.h>
30 /** This class is an XForms GUI base class.
31 It is meant to be used solely as the parent class to FormBaseBI
36 class FormBase : public DialogBase {
38 /// Callback functions
39 static int WMHideCB(FL_FORM *, void *);
41 static void ApplyCB(FL_OBJECT *, long);
43 static void OKCB(FL_OBJECT *, long);
45 static void CancelCB(FL_OBJECT *, long);
47 static void InputCB(FL_OBJECT *, long);
49 static void RestoreCB(FL_OBJECT *, long);
53 FormBase(LyXView *, Dialogs *, string const &,
54 ButtonPolicy *, char const *, char const *);
58 /** Redraw the form (on receipt of a Signal indicating, for example,
59 that the xform colors have been re-mapped).
60 Must be virtual because dialogs with tabbed folders will need to
61 redraw the form for each tab.
63 virtual void redraw();
65 /// Create the dialog if necessary, update it and display it.
69 /// Update the dialog.
70 virtual void update() {}
71 /// Connect signals. Also perform any necessary initialisation.
72 virtual void connect();
73 /// Disconnect signals. Also perform any necessary housekeeping.
74 virtual void disconnect();
76 virtual void build() = 0;
77 /** Filter the inputs on callback from xforms
78 Return true if inputs are valid.
80 virtual bool input( FL_OBJECT *, long) {
83 /// Apply from dialog (modify or create inset)
84 virtual void apply() {}
90 /// Cancel from dialog
91 virtual void cancel() {
94 /// Restore from dialog
95 virtual void restore() {
98 /// Pointer to the actual instantiation of xform's form
99 virtual FL_FORM * form() const = 0;
101 /** Which LyXFunc do we use?
102 We could modify Dialogs to have a visible LyXFunc* instead and
103 save a couple of bytes per dialog.
106 /// Useable even in derived-class's const functions.
107 mutable ButtonController bc_;
108 /// Used so we can get at the signals we have to connect to.
112 /// Redraw connection.
114 /// dialog title, displayed by WM.
120 /// Overcome a dumb xforms sizing bug
127 /** This class is an XForms GUI base class for Buffer Independent dialogs.
128 Such dialogs do not require an update Connection although they may use
129 an update() function which is also supported by restore().
131 class FormBaseBI : public FormBase {
134 FormBaseBI(LyXView *, Dialogs *, string const &,
136 char const * close = N_("Close"),
137 char const * cancel = N_("Cancel"));
140 virtual void connect();
144 /** This class is an XForms GUI base class for Buffer Dependent dialogs
146 class FormBaseBD : public FormBase {
149 FormBaseBD(LyXView *, Dialogs *, string const &,
151 char const * close = N_("Close"),
152 char const * cancel = N_("Cancel"));
155 virtual void connect();
156 /// Disconnect signals
157 virtual void disconnect();
158 /// bool indicates if a buffer switch took place
159 virtual void updateSlot(bool) { update(); }
161 /// Update connection.