> | if (c == LyXParagraph::META_INSET) {
> | Inset const * tmpinset = row->par()->GetInset(pos);
> | if (tmpinset) {
> | tmpinset->draw(bview, font, offset+row->baseline(), x,
> | cleared);
> | }
> | ...
> | }
> |
> | It seems that this is a good place to check the contents of the inset and if
> | empty to remove it.
> No, if empty (cancelled) it should not have been inserted in the first
> place.
> What you need to to is to separate the inset dialog from the inset,
> sot that you can call the dialog first and create the inset on basis
> of information entered there. Then you will now if it is ok to insert
> the inset in the first place.
First, a summary of the current behaviour of (say) the citation inset. Or, at
least, my understanding of what's going on:
------------------------------------------------------
Pressing Insert->Citation Reference inserts a new inset in the
LyXParagraph::insetlist of insets and launches the citation dialog by calling
Edit().
case LFUN_INSERT_CITATION:
{
InsetCitation * new_inset = new InsetCitation();
...
if (owner->view()->insertInset(new_inset))
new_inset->Edit(owner->view(), 0, 0, 0);
}
break;
The program control now moves on to LyXText::draw() where the call to draw the
inset on the page is launched
if (c == LyXParagraph::META_INSET) {
Inset const * tmpinset = row->par()->GetInset(pos);
if (tmpinset) {
tmpinset->draw(bview, font, offset+row->baseline(), x,
cleared);
}
Note that the inset exists but is currently empty, because the citation dialog
has been launched but has not returned anything. We consequently get a little
grey box containing only [].
The inset is redrawn once the dialog is closed. If its closed by pressing Ok,
then the inset is flagged to be redrawn, otherwise no new drawing is done.
-----------------------------------------------------------
What you (Lars) are suggesting is the GUI-Independence way of doing things. Ie,
FormCitation and InsetCitation are separate classes.
Pressing Insert->Citation Reference will launch a signal to show the citation
dialog (FormCitation). Nothing will be inserted in the paragraph. Callbacks
from this dialog can then be examined to see whether an inset (InsetCitation)
should be created, modified or deleted. Only then will anything be drawn in the
main lyx window.
Is this description correct. If so, would you like me to have a go???
Angus