2001-03-15 13:37:04 +00:00
|
|
|
This directory provides the controllers that act as an interface between the
|
2001-04-03 14:30:58 +00:00
|
|
|
LyX kernel and the GUI-specific implementations of each dialog. It also
|
2001-03-15 13:37:04 +00:00
|
|
|
provides abstract base classes from which GUI-specific implemetations of the
|
2001-04-03 14:30:58 +00:00
|
|
|
ButtonController and each separate dialog should be derived (see
|
2001-03-15 13:37:04 +00:00
|
|
|
ButtonControlBase.[Ch] and ViewBase.h respectively).
|
|
|
|
|
2001-04-03 14:30:58 +00:00
|
|
|
The Controller connects the GUI-specific dialog to any appropriate signals and
|
2001-03-15 13:37:04 +00:00
|
|
|
dispatches any changes in the data to the kernel. It has no knowledge of the
|
|
|
|
actual instantiation of the GUI-dependent View and ButtonController, which
|
|
|
|
should therefore be created elsewhere. Once created, the Controller will take
|
|
|
|
care of their initialisation, management and, ultimately, destruction.
|
|
|
|
|
2001-04-03 14:30:58 +00:00
|
|
|
This leaves the GUI-specific dialog (and its author!) to worry only about the
|
2001-03-15 13:37:04 +00:00
|
|
|
data that it has been created to input/modify.
|
|
|
|
|
|
|
|
This concept has been instatiated for the Citation dialog only at the moment.
|
|
|
|
See xforms-new/FormCitation.[Ch] for an xforms-specific View of the dialog.
|
2001-03-26 08:14:39 +00:00
|
|
|
|
|
|
|
How the code works.
|
|
|
|
===================
|
|
|
|
|
|
|
|
I'll describe Inset-type dialogs (eg, the Citation dialog). Non-inset-type
|
2003-09-09 18:27:24 +00:00
|
|
|
(eg the Document dialog) have similar flow, but the important controller
|
2001-03-26 08:14:39 +00:00
|
|
|
functions are to be found in ControlDialogs.h, not ControlInset.h.
|
|
|
|
|
|
|
|
Let's use the citation dialog as an example.
|
|
|
|
|
|
|
|
The dialog is launched by :
|
|
|
|
a) clicking on an existing inset, emitting the showCitation()
|
|
|
|
(Dialogs.h) signal, connected to the showInset() slot
|
|
|
|
(controllers/ControlInset.h) in theControlCitation c-tor.
|
|
|
|
b) request a new inset (eg from the menubar), emitting a
|
|
|
|
createCitation() signal (Dialogs.h) connected to the createInset()
|
2003-09-09 18:27:24 +00:00
|
|
|
slot (controllers/ControlInset.h) in theControlCitation c-tor.
|
2001-03-26 08:14:39 +00:00
|
|
|
|
|
|
|
The user presses the Ok, Apply, Cancel or Restore buttons. In xforms
|
|
|
|
these are connected to the button controller (xforms/FormCitation.C:
|
2003-09-09 18:27:24 +00:00
|
|
|
build) so:
|
2001-03-26 08:14:39 +00:00
|
|
|
bc().setOK(dialog_->button_ok);
|
|
|
|
bc().setApply(dialog_->button_apply);
|
|
|
|
bc().setCancel(dialog_->button_cancel);
|
2001-04-03 14:30:58 +00:00
|
|
|
bc().setRestore(dialog_->button_restore);
|
2003-09-09 18:27:24 +00:00
|
|
|
The button controller alters the state of the buttons (active/inactive).
|
2001-03-26 08:14:39 +00:00
|
|
|
xforms works by callbacks, so clicking on say the button_ok button
|
2003-09-09 18:27:24 +00:00
|
|
|
causes a callback event to (see FormBase.C)
|
2001-03-26 08:14:39 +00:00
|
|
|
|
|
|
|
extern "C" void C_FormBaseOKCB(FL_OBJECT * ob, long)
|
|
|
|
{
|
|
|
|
GetForm(ob)->OKButton();
|
|
|
|
}
|
|
|
|
|
|
|
|
GetForm() extracts the actual instance of FormCitation that caused the
|
|
|
|
event and calls OKButton() (see controllers/ViewBase.h) which in turn
|
|
|
|
calls the controller's OKButton method. (The ViewBase method exists
|
2003-09-09 18:27:24 +00:00
|
|
|
only because :
|
2001-03-26 08:14:39 +00:00
|
|
|
/** These shortcuts allow (e.g. xform's) global callback functions
|
|
|
|
access to the buttons without making the whole controller_
|
|
|
|
public. */
|
|
|
|
|
|
|
|
So, ultimately, pressing button_ok on the Citation dialog calls
|
2003-09-09 18:27:24 +00:00
|
|
|
ControlBase::OKButton().
|
2001-03-26 08:14:39 +00:00
|
|
|
|
|
|
|
void ControlBase::OKButton()
|
|
|
|
{
|
|
|
|
apply();
|
|
|
|
hide();
|
|
|
|
bc().ok();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
apply() and hide() are pure virtual methods, instantiated in
|
|
|
|
ControlInset.h because the Citation dialog is an inset dialog and all
|
2003-09-09 18:27:24 +00:00
|
|
|
insets are functionally identical.
|
2001-03-26 08:14:39 +00:00
|
|
|
|
|
|
|
template <class Inset, class Params>
|
|
|
|
void ControlInset<Inset, Params>::apply()
|
|
|
|
{
|
|
|
|
if (lv_.buffer()->isReadonly())
|
|
|
|
return;
|
|
|
|
|
|
|
|
view().apply();
|
|
|
|
|
|
|
|
if (inset_ && params() != getParams(*inset_))
|
|
|
|
applyParamsToInset();
|
|
|
|
else
|
|
|
|
applyParamsNoInset();
|
|
|
|
}
|
|
|
|
|
|
|
|
applyParamsToInset() and applyParamsNoInset(); are to be found in
|
|
|
|
FormCommand.[Ch] because the citation inset is derived from
|
|
|
|
InsetCommand and this subset of insets have identical internal
|
2003-09-09 18:27:24 +00:00
|
|
|
structure and so the params can be applied in the same way.
|
2001-03-26 08:14:39 +00:00
|
|
|
|