]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/xforms/Dialogs.C
remove defaults stuff, let Qt handle no toolbar
[lyx.git] / src / frontends / xforms / Dialogs.C
index de38fe37ccf536c4612bd8f20bdffbf6b6446b17..8d912149d538223ad7579edb268fdad9a05969b4 100644 (file)
-/* 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-2001 The LyX Team.
- *
- * ======================================================
+ * Full author contact details are available in file CREDITS
  */
 
 #include <config.h>
 
-#ifdef __GNUG__
-#pragma implementation
-#endif
-
 #include "Dialogs.h"
+#include "Dialog.h"
 
-#include "GUI.h"
-#include "xformsBC.h"
+#include "Tooltips.h"
 
-#include "combox.h"       // needed for clean destruction of boost::scoped_ptr
-#include "form_aboutlyx.h"
-#include "form_bibitem.h"
-#include "form_bibtex.h"
-#include "form_browser.h"
-#include "form_character.h"
-#include "form_citation.h"
-#include "form_error.h"
-#include "form_ert.h"
-#include "form_external.h"
-#include "form_float.h"
-#include "form_forks.h"
-#include "form_graphics.h"
-#include "form_include.h"
-#include "form_index.h"
-#include "form_minipage.h"
-#include "form_preamble.h"
-#include "form_print.h"
-#include "form_ref.h"
-#include "form_search.h"
-#include "form_sendto.h"
-#include "form_spellchecker.h"
-#include "form_tabular_create.h"
-#include "form_texinfo.h"
-#include "form_thesaurus.h"
-#include "form_toc.h"
-#include "form_url.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 "FormError.h"
 #include "FormERT.h"
 #include "FormExternal.h"
 #include "FormFloat.h"
-#include "FormForks.h"
 #include "FormGraphics.h"
 #include "FormInclude.h"
-#include "FormIndex.h"
 #include "FormLog.h"
 #include "FormMinipage.h"
-#include "FormPreamble.h"
-#include "FormPrint.h"
+#include "FormParagraph.h"
 #include "FormRef.h"
-#include "FormSearch.h"
-#include "FormSendto.h"
+#include "FormTabular.h"
 #include "FormShowFile.h"
-#include "FormSpellchecker.h"
 #include "FormTabularCreate.h"
-#include "FormTexinfo.h" 
-#include "FormThesaurus.h" 
+#include "FormText.h"
 #include "FormToc.h"
 #include "FormUrl.h"
 #include "FormVCLog.h"
+#include "FormWrap.h"
 
-#include "FormDocument.h"
-#include "FormMathsPanel.h"
-#include "FormParagraph.h"
-#include "FormPreferences.h"
-#include "FormTabular.h"
+#ifdef HAVE_LIBAIKSAURUS
+#include "ControlThesaurus.h"
+#include "FormThesaurus.h"
+#endif
 
-#include "Tooltips.h"
+#include "xformsBC.h"
+#include "ButtonController.h"
 
-/// Are the tooltips on or off?
-bool Dialogs::tooltipsEnabled()
+
+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_;
+};
+
+
+} // namespace anon
+
+
+bool Dialogs::isValidName(string const & name) const
 {
-       return Tooltips::enabled();
+       return std::find_if(dialognames, end_dialognames,
+                           cmpCStr(name.c_str())) != end_dialognames;
 }
 
 
-Dialogs::Dialogs(LyXView * lv)
+Dialog * Dialogs::build(string const & name)
 {
-       add(new GUIAboutlyx<FormAboutlyx, xformsBC>(*lv, *this));
-       add(new GUIBibitem<FormBibitem, xformsBC>(*lv, *this));
-       add(new GUIBibtex<FormBibtex, xformsBC>(*lv, *this));
-       add(new GUICharacter<FormCharacter, xformsBC>(*lv, *this));
-       add(new GUICitation<FormCitation, xformsBC>(*lv, *this));
-       add(new GUIError<FormError, xformsBC>(*lv, *this));
-       add(new GUIERT<FormERT, xformsBC>(*lv, *this));
-       add(new GUIExternal<FormExternal, xformsBC>(*lv, *this));
-       add(new GUIForks<FormForks, xformsBC>(*lv, *this));
-       add(new GUIGraphics<FormGraphics, xformsBC>(*lv, *this));
-       add(new GUIInclude<FormInclude, xformsBC>(*lv, *this));
-       add(new GUIIndex<FormIndex, xformsBC>(*lv, *this));
-       add(new GUILog<FormLog, xformsBC>(*lv, *this));
-       add(new GUIMinipage<FormMinipage, xformsBC>(*lv, *this));
-       add(new GUIFloat<FormFloat, xformsBC>(*lv, *this));
-       add(new GUIPreamble<FormPreamble, xformsBC>(*lv, *this));
-       add(new GUIPrint<FormPrint, xformsBC>(*lv, *this));
-       add(new GUIRef<FormRef, xformsBC>(*lv, *this));
-       add(new GUISearch<FormSearch, xformsBC>(*lv, *this));
-       add(new GUISendto<FormSendto, xformsBC>(*lv, *this));
-       add(new GUIShowFile<FormShowFile, xformsBC>(*lv, *this));
-       add(new GUISpellchecker<FormSpellchecker, xformsBC>(*lv, *this));
-       add(new GUITabularCreate<FormTabularCreate, xformsBC>(*lv, *this));
+       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
-       add(new GUIThesaurus<FormThesaurus, xformsBC>(*lv, *this));
+       } else if (name == "thesaurus") {
+               dialog->setController(new ControlThesaurus(*dialog));
+               dialog->setView(new FormThesaurus(*dialog));
+               dialog->bc().bp(new OkApplyCancelReadOnlyPolicy);
 #endif
-       add(new GUITexinfo<FormTexinfo, xformsBC>(*lv, *this));
-       add(new GUIToc<FormToc, xformsBC>(*lv, *this));
-       add(new GUIUrl<FormUrl, xformsBC>(*lv, *this));
-       add(new GUIVCLog<FormVCLog, xformsBC>(*lv, *this));
-
-       add(new FormDocument(lv, this));
-       add(new FormMathsPanel(lv, this));
-       add(new FormParagraph(lv, this));
-       add(new FormPreferences(lv, this));
-       add(new FormTabular(lv, this));
-       
-       // reduce the number of connections needed in
-       // dialogs by a simple connection here.
-       hideAll.connect(hideBufferDependent.slot());
+       } 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;
+}
+
+
+void Dialogs::toggleTooltips()
+{
+       Tooltips::toggleEnabled();
+}
+
+
+/// Are the tooltips on or off?
+bool Dialogs::tooltipsEnabled()
+{
+       return Tooltips::enabled();
 }