-/* This file is part of
- * ======================================================
+/**
+ * \file xforms/Dialogs.C
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
*
- * LyX, The Document Processor
+ * \author Angus Leeming
*
- * Copyright 1995 Matthias Ettrich
- * Copyright 1995-2000 The LyX Team.
- *
- * ======================================================
+ * Full author contact details are available in file CREDITS
*/
#include <config.h>
#include "Dialogs.h"
+#include "Dialog.h"
+
+#include "Tooltips.h"
+
+#include "ControlAboutlyx.h"
+#include "ControlBibtex.h"
+#include "ControlChanges.h"
+#include "ControlCharacter.h"
+#include "ControlCitation.h"
+#include "ControlCommand.h"
+#include "ControlError.h"
+#include "ControlERT.h"
+#include "ControlExternal.h"
+#include "ControlFloat.h"
+#include "ControlGraphics.h"
+#include "ControlInclude.h"
+#include "ControlLog.h"
+#include "ControlMinipage.h"
+#include "ControlParagraph.h"
+#include "ControlRef.h"
+#include "ControlShowFile.h"
+#include "ControlTabular.h"
+#include "ControlTabularCreate.h"
+#include "ControlToc.h"
+#include "ControlVCLog.h"
+#include "ControlWrap.h"
+
+#include "FormAboutlyx.h"
+#include "FormBibitem.h"
+#include "FormBibtex.h"
+#include "FormChanges.h"
+#include "FormCharacter.h"
#include "FormCitation.h"
-#include "FormCopyright.h"
-#include "FormDocument.h"
#include "FormError.h"
+#include "FormERT.h"
+#include "FormExternal.h"
+#include "FormFloat.h"
#include "FormGraphics.h"
-#include "FormIndex.h"
+#include "FormInclude.h"
+#include "FormLog.h"
+#include "FormMinipage.h"
#include "FormParagraph.h"
-#include "FormPreferences.h"
-#include "FormPrint.h"
#include "FormRef.h"
#include "FormTabular.h"
+#include "FormShowFile.h"
#include "FormTabularCreate.h"
+#include "FormText.h"
#include "FormToc.h"
#include "FormUrl.h"
-#include "debug.h"
+#include "FormVCLog.h"
+#include "FormWrap.h"
-#ifdef __GNUG__
-#pragma implementation
+#ifdef HAVE_LIBAIKSAURUS
+#include "ControlThesaurus.h"
+#include "FormThesaurus.h"
#endif
-// temporary till ported
-extern void ShowCredits();
+#include "xformsBC.h"
+#include "ButtonController.h"
+
+
+namespace {
+
+char const * const dialognames[] = { "about", "bibitem", "bibtex", "changes",
+"character", "citation", "error", "ert", "external", "file", "float",
+"graphics", "include", "index", "label", "log", "minipage", "paragraph",
+"ref", "tabular", "tabularcreate",
+
+#ifdef HAVE_LIBAIKSAURUS
+"thesaurus",
+#endif
+
+"toc", "url", "vclog", "wrap" };
+
+char const * const * const end_dialognames =
+ dialognames + (sizeof(dialognames) / sizeof(char *));
+
+struct cmpCStr {
+ cmpCStr(char const * name) : name_(name) {}
+ bool operator()(char const * other) {
+ return strcmp(other, name_) == 0;
+ }
+private:
+ char const * name_;
+};
-// Signal enabling all visible popups to be redrawn if so desired.
-// E.g., when the GUI colours have been remapped.
-Signal0<void> Dialogs::redrawGUI;
+} // namespace anon
-Dialogs::Dialogs(LyXView * lv)
+bool Dialogs::isValidName(string const & name) const
{
- dialogs_.push_back(new FormCitation(lv, this));
- dialogs_.push_back(new FormCopyright(lv, this));
- dialogs_.push_back(new FormDocument(lv, this));
- dialogs_.push_back(new FormError(lv, this));
- dialogs_.push_back(new FormGraphics(lv, this));
- dialogs_.push_back(new FormIndex(lv, this));
- dialogs_.push_back(new FormParagraph(lv, this));
- dialogs_.push_back(new FormPreferences(lv, this));
- dialogs_.push_back(new FormPrint(lv, this));
- dialogs_.push_back(new FormRef(lv, this));
- dialogs_.push_back(new FormTabular(lv, this));
- dialogs_.push_back(new FormTabularCreate(lv, this));
- dialogs_.push_back(new FormToc(lv, this));
- dialogs_.push_back(new FormUrl(lv, this));
-
- showCredits.connect(slot(ShowCredits));
-
- // reduce the number of connections needed in
- // dialogs by a simple connection here.
- hideAll.connect(hideBufferDependent.slot());
+ return std::find_if(dialognames, end_dialognames,
+ cmpCStr(name.c_str())) != end_dialognames;
}
-Dialogs::~Dialogs()
+Dialog * Dialogs::build(string const & name)
{
- for (vector<DialogBase *>::iterator iter = dialogs_.begin();
- iter != dialogs_.end();
- ++iter) {
- lyxerr << "delete *iter" << endl;
- delete *iter;
+ if (!isValidName(name))
+ return 0;
+
+ Dialog * dialog = new Dialog(lyxview_, name);
+ dialog->bc().view(new xformsBC(dialog->bc()));
+
+ if (name == "about") {
+ dialog->setController(new ControlAboutlyx(*dialog));
+ dialog->setView(new FormAboutlyx(*dialog));
+ dialog->bc().bp(new OkCancelPolicy);
+ } else if (name == "bibitem") {
+ dialog->setController(new ControlCommand(*dialog, name));
+ dialog->setView(new FormBibitem(*dialog));
+ dialog->bc().bp(new OkCancelReadOnlyPolicy);
+ } else if (name == "bibtex") {
+ dialog->setController(new ControlBibtex(*dialog));
+ dialog->setView(new FormBibtex(*dialog));
+ dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
+ } else if (name == "character") {
+ dialog->setController(new ControlCharacter(*dialog));
+ dialog->setView(new FormCharacter(*dialog));
+ dialog->bc().bp(new OkApplyCancelReadOnlyPolicy);
+ } else if (name == "changes") {
+ dialog->setController(new ControlChanges(*dialog));
+ dialog->setView(new FormChanges(*dialog));
+ dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
+ } else if (name == "citation") {
+ dialog->setController(new ControlCitation(*dialog));
+ dialog->setView(new FormCitation(*dialog));
+ dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
+ } else if (name == "error") {
+ dialog->setController(new ControlError(*dialog));
+ dialog->setView(new FormError(*dialog));
+ dialog->bc().bp(new OkCancelPolicy);
+ } else if (name == "ert") {
+ dialog->setController(new ControlERT(*dialog));
+ dialog->setView(new FormERT(*dialog));
+ dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
+ } else if (name == "external") {
+ dialog->setController(new ControlExternal(*dialog));
+ dialog->setView(new FormExternal(*dialog));
+ dialog->bc().bp(new OkApplyCancelReadOnlyPolicy);
+ } else if (name == "file") {
+ dialog->setController(new ControlShowFile(*dialog));
+ dialog->setView(new FormShowFile(*dialog));
+ dialog->bc().bp(new OkCancelPolicy);
+ } else if (name == "float") {
+ dialog->setController(new ControlFloat(*dialog));
+ dialog->setView(new FormFloat(*dialog));
+ dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
+ } else if (name == "graphics") {
+ dialog->setController(new ControlGraphics(*dialog));
+ dialog->setView(new FormGraphics(*dialog));
+ dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
+ } else if (name == "include") {
+ dialog->setController(new ControlInclude(*dialog));
+ dialog->setView(new FormInclude(*dialog));
+ dialog->bc().bp(new OkApplyCancelReadOnlyPolicy);
+ } else if (name == "index") {
+ dialog->setController(new ControlCommand(*dialog, name));
+ dialog->setView(new FormText(*dialog,
+ _("Index"), _("Keyword:|#K")));
+ dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
+ } else if (name == "label") {
+ dialog->setController(new ControlCommand(*dialog, name));
+ dialog->setView(new FormText(*dialog,
+ _("Label"), _("Label:|#L")));
+ dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
+ } else if (name == "log") {
+ dialog->setController(new ControlLog(*dialog));
+ dialog->setView(new FormLog(*dialog));
+ dialog->bc().bp(new OkCancelPolicy);
+ } else if (name == "minipage") {
+ dialog->setController(new ControlMinipage(*dialog));
+ dialog->setView(new FormMinipage(*dialog));
+ dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
+ } else if (name == "paragraph") {
+ dialog->setController(new ControlParagraph(*dialog));
+ dialog->setView(new FormParagraph(*dialog));
+ dialog->bc().bp(new OkApplyCancelReadOnlyPolicy);
+ } else if (name == "ref") {
+ dialog->setController(new ControlRef(*dialog));
+ dialog->setView(new FormRef(*dialog));
+ dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
+ } else if (name == "tabular") {
+ dialog->setController(new ControlTabular(*dialog));
+ dialog->setView(new FormTabular(*dialog));
+ dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
+ } else if (name == "tabularcreate") {
+ dialog->setController(new ControlTabularCreate(*dialog));
+ dialog->setView(new FormTabularCreate(*dialog));
+ dialog->bc().bp(new IgnorantPolicy);
+#ifdef HAVE_LIBAIKSAURUS
+ } else if (name == "thesaurus") {
+ dialog->setController(new ControlThesaurus(*dialog));
+ dialog->setView(new FormThesaurus(*dialog));
+ dialog->bc().bp(new OkApplyCancelReadOnlyPolicy);
+#endif
+ } else if (name == "toc") {
+ dialog->setController(new ControlToc(*dialog));
+ dialog->setView(new FormToc(*dialog));
+ dialog->bc().bp(new OkCancelPolicy);
+ } else if (name == "url") {
+ dialog->setController(new ControlCommand(*dialog, name));
+ dialog->setView(new FormUrl(*dialog));
+ dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
+ } else if (name == "vclog") {
+ dialog->setController(new ControlVCLog(*dialog));
+ dialog->setView(new FormVCLog(*dialog));
+ dialog->bc().bp(new OkCancelPolicy);
+ } else if (name == "wrap") {
+ dialog->setController(new ControlWrap(*dialog));
+ dialog->setView(new FormWrap(*dialog));
+ dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
}
+
+ return dialog;
}
-/*****************************************************************************
-
-Q. WHY does Dialogs::Dialogs pass `this' to dialog constructors?
-
-A. To avoid a segfault.
- The dialog constructors need to connect to their
- respective showSomeDialog signal(*) but in order to do
- that they need to get the address of the Dialogs instance
- from LyXView::getDialogs(). However, since the Dialogs
- instance is still being constructed at that time
- LyXView::getDialogs() will *not* return the correct
- address because it hasn't finished being constructed.
- A Catch-22 situation (or is that the chicken and the egg...).
- So to get around the problem we pass the address of
- the newly created Dialogs instance using `this'.
-
-(*) -- I'm using signals exclusively to guarantee that the gui code
- remains hidden from the rest of the system. In fact the only
- header related to dialogs that anything in the non-gui-specific
- code gets to see is Dialogs.h! Even Dialogs.h doesn't know what a
- FormCopyright class looks like or that its even going to be used!
-
- No other gui dialog headers are seen outside of the gui-specific
- directories! This ensures that the gui is completely separate from
- the rest of LyX. All this through the use of a few simple signals.
- BUT, the price is that during construction we need to connect the
- implementations show() method to the showSomeDialog signal and this
- requires that we have an instance of Dialogs and the problem mentioned
- above.
-
- Almost all other dialogs should be able to operate using the same style
- of signalling used for Copyright. Exceptions should be handled
- by adding a specific show or update signal. For example, spellchecker
- needs to set the next suspect word and its options/replacements so we
- need a:
- Signal0<void> updateSpellChecker;
-
- Since we would have to have a
- Signal0<void> showSpellChecker;
-
- in order to just see the spellchecker and let the user push the [Start]
- button then the updateSpellChecker signal will make the SpellChecker
- dialog get the new word and replacements list from LyX. If you really,
- really wanted to you could define a signal that would pass the new
- word and replacements:
- Signal2<void, string, vector<string> > updateSpellChecker;
-
- (or something similar) but, why bother when the spellchecker can get
- it anyway with a LyXFunc call or two. Besides if someone extends
- what a dialog does then they also have to change code in the rest of
- LyX to pass more parameters or get the extra info via a function
- call anyway. Thus reducing the independence of the two code bases.
-
- We don't need a separate update signal for each dialog because most of
- them will be changed only when the buffer is changed (either by closing
- the current open buffer or switching to another buffer in the current
- LyXView -- different BufferView same LyXView or same BufferView same
- LyXView).
-
- So we minimise signals but maximise independence and programming
- simplicity, understandability and maintainability. It's also
- extremely easy to add support for Qt or gtk-- because they use
- signals already. Guis that use callbacks, like xforms, must have their
- code wrapped up like that in the form_copyright.[Ch] which is awkward
- but will at least allow multiple instances of the same dialog.
-
- Signals will also be a great help in controlling the splashscreen --
- once signalled to hide it can disconnect from the signal and remove
- itself from memory.
-
- LyXFuncs will be used for requesting/setting LyX internal info. This
- will ensure that scripts or LyXServer-connected applications can all
- have access to the same calls as the internal user-interface.
-
-******************************************************************************/
+void Dialogs::toggleTooltips()
+{
+ Tooltips::toggleEnabled();
+}
+
+
+/// Are the tooltips on or off?
+bool Dialogs::tooltipsEnabled()
+{
+ return Tooltips::enabled();
+}